pub struct TextEditorStateInner { /* private fields */ }Expand description
State structure for the text editor, managing text content, cursor, selection, and editing logic. Core text editing state, shared between components Core state for text editing, including content, selection, cursor, and interaction state.
This struct manages the text buffer, selection, cursor position, focus, and user interaction state.
It is designed to be shared between UI components via a TextEditorStateHandle.
Implementations§
Source§impl TextEditorStateInner
impl TextEditorStateInner
Sourcepub fn new(size: Dp, line_height: Option<Dp>) -> Self
pub fn new(size: Dp, line_height: Option<Dp>) -> Self
Creates a new TextEditorState with the given font size and optional line height.
§Arguments
size- Font size in Dp.line_height- Optional line height in Dp. IfNone, uses 1.2x the font size.
Sourcepub fn with_selection_color(
size: Dp,
line_height: Option<Dp>,
selection_color: Color,
) -> Self
pub fn with_selection_color( size: Dp, line_height: Option<Dp>, selection_color: Color, ) -> Self
Creates a new TextEditorState with a custom selection highlight color.
§Arguments
size- Font size in Dp.line_height- Optional line height in Dp.selection_color- Color used for selection highlight.
Sourcepub fn line_height(&self) -> Px
pub fn line_height(&self) -> Px
Returns the line height in pixels.
Sourcepub fn text_data(&mut self, constraint: TextConstraint) -> TextData
pub fn text_data(&mut self, constraint: TextConstraint) -> TextData
Returns the current text buffer as TextData, applying the given layout constraints.
§Arguments
constraint- Layout constraints for text rendering.
Sourcepub fn focus_handler(&self) -> &Focus
pub fn focus_handler(&self) -> &Focus
Returns a reference to the internal focus handler.
Sourcepub fn focus_handler_mut(&mut self) -> &mut Focus
pub fn focus_handler_mut(&mut self) -> &mut Focus
Returns a mutable reference to the internal focus handler.
Sourcepub fn editor(&self) -> &Editor<'static>
pub fn editor(&self) -> &Editor<'static>
Returns a reference to the underlying glyphon::Editor.
Sourcepub fn editor_mut(&mut self) -> &mut Editor<'static>
pub fn editor_mut(&mut self) -> &mut Editor<'static>
Returns a mutable reference to the underlying glyphon::Editor.
Sourcepub fn blink_timer(&self) -> Instant
pub fn blink_timer(&self) -> Instant
Returns the current blink timer instant (for cursor blinking).
Sourcepub fn update_blink_timer(&mut self)
pub fn update_blink_timer(&mut self)
Resets the blink timer to the current instant.
Sourcepub fn selection_color(&self) -> Color
pub fn selection_color(&self) -> Color
Returns the current selection highlight color.
Sourcepub fn current_selection_rects(&self) -> &Vec<RectDef>
pub fn current_selection_rects(&self) -> &Vec<RectDef>
Returns a reference to the current selection rectangles.
Sourcepub fn set_selection_color(&mut self, color: Color)
pub fn set_selection_color(&mut self, color: Color)
Sourcepub fn handle_click(
&mut self,
position: PxPosition,
timestamp: Instant,
) -> ClickType
pub fn handle_click( &mut self, position: PxPosition, timestamp: Instant, ) -> ClickType
Sourcepub fn start_drag(&mut self)
pub fn start_drag(&mut self)
Starts a drag operation (for text selection).
Sourcepub fn is_dragging(&self) -> bool
pub fn is_dragging(&self) -> bool
Returns true if a drag operation is in progress.
Sourcepub fn last_click_position(&self) -> Option<PxPosition>
pub fn last_click_position(&self) -> Option<PxPosition>
Returns the last click position, if any.
Sourcepub fn update_last_click_position(&mut self, position: PxPosition)
pub fn update_last_click_position(&mut self, position: PxPosition)
Updates the last click position (used for drag tracking).
§Arguments
position- The new last click position.
Sourcepub fn map_key_event_to_action(
&mut self,
key_event: KeyEvent,
key_modifiers: ModifiersState,
clipboard: &mut Clipboard,
) -> Option<Vec<Action>>
pub fn map_key_event_to_action( &mut self, key_event: KeyEvent, key_modifiers: ModifiersState, clipboard: &mut Clipboard, ) -> Option<Vec<Action>>
Map keyboard events to text editing actions Maps a keyboard event to a list of text editing actions for the editor.
This function translates keyboard input (including modifiers) into editing actions such as character insertion, deletion, navigation, and clipboard operations.
§Arguments
key_event- The keyboard event to map.key_modifiers- The current keyboard modifier state.clipboard- Mutable reference to the clipboard for clipboard operations.
§Returns
An optional vector of glyphon::Action to be applied to the editor.
Auto Trait Implementations§
impl Freeze for TextEditorStateInner
impl RefUnwindSafe for TextEditorStateInner
impl Send for TextEditorStateInner
impl Sync for TextEditorStateInner
impl Unpin for TextEditorStateInner
impl !UnwindSafe for TextEditorStateInner
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more