Skip to main content

document_session_api/
text_input.rs

1// SPDX-License-Identifier: MPL-2.0
2//! Focused native text-control observations, without document values or IDs.
3
4/// Caret rectangle in the session's logical viewport coordinates, after page
5/// zoom and scrolling. Window placement and device scale belong to the host.
6/// An offscreen caret may have negative coordinates.
7#[derive(Clone, Copy, Debug, PartialEq)]
8pub struct SessionTextInputRect {
9    pub x: f64,
10    pub y: f64,
11    pub width: f64,
12    pub height: f64,
13}
14
15/// Metadata and geometry for the focused writable text control. Selection
16/// offsets address its displayed editing value in UTF-16 code units. They do
17/// not address the separate, UTF-8-indexed `SessionIme::Preedit` string.
18///
19/// Geometry comes from the current completed layout. No field text, password
20/// value, document node identity or native window handle crosses this boundary.
21#[derive(Clone, Debug, PartialEq)]
22pub struct SessionTextInputState {
23    pub element_kind: String,
24    pub input_type: String,
25    pub input_mode: String,
26    pub autocomplete: String,
27    pub multiline: bool,
28    pub password: bool,
29    pub selection_utf16: (u32, u32),
30    pub caret: SessionTextInputRect,
31}