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>
impl<XMSG> Editor<XMSG>
pub fn from_str(options: Options, content: &str) -> Editor<XMSG>
pub fn text_buffer(&self) -> &TextBuffer
pub fn set_selection( &mut self, start: OPoint<i32, Const<2>>, end: OPoint<i32, Const<2>>, )
pub fn selection(&self) -> &Selection
pub fn selected_text(&self) -> Option<String>
pub fn cut_selected_text(&mut self) -> Option<String>
pub fn is_selected(&self, loc: OPoint<i32, Const<2>>) -> bool
pub fn clear_selection(&mut self)
pub fn set_selection_start(&mut self, start: OPoint<i32, Const<2>>)
pub fn set_selection_end(&mut self, end: OPoint<i32, Const<2>>)
pub fn get_char(&self, loc: OPoint<usize, Const<2>>) -> Option<char>
pub fn get_position(&self) -> OPoint<usize, Const<2>>
pub fn get_content(&self) -> String
pub fn total_lines(&self) -> usize
Source§impl<XMSG> Editor<XMSG>
impl<XMSG> Editor<XMSG>
pub fn process_commands( &mut self, commands: impl IntoIterator<Item = Command>, ) -> Vec<XMSG>
Sourcepub fn process_command(&mut self, command: Command) -> bool
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
pub fn clear(&mut self)
Sourcepub fn on_change<F>(self, f: F) -> Editor<XMSG>
pub fn on_change<F>(self, f: F) -> Editor<XMSG>
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.
pub fn add_on_change_listener<F>(&mut self, f: F)
Sourcepub fn on_change_notify<F>(self, f: F) -> Editor<XMSG>
pub fn on_change_notify<F>(self, f: F) -> Editor<XMSG>
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.
pub fn add_on_change_notify<F>(&mut self, f: F)
pub fn emit_on_change_listeners(&self) -> Vec<XMSG>
pub fn numberline_wide(&self) -> usize
Trait Implementations§
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> 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
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.