Skip to content
Open
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
15 changes: 15 additions & 0 deletions devel/201_80.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# [201_80] 定制化表格handles显示

## 如何测试
1. 插入任意样式的表格(大表格、小表格除外),handles应该正确显示,且支持拖拽
2. 插入`align`、`eqnarray`、`gather`、`multline`、`alignat`、`flalign`等数学环境,handles应该不显示,且不支持拖拽
3. 手动修改样式TS文件(`样式`->`编辑样式`),插入 `<assign|table-handles|false>` 后保存
4. 再次插入任意表格,handles应该始终不显示,且不支持拖拽

## 2026/2/9
### What
在align环境等数学环境下的所有表格结构的组件,在编辑时,handles都应该不显示,也不应支持拖拽

### How
1. 在 `vars.hpp`、 `vars.cpp` 和 `env_default.cpp` 中添加 `TABLE_HANDLES` 环境变量,默认值为 `"true"`,表示表格handles默认显示
2. 在 `edit_repaint.cpp` 中的 `repaint_table_handles` 函数中添加判断,如果当前表格所在环境不是“真表格”(通过 `is_true_table` 判断),则不显示handles;如果 `TABLE_HANDLES` 环境变量值为 `"false"`,则始终不显示handles
1 change: 1 addition & 0 deletions moebius/moebius/drd/drd_std.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,7 @@ init_std_drd () {
init_var (TABLE_MIN_COLS, TYPE_INTEGER);
init_var (TABLE_MAX_ROWS, TYPE_INTEGER);
init_var (TABLE_MAX_COLS, TYPE_INTEGER);
init_var (TABLE_HANDLES, TYPE_STRING);

init_var (CELL_FORMAT, TYPE_ADHOC);
init_var (CELL_DECORATION, TYPE_ADHOC);
Expand Down
1 change: 1 addition & 0 deletions moebius/moebius/vars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ string TABLE_MIN_ROWS ("table-min-rows");
string TABLE_MIN_COLS ("table-min-cols");
string TABLE_MAX_ROWS ("table-max-rows");
string TABLE_MAX_COLS ("table-max-cols");
string TABLE_HANDLES ("table-handles");

/******************************************************************************
* Environment variables for cells of tables
Expand Down
1 change: 1 addition & 0 deletions moebius/moebius/vars.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ extern string TABLE_MIN_ROWS;
extern string TABLE_MIN_COLS;
extern string TABLE_MAX_ROWS;
extern string TABLE_MAX_COLS;
extern string TABLE_HANDLES;

extern string CELL_FORMAT;
extern string CELL_DECORATION;
Expand Down
15 changes: 15 additions & 0 deletions src/Edit/Interface/edit_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,21 @@ edit_interface_rep::is_embedded_widget () {
// FIXME: could be made more robust: test should not be based on file name
}

bool
edit_interface_rep::is_true_table (path p) {
for (path q= p; !is_nil (q) && q != rp; q= path_up (q)) {
tree qt= subtree (et, q);
if (is_compound (qt, "align") || is_compound (qt, "align*") ||
is_compound (qt, "eqnarray") || is_compound (qt, "eqnarray*") ||
is_compound (qt, "gather") || is_compound (qt, "gather*") ||
is_compound (qt, "multline") || is_compound (qt, "multline*") ||
is_compound (qt, "alignat") || is_compound (qt, "alignat*") ||
is_compound (qt, "flalign") || is_compound (qt, "flalign*"))
return false;
}
return true;
}

void
edit_interface_rep::handle_get_size_hint (SI& w, SI& h) {
gui_root_extents (w, h);
Expand Down
1 change: 1 addition & 0 deletions src/Edit/Interface/edit_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ class edit_interface_rep : virtual public editor_rep {
/* event handlers */
bool is_editor_widget ();
bool is_embedded_widget ();
bool is_true_table (path p);
void handle_get_size_hint (SI& w, SI& h);
void handle_notify_resize (SI w, SI h);
void handle_keypress (string key, time_t t);
Expand Down
8 changes: 8 additions & 0 deletions src/Edit/Interface/edit_repaint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,13 @@ edit_interface_rep::draw_image_resize_handles (renderer ren) {

void
edit_interface_rep::draw_table_resize_handles (renderer ren) {
if (as_string (get_env_value (TABLE_HANDLES)) == "false") {
if (!is_zero (last_table_brec)) invalidate (last_table_brec);
last_table_brec= rectangle (0, 0, 0, 0);
last_table_hr = 0;
return;
}

// 鼠标位于表格中时,绘制 handles
SI hs = 8 * ren->pixel; // handles 半径(正方形半边长)
rectangle new_table_brec= rectangle (0, 0, 0, 0);
Expand All @@ -260,6 +267,7 @@ edit_interface_rep::draw_table_resize_handles (renderer ren) {
for (path p= path_up (tp); !is_nil (p) && p != rp; p= path_up (p)) {
tree st= subtree (et, p);
if (!is_func (st, TABLE)) continue;
if (!is_true_table (p)) break;

selection sel= eb->find_check_selection (p * 0, p * 1);
if (!sel->valid || is_nil (sel->rs)) break;
Expand Down
1 change: 1 addition & 0 deletions src/Typeset/Env/env_default.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ initialize_default_env () {
env (TABLE_MIN_COLS) = ""; // suggested minimal number of columns
env (TABLE_MAX_ROWS) = ""; // suggested maximal number of rows
env (TABLE_MAX_COLS) = ""; // suggested maximal number of columns
env (TABLE_HANDLES) = "true"; // show table resize handles

env (CELL_DECORATION) = ""; // decorating table of cell
env (CELL_FORMAT) = tree (TFORMAT); // format of cell
Expand Down