Skip to content

Commit 90c5f0e

Browse files
authored
[0401] 表格单元格边框添加斜线选项 (#3308)
1 parent 253959b commit 90c5f0e

18 files changed

Lines changed: 247 additions & 25 deletions

File tree

Lines changed: 18 additions & 0 deletions
Loading
Lines changed: 18 additions & 0 deletions
Loading
Lines changed: 18 additions & 0 deletions
Loading
Lines changed: 18 additions & 0 deletions
Loading
Lines changed: 18 additions & 0 deletions
Loading
Lines changed: 18 additions & 0 deletions
Loading

TeXmacs/progs/table/table-edit.scm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,14 @@
750750
(:argument b "Top border width")
751751
(cell-set-borders b #f #f #f b #f #f #f))
752752

753+
(tm-define (cell-set-dborder b)
754+
(:argument b "Diagonal border width")
755+
(cell-set-format* "cell-dborder" b))
756+
757+
(tm-define (cell-set-aborder b)
758+
(:argument b "Anti-diagonal border width")
759+
(cell-set-format* "cell-aborder" b))
760+
753761
(define cell-current-pen-width "1ln")
754762

755763
(define (cell-test-pen-width? pen)

TeXmacs/progs/table/table-menu.scm

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,11 @@
210210
((icon "tm_border_rtb.xpm")
211211
(cell-set-borders width width "0ln" width #f #f #f #f))
212212
((icon "tm_border_lrtb.xpm")
213-
(cell-set-borders width width width width #f #f #f #f))))
213+
(cell-set-borders width width width width #f #f #f #f))
214+
((icon "tm_border_d.xpm")
215+
(cell-set-format* "cell-dborder" width))
216+
((icon "tm_border_a.xpm")
217+
(cell-set-format* "cell-aborder" width))))
214218

215219
(menu-bind cell-borders-icons-menu
216220
(with width (cell-get-pen-width)
@@ -243,13 +247,15 @@
243247
("Left" (interactive cell-set-lborder))
244248
("Right" (interactive cell-set-rborder))
245249
("Bottom" (interactive cell-set-bborder))
246-
("Top" (interactive cell-set-tborder)))
250+
("Top" (interactive cell-set-tborder))
251+
("Diagonal" (interactive cell-set-dborder))
252+
("Anti-diagonal" (interactive cell-set-aborder)))
247253

248254
(menu-bind cell-alt-border-menu
249255
(tile 4 (link cell-border-icons-menu))
250-
(if (selection-active-table?)
251-
---
252-
(tile 4 (link cell-borders-icons-menu))))
256+
(when (selection-active-table?)
257+
---
258+
(tile 4 (link cell-borders-icons-menu))))
253259

254260
(menu-bind cell-padding-menu
255261
("All" (interactive cell-set-padding))

TeXmacs/progs/table/table-widgets.scm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,13 @@
196196
(list (cell-get-format "cell-tborder") "0ln" "1ln") "6em"))
197197
(item (text "Bottom:")
198198
(input (cell-set-format* "cell-bborder" answer) "string"
199-
(list (cell-get-format "cell-bborder") "0ln" "1ln") "6em")))))
199+
(list (cell-get-format "cell-bborder") "0ln" "1ln") "6em"))
200+
(item (text "Diagonal:")
201+
(input (cell-set-format* "cell-dborder" answer) "string"
202+
(list (cell-get-format "cell-dborder") "0ln" "1ln") "6em"))
203+
(item (text "Anti-diagonal:")
204+
(input (cell-set-format* "cell-aborder" answer) "string"
205+
(list (cell-get-format "cell-aborder") "0ln" "1ln") "6em")))))
200206

201207
(tm-widget (cell-padding-widget)
202208
(horizontal

devel/0401.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# [0401] 表格单元格边框添加斜线选项
2+
3+
## 如何测试
4+
1. 打开 Mogan STEM,新建一个空白文档。
5+
2. 插入一个表格(如 2x2)。
6+
3. 选中某个单元格。
7+
4. 点击菜单栏 **单元格 -> 边框**,或点击工具栏的 **改变单元格边框** 图标。
8+
5. 确认边界选项面板中**出现两个斜线图标按钮**(与其他边框选项样式一致)。
9+
- **对角线**(╲):从左上到右下
10+
- **反对角线**(╱):从右上到左下
11+
6. 点击**对角线**图标,确认单元格中出现从左上到右下的斜线,**斜线两端应紧贴单元格边缘,不留空隙**
12+
7. 取消对角线,点击**反对角线**图标,确认出现从右上到左下的斜线,同样紧贴边缘。
13+
8. 同时选中两个斜线图标,确认单元格中出现交叉斜线(×)。
14+
9. 打开 **单元格属性** 面板(右键单元格 -> 单元格属性),确认边框区域有 "对角线" 和 "反对角线" 两个输入框,可手动输入线宽(如 `1ln`)。
15+
16+
## 2026/05/11
17+
### what
18+
在表格单元格的边框设置中新增两种斜线选项,使用户可以为单元格添加斜线边框。具体包括:
19+
- 底层新增 `cell-dborder`(对角线)和 `cell-aborder`(反对角线)环境变量和对应渲染支持
20+
- `cell_box` 新增斜线绘制逻辑:
21+
- `dborder`:从左上到右下的斜线(╱)
22+
- `aborder`:从右上到左下的斜线(╲)
23+
- 斜线通过多边形填充绘制,两端延伸至单元格实际边界,避免边缘空隙
24+
- 在边框图标面板(`cell-border-icons-menu`)中新增两个斜线图标按钮
25+
-`cell-border-menu` 菜单和单元格属性面板中新增斜线设置入口
26+
27+
### why
28+
用户需要在表格单元格中绘制斜线(如表头斜线分割),而原有系统仅支持上下左右四条边,不满足该需求。

0 commit comments

Comments
 (0)