Struct WebEditor

Source
pub struct WebEditor<XMSG> {
    pub editor: Editor<XMSG>,
    pub is_focused: bool,
    /* private fields */
}
Expand description

rename this to WebEditor

Fields§

§editor: Editor<XMSG>§is_focused: bool

Implementations§

Source§

impl<XMSG> WebEditor<XMSG>

Source

pub fn from_str(options: Options, content: &str) -> Self

Source

pub fn set_syntax_token(&mut self, syntax_token: &str)

Source

pub fn set_theme(&mut self, theme_name: &str)

Source

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

Source

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

Source

pub fn get_content(&self) -> String

Source§

impl<XMSG> WebEditor<XMSG>

Source

pub fn set_mouse_cursor(&mut self, mouse_cursor: MouseCursor)

Source

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

Source

pub fn get_position(&self) -> Point2<usize>

Source

pub fn rehighlight_visible_lines(&mut self)

rehighlight from 0 to the end of the visible lines

Source

pub fn rehighlight_non_visible_lines_in_background(&mut self)

rehighlight the rest of the lines that are not visible

Source

pub fn keyevent_to_command(ke: &KeyboardEvent) -> Option<Command>

Source

pub fn process_keypress(&mut self, ke: &KeyboardEvent) -> Effects<Msg, XMSG>

make this into keypress to command

Source

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

Source

pub fn highlight_lines( text_edit: &TextEdit, text_highlighter: &mut TextHighlighter, ) -> Vec<Vec<(Style, Vec<Ch>)>>

Source

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

Source

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

Source

pub fn is_selected(&self, loc: Point2<i32>) -> bool

Source

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

Source

pub fn clear(&mut self)

Source

pub fn set_selection(&mut self, start: Point2<i32>, end: Point2<i32>)

Source

pub fn copy_selected_text_to_clipboard(&self) -> bool

Source

pub fn cut_selected_text_to_clipboard(&mut self) -> bool

Source

pub fn bounding_rect(&self) -> Option<(Point2<f32>, Point2<f32>)>

calculate the bounding rect of the editor using a DOM call getBoundingClientRect

Source

pub fn in_bounds(&self, client_x: f32, client_y: f32) -> bool

check if this mouse client x and y is inside the editor bounds

Source

pub fn editor_offset(&self) -> Option<Point2<f32>>

Source

pub fn relative_client(&self, client_x: i32, client_y: i32) -> Point2<i32>

calculate the points relative to the editor bounding box

Source

pub fn total_lines(&self) -> usize

Source

pub fn client_to_grid(&self, client_x: i32, client_y: i32) -> Point2<i32>

convert screen coordinate to grid coordinate taking into account the editor element

Source

pub fn client_to_grid_clamped( &self, client_x: i32, client_y: i32, ) -> Point2<i32>

convert screen coordinate to grid coordinate clamped negative values due to padding in the line number

Source

pub fn cursor_to_client(&self) -> Point2<f32>

convert current cursor position to client coordinate relative to the editor div

Source

pub fn view_status_line<MSG>(&self) -> Node<MSG>

the view for the status line

Source

pub fn view_highlighted_lines<MSG>(&self) -> Node<MSG>

Source

pub fn plain_view<MSG>(&self) -> Node<MSG>

Source

pub fn status_line_height(&self) -> i32

height of the status line which displays editor infor such as cursor location

Source

pub fn view_text_edit<MSG>(&self) -> Node<MSG>

Trait Implementations§

Source§

impl<XMSG> Component<Msg, XMSG> for WebEditor<XMSG>

Source§

fn update(&mut self, msg: Msg) -> Effects<Msg, XMSG>

Update the model of this component and return follow up and/or effects that will be executed on the next update loop
Source§

fn view(&self) -> Node<Msg>

the view of the component
Source§

fn style(&self) -> String

optionally a Component can specify its own css style
Source§

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

Component can have component id to identify themselves
Source§

impl<XMSG> CustomElement<Msg> for WebEditor<XMSG>
where XMSG: 'static,

Source§

fn attribute_changed<APP>( program: &Program<APP, Msg>, attr_name: &str, _old_value: JsValue, new_value: JsValue, )
where APP: Application<Msg> + 'static,

this is called when the attributes in the mount is changed

Source§

fn custom_tag() -> &'static str

the custom tag that this custom element will be registerd to the browser
Source§

fn observed_attributes() -> Vec<&'static str>

returns the attributes that is observed by this component These are the names of the attributes the component is interested in
Source§

fn connected_callback(&mut self)

the component is attached to the dom
Source§

fn disconnected_callback(&mut self)

the component is removed from the DOM
Source§

fn adopted_callback(&mut self)

the component is moved or attached to the dom
Source§

impl<XMSG> Default for WebEditor<XMSG>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<XMSG> Freeze for WebEditor<XMSG>

§

impl<XMSG> !RefUnwindSafe for WebEditor<XMSG>

§

impl<XMSG> !Send for WebEditor<XMSG>

§

impl<XMSG> !Sync for WebEditor<XMSG>

§

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

§

impl<XMSG> !UnwindSafe for WebEditor<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<COMP, MSG> Application<MSG> for COMP
where COMP: Component<MSG, ()> + 'static + CustomElement<MSG>, MSG: 'static,

Source§

fn update(&mut self, msg: MSG) -> Cmd<COMP, MSG>

Update the component with a message. The update function returns a Cmd, which can be executed by the runtime. Read more
Source§

fn view( &self, ) -> Node<&'static str, &'static str, Leaf<MSG>, &'static str, AttributeValue<MSG>>

Returns a node on how the component is presented.
Source§

fn style(&self) -> String

optionally an Application can specify its own css style
Source§

fn init(&mut self) -> Cmd<Self, MSG>
where Self: Sized + 'static,

The application can implement this method where it can modify its initial state. This method is called right after the program is mounted into the DOM.
Source§

fn measurements(&self, measurements: Measurements) -> Cmd<Self, MSG>
where Self: Sized + 'static,

This is called after dispatching and updating the dom for the component This is for diagnostic and performance measurement purposes. 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.