Function draw_editable_mono_line

Source
pub fn draw_editable_mono_line(
    baseline_x: f32,
    baseline_y: f32,
    text: &str,
    caret_byte: usize,
    selection: Option<Selection>,
    preedit: Option<&ImePreedit>,
    focused: bool,
    now_ms: i64,
    style: EditableTextStyle,
    text_system: &mut TextSystem,
) -> Vec<DrawCmd>
Expand description

Single-line editable text; baseline Y = baseline_y (see DrawText.pos[1]).

Paint order: selection background (optional) → glyphs → caret. Byte offsets use UTF-8 bytes and must be character boundaries when preedit insertion occurs. Selection is intentionally hidden during preedit. The function allocates a display string and returns newly owned draw commands.

§Panics

Panics when a non-empty preedit is inserted at a clamped caret_byte that is not a UTF-8 character boundary.

§Examples

use ailloli_ui_widgets::text::{draw_editable_mono_line, EditableTextStyle};
use ailloli_ui_text::TextSystem;
let mut text_system = TextSystem::new();
let commands = draw_editable_mono_line(
    4.0, 18.0, "hello", 5, None, None, false, 0,
    EditableTextStyle::default(), &mut text_system,
);
assert_eq!(commands.len(), 1); // glyph command; unfocused means no caret