Repository navigation
ALI-2565: Select part of Quick View's text from the keyboard (F7 caret mode) - #67
Merged
Merged
Conversation
…aret mode) F7 in a text or Markdown preview turns on a caret at the start of the first line in view. The arrows move it by a character or a line, Ctrl+Left and Ctrl+Right by a word, Home and End to the ends of the line as it's shown, and Ctrl+Home and Ctrl+End to the ends of the text. Shift with any of them selects from where it started, and Ctrl+C copies as before. Up and Down keep a column across shorter lines. A click moves the caret. F7 or Escape turns it off; Escape then doesn't close the window. The view scrolls to keep the caret in sight. The caret works on wrapped lines (the end of one is drawn at its end), tabs (one step, drawn at the stop) and Markdown tables (cell by cell, rules passed over), using the layout's offsets, so what's selected copies as a drag's selection does. It costs nothing while off, and doesn't blink: no timer runs, and a key repaints only the caret's old and new lines, or the document when the selection or the scroll changes. Idle wakeups with it on stay at 0. The caret is 2 px (new token doc-caret), in foreground on the background and on-selection on the selection, half in each at the selection's edge, so each half has 3:1 on what it's on in every theme: foreground and on-selection are the same as selection and base in Osaka Jade, so a single colour couldn't. The token file lists the pairs. A screen reader hears "Caret mode on" and "Caret mode off", and in caret mode the keyboard is on a read-only paragraph holding the caret's line (table cells apart by spaces), with its caret and selection. Within a line the caret and selection events are sent as a field's are; moving to another line is a new line rather than an edit, so the caret is said to move and the line is read from there.
Member
Author
|
Review round 1. The code-review skill ran, along with
Confirmed fine:
|
… closing - A double or triple click in caret mode left the caret where the pointer was, inside the word or line, so Shift+arrow grew the selection from the wrong end. The caret now goes to the word's or line's end, and Shift grows it from its start. What a screen reader is told of the line's selection comes from the same place (CaretMode::other_end). - Escape held after it turned caret mode off closed the window on the next repeat. Repeats after that are swallowed; a second press still closes. - Ctrl+A in caret mode puts the caret at the end, so Shift gives some back. - In caret mode, Previous file, Next file and Close no longer give Left, Right and Escape as their keys, as those move the caret and leave the mode. - A resize keeps the caret at a wrapped line's end if it was there, scrolls it into view, and tells a screen reader the line laid out again is a new one rather than an edit. - On an empty list item, quote or code line, the caret is where its text would start, not at the page's margin. - The README says the arrows don't go to other files in caret mode, Shift+Up and Shift+Down select, and Page Up, Page Down and the wheel scroll without moving the caret.
Member
Author
|
Round 1 fixes are in 5e28679.
Unit tests: 527 + 441 + 5. Clippy: 0 warnings. |
Member
Author
|
Review round 2 (by hand, narrow check of 5e28679): no P1 or P2. Each round 1 fix holds:
Being fixed (P3, all scrolling):
|
…om it - A double or triple click in caret mode scrolls the caret, now at the end of the word or line, into view, so a wrapped paragraph ending below the window shows its end. - Ctrl+A in caret mode puts the caret at the end but leaves the view where it is, as Page Down and the wheel do; the next arrow goes to the caret. - A resize keeps the caret in view only if it was in view before, so a view scrolled away from it with the wheel stays where it was.
Member
Author
|
Round 2 fixes are in 880b53a.
The review loop stops here: round 2 had only P3s, and these three are small scrolling changes covered by tests. Unit tests: 529 + 441 + 5. Clippy: 0 warnings. |
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.
Fixes ALI-2565.
In Quick View, the mouse could select any part of a text or Markdown preview, but the keyboard could only select all of it (Ctrl+A). Someone who can't use a mouse had no way to copy just a line or a word. This adds a caret mode, as browsers have.
Behaviour
Layoutoffsets indocview.rs. The caret resets when a new document arrives.Cost
There's no blink timer. Nothing is computed or drawn while caret mode is off, and a key press repaints only the old and new caret lines, or the document area when the selection or scroll changes.
10,000-line text, headless sway:
Contrast
design/build --checknow lists the caret pairs at a 3:1 minimum. The lowest across all 11 themes:One miss, and its fix: in Osaka Jade, foreground equals selection (1.00:1), so no single caret colour works. At a selection edge, the caret is half foreground on the background side and half on-selection on the selection side, so each half has its own background's contrast. The caret is 2 px wide (new token
doc-caret), since it doesn't blink.Judgement calls (made overnight, for Mike to confirm)
_as word characters, the same as double-click.Checks
design/build --checkpasses.caret_mode_selects_part_of_a_line_from_the_keyboardselects "hunter2" and a table row from the keyboard, reads them back withwl-pastein light and dark, and fails against main. The screen-reader check now covers the announcements and the caret line's events.~/.cache/gannet-dev/gannet-caret), and it hasn't been heard with real Orca (only the scripted AT-SPI client). This stays a draft until he's tried it.