Skip to content

Feat: CodeEditor caret rects, key preview, code pointer, line and range backgrounds (FR-38, #553 #554 #555 #542) - #712

Merged
b-re-w merged 10 commits into
developfrom
feat/code-editor-ember-gaps
Nov 13, 2026
Merged

b-re-w merged 10 commits into
developfrom
feat/code-editor-ember-gaps

Conversation

@b-re-w

@b-re-w b-re-w commented Nov 13, 2026

Copy link
Copy Markdown
Member

Closes #553
Closes #554
Closes #555
Closes #542

Four SPEC commits first (FR-38 criteria 19-22, leader-approved provisional), then one code commit each.

Tests: fr38_editor_reports_the_caret_rect, fr38_editor_answers_position_rects, fr38_editor_key_preview_consumes_keys, fr38_editor_key_preview_skips_composition, fr38_editor_pointer_reports_text_position, fr38_line_background_spans_the_width_and_follows_edits, fr38_range_background_paints_its_characters (+ model and Rust wire tests), field and drawn paths. Local: fmt, clippy clean; cargo test 530/0; Kotlin 11 classes 132/132; spec-cites ok. events.bin 1599. Capture: diff-tinted editor (.scratch/p19/captures2/542-*.png). dioxus-compose follow-up filed separately.

)

Leader-approved provisional SPEC (darkpyonix leader, 2026-11-13; owner
delegated mockup-matching toolkit SPEC).
…#554)

Leader-approved provisional SPEC (darkpyonix leader, 2026-11-13; owner
delegated mockup-matching toolkit SPEC).
…erion 21, #555)

Leader-approved provisional SPEC (darkpyonix leader, 2026-11-13; owner
delegated mockup-matching toolkit SPEC).
…on 22, #542)

Leader-approved provisional SPEC (darkpyonix leader, 2026-11-13; owner
delegated mockup-matching toolkit SPEC).
…eries (FR-38, #553)

Covers FR-38 criterion 19.

Wire: the OnCaretRect handler property (195), the CaretRect event (64:
line, column, x, y, width, height) and the QueryPositionRect command
(39: node, request, line, column) answered by the PositionRect event
(65: request, a found word, the rectangle). Both events are 40 bytes, the
command 20. Rectangles are in the window's dp, so the editor's scroll and
the window's zoom are in them. Rust: CodeRect, CaretRect,
Batch::query_position_rect and code::position_query, whose callback the
Host calls once when the answer arrives. The vectors gain the command and
both events (events.bin is 1519 bytes).

Renderer: the field path and the drawn path find the caret after layout,
from the draw pass and the layout callbacks, and the model reports it at
most once a frame and only when it moved. A query is answered at once
where the editor is drawn and after its first draw otherwise; a position
that is scrolled away, folded or not in the document, a node that is not
an editor, and an editor removed before it was drawn are answered with
nothing, so every query has exactly one answer.

Tests: fr38_editor_reports_the_caret_rect (19.1) and
fr38_editor_answers_position_rects (19.2) on both paths, plus
fr38_editor_answers_position_rects_through_the_interpreter and
fr38_on_caret_rect_is_a_property_of_an_editor in CodeEditorAnchorTest;
fr38_caret_and_position_rects_keep_their_assigned_tags,
fr38_editor_reports_the_caret_rect_on_the_wire and
fr38_editor_answers_position_rects_on_the_wire in code_editor.rs; the
vector offsets in ProtocolVectorsTest.
…les them (FR-38, #554)

Covers FR-38 criterion 20.

Wire: the OnKeyPreview handler property (196). What it hears is the
existing KeyDown record of FR-12.1 (code, text, modifiers, repeat), and
the synchronous result says whether the Host took the key.

Renderer: the field path asks from its preview key handler and the drawn
path at the top of its key handling, so a key the Host consumes never
reaches the editor. Nothing is offered while an input method composes, a
release is never offered, and every event passes the held-key tracker so
a repeat is marked as one.

Tests: fr38_editor_key_preview_consumes_keys (20.1, both paths) and
fr38_editor_key_preview_skips_composition (20.2) in
CodeEditorInputHooksTest; fr38_editor_key_preview_keeps_its_tag_and_the_key_down_record
in code_editor.rs.
…der them (FR-38, #555)

Covers FR-38 criterion 21.

Wire: the OnCodePointer handler property (197), with the kinds taken from
the node's PointerKinds mask, which an editor now accepts. The CodePointer
event (66) is the 72 byte Pointer record followed by the line and the
column under the pointer, both u32::MAX over no character: 80 bytes. Rust:
code::CodePointer, a PointerEvent and the position. The event vector gains
one (events.bin is 1599 bytes).

Renderer: the editor's view carries the same pointer node a subscribed node
does, on the same router, so the kinds, the buttons, the modifiers, the
click count, capture, the menu and a move a frame are FR-46's own. It
routes in the first pass rather than the main one, so a Down the Host
consumes is consumed before the field's selection gesture or the drawn
editor's press sees it, and the caret stays. The field path finds the
character through the field's layout and the drawn path through its rows;
the gutter, past a line's end, a lens row and below the last line are over
no character.

Tests: fr38_editor_pointer_reports_text_position (21.1, both paths) in
CodeEditorInputHooksTest; fr38_editor_pointer_reports_text_position_on_the_wire
in code_editor.rs; the vector offset in ProtocolVectorsTest. PointerEventsTest
still passes on the shared router.
…FR-38, #542)

Covers FR-38 criterion 22.

Wire: DecorationKind gains LineBackground (5) and RangeBackground (6),
appended, in the existing 44 byte decoration record with a ColorRole.
Rust: Decoration::line_background(version, line_start, line_end, role),
the lines as a range from the start of the first to the start of the
last, and Decoration::range_background(version, range, role). The
mutation vector's decoration list gains one of each.

Renderer: a line background is followed as lines, the way a gutter mark
is, and goes only when every one of its lines is deleted; a range
background follows like any other range. The field path draws line tints
behind the field across the row from the gutter to the right edge, and
range tints in the field's own layout; the drawn path draws both per row
before the selection and the text. DiffAdded and DiffRemoved take the
design system's container tint for a line and the emphasis tint for a
range; those four roles are drawn as they are, and any other role as a
wash of its colour at the strengths the container and emphasis tints are
mixed at. A background without a role is refused with a protocol error.
The design showcase's editor gains one of each.

Tests: fr38_line_background_spans_the_width_and_follows_edits (22.1) and
fr38_range_background_paints_its_characters (22.2) on both paths, and
fr38_line_and_range_backgrounds_follow_edits_in_the_model, in
CodeEditorBackgroundTest; fr38_line_and_range_backgrounds_round_trip_on_the_wire
in code_editor.rs; the decoration vector in ProtocolVectorsTest.
…mber-gaps

# Conflicts:
#	CHANGELOG.md
#	compose-rust/android-kotlin/shared/Protocol.gen.kt
#	compose-rust/schema-hash.txt
#	compose-rust/src/codegen.rs
#	compose-rust/src/protocol.rs
#	compose-rust/src/schema.rs
#	compose-rust/tests/vectors/events.bin
#	compose-rust/tests/vectors/mutations.bin
#	compose-rust/tests/vectors/vectors.json
#	renderer/desktop/src/protocol/Protocol.gen.kt
#	renderer/desktop/test/ProtocolVectorsTest.kt
@b-re-w

b-re-w commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

Re-verified after merging develop (incl. #713, #714, #715): Rust 542/0; Kotlin 8 CodeEditor classes + ProtocolVectorsTest + PointerEventsTest + KeyEventTest 135/135, PickerTest 9/9; spec-cites ok. Merged after v0.0.8 was cut; part of 0.0.9.

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