Skip to main content

Module mouse

Module mouse 

Source
Expand description

MO.2: editor-body mouse hit-testing.

ui.mouse has existed since MO.1, but only modeline elements listened to it — the TUI’s event handler returned early on anything that was not a left-press on a modeline zone, and the GPUI peer had hit-test primitives with no listener at all. This module is the shared half of giving the editor body scroll, click-to-position and drag-to-select.

§What lives here, and what does not

Here: the pane hit map (which pane owns a screen cell, and where its text starts) and the semantic target a resolved gesture produces. Both are renderer-neutral.

Not here: how a renderer arrives at a cell. The TUI reads (column, row) straight off a crossterm event; GPUI divides pixels by a glyph advance. That geometry belongs to each peer, and the ModelineHitMap beside this one draws the line in the same place.

§Recorded, not re-derived

The zones are pushed by the renderer during paint, and cleared at the top of every frame — exactly like crate::modeline::ModelineHitMap. A map rebuilt from layout inputs after the fact is a second implementation of the layout, free to disagree with the one on screen; the symptom of a disagreement is a click landing a pane away, which reads as a broken feature rather than as stale geometry. A pane that stops painting stops being clickable, because nothing pushed a zone for it.

Structs§

BodyHit
A screen cell resolved against the painted layout.
PaneHitMap
Every pane body painted this frame.
PaneHitZone
One pane’s painted body, recorded for hit-testing.
RowOrigin
Which part of the buffer a painted row came from.

Constants§

MOUSE_SCROLL_LINES
Vim’s mousescroll default (ver:3): one wheel notch moves three lines. Named rather than inlined so the two call sites (wheel up and wheel down) cannot drift, and so the eventual option has an obvious thing to replace.