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: CursorInfoCursor 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
impl Editor
Sourcepub fn new(
cx: Scope,
doc: Rc<dyn Document>,
style: Rc<dyn Styling>,
modal: bool,
) -> Editor
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
Sourcepub fn new_id(
cx: Scope,
id: EditorId,
doc: Rc<dyn Document>,
style: Rc<dyn Styling>,
modal: bool,
) -> Editor
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
Sourcepub fn new_direct(
cx: Scope,
id: EditorId,
doc: Rc<dyn Document>,
style: Rc<dyn Styling>,
modal: bool,
) -> Editor
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);pub fn id(&self) -> EditorId
pub fn doc_track(&self) -> Rc<dyn Document>
pub fn doc_signal(&self) -> RwSignal<Rc<dyn Document>>
pub fn config_id(&self) -> ConfigId
pub fn recreate_view_effects(&self)
Sourcepub fn update_doc(
&self,
doc: Rc<dyn Document>,
styling: Option<Rc<dyn Styling>>,
)
pub fn update_doc( &self, doc: Rc<dyn Document>, styling: Option<Rc<dyn Styling>>, )
Swap the underlying document out
pub fn update_styling(&self, styling: Rc<dyn Styling>)
pub fn duplicate(&self, editor_id: Option<EditorId>) -> Editor
Sourcepub fn text(&self) -> Rope
pub fn text(&self) -> Rope
Get the text of the document
You should typically prefer Self::rope_text
Sourcepub fn rope_text(&self) -> RopeTextVal
pub fn rope_text(&self) -> RopeTextVal
Get the RopeTextVal from doc untracked
pub fn lines(&self) -> &Lines
pub fn text_prov(&self) -> &Self
pub fn set_preedit( &self, text: String, cursor: Option<(usize, usize)>, offset: usize, )
pub fn commit_preedit(&self)
pub fn clear_preedit(&self)
pub fn receive_char(&self, c: &str)
Sourcepub fn pointer_down_primary(&self, state: &PointerState)
pub fn pointer_down_primary(&self, state: &PointerState)
Default handler for PointerDown event
pub fn left_click(&self, state: &PointerState)
pub fn single_click(&self, pointer_event: &PointerState)
pub fn double_click(&self, pointer_event: &PointerState)
pub fn triple_click(&self, pointer_event: &PointerState)
pub fn pointer_move(&self, pointer_event: &PointerState)
pub fn pointer_up(&self, _pointer_event: &PointerState)
pub fn page_move(&self, down: bool, mods: Modifiers)
pub fn center_window(&self)
pub fn top_of_window(&self, scroll_off: usize)
pub fn bottom_of_window(&self, scroll_off: usize)
pub fn scroll(&self, top_shift: f64, down: bool, count: usize, mods: Modifiers)
pub fn phantom_text(&self, line: usize) -> PhantomTextLine
pub fn line_height(&self, line: usize) -> f32
Sourcepub fn iter_vlines(
&self,
backwards: bool,
start: VLine,
) -> impl Iterator<Item = VLineInfo> + '_
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.
Sourcepub fn iter_vlines_over(
&self,
backwards: bool,
start: VLine,
end: VLine,
) -> impl Iterator<Item = VLineInfo> + '_
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
Sourcepub fn iter_rvlines(
&self,
backwards: bool,
start: RVLine,
) -> impl Iterator<Item = VLineInfo<()>> + '_
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.
Sourcepub fn iter_rvlines_over(
&self,
backwards: bool,
start: RVLine,
end_line: usize,
) -> impl Iterator<Item = VLineInfo<()>> + '_
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.
pub fn first_rvline_info(&self) -> VLineInfo<()>
pub fn last_vline(&self) -> VLine
pub fn last_rvline(&self) -> RVLine
pub fn last_rvline_info(&self) -> VLineInfo<()>
Sourcepub fn offset_to_line_col(&self, offset: usize) -> (usize, usize)
pub fn offset_to_line_col(&self, offset: usize) -> (usize, usize)
Convert an offset into the buffer into a line and idx.
pub fn offset_of_line(&self, offset: usize) -> usize
pub fn offset_of_line_col(&self, line: usize, col: usize) -> usize
Sourcepub fn line_of_offset(&self, offset: usize) -> usize
pub fn line_of_offset(&self, offset: usize) -> usize
Get the buffer line of an offset
Sourcepub fn first_non_blank_character_on_line(&self, line: usize) -> usize
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.
pub fn line_end_col(&self, line: usize, caret: bool) -> usize
pub fn select_word(&self, offset: usize) -> (usize, usize)
Sourcepub fn vline_of_offset(&self, offset: usize, affinity: CursorAffinity) -> VLine
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.
pub fn vline_of_line(&self, line: usize) -> VLine
pub fn rvline_of_line(&self, line: usize) -> RVLine
pub fn vline_of_rvline(&self, rvline: RVLine) -> VLine
Sourcepub fn offset_of_vline(&self, vline: VLine) -> usize
pub fn offset_of_vline(&self, vline: VLine) -> usize
Get the nearest offset to the start of the visual line.
Sourcepub fn vline_col_of_offset(
&self,
offset: usize,
affinity: CursorAffinity,
) -> (VLine, usize)
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.
pub fn rvline_of_offset( &self, offset: usize, affinity: CursorAffinity, ) -> RVLine
pub fn rvline_col_of_offset( &self, offset: usize, affinity: CursorAffinity, ) -> (RVLine, usize)
pub fn offset_of_rvline(&self, rvline: RVLine) -> usize
pub fn vline_info(&self, vline: VLine) -> VLineInfo
pub fn screen_rvline_info_of_offset( &self, offset: usize, affinity: CursorAffinity, ) -> Option<VLineInfo<()>>
pub fn rvline_info(&self, rvline: RVLine) -> VLineInfo<()>
pub fn rvline_info_of_offset( &self, offset: usize, affinity: CursorAffinity, ) -> VLineInfo<()>
Sourcepub fn first_col<T: Debug>(&self, info: VLineInfo<T>) -> usize
pub fn first_col<T: Debug>(&self, info: VLineInfo<T>) -> usize
Get the first column of the overall line of the visual line
Sourcepub fn last_col<T: Debug>(&self, info: VLineInfo<T>, caret: bool) -> usize
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
pub fn max_line_width(&self) -> f64
Sourcepub fn line_point_of_offset(
&self,
offset: usize,
affinity: CursorAffinity,
) -> Point
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.
Sourcepub fn line_point_of_line_col(
&self,
line: usize,
col: usize,
affinity: CursorAffinity,
force_affinity: bool,
) -> Point
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.
Sourcepub fn points_of_offset(
&self,
offset: usize,
affinity: CursorAffinity,
) -> (Point, Point)
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.
Sourcepub fn offset_of_point(
&self,
mode: Mode,
point: Point,
) -> (usize, bool, CursorAffinity)
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.
Sourcepub fn line_col_of_point_with_phantom(&self, point: Point) -> (usize, usize)
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.
Sourcepub fn line_col_of_point(
&self,
mode: Mode,
point: Point,
) -> ((usize, usize), bool, CursorAffinity)
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.
pub fn line_horiz_col( &self, line: usize, horiz: &ColPosition, caret: bool, ) -> usize
Sourcepub fn rvline_horiz_col(
&self,
rvline: RVLine,
horiz: &ColPosition,
caret: bool,
) -> usize
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)
Sourcepub fn move_right(&self, offset: usize, mode: Mode, count: usize) -> usize
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§impl Editor
impl Editor
pub fn text_layout(&self, line: usize) -> Arc<TextLayoutLine>
pub fn text_layout_trigger( &self, line: usize, trigger: bool, ) -> Arc<TextLayoutLine>
Trait Implementations§
Source§impl TextLayoutProvider for Editor
impl TextLayoutProvider for Editor
fn text(&self) -> Rope
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
fn before_phantom_col(&self, line: usize, col: usize) -> usize
Source§fn has_multiline_phantom(&self) -> bool
fn has_multiline_phantom(&self) -> bool
Source§fn rope_text(&self) -> RopeTextVal
fn rope_text(&self) -> RopeTextVal
text. Read moreAuto 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> 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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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