Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# 开发规范

## C++ 代码规范

1. **不使用标准 C++ 库**:Mogan 使用自研的 C++ 基础设施(如 lolly/moebius 库),内部类型(`string`、`list`、`array`、`tree`、`path` 等)均有自定义实现,与 `std::` 不兼容。
2. **输出流使用项目内置 `cout`**:调试输出应使用全局 `cout`(类型为 `tm_ostream`),而非 `std::cout`;换行使用 `LF` 宏或 `"\n"`,不要使用 `std::endl`。
3. **容器不支持现代 C++ 特性**:自定义容器(如 `rectangles`、`list`)不支持范围 for 循环(range-based for),需使用传统的迭代器或 `is_nil()`/`next` 遍历。
4. **类型转换使用项目函数**:自定义类型(如 `path`)没有标准 `operator<<` 重载,输出前需先用 `as_string()` 转换。

## 分支命名规则

分支格式:`username/200_27/xxx`
Expand Down
32 changes: 32 additions & 0 deletions TeXmacs/tests/tmu/0113.tmu
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<TMU|<tuple|1.1.0|2026.2.4>>

<style|<tuple|generic|chinese|table-captions-above|number-europe|preview-ref>>

<\body>
\;

<tabular|<tformat|<table|<row|<cell|(1,1)>|<cell|>|<cell|>>|<row|<cell|>|<cell|<subtable|<tformat|<cwith|1|-1|1|-1|cell-tborder|0ln>|<cwith|1|-1|1|-1|cell-bborder|0ln>|<cwith|1|-1|1|-1|cell-lborder|0ln>|<cwith|1|-1|1|-1|cell-rborder|0ln>|<table|<row|<cell|>|<cell|>>|<row|<cell|>|<cell|>>>>>>|<cell|>>|<row|<cell|>|<cell|(3,2)>|<cell|(3,3)>>>>>
</body>

<\initial>
<\collection>
<associate|page-medium|paper>
<associate|page-screen-margin|false>
</collection>
</initial>

<\references>
<\collection>
<associate|auto-1|<tuple|1|1>>
</collection>
</references>

<\auxiliary>
<\collection>
<\associate|table>
<tuple|normal|<\surround|<hidden-binding|<tuple>|1>|>
\;
</surround>|<pageref|auto-1>>
</associate>
</collection>
</auxiliary>
27 changes: 27 additions & 0 deletions devel/0113.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# [0113] 修复无框表格中子表格与单元格细线重叠问题

## 相关文档
- [dddd.md](dddd.md) - 任务文档模板
- [0403.md](0403.md) - 修复合并单元格后编辑线条重叠问题(参考其 `env_rects` 绘制修复思路)

## 如何测试

### 启动测试文档
```bash
xmake r stem TeXmacs/tests/tmu/0113.tmu
```

### 验证步骤
1. 打开 Mogan STEM,新建一个空白文档。
2. 插入一个无框表格(如 2x2,边框类型设为无框)。
3. 在无框表格的某个单元格中,再次插入一个子表格(可以是带框或无框)。
4. 确认**"显示表格单元格"**偏好设置已开启(编辑 -> 首选项 -> 其他 -> 显示表格单元格)。
5. 观察子表格与父表格单元格边界处,确认**编辑时的辅助线条(灰色细框)没有出现重叠或错位**。
6. 对比修复前:子表格边框与父表格单元格细线在同一位置绘制,导致线条加粗或视觉重叠。
7. 测试不同边框类型的组合(父无框+子有框、父无框+子无框等),确认边界显示一致。
8. 测试包含合并单元格的无框表格中嵌套子表格,确认无额外线条问题。

## What
在 `0113.tmu` 文档中,(2,2) 单元格内嵌套了一个子表格。当光标位于该子表格的单元格中时,子表格的上边框会与父单元格 (2,2) 的上边框重叠,子表格的下边框也会与父单元格 (2,2) 的下边框重叠。

期望的行为:两条边框在几何位置上重合,但视觉上不应感知到重叠(即线条不应加粗或变深)。
31 changes: 30 additions & 1 deletion src/Edit/Interface/edit_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,12 @@ edit_interface_rep::compute_env_rects (path p, rectangles& rs, bool recurse) {
tree st= subtree (et, p);
if ((is_func (st, TABLE) || is_func (st, SUBTABLE)) && recurse &&
get_preference ("show table cells") == "on") {
bool is_subtable_inner= false;
if (is_func (st, TABLE)) {
tree ppt= subtree (et, path_up (path_up (p)));
if (is_func (ppt, SUBTABLE)) is_subtable_inner= true;
}

rectangles rl;

int table_rows= N (st);
Expand Down Expand Up @@ -656,7 +662,30 @@ edit_interface_rep::compute_env_rects (path p, rectangles& rs, bool recurse) {

rectangles selp= thicken (rsel, pixel / 2, pixel / 2);
rectangles selm= thicken (rsel, -pixel / 2, -pixel / 2);
rl << simplify (::correct (selp - selm));

if (is_subtable_inner) {
rectangles rdiff;
if (i > 0) {
rdiff << rectangles (rectangle (selp->item->x1, selm->item->y2,
selp->item->x2, selp->item->y2));
}
if (i + 1 < table_rows) {
rdiff << rectangles (rectangle (selp->item->x1, selp->item->y1,
selp->item->x2, selm->item->y1));
}
if (j > 0) {
rdiff << rectangles (rectangle (selp->item->x1, selm->item->y1,
selm->item->x1, selm->item->y2));
}
if (j + 1 < N (cell_cache[i])) {
rdiff << rectangles (rectangle (selm->item->x2, selm->item->y1,
selp->item->x2, selm->item->y2));
}
rl << simplify (::correct (rdiff));
}
else {
rl << simplify (::correct (selp - selm));
}
}
}
}
Expand Down
Loading