Explore output with the keyboard: Enter/Escape, siblings, Shift+arrows (#2382) - #2409
Merged
Merged
Conversation
Steps two and three of #2382. With a part of an output selected: - Enter goes into the selected expression: from a result to its expression, from a fraction to its numerator, from a matrix to its first entry. On a part with no parts it keeps its old meaning (a new input cell holding the selection). - Escape goes back out, and from a whole result back into the input. - Left/Right select the neighbouring part; in a matrix all four arrow keys move from entry to entry, skipping elided ones. - Shift+Left/Right grow or shrink the selection over neighbouring parts of the same cell list; a matrix entry is selected as a one-entry block, so Shift+arrows grow it exactly like a dragged block (#2370). The tree walked is the expression's structure (GetInnerCell()), not the draw list, so line breaks don't change what a key does. It lives in the new OutputNavigation, which knows nothing about key events and is tested on parsed output. Glyphs a cell only draws while broken into lines ("sqrt(", ",", ")") are not parts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014i39UdkdrHCP1EUWkG9snP
The test is red on the Windows jobs on main: wxYield() dispatches no socket events on MSW without an active event loop. Same change as #2410; it no-ops once main carries it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014i39UdkdrHCP1EUWkG9snP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Gunter · project thread
Steps two and three of #2382. Step one was #2383 and #2384.
Before: the keyboard could select a whole result of a cell's output, but nothing smaller. Enter on a selected result opened a new input cell holding its text.
After: with a part of an output selected, Enter goes into it and selects its first part: from a result to its expression, then from a fraction to its numerator, from a function to its name, from a matrix to its first entry, and so on. Escape goes back out one level at a time, and from a whole result back into the cell's input. Left and Right select the neighbouring part. In a matrix, all four arrow keys move from entry to entry and skip elided ones. Shift+Left and Shift+Right grow or shrink the selection over neighbouring parts. A matrix entry is selected as a one-entry block, so Shift+arrows grow it the same way they grow a block dragged with the mouse (#2370). Every move raises the same accessibility focus event step one does.
A few choices worth checking:
x) keeps its old meaning: it opens a new cell holding the selection. So the old Enter still works on leaves, but not on whole results.How: a new
OutputNavigation(insrc/worksheet/) models the output as a tree built from the expression's structure (OnInner()), not from the draw list, so a line break doesn't change what a key does. Glyphs that a cell only draws while broken into lines (sqrt(,,,),/,^, a limit'slim) are left out, and so are hidden and empty cells and elided matrix entries. An item that only wraps a single part, such as a matrix entry holding one fraction, is looked through, so that Enter always visibly changes the selection. It knows nothing about key events.Worksheet::NavigateOutput()maps the keys onto it. The node is found by searching the tree, so no state goes stale when the mouse changes the selection. The one exception is the Shift anchor, which is aCellPtr.Tests:
test_OutputKeyboardNavigationgains 5 scenarios, covering Enter/Escape round trips, glyph filtering, Enter on a leaf, Shift growing and shrinking from either end, and matrix entry movement, block growth and entering an entry. With the key handler disabled, 16 of the new assertions fail. All 58 unit tests pass locally with a unity build. I also checked it live in Xvfb onmatrix([1,x/(y+1)],[3,sin(z)])anda+b^2+sqrt(c): the entry and the numerator highlight, and so does a run grown with Shift. That live check is what found the numerator/denominator case, which now has its own test.Docs: a new manual section, "Exploring output with the keyboard" (it covers step one too), and a NEWS entry.
🤖 Generated with Claude Code
https://claude.ai/code/session_014i39UdkdrHCP1EUWkG9snP
Generated by Claude Code