Editor

Struct Editor 

Source
pub struct Editor {
Show 19 fields pub cx: Cell<Scope>, pub active: RwSignal<bool>, pub read_only: RwSignal<bool>, pub cursor: RwSignal<Cursor>, pub window_origin: RwSignal<Point>, pub viewport: RwSignal<Rect>, pub parent_size: RwSignal<Rect>, pub editor_view_focused: Trigger, pub editor_view_focus_lost: Trigger, pub editor_view_id: RwSignal<Option<ViewId>>, pub scroll_delta: RwSignal<Vec2>, pub scroll_to: RwSignal<Option<Vec2>>, pub screen_lines: RwSignal<ScreenLines>, pub register: RwSignal<Register>, pub cursor_info: CursorInfo, pub last_movement: RwSignal<Movement>, pub ime_allowed: RwSignal<bool>, pub es: RwSignal<EditorStyle>, pub floem_style_id: RwSignal<u64>, /* private fields */
}
Expand description

The main structure for the editor view itself.

This can be considered to be the data part of the View. It holds an Rc<dyn Document> within as the document it is a view into.

Fields§

§cx: Cell<Scope>§active: RwSignal<bool>§read_only: RwSignal<bool>

Whether you can edit within this editor.

§cursor: RwSignal<Cursor>§window_origin: RwSignal<Point>§viewport: RwSignal<Rect>§parent_size: RwSignal<Rect>§editor_view_focused: Trigger§editor_view_focus_lost: Trigger§editor_view_id: RwSignal<Option<ViewId>>§scroll_delta: RwSignal<Vec2>

The current scroll position.

§scroll_to: RwSignal<Option<Vec2>>§screen_lines: RwSignal<ScreenLines>§register: RwSignal<Register>

Modal mode register

§cursor_info: CursorInfo

Cursor rendering information, such as the cursor blinking state.

§last_movement: RwSignal<Movement>§ime_allowed: RwSignal<bool>

Whether ime input is allowed.

Should not be set manually outside of the specific handling for ime.

§es: RwSignal<EditorStyle>

The Editor Style

§floem_style_id: RwSignal<u64>

Implementations§

Source§

impl Editor

Source

pub fn new( cx: Scope, doc: Rc<dyn Document>, style: Rc<dyn Styling>, modal: bool, ) -> Editor

Create a new editor into the given document, using the styling.

doc: The backing Document, such as TextDocument style: How the editor should be styled, such as SimpleStyling

Source

pub fn new_id( cx: Scope, id: EditorId, doc: Rc<dyn Document>, style: Rc<dyn Styling>, modal: bool, ) -> Editor

Create a new editor into the given document, using the styling.

id should typically be constructed by EditorId::next

doc: The backing Document, such as TextDocument style: How the editor should be styled, such as SimpleStyling

Source

pub fn new_direct( cx: Scope, id: EditorId, doc: Rc<dyn Document>, style: Rc<dyn Styling>, modal: bool, ) -> Editor

Create a new editor into the given document, using the styling. id should typically be constructed by EditorId::next doc: The backing Document, such as TextDocument style: How the editor should be styled, such as SimpleStyling This does not create the view effects. Use this if you’re creating an editor and then replacing signals. Invoke Editor::recreate_view_effects when you are done.

let shared_scroll_beyond_last_line = /* ... */;
let editor = Editor::new_direct(cx, id, doc, style);
editor.scroll_beyond_last_line.set(shared_scroll_beyond_last_line);
Source

pub fn id(&self) -> EditorId

Source

pub fn doc(&self) -> Rc<dyn Document>

Get the document untracked

Source

pub fn doc_track(&self) -> Rc<dyn Document>

Source

pub fn doc_signal(&self) -> RwSignal<Rc<dyn Document>>

Source

pub fn config_id(&self) -> ConfigId

Source

pub fn recreate_view_effects(&self)

Source

pub fn update_doc( &self, doc: Rc<dyn Document>, styling: Option<Rc<dyn Styling>>, )

Swap the underlying document out

Source

pub fn update_styling(&self, styling: Rc<dyn Styling>)

Source

pub fn duplicate(&self, editor_id: Option<EditorId>) -> Editor

Source

pub fn style(&self) -> Rc<dyn Styling>

Get the styling untracked

Source

pub fn text(&self) -> Rope

Get the text of the document

You should typically prefer Self::rope_text

Source

pub fn rope_text(&self) -> RopeTextVal

Get the RopeTextVal from doc untracked

Source

pub fn lines(&self) -> &Lines

Source

pub fn text_prov(&self) -> &Self

Source

pub fn set_preedit( &self, text: String, cursor: Option<(usize, usize)>, offset: usize, )

Source

pub fn commit_preedit(&self)

Source

pub fn clear_preedit(&self)

Source

pub fn receive_char(&self, c: &str)

Source

pub fn pointer_down_primary(&self, state: &PointerState)

Default handler for PointerDown event

Source

pub fn left_click(&self, state: &PointerState)

Source

pub fn single_click(&self, pointer_event: &PointerState)

Source

pub fn double_click(&self, pointer_event: &PointerState)

Source

pub fn triple_click(&self, pointer_event: &PointerState)

Source

pub fn pointer_move(&self, pointer_event: &PointerState)

Source

pub fn pointer_up(&self, _pointer_event: &PointerState)

Source

pub fn page_move(&self, down: bool, mods: Modifiers)

Source

pub fn center_window(&self)

Source

pub fn top_of_window(&self, scroll_off: usize)

Source

pub fn bottom_of_window(&self, scroll_off: usize)

Source

pub fn scroll(&self, top_shift: f64, down: bool, count: usize, mods: Modifiers)

Source

pub fn phantom_text(&self, line: usize) -> PhantomTextLine

Source

pub fn line_height(&self, line: usize) -> f32

Source

pub fn iter_vlines( &self, backwards: bool, start: VLine, ) -> impl Iterator<Item = VLineInfo> + '_

Iterate over the visual lines in the view, starting at the given line.

Source

pub fn iter_vlines_over( &self, backwards: bool, start: VLine, end: VLine, ) -> impl Iterator<Item = VLineInfo> + '_

Iterate over the visual lines in the view, starting at the given line and ending at the given line. start_line..end_line

Source

pub fn iter_rvlines( &self, backwards: bool, start: RVLine, ) -> impl Iterator<Item = VLineInfo<()>> + '_

Iterator over relative VLineInfos, starting at the buffer line, start_line. The visual_lines provided by this will start at 0 from your start_line. This is preferable over iter_lines if you do not need to absolute visual line value.

Source

pub fn iter_rvlines_over( &self, backwards: bool, start: RVLine, end_line: usize, ) -> impl Iterator<Item = VLineInfo<()>> + '_

Iterator over relative VLineInfos, starting at the buffer line, start_line and ending at end_line.

start_line..end_line

This is preferable over iter_lines if you do not need to absolute visual line value.

Source

pub fn first_rvline_info(&self) -> VLineInfo<()>

Source

pub fn num_lines(&self) -> usize

The number of lines in the document.

Source

pub fn last_line(&self) -> usize

The last allowed buffer line in the document.

Source

pub fn last_vline(&self) -> VLine

Source

pub fn last_rvline(&self) -> RVLine

Source

pub fn last_rvline_info(&self) -> VLineInfo<()>

Source

pub fn offset_to_line_col(&self, offset: usize) -> (usize, usize)

Convert an offset into the buffer into a line and idx.

Source

pub fn offset_of_line(&self, offset: usize) -> usize

Source

pub fn offset_of_line_col(&self, line: usize, col: usize) -> usize

Source

pub fn line_of_offset(&self, offset: usize) -> usize

Get the buffer line of an offset

Source

pub fn first_non_blank_character_on_line(&self, line: usize) -> usize

Returns the offset into the buffer of the first non blank character on the given line.

Source

pub fn line_end_col(&self, line: usize, caret: bool) -> usize

Source

pub fn select_word(&self, offset: usize) -> (usize, usize)

Source

pub fn vline_of_offset(&self, offset: usize, affinity: CursorAffinity) -> VLine

affinity decides whether an offset at a soft line break is considered to be on the previous line or the next line.

If affinity is CursorAffinity::Forward and is at the very end of the wrapped line, then the offset is considered to be on the next line.

Source

pub fn vline_of_line(&self, line: usize) -> VLine

Source

pub fn rvline_of_line(&self, line: usize) -> RVLine

Source

pub fn vline_of_rvline(&self, rvline: RVLine) -> VLine

Source

pub fn offset_of_vline(&self, vline: VLine) -> usize

Get the nearest offset to the start of the visual line.

Source

pub fn vline_col_of_offset( &self, offset: usize, affinity: CursorAffinity, ) -> (VLine, usize)

Get the visual line and column of the given offset.

The column is before phantom text is applied.

Source

pub fn rvline_of_offset( &self, offset: usize, affinity: CursorAffinity, ) -> RVLine

Source

pub fn rvline_col_of_offset( &self, offset: usize, affinity: CursorAffinity, ) -> (RVLine, usize)

Source

pub fn offset_of_rvline(&self, rvline: RVLine) -> usize

Source

pub fn vline_info(&self, vline: VLine) -> VLineInfo

Source

pub fn screen_rvline_info_of_offset( &self, offset: usize, affinity: CursorAffinity, ) -> Option<VLineInfo<()>>

Source

pub fn rvline_info(&self, rvline: RVLine) -> VLineInfo<()>

Source

pub fn rvline_info_of_offset( &self, offset: usize, affinity: CursorAffinity, ) -> VLineInfo<()>

Source

pub fn first_col<T: Debug>(&self, info: VLineInfo<T>) -> usize

Get the first column of the overall line of the visual line

Source

pub fn last_col<T: Debug>(&self, info: VLineInfo<T>, caret: bool) -> usize

Get the last column in the overall line of the visual line

Source

pub fn max_line_width(&self) -> f64

Source

pub fn line_point_of_offset( &self, offset: usize, affinity: CursorAffinity, ) -> Point

Returns the point into the text layout of the line at the given offset. x being the leading edge of the character, and y being the baseline.

Source

pub fn line_point_of_line_col( &self, line: usize, col: usize, affinity: CursorAffinity, force_affinity: bool, ) -> Point

Returns the point into the text layout of the line at the given line and col. x being the leading edge of the character, and y being the baseline.

Source

pub fn points_of_offset( &self, offset: usize, affinity: CursorAffinity, ) -> (Point, Point)

Get the (point above, point below) of a particular offset within the editor.

Source

pub fn offset_of_point( &self, mode: Mode, point: Point, ) -> (usize, bool, CursorAffinity)

Get the offset of a particular point within the editor. The boolean indicates whether the point is inside the text or not Points outside of vertical bounds will return the last line. Points outside of horizontal bounds will return the last column on the line.

Source

pub fn line_col_of_point_with_phantom(&self, point: Point) -> (usize, usize)

Get the actual (line, col) of a particular point within the editor.

Source

pub fn line_col_of_point( &self, mode: Mode, point: Point, ) -> ((usize, usize), bool, CursorAffinity)

Get the (line, col) of a particular point within the editor. The boolean indicates whether the point is within the text bounds. Points outside of vertical bounds will return the last line. Points outside of horizontal bounds will return the last column on the line.

Source

pub fn line_horiz_col( &self, line: usize, horiz: &ColPosition, caret: bool, ) -> usize

Source

pub fn rvline_horiz_col( &self, rvline: RVLine, horiz: &ColPosition, caret: bool, ) -> usize

Advance to the right in the manner of the given mode. Get the column from a horizontal at a specific line index (in a text layout)

Source

pub fn move_right(&self, offset: usize, mode: Mode, count: usize) -> usize

Advance to the right in the manner of the given mode.

This is not the same as the Movement::Right command.

Source

pub fn move_left(&self, offset: usize, mode: Mode, count: usize) -> usize

Advance to the left in the manner of the given mode. This is not the same as the Movement::Left command.

Source§

impl Editor

Source

pub fn text_layout(&self, line: usize) -> Arc<TextLayoutLine>

Source

pub fn text_layout_trigger( &self, line: usize, trigger: bool, ) -> Arc<TextLayoutLine>

Trait Implementations§

Source§

impl Clone for Editor

Source§

fn clone(&self) -> Editor

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Editor

Source§

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

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

impl TextLayoutProvider for Editor

Source§

fn text(&self) -> Rope

Source§

fn new_text_layout( &self, line: usize, _font_size: usize, _wrap: ResolvedWrap, ) -> Arc<TextLayoutLine>

Source§

fn before_phantom_col(&self, line: usize, col: usize) -> usize

Translate a column position into the position it would be before combining with the phantom text
Source§

fn has_multiline_phantom(&self) -> bool

Whether the text has any multiline phantom text. Read more
Source§

fn rope_text(&self) -> RopeTextVal

Shorthand for getting a rope text version of text. Read more

Auto Trait Implementations§

§

impl !Freeze for Editor

§

impl !RefUnwindSafe for Editor

§

impl !Send for Editor

§

impl !Sync for Editor

§

impl Unpin for Editor

§

impl !UnwindSafe for Editor

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.
Source§

impl<T> WithSubscriber for T

Source§

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

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,

Source§

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