Struct Editor

Source
pub struct Editor<XMSG> {
    pub text_edit: TextEdit,
    /* private fields */
}
Expand description

An editor with core functionality platform specific UI

Fields§

§text_edit: TextEdit

Implementations§

Source§

impl<XMSG> Editor<XMSG>

Source

pub fn from_str(options: Options, content: &str) -> Editor<XMSG>

Source

pub fn text_buffer(&self) -> &TextBuffer

Source

pub fn set_selection( &mut self, start: OPoint<i32, Const<2>>, end: OPoint<i32, Const<2>>, )

Source

pub fn selection(&self) -> &Selection

Source

pub fn selected_text(&self) -> Option<String>

Source

pub fn cut_selected_text(&mut self) -> Option<String>

Source

pub fn is_selected(&self, loc: OPoint<i32, Const<2>>) -> bool

Source

pub fn clear_selection(&mut self)

Source

pub fn set_selection_start(&mut self, start: OPoint<i32, Const<2>>)

Source

pub fn set_selection_end(&mut self, end: OPoint<i32, Const<2>>)

Source

pub fn get_char(&self, loc: OPoint<usize, Const<2>>) -> Option<char>

Source

pub fn get_position(&self) -> OPoint<usize, Const<2>>

Source

pub fn get_content(&self) -> String

Source

pub fn total_lines(&self) -> usize

Source§

impl<XMSG> Editor<XMSG>

Source

pub fn process_commands( &mut self, commands: impl IntoIterator<Item = Command>, ) -> Vec<XMSG>

Source

pub fn process_command(&mut self, command: Command) -> bool

TODO: convert this into process_commands where each command marks whether the content has changed or not then once all of the commands have been executed, the emit and rehighlight will commence

TODO option2: have a boolean flag, for each of the command to determine if the editor content changed or not

Source

pub fn clear(&mut self)

Source

pub fn on_change<F>(self, f: F) -> Editor<XMSG>
where F: Fn(String) -> XMSG + 'static,

Attach a callback to this editor where it is invoked when the content is changed.

Note:The content is extracted into string and used as a parameter to the function. This may be a costly operation when the editor has lot of text on it.

Source

pub fn add_on_change_listener<F>(&mut self, f: F)
where F: Fn(String) -> XMSG + 'static,

Source

pub fn on_change_notify<F>(self, f: F) -> Editor<XMSG>
where F: Fn(()) -> XMSG + 'static,

Attach an callback to this editor where it is invoked when the content is changed. The callback function just notifies the parent component that uses the Editor component. It will be up to the parent component to extract the content of the editor manually.

This is intended to be used in a debounced or throttled functionality where the component decides when to do an expensive operation based on time and recency.

Source

pub fn add_on_change_notify<F>(&mut self, f: F)
where F: Fn(()) -> XMSG + 'static,

Source

pub fn emit_on_change_listeners(&self) -> Vec<XMSG>

Source

pub fn numberline_wide(&self) -> usize

Trait Implementations§

Source§

impl<XMSG> Default for Editor<XMSG>
where XMSG: Default,

Source§

fn default() -> Editor<XMSG>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<XMSG> Freeze for Editor<XMSG>

§

impl<XMSG> !RefUnwindSafe for Editor<XMSG>

§

impl<XMSG> !Send for Editor<XMSG>

§

impl<XMSG> !Sync for Editor<XMSG>

§

impl<XMSG> Unpin for Editor<XMSG>
where XMSG: Unpin,

§

impl<XMSG> !UnwindSafe for Editor<XMSG>

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.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.