Skip to main content

RopeEditor

Struct RopeEditor 

Source
pub struct RopeEditor { /* private fields */ }
Expand description

TextEditor implementing a Rope

Implementations§

Source§

impl RopeEditor

Source

pub fn new( text: String, selection: TextSelection, indentation: u8, history: EditorHistory, ) -> Self

Source

pub fn rope(&self) -> &Rope

Source

pub fn set_preedit(&mut self, text: &str)

Insert or replace IME preedit text at the current cursor position.

The preedit text is inserted directly into the rope without recording undo history. If there is already active preedit text, it is replaced. An empty text clears the preedit.

Source

pub fn clear_preedit(&mut self)

Remove active preedit text from the rope and restore the cursor.

Source

pub fn has_preedit(&self) -> bool

Whether there is active IME preedit text in the rope.

Source

pub fn committed_text(&self) -> String

Returns the rope content with preedit text excluded.

This represents the “committed” text that should be synced to external state.

Source

pub fn preedit_text_segments(&self) -> (String, String, String)

Returns the rope text split into (before_preedit, preedit, after_preedit).

If there is no active preedit, returns the full rope text as before with empty preedit and after segments.

Trait Implementations§

Source§

impl Display for RopeEditor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl TextEditor for RopeEditor

Source§

type LinesIterator<'a> = LinesIterator<'a>

Source§

fn lines(&self) -> Self::LinesIterator<'_>

Iterator over all the lines in the text.
Source§

fn insert_char(&mut self, ch: char, idx: usize) -> usize

Insert a character in the text in the given position.
Source§

fn insert(&mut self, text: &str, idx: usize) -> usize

Insert a string in the text in the given position.
Source§

fn remove(&mut self, range_utf16: Range<usize>) -> usize

Remove a part of the text.
Source§

fn char_to_line(&self, char_idx: usize) -> usize

Get line from the given char
Source§

fn line_to_char(&self, line_idx: usize) -> usize

Get the first char from the given line
Source§

fn utf16_cu_to_char(&self, utf16_cu_idx: usize) -> usize

Source§

fn char_to_utf16_cu(&self, idx: usize) -> usize

Source§

fn line(&self, line_idx: usize) -> Option<Line<'_>>

Get a line from the text
Source§

fn len_lines(&self) -> usize

Total of lines
Source§

fn len_chars(&self) -> usize

Total of chars
Source§

fn len_utf16_cu(&self) -> usize

Total of utf16 code units
Source§

fn selection(&self) -> &TextSelection

Get a readable text selection
Source§

fn selection_mut(&mut self) -> &mut TextSelection

Get a mutable reference to text selection
Source§

fn has_any_selection(&self) -> bool

Source§

fn get_selection(&self) -> Option<(usize, usize)>

Source§

fn set(&mut self, text: &str)

Source§

fn clear_selection(&mut self)

Source§

fn set_selection(&mut self, (from, to): (usize, usize))

Source§

fn get_selected_text(&self) -> Option<String>

Source§

fn get_selection_range(&self) -> Option<(usize, usize)>

Source§

fn undo(&mut self) -> Option<TextSelection>

Source§

fn redo(&mut self) -> Option<TextSelection>

Source§

fn editor_history(&mut self) -> &mut EditorHistory

Source§

fn get_indentation(&self) -> u8

Source§

fn cursor_row(&self) -> usize

Get the cursor row
Source§

fn cursor_col(&self) -> usize

Get the cursor column
Source§

fn cursor_down(&mut self) -> bool

Move the cursor 1 line down
Source§

fn cursor_up(&mut self) -> bool

Move the cursor 1 line up
Source§

fn cursor_right(&mut self) -> bool

Move the cursor 1 char to the right
Source§

fn cursor_left(&mut self) -> bool

Move the cursor 1 char to the left
Source§

fn cursor_pos(&self) -> usize

Get the cursor position
Source§

fn move_cursor_to(&mut self, pos: usize)

Move the cursor position
Source§

fn get_visible_selection( &self, editor_line: EditorLine, ) -> Option<(usize, usize)>

Source§

fn measure_selection(&self, to: usize, line_index: EditorLine) -> TextSelection

Source§

fn process_key( &mut self, key: &Key, modifiers: &Modifiers, allow_tabs: bool, allow_changes: bool, allow_clipboard: bool, ) -> TextEvent

Source§

fn find_word_boundaries(&self, pos: usize) -> (usize, usize)

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> IntoReadable<T> for T
where T: 'static,

§

fn into_readable(self) -> Readable<T>

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,