Repository navigation
feat: the cursor's row and the row at a screen cell - #15
Merged
Merged
Conversation
… row Engine::cursor_row and Engine::row_at return a DiffRow: the file the row belongs to (index and path), its DiffRowKind, its wrapped part, its original line numbers and the side. They answer on headings, sticky headings, hunk headings, gaps, metadata notes, empty split cells, No newline marks and wrapped parts, and move nothing.
backnotprop
added a commit
to plannotator/plannotator-tui
that referenced
this pull request
Nov 23, 2026
…ng it The code review worked out which file the cursor was in from the moves it sent the viewer. With wrapping on, after a page move, after the wheel near a heading, after a click on the sticky heading and when two events came before a frame, that guess named the wrong file, so x, C, n and N and ctrl+n acted on it and the list and the footer showed it. diffs-rs now says which row the cursor is on, on every kind of row, and which row is drawn at a screen cell (plannotator/diffs-rs#15). The review asks it every time: the move model and the per-file row projection are gone, and nothing about the position is kept between events and frames. The list and the footer copy the answer after every event and before every frame. A selection kept to its hunk now asks the viewer which hunk the cursor is in, so a jump to the next hunk ends the growing and j moves on from there. Until diffs-rs publishes the new API, it comes from the branch by [patch.crates-io]. A panic now turns off mouse capture, focus reports, bracketed paste and the keyboard flags before ratatui's hook gives the screen back.
… docs - DiffRow::hunk is None on context lines a gap revealed and on their "No newline" mark: they are in no hunk. It named the hunk above them. - DiffRow is #[non_exhaustive], as DiffRowKind is. - cursor_row and row_at say exactly when they return None, and how side reads on the sticky heading and on the column between split panes. Field docs for review and kind, a rustdoc example, and an example in the embedding guide by the file marks.
Merged
sebastianst
pushed a commit
to sebastianst/plannotator-tui
that referenced
this pull request
Nov 24, 2026
…lannotator#188) * feat(review): drag over diff lines with the mouse to select them for a comment A drag in the diff or the whole-file view selects whole lines on the side it started on, as the browser's code review anchors them. The lines are shaded while dragging, dragging past the pane's edge scrolls, and the release makes them the selection with a comment/suggest toolbar beside it. copy_on_select copies the lines on release; when it is off, y copies them. The wheel scrolls the key help. diffs-rs has clicks and the wheel but no drag, so each drag step clicks the viewer at the pressed column and reads the line the cursor landed on. * docs: the mouse in the code review * fix(review): draw a selection as one block of colour, without the bar or the underline diffs-rs marks selected lines with a bar in the first cell, which turns into the cursor's thinner bar on the cursor's row, and underlines their text. The pass over the drawn rows now blanks that cell, takes the underline off, and fills each selected pane to its end, the split's middle line or the pane's edge. The keyboard's v selection, a drag and the whole-file view all look the same: grey on dark, the theme's light blue on light. * feat(review): drag the lines between the panes to resize the file list and the notes The line right of the file list and a new one left of the notes panel take presses before anything else in the review: a drag resizes the pane, a double click fits it again, and the line lights up under the pointer and while dragged. A press on a line never moves the cursor or starts a selection. The width uses the same state as < and >, so it stays through filters and reloads and auto-fit stops overriding it; the diff keeps its minimum. { and } (widen-notes, narrow-notes) resize the notes by keys. * fix(review): a lit pane line changes colour only Bold made terminals draw the line with a shorter glyph, so a lit line broke into dashes while the unlit one stayed solid. * feat(review): shade the other side's rows inside a unified selection In the unified view a removed line sits among the new lines a selection covers, and was left unshaded, so the selection read as two blocks. Rows strictly between the first and the last selected row now take the selection colour too. Only the look changes: the note covers and quotes the selected side's lines alone. * fix(review): the mouse never ends the review or leaves a drag behind - A release over lines no longer shown (another view, a reloaded or filtered diff) selects nothing and says so. No mouse event can end the review: an error is said in the footer. - One place drops a drag of lines or of a pane's edge, its shading with it: a key, a paste, a resize, focus lost, a second press, a move with no button held, or any mouse event outside Browse. Focus change reporting is on so a release outside the window is noticed. - A drag and a growing `v` selection stay in the hunk they started in. The shading between selected rows skips headings and gaps. - Which file and row the cursor is on is worked out from the viewer's own row layout and the last frame, without pressing keys: `v` no longer grows by itself, `n`/`N` put the heading on the top row, and a click on a heading scrolls nothing. - Configs that set `copy` keep it on the document screen: the code review copies with its own `copy-lines` action, which takes `copy`'s keys when only `copy` is set. - A double click on a pane's edge needs two clicks on one cell without a move. A width chosen for the list or the notes stays the choice through a narrower window. - The toolbar ignores clicks beside its buttons and never covers a selected row; after a drag up the view stays put on release, and a shift-click grows from the line first pressed. The split's middle is found by geometry, so a bar in the code no longer cuts the shading. * fix(review): the review's toolbar labels use the readable chip colours Comment takes the document toolbar's comment colour, suggest its own 256-colour pair, and both join the contrast test in ui::chips. * fix(ui): the review-only chip colours build on Windows, where the review is not compiled * fix(review): take the cursor's file from the viewer instead of guessing it The code review worked out which file the cursor was in from the moves it sent the viewer. With wrapping on, after a page move, after the wheel near a heading, after a click on the sticky heading and when two events came before a frame, that guess named the wrong file, so x, C, n and N and ctrl+n acted on it and the list and the footer showed it. diffs-rs now says which row the cursor is on, on every kind of row, and which row is drawn at a screen cell (plannotator/diffs-rs#15). The review asks it every time: the move model and the per-file row projection are gone, and nothing about the position is kept between events and frames. The list and the footer copy the answer after every event and before every frame. A selection kept to its hunk now asks the viewer which hunk the cursor is in, so a jump to the next hunk ends the growing and j moves on from there. Until diffs-rs publishes the new API, it comes from the branch by [patch.crates-io]. A panic now turns off mouse capture, focus reports, bracketed paste and the keyboard flags before ratatui's hook gives the screen back. * build: take diffs-rs from the branch's latest commit * fix(review): diffs-rs 0.2.2 from crates.io; ctrl+n past a path's two files - Depend on diffs-rs 0.2.2, which has Engine::cursor_row and Engine::row_at, instead of the branch by [patch.crates-io]. - ctrl+n goes by the viewer's file index and passes over every file of the path the cursor is on, so a symlink deleted and a file added in its place no longer bring it back to the same file. The count of files not viewed counts each path once. - The panic hook that turns the input modes off is in place before mouse capture or any other mode is on.
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.
This adds two read-only methods to
Engineso a host can tell which file and row the cursor is on, on every kind of row, and what row is drawn at a screen cell. plannotator-tui's code review needs it: it now guesses the cursor's file from the moves it sends. With wrapping on, after a page move or the wheel near a file heading, that guess names the wrong file, soxandCact on the wrong file.API
cursor_rowreads the cursor itself, so it is right after any command or event, before the next frame. Unlikeselected_source, it answers on headings, hunk headings, gaps, binary and mode-only notes, an empty side of a split row, "No newline" marks and every wrapped part.row_atreads the last frame, as a click would. It returnsStickyHeaderfor the heading drawn over the top row, which a click does not move to.Option. They areNonefor a diff with no files, afterreplace()until the new files arrive, and on a revealed context line whose source was withdrawn.cursor_rowis alsoNonebefore the first file.row_atis alsoNonebefore the first draw, with help open, outside the diff area and below the last row. The rustdoc and the embedding guide list these cases.Options, no changed signatures, and no change in behaviour. I left the drag code as it is: a drag moves the cursor so the view scrolls at the edges, androw_atwould not change that.Tests
src/engine/tests/rows.rsuses a patch with a binary file, a mode-only change, a rename, a deleted file, a new file, a file with two hunks and gaps, a very wide line, a deleted symlink with a new file of the same path, and "No newline" on both sides.row_atis checked against the drawn text on every screen row: file, kind, hunk and line numbers.cursor_rowmust equalrow_atat the cursor's screen row and agree withselected_source.tests/engine.rscovers a host pane drawn at an offset.Checks run locally
cargo fmt --check, both clippy runs, and the doctests.cargo test --release --locked -- --test-threads=1.There is no version bump. The CHANGELOG entry is under "Unreleased".