Function display_buffer_for_edit

Source
pub fn display_buffer_for_edit(
    buffer: &TextBuffer,
    edit: &TextEditState,
) -> EditorDisplayBuffer
Expand description

Produces text and caret geometry input for the current IME state.

No preedit or empty preedit returns an unchanged clone with the source caret clamped to buffer length. A preedit selection uses its end byte clamped to preedit length; absent selection positions after all preedit bytes.

ยงExamples

use ailloli_ui_editor::input::ime::display_buffer_for_edit;
use ailloli_ui_text::{TextBuffer, TextEditState};
let buffer = TextBuffer::from_string("hello");
let display = display_buffer_for_edit(&buffer, &TextEditState::new());
assert_eq!(display.buffer.as_str(), "hello");
assert_eq!(display.caret_byte, 0);