Skip to content

input: gutter cursor style + line hitbox accessors#2412

Draft
glani wants to merge 1 commit into
longbridge:mainfrom
glani:heretic/gutter-cursor-hitbox
Draft

input: gutter cursor style + line hitbox accessors#2412
glani wants to merge 1 commit into
longbridge:mainfrom
glani:heretic/gutter-cursor-hitbox

Conversation

@glani

@glani glani commented May 29, 2026

Copy link
Copy Markdown
Contributor

Problem

Two small gaps for editors that show a line-number gutter:

  1. The mouse cursor stays a text I-beam over the gutter, so the
    line-number column reads as part of the text-insertion area even
    though it isn't.
  2. A consumer has no way to find where the gutter is on screen, or where
    a given buffer line is, without re-deriving layout — which it needs
    for things like click-to-select-line, breakpoint toggles, or placing
    a popover next to a specific line.

Solution

Gutter cursor. When the mode shows line numbers, paint sets
CursorStyle::Arrow over the line-number hitbox so the gutter no longer
reads as the text-insertion area. Gated on InputMode::line_number(), so
single-line and auto-grow inputs are unaffected.

Two read-only accessors on InputState:

pub fn line_number_hitbox(&self) -> Option<&Hitbox>;
pub fn visible_line_bounds(&self, row: u32) -> Option<Bounds<Pixels>>;
  • line_number_hitbox() exposes the gutter hitbox captured during the
    last paint.
  • visible_line_bounds(row) returns the on-screen bounds of a buffer row
    from the last layout, soft-wrap aware.

Both are primitives for consumer-side click routing. The only behavior
change is the mouse cursor over the gutter (which previously had no
special cursor); everything else is strictly additive.

Two small, additive primitives for editors that show a line-number
gutter.

Gutter cursor: when the mode shows line numbers, paint sets
`CursorStyle::Arrow` over the line-number hitbox so the gutter no longer
reads as the text-insertion area. Gated on `InputMode::line_number()`, so
single-line and auto-grow modes are unaffected.

Line hitbox accessors on `InputState`:
- `line_number_hitbox() -> Option<&Hitbox>` exposes the gutter hitbox
  captured during the last paint.
- `visible_line_bounds(row) -> Option<Bounds<Pixels>>` returns the
  on-screen bounds of a buffer row from the last layout, soft-wrap aware.

Both accessors are primitives for consumer-side click routing. No change
to existing behavior.
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