diff options
| author | eunhhu <[email protected]> | 2026-09-26 10:57:03 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-09-26 10:57:03 +0100 |
| commit | f6be15d01ac184f070e1bb34af12689f68eb9140 (patch) | |
| tree | 4ebfac5e6baf066b58136c2f71a70ab007ea5f5d /src/screen.c | |
| parent | 04e883a310fd3914d6f4294a92b08b3fe9f55686 (diff) | |
| download | vega-f6be15d01ac184f070e1bb34af12689f68eb9140.tar.gz vega-f6be15d01ac184f070e1bb34af12689f68eb9140.zip | |
Move the focus from a surface: clicks, the wheel, point
Only the app's key handlers could move a list's focus. When the focus
view is a plain index position (`view tasks_list_focus = at.position`),
Vega now asks Pure for that index and moves it as a user pointing at a
row (pure_app_point), with no code in the app. The grid remembers which
item each line shows; in the TUI a click on a row focuses it and the
wheel moves the focus one row (SGR mouse reports, turned off on exit).
Scripts say point VIEW ROW or click LINE COLUMN on the last shown frame.
The focus is stored like any event, so the next run of any surface
starts from it.
The model now points too: random scripts with points (some past the
end) and TUI clicks still match it on every surface, a mouse click on a
real pseudo-terminal moves the focus, and the stored session keeps it.
Diffstat (limited to 'src/screen.c')
| -rw-r--r-- | src/screen.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/screen.c b/src/screen.c index 2d4c6dc..3e8b2c4 100644 --- a/src/screen.c +++ b/src/screen.c @@ -32,12 +32,14 @@ void vega_screen(VegaScreen *screen, const PureModule *m) { for (uint32_t i = 0; i < m->views && screen->count < VEGA_PARTS; ++i) { if (m->view_table[i] || (int)i == screen->title || focus_view[i]) continue; VegaPart *part = &screen->parts[screen->count++]; - *part = (VegaPart){.kind = VEGA_FIELD, .view = i, .focus = -1, .label = -1, .tone = -1, .detail = -1, .badge = -1}; + *part = (VegaPart){.kind = VEGA_FIELD, .view = i, .focus = -1, .pointer = -1, .label = -1, .tone = -1, .detail = -1, + .badge = -1}; if (m->view_type[i] != PURE_VIEW_TABLE) continue; char name[PURE_MODULE_NAME + 8]; snprintf(name, sizeof(name), "%s_focus", m->view_names[i]); part->focus = pure_module_view(m, name); if (part->focus >= 0 && !focus_view[part->focus]) part->focus = -1; + part->pointer = part->focus >= 0 ? pure_module_position(m, (uint32_t)part->focus) : -1; part->label = column(m, i, "label", PURE_VIEW_TEXT); part->tone = column(m, i, "tone", PURE_VIEW_NUM); part->kind = part->label >= 0 ? VEGA_LIST : VEGA_TABLE; @@ -155,6 +157,10 @@ size_t vega_focus(PureApp *app, const VegaPart *part) { return focus >= (double)(rows - 1) ? rows - 1 : (size_t)focus; } +bool vega_point(PureApp *app, const VegaPart *part, size_t row) { + return part->pointer >= 0 && pure_app_point(app, (uint32_t)part->pointer, row) == PURE_OK; +} + VegaTone vega_tone(PureApp *app, const VegaPart *part, size_t row) { double tone; if (part->tone < 0 || !vega_number(app, (uint32_t)part->tone, row, &tone)) return VEGA_NORMAL; |
