[0627] 让tabular的边界可以修改颜色#3535
Open
JackYansongLi wants to merge 14 commits into
Open
Conversation
…er width elimination
…lor, padding - Move pen width and padding into submenus to reduce vertical length - Group border color under Border alongside pen width and border styles - Add zh_CN translation for "border color" Co-Authored-By: Claude Opus 4.7 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
任务目标 (What)
在 Mogan 中实现表格(tabular)及单元格边框颜色的完全自定义功能:
cell-border-color和table-border-color属性。merge_borders)增加了基于修改顺序(cwithPrecedence)的边界优先级判决。当相邻单元格有边框颜色冲突时,自动消除低优先级边框,从而渲染显示出最后选择修改的那个单元格的共享边颜色。为什么需要这个任务 (Why)
目前 Mogan 表格(tabular)的边框颜色硬编码为当前环境的文本前景色(通常为黑色),用户无法直接修改表格的边框颜色。这限制了表格样式的丰富程度,有必要支持边框颜色的单独自定义。此外,当相邻单元格颜色不同时,重叠边界必须统一展现最后修改的颜色,绝不能因为光标切换重排版而发生混乱、闪烁或颜色覆写。
实现思路 (How)
CELL_BORDER_COLOR和TABLE_BORDER_COLOR:moebius/moebius/vars.hpp/vars.cpp。drd_std.cpp注册为TYPE_COLOR类型,在env_default.cpp初始化其默认值(默认继承前景色,即"")。cell_rep和table_rep中添加tree bcolor字段和int bcolor_precedence(优先级进度):table_rep::typeset_table中从 TFORMAT 中解析出cwith的声明索引作为优先级存储,最后修改的优先级最高。table_rep::merge_borders中执行宽度和优先级合并。共享段优先级低于最大优先级的单元格边框被置为 0,防止重复绘制 and 冲突。table_rep::finish()和var_finish()中强制重新进行合并决策,防止局部重排版引发的状态回滚。environment.scm定义对应的环境变量。table-edit.scm提供cell-set-border-color及table-set-border-color两个 setter。table-widgets.scm在属性面板加入颜色编辑框。table-menu.scm引入包含一键 Default、Foreground、Palette 调色盘、其他自定义颜色的完整颜色选取列表。如何测试 (Testing)
2. 确定性测试(单元测试)
运行自动化测试套件:
xmake b edit_table_test && xmake r edit_table_test此单元测试额外覆盖了以下关键判定场景:
test_adjacent_border_colors():验证当相邻单元格有边框颜色冲突(例如 Cell 1 优先级低,Cell 2 优先级高)时,C++ 能够正确判定,使低优先级单元格的右侧重合边框宽度消除(降为 0),保证高优先级单元格的颜色正确绘制在共享边界上。test_adjacent_border_colors_on_cell_typeset():验证即使局部单元格发生重排版(Re-typeset)使宽度重置,执行表格 final 组装(finish())时依然能重新进行优先级合并判决,确保重排版后合并色不丢失。3. 非确定性测试(界面及功能手动验证)
测试 3.2.1:通过“焦点工具栏”的边框弹出菜单进行修改(最直观)
xmake b stem && xmake r stemAlt+t然后tab几次)。测试 3.2.2:相邻单元格共享边界(Border Conflict)合并测试
cwith优先级),C++ 应当正确将低优先级的 Cell 1 右边界消除,让 Cell 2 的蓝色左边界完美显示出来。