Skip to content

ariadne: persist table column widths (tree.<id>.columns); fix the row-split 16 px first-walk pin - #727

Merged
transfix merged 3 commits into
masterfrom
feat/ariadne-table-columns
Oct 20, 2026
Merged

transfix merged 3 commits into
masterfrom
feat/ariadne-table-columns

Conversation

@transfix

Copy link
Copy Markdown
Owner

This PR includes #724's commit (Kitty/Sixel, 1a599395b) underneath its own (3e750c1fb), so CI runs against master. Review the top commit only. Once #724 merges, I'll rebase onto master and its commit will drop out.

A resizable table now persists its column widths to tree.<id>.columns, the column counterpart of a row split's tree.<id>.tracks. This also fixes the FTXUI row-split bug where the first walk pinned a natural pane at 16 px.

What changes

  • Contract (inc/cvc/ariadne/backend.h): new seed_grid_columns(widths) (before begin_grid, applied once by the backend, so a live drag wins) and grid_columns() (after end_grid). Both are non-pure no-ops by default.
  • Core (ariadne.cpp, beside the row-split code): for resizable && !is_row_split(), it seeds from tree.<id>.columns and writes the reported widths back. The write is skipped when nothing changed. Tables that are not resizable, and row splits, never use the key.
  • Units: px for every column; 0 means "not set" (the column keeps its authored track).
  • Stretch columns: decided px, read as weights. Every backend reports the px it draws, so the key means the same thing everywhere.
    • The ImGui backend seeds a stretch column with its persisted px as its weight, so stretch columns keep their proportions at another table width.
    • The FTXUI backend fixes a seeded column at its width.
  • FTXUI:
    • A persisted width fixes its column once (px_to_cols).
    • The table reports the columns it holds at a size: authored px as written (so a reload never drifts), seeded, or dragged. A stretch column reports 0.
  • ImGui:
    • Persisted widths become TableSetupColumn's init width/weight. ImGui applies those only when it creates the table, so the seed is apply-once.
    • Widths are read back through imgui_internal: GetCurrentTable()->Columns[i].WidthGiven, the value TableSetupColumn takes back. They are read before EndTable, and only once IsLayoutLocked.
  • Row-split fix:
    • Cause: FTXUI measured a naturally laid-out pane from its reflected box. On the first walk that box had never been laid out (1 cell, so 16 px), the value was persisted, and the next load pinned the pane at one row.
    • Fix: a natural pane now reports 0 and stays natural. Authored and dragged panes persist as before, and a report with nothing set writes nothing.

Tests

  • ariadne_runtime_test:
    • ResizableTableColumnsSeedAndPersist: seed, write-back, no tracks.
    • OnlyAResizableTablePersistsColumns: tables that are not resizable and row splits ignore the key.
  • ariadne_ftxui_test:
    • ANaturalPaneIsNotPinnedByTheFirstWalk: the regression. The first walk persists 80,0, and a reload shows all three lines of the natural pane.
    • DraggedTableColumnsPersistAndSeedTheNextLoad: the table starts at 80,80,0, a drag persists 112,48,0, and a fresh load from that state lays out the same columns and reports them unchanged.
  • New cvcgl_imgui_table_columns, run on a bare ImGui context (no window, no GL):
    • authored widths: 100 px fixed, equal stretch columns;
    • a seeded fixed width (160) and 3:1 stretch weights;
    • a persist → reload round trip.
  • Locally ctest -R 'ariadne|Ariadne|cvcgl_terminal_scene|cvcgl_imgui_table_columns': 409/409.

FtxuiBackend now draws images in real pixels where the terminal can:

- Kitty: each image is sent once, out of band, after the frame that first
  draws it (a=T, U=1, f=24, q=2, chunked base64), and shown through Unicode
  placeholder cells (U+10EEEE + row/column diacritics, fg = image id). A
  window or menu over an image hides exactly the cells it covers, and
  FTXUI's full repaint redraws the placeholders. An image is re-sent only
  when its pixels change and deleted once no frame draws it; images wider
  or taller than 297 cells go as tiles.
- Sixel: a bitmap is re-sent after each draw, inside synchronized-output
  marks, clipped to the cells nothing covers (the node draws a half-block
  underlay; a pass after the frame finds the cells still showing it).
  Fixed 6x7x6 palette (fewer where XTSMGRAPHICS says so), ordered dither.

run() probes the terminal before FTXUI takes the tty (a kitty query,
CSI 16 t and DA1 on /dev/tty in raw mode), merges FTXUI's DA1 capabilities
for Sixel, and reads the cell size in pixels from TIOCGWINSZ every frame.
Options::cell_px_w/h stays the layout unit; the real cell size only sets
the raster. Options::ImageColor gains Kitty and Sixel; Auto picks Kitty,
else Sixel (when the cell size is known), else half-blocks. Hosted mode
(tvision) keeps half-blocks.

The encoders and the probe-reply parser are pure functions in
term_graphics.h, unit-tested in ariadne_term_graphics_test. take_graphics()
returns the bytes run() writes after a frame, so the backend paths are
tested headless too.

cvcGL's TerminalScene renders at the cells' real pixels when a pixel mode
is on (FtxuiBackend::image_raster) and maps drags with the frame's own
pixels per cell. ari and ariadne_terminal take --graphics; ari also takes
--image NAME=FILE (new example terminal_images.ari), and snapshot
--cell-size. The .ari schema now allows an image widget's scalar size.
… the first walk

A resizable table (a resizable grid that is not a row split) now keeps its
column widths in tree.<id>.columns, the column counterpart of a row
split's tree.<id>.tracks. The backend seam is the same shape:
Backend::seed_grid_columns (before begin_grid, applied once) and
grid_columns (after end_grid); the core seeds and writes back beside the
row-split code. Widths are px for every column; 0 means "not set".

- FTXUI: a persisted width fixes its column once (px_to_cols), and the
  table reports the columns it holds at a size (authored px as written,
  seeded or dragged) and 0 for a stretch column.
- ImGui: the persisted widths become TableSetupColumn's init values, which
  ImGui applies when it creates the table, so a drag wins: a fixed column
  takes its width, a stretch column its weight (stretch proportions survive
  another table width). Widths come back from imgui_internal
  (Columns[i].WidthGiven) before EndTable, once the layout is locked.

Row-split fix: the FTXUI backend measured a naturally laid-out pane from
its box, which on the first walk had never been laid out (one cell, so
16 px). That was persisted, and the next load pinned the pane at one row.
A natural pane now reports 0, so it stays natural; dragged and authored
panes persist as before.

Tests: ariadne_runtime_test (the core key, and only resizable tables use
it), ariadne_ftxui_test (the row-split regression, drag -> persist ->
seed), and the new cvcgl_imgui_table_columns (a bare ImGui context:
authored widths, a seeded fixed width and 3:1 stretch weights, round trip).
…-table-columns

# Conflicts:
#	docs/ARIADNE.md
#	src/ari/main.cpp
#	src/cvc/CMakeLists.txt
#	src/cvc/tests/CMakeLists.txt
@transfix
transfix merged commit 8a84b9c into master Oct 20, 2026
24 checks passed
@transfix
transfix deleted the feat/ariadne-table-columns branch October 20, 2026 12:12
transfix added a commit that referenced this pull request Oct 20, 2026
…aches libcvcGL

cvcgl_imgui_table_columns (#727) segfaulted on package-windows once #725 put a
real imgui into the Windows CI build. The test creates its ImGui context in
the test executable and drives ImGuiBackend, which runs inside cvcGL.dll. The
cvcpkg Windows imgui is a static library, so the exe and the DLL each carry a
copy of imgui with its own current context, and the backend found none.
(ImGuiOverlay creates its context inside libcvcGL, so overlay hosts never hit
this; a shared imgui, as on Linux, has one copy.)

ImGuiBackend::setImGuiContext(ctx) makes ctx current in libcvcGL's copy; the
test hands its context over after CreateContext and clears it before
destroying it, which it now does by pointer (with a shared imgui clearing
libcvcGL's current context clears the test's too).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant