Skip to content

ariadne: a context menu on text in every backend: Cut, Copy, Paste, Select all (§5.28) - #1476

Merged
transfix merged 3 commits into
masterfrom
feat/ariadne-text-context-menu
Nov 24, 2026
Merged

transfix merged 3 commits into
masterfrom
feat/ariadne-text-context-menu

Conversation

@transfix

@transfix transfix commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Joe asked for this while testing cyprty: highlight or right-click notification messages and other strings, and get a copy, cut and paste menu (pasting into text fields) in place of the browser's own right-click. He later added that it must work in the native hosts and the terminal backends too.

So text in every Ariadne host now has a context menu, with nothing in the document asking for it. A right-click opens it. So does a long press on a touch screen (half a second, the finger still), and Shift+F10 or the Menu key in a terminal. New section docs/ARIADNE.md §5.28; §5.15, §5.24 and §10.7 point to it.

Under the pointer The menu
input_text:, message_input: Cut, Copy, Paste, Select all
text: (a bound value copies its value), a rich text Copy, Select text...
text_view: (the chat log, a console) Copy line (the message under the pointer), Copy all, Select text...
A notification: the bell's entry, a Notifications window line Copy, of the whole message, not its one-line entry
  • Cut and Copy take the selection, or the whole text when nothing is selected. A password field has neither.
  • Paste goes at the cursor, over the selection. A one-line field drops line breaks.
  • Select text... shows the text in a read-only field, to select a part of it and copy that.

Per host

  • ImGui, natively (arigl, cvcGL): the system clipboard, as Ctrl+C and Ctrl+V already use it. The menu edits through the field's own InputText callback, so ImGui's undo takes back a Cut or a Paste.
  • arigl-web:
    • Copy is navigator.clipboard.writeText.
    • Paste is navigator.clipboard.readText(), which answers later; the text goes into the field when it does. Chrome asks once for the permission. Firefox and Safari show their own Paste button.
    • ImGui sees a click a frame after the browser does, and Safari allows these calls only inside the click. So the item under the pointer is armed (cvc::gl::clipboard::arm), and a page listener makes the call in the pointer release over it.
    • A refused read leaves the field focused, with a note to press Ctrl+V. Ctrl+V still works through the page's paste event.
    • The canvas already suppressed the browser's own menu.
  • FTXUI (ari):
    • Copy is OSC 52.
    • Paste is an OSC 52 read (ESC ] 52 ; c ; ? ESC \), answered by xterm with allowWindowOps, foot, kitty and iTerm2. FTXUI 7.0.3 hands the answer over as a special event; I checked that under a pty.
    • A silent terminal gets a hint after 3 s to use its own paste, which types into the field as before.
    • Fields gain a selection: Shift with the arrows, Home and End.
    • The ari.html page now answers the OSC 52 read with readText(), and keeps the browser's menu off the terminal while the program has the mouse.
  • tvision: tvision's TClipboard for both. A Paste arrives as a paste of keys. The bell's menu is tvision's own menu, so copy a notification from the Notifications window there.

Tests

  • cvcgl_imgui_context_menu (new, no GL, ImGui's own clipboard). It covers a field's Copy, Select all + Cut, Paste with and without a selection, and ImGui's undo of a Paste. It also covers password fields, a message field's multi-line paste, text and value Copy, the Select text window, a text view's Copy line and Copy all, the bell's entry and the Notifications line, and a touch long press whose lifting finger picks nothing.
  • ariadne_ftxui_test: ARightClickOnATextOffersCopy, AFieldsMenuCutsCopiesAndPastes (including Shift+F10), ATextViewsMenuCopiesALineOrAll, ANotificationsEntryCopiesItsWholeMessage, APasteWithNoTerminalToAskSaysHowToPaste (hosted).
  • ariadne_term_graphics_test's Osc52ReadsAndItsAnswer; ariadne_runtime_test's ANotificationsEntryCopiesItsWholeMessage.
  • src/arigl/web/test/arigl_web_clipboard.mjs (new): arigl-web in headless Chrome with the clipboard granted, driven through the page's own mouse and keys.
    • It covers text Copy, field Paste and Cut, and a refused read: the field takes the focus and Ctrl+V's paste event lands there.
    • On ari.html (FTXUI in xterm.js) it focuses the field, opens its menu with Shift+F10, and pastes through the OSC 52 read the page answers.
    • It finds menu items through the armed state, so no coordinates are hard-coded. It is added to ci.yml's arigl-web job, whose path filter now includes src/cvcGL/Clipboard.cpp and ImGuiBackend.cpp.

Run locally (Linux, RelWithDebInfo), all passing: cvcgl_imgui_context_menu, cvcgl_imgui_chat_widgets, all 119 of ariadne_ftxui_test, ariadne_term_graphics_test and the runtime's notification tests. arigl_web_clipboard.mjs also passes in headless Chrome 152 (SwiftShader), twice, against a single-threaded arigl-web built by the recipe's script. Its deps came fresh from the catalog: this box's older wasm prefixes predate #1409's wasm exceptions and no longer link.

Not checked: Firefox and Safari's own Paste prompts (headless Chrome only), a real touch screen's long press (simulated in the ImGui test), and a real terminal answering the OSC 52 read (FTXUI's parsing of the answer was checked under a pty).

Formatting: clang-format 18.1.8 on the changed lines. The JavaScript inside EM_JS sits between clang-format off and on, as web_audio.cpp does.

…elect all (§5.28)

A right-click on text opens a context menu in every host, with nothing in the
document asking for it. So does a long press on a touch screen, and Shift+F10
or the Menu key in a terminal.

- A field (input_text, message_input): Cut, Copy, Paste and Select all, on the
  selection or, with none, the whole text. A password field has no Cut or Copy.
- A text, a bound value (its value), a rich text: Copy, and Select text...,
  which shows the text in a read-only field to copy a part of it.
- A text_view: Copy line (the line under the pointer, a chat message), Copy all.
- A notification, in the bell's menu or the Notifications window: Copy, of the
  whole message. The core hands it over with Backend::next_item_copy.

ImGui natively uses the system clipboard, and edits through the field's
callback, so ImGui's undo has the menu's Cut and Paste. In the browser Paste is
navigator.clipboard.readText(), and the text goes in when it answers. The
clipboard calls run inside the pointer release over the menu item
(cvc::gl::clipboard::arm), as Safari requires. A refused read leaves the field
focused for Ctrl+V, whose paste event works as before.

FTXUI copies with OSC 52 and pastes with an OSC 52 read, answered by xterm with
allowWindowOps, foot, kitty, iTerm2 and the ari.html page; a silent terminal
gets a hint to use its own paste. Its fields gain a selection (Shift with the
arrows, Home, End). tvision uses TClipboard for both.

Tests: cvcgl_imgui_context_menu; ariadne_ftxui_test (five cases);
ariadne_term_graphics_test's Osc52ReadsAndItsAnswer; ariadne_runtime_test's
ANotificationsEntryCopiesItsWholeMessage; and arigl_web_clipboard.mjs in
headless Chrome, added to ci.yml's arigl-web job.
…a refused read told apart

The clipboard API wants a focused document, which a headless tab is not unless
DevTools emulates it. The probes go in near the window's left edge, so they are
over a short text too. Ctrl+V sends Control first. The refused-read step puts
another text on the clipboard than its paste event carries. When the package has
ari.html, the same document there: Shift+F10 on the field, then Paste, read with
OSC 52 and answered by the page.
@transfix
transfix enabled auto-merge (squash) November 23, 2026 06:47
…ontext-menu

# Conflicts:
#	src/cvcGL/ariadne/ImGuiBackend.cpp
@transfix
transfix merged commit af45354 into master Nov 24, 2026
30 of 31 checks passed
@transfix
transfix deleted the feat/ariadne-text-context-menu branch November 24, 2026 10:20
transfix added a commit that referenced this pull request Nov 24, 2026
Conflict in ci.yml's arigl-web gate: master's #1476 runs it when the
clipboard changes, SH2 when how a viewport widget's view draws changes.
Both kept.
transfix added a commit that referenced this pull request Nov 25, 2026
…' after #1452, Cmd+Z in the context-menu test

The ci/full run of the first commit (45375289474) passed the six new macOS
goldens on all four lanes and left two failures:

- cvcgl_ari_golden: volren_views (#1498), 882 px beyond +-40. Its four lanes'
  frames are byte-identical, the same picture with box edges and the volren's
  shading a pixel apart. Committed as volren_views.macos.png.
- cvcgl_imgui_context_menu (#1476): "ImGui's undo takes the paste back". The
  test pressed ImGuiMod_Ctrl+Z. With ConfigMacOSXBehaviors (on Apple),
  io.AddKeyEvent swaps Cmd and Ctrl, so that arrives as Super and InputText
  doesn't undo. The test now presses ImGuiMod_Super there, the key a Mac's
  Cmd arrives as, which ImGui turns into its shortcut key. Checked against
  ImGui 1.92.9 with a standalone InputText: with macOS behaviours Ctrl+Z
  leaves 'abc' and Super+Z undoes to 'ab', and the reverse without them.

Master since then has #1452, which re-captured volume_grid, _quad and
_contours for its Segmentation tab and added volume_grid_segment (366 px on
macOS). Their .macos.png are the v4.0.8 tag run's (45478904899) frames,
byte-identical across the four lanes, and the same pictures as the llvmpipe
goldens.
transfix added a commit that referenced this pull request Nov 25, 2026
…ext_menu:)

Master's #1476 gave every backend a built-in context menu on text (Cut,
Copy, Paste, Select text..., ARIADNE.md 5.28) and 5.29 a picture's Save.
SH8's context_menu: now joins that menu instead of running beside it:

- One request opens one menu. Over a widget with entries of its own
  (a field, a text, a picture) those come first, then under a rule the
  items of the innermost context_menu: around it; over anything else
  inside one, its items alone; with none around, #1476's menu as is.
- ImGui: the document's areas live in #1476's ContextMenus. A menu a
  text or field opens remembers the innermost area, which appends its
  items to the same popup; elsewhere the area opens one through the
  same open()/begin() (its long press, Escape, one claim a frame).
- FTXUI: #1476's ctx menu holds the leaf's entries and keeps the
  area's items as rows after them; one Shift+F10 / Menu path, one
  right-click path. The duplicate key decoding is gone (master had it).
- tvision: Options::host_draws_context_menu; hosted_context_menu() and
  pick_context_entry() let the bridge show the menu with popupMenu at
  its place, so a short window no longer cuts it off. That was the
  failing ari_run_context_menu_tvision: a two-row window drew the menu
  as an empty frame.
- The section is ARIADNE.md 5.30; 5.28 points to it. The closed schema
  (ari.v1.schema.json, from #1464) learns context_menu on the document,
  groups, panels, windows, overlays, custom widgets and include sites,
  and kBuiltinBlocks lists it.
- Picks: pick_props takes master's node map (id and node, for a node's
  own on_pick:); CustomEdit keeps both events and context_pick.

The ImGui test for SH8 is cvcgl_imgui_document_menu (master's
cvcgl_imgui_context_menu keeps its name); FTXUI gains
AFieldInACardOffersItsOwnEntriesThenTheCards and
AHostedContextMenuIsAModelForTheHost; the context_menu golden now shows
the text's Copy and Select text... above the card's items.
transfix added a commit that referenced this pull request Nov 25, 2026
…t, ci/full for new goldens (#1526)

* cvcgl_ari_golden: macOS goldens for the six mesh and volume documents added since 11-20

contour_tiler, skeleton, molecule_skeleton, volume_grid, volume_grid_quad and
volume_grid_contours were added between 2026-11-20 and 11-23 with llvmpipe
goldens only. Pull requests skip the macOS package lanes, so none of them was
compared under the Apple Software Renderer before it merged. Since then all
four macOS package lanes have failed cvcgl_ari_golden on master and on the
v4.0.3 to v4.0.6 tags: 1,066 to 4,889 px beyond +-40, with the same counts in
every run.

The macOS frames are the same pictures. Edges of lines, translucent surfaces
and nearest-sampled texels land a pixel apart, as on orthoslicer. On
volume_grid_quad the Probe tab's Min/Max is also one float32 ulp off on the
arm64 runner. The four lanes' frames are byte-identical, so the v4.0.6 tag
run's (45246162146) are committed as <name>.macos.png, as docs/ARIADNE.md
describes. ARIADNE.md now says to run a new golden through ci/full/** before
it merges.

* macOS: volren_views and volume_grid_segment goldens, the volume grids' after #1452, Cmd+Z in the context-menu test

The ci/full run of the first commit (45375289474) passed the six new macOS
goldens on all four lanes and left two failures:

- cvcgl_ari_golden: volren_views (#1498), 882 px beyond +-40. Its four lanes'
  frames are byte-identical, the same picture with box edges and the volren's
  shading a pixel apart. Committed as volren_views.macos.png.
- cvcgl_imgui_context_menu (#1476): "ImGui's undo takes the paste back". The
  test pressed ImGuiMod_Ctrl+Z. With ConfigMacOSXBehaviors (on Apple),
  io.AddKeyEvent swaps Cmd and Ctrl, so that arrives as Super and InputText
  doesn't undo. The test now presses ImGuiMod_Super there, the key a Mac's
  Cmd arrives as, which ImGui turns into its shortcut key. Checked against
  ImGui 1.92.9 with a standalone InputText: with macOS behaviours Ctrl+Z
  leaves 'abc' and Super+Z undoes to 'ab', and the reverse without them.

Master since then has #1452, which re-captured volume_grid, _quad and
_contours for its Segmentation tab and added volume_grid_segment (366 px on
macOS). Their .macos.png are the v4.0.8 tag run's (45478904899) frames,
byte-identical across the four lanes, and the same pictures as the llvmpipe
goldens.
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