JFLib

ui/text_surface.rs#

Source: lib/ui/text_surface.rs

Input/selection overlay for externally laid out rich text. New opt-in UI API.
The caller paints content; the existing textbox engine handles Unicode, clipboard and IME.
  • struct TextSurfaceLine One visual line of a text editing surface, in absolute physical window coordinates.
    • start: usize -- UTF-8 byte range, excluding an explicit newline. Soft wraps share their boundary.
    • end: usize
    • rect: [i32; 4] -- Hit/selection rectangle [x, y, width, height]. It may cover a different page per line.
    • carets: Vec<(usize, i32)> -- UTF-8 byte caret stops and their absolute x coordinates, in logical order.

impl Ui

  • fn textbox_surface( &mut self, id: u32, text: &mut String, cap_flags: u32, lines: &[TextSurfaceLine], ) -> u32 Edit one UTF-8 buffer over caller-rendered rich text, without repainting its content. Layout may span differently sized/aligned lines and pages; each UTF-8 scalar boundary needs a caret stop. Text changes report EV_ACT and request a fresh layout on the next pass. Invalid ranges reject the call without consuming input. The caller owns scroll positioning and document history. Ordinary textboxes are unaffected.
  • fn textbox_surface_change(&self) -> Option<(usize, usize, String)> Replacement in the original buffer from the most recent surface call. The range respects the actual insertion location even when surrounding characters repeat.

Source: docs/API.md in the JFLib repository.