Skip to main content

EditorState

Struct EditorState 

Source
pub struct EditorState {
Show 21 fields pub show_line_numbers: bool, pub font_size: Pixels, pub line_height: Pixels, pub font_family_override: Option<SharedString>, pub cursor_color_override: Option<Hsla>, pub selection_color_override: Option<Hsla>, pub line_number_color_override: Option<Hsla>, pub line_number_active_color_override: Option<Hsla>, pub gutter_bg_override: Option<Hsla>, pub search_match_color_overrides: Option<(Hsla, Hsla)>, pub current_line_color_override: Option<Hsla>, pub bracket_match_color_override: Option<Hsla>, pub word_highlight_color_override: Option<Hsla>, pub indent_guide_color_override: Option<Hsla>, pub indent_guide_active_color_override: Option<Hsla>, pub fold_marker_color_override: Option<Hsla>, pub diagnostic_error_color: Option<Hsla>, pub diagnostic_warning_color: Option<Hsla>, pub diagnostic_info_color: Option<Hsla>, pub diagnostic_hint_color: Option<Hsla>, pub syntax_color_fn: Option<Box<dyn Fn(&str) -> Hsla>>, /* private fields */
}

Fields§

§show_line_numbers: bool§font_size: Pixels§line_height: Pixels§font_family_override: Option<SharedString>§cursor_color_override: Option<Hsla>§selection_color_override: Option<Hsla>§line_number_color_override: Option<Hsla>§line_number_active_color_override: Option<Hsla>§gutter_bg_override: Option<Hsla>§search_match_color_overrides: Option<(Hsla, Hsla)>§current_line_color_override: Option<Hsla>§bracket_match_color_override: Option<Hsla>§word_highlight_color_override: Option<Hsla>§indent_guide_color_override: Option<Hsla>§indent_guide_active_color_override: Option<Hsla>§fold_marker_color_override: Option<Hsla>§diagnostic_error_color: Option<Hsla>§diagnostic_warning_color: Option<Hsla>§diagnostic_info_color: Option<Hsla>§diagnostic_hint_color: Option<Hsla>§syntax_color_fn: Option<Box<dyn Fn(&str) -> Hsla>>

Implementations§

Source§

impl EditorState

Source

pub fn new(cx: &mut Context<'_, Self>) -> Self

Source

pub fn set_cursor_position( &mut self, line: usize, col: usize, cx: &mut Context<'_, Self>, )

Source

pub fn set_font_size(&mut self, size: f32, cx: &mut Context<'_, Self>)

Source

pub fn set_font_family( &mut self, family: impl Into<SharedString>, cx: &mut Context<'_, Self>, )

Source

pub fn set_diagnostics( &mut self, diagnostics: Vec<EditorDiagnostic>, cx: &mut Context<'_, Self>, )

Source

pub fn diagnostics(&self) -> &[EditorDiagnostic]

Source

pub fn diagnostics_at_line(&self, line: usize) -> Vec<&EditorDiagnostic>

Source

pub fn content(&self) -> String

Source

pub fn is_empty(&self) -> bool

Source

pub fn line_count(&self) -> usize

Source

pub fn cursor(&self) -> Position

Source

pub fn is_modified(&self) -> bool

Source

pub fn file_path(&self) -> Option<&PathBuf>

Source

pub fn language(&self) -> Language

Source

pub fn syntax_tree(&self) -> Option<&Tree>

Source

pub fn word_at_cursor(&self) -> Option<(String, usize)>

Source

pub fn find_matching_bracket(&self) -> Option<(Position, Position)>

Source

pub fn word_under_cursor_full(&self) -> Option<(String, usize, usize)>

Source

pub fn compute_fold_ranges(&mut self)

Source

pub fn toggle_fold_at_line(&mut self, line: usize, cx: &mut Context<'_, Self>)

Source

pub fn fold_all(&mut self, cx: &mut Context<'_, Self>)

Source

pub fn unfold_all(&mut self, cx: &mut Context<'_, Self>)

Source

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

Source

pub fn display_lines(&self) -> Rc<Vec<usize>>

Source

pub fn display_line_count(&self) -> usize

Source

pub fn buffer_line_to_display_row(&self, buffer_line: usize) -> Option<usize>

Source

pub fn display_row_to_buffer_line(&self, display_row: usize) -> usize

Source

pub fn fold_ranges(&self) -> &[FoldRange]

Source

pub fn folded_ranges(&self) -> &[FoldRange]

Source

pub fn scope_breadcrumbs(&self) -> Vec<(String, usize)>

Source

pub fn cursor_screen_position( &self, line_height: Pixels, ) -> Option<Point<Pixels>>

Source

pub fn apply_completion( &mut self, trigger_col: usize, insert_text: &str, cx: &mut Context<'_, Self>, )

Source

pub fn set_content(&mut self, content: &str, cx: &mut Context<'_, Self>)

Source

pub fn set_language(&mut self, lang: Language)

Source

pub fn set_overlay_active_check( &mut self, check: impl Fn(&App) -> bool + 'static, )

Source

pub fn load_file( &mut self, path: impl Into<PathBuf>, cx: &mut Context<'_, Self>, )

Source

pub fn save_to_file( &mut self, path: impl Into<PathBuf>, cx: &mut Context<'_, Self>, ) -> bool

Source

pub fn save(&mut self, cx: &mut Context<'_, Self>) -> bool

Source

pub fn content_version(&self) -> u64

Source

pub fn undo(&mut self, _: &Undo, _: &mut Window, cx: &mut Context<'_, Self>)

Source

pub fn redo(&mut self, _: &Redo, _: &mut Window, cx: &mut Context<'_, Self>)

Source

pub fn move_up( &mut self, _: &MoveUp, _: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn move_down( &mut self, _: &MoveDown, _: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn move_left( &mut self, _: &MoveLeft, _: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn move_right( &mut self, _: &MoveRight, _: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn move_word_left( &mut self, _: &MoveWordLeft, _: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn move_word_right( &mut self, _: &MoveWordRight, _: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn move_to_line_start( &mut self, _: &MoveToLineStart, _: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn move_to_line_end( &mut self, _: &MoveToLineEnd, _: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn move_to_doc_start( &mut self, _: &MoveToDocStart, _: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn move_to_doc_end( &mut self, _: &MoveToDocEnd, _: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn page_up( &mut self, _: &PageUp, _: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn page_down( &mut self, _: &PageDown, _: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn select_up( &mut self, _: &SelectUp, _: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn select_down( &mut self, _: &SelectDown, _: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn select_left( &mut self, _: &SelectLeft, _: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn select_right( &mut self, _: &SelectRight, _: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn select_to_line_start( &mut self, _: &SelectToLineStart, _: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn select_to_line_end( &mut self, _: &SelectToLineEnd, _: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn select_all( &mut self, _: &SelectAll, _: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn backspace( &mut self, _: &Backspace, _: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn delete(&mut self, _: &Delete, _: &mut Window, cx: &mut Context<'_, Self>)

Source

pub fn delete_word( &mut self, _: &DeleteWord, _: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn enter(&mut self, _: &Enter, _: &mut Window, cx: &mut Context<'_, Self>)

Source

pub fn tab(&mut self, _: &Tab, _: &mut Window, cx: &mut Context<'_, Self>)

Source

pub fn copy(&mut self, _: &Copy, _: &mut Window, cx: &mut Context<'_, Self>)

Source

pub fn cut(&mut self, _: &Cut, _: &mut Window, cx: &mut Context<'_, Self>)

Source

pub fn paste(&mut self, _: &Paste, _: &mut Window, cx: &mut Context<'_, Self>)

Source

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

Source

pub fn search_query(&self) -> &str

Source

pub fn search_match_count(&self) -> usize

Source

pub fn current_match_index(&self) -> Option<usize>

Source

pub fn search_case_sensitive(&self) -> bool

Source

pub fn search_use_regex(&self) -> bool

Source

pub fn find_all(&mut self, query: &str, cx: &mut Context<'_, Self>)

Source

pub fn find_next(&mut self, cx: &mut Context<'_, Self>)

Source

pub fn find_previous(&mut self, cx: &mut Context<'_, Self>)

Source

pub fn replace_current(&mut self, replacement: &str, cx: &mut Context<'_, Self>)

Source

pub fn replace_all(&mut self, replacement: &str, cx: &mut Context<'_, Self>)

Source

pub fn invalidate_line_layouts(&mut self, cx: &mut Context<'_, Self>)

Source

pub fn set_search_case_sensitive( &mut self, val: bool, cx: &mut Context<'_, Self>, )

Source

pub fn set_search_regex(&mut self, val: bool, cx: &mut Context<'_, Self>)

Source

pub fn goto_line(&mut self, line: usize, cx: &mut Context<'_, Self>)

Source

pub fn scroll_horizontal(&mut self, delta: Pixels, cx: &mut Context<'_, Self>)

Source

pub fn scroll_offset_x(&self) -> Pixels

Source

pub fn max_line_width(&self) -> Pixels

Trait Implementations§

Source§

impl EntityInputHandler for EditorState

Source§

fn text_for_range( &mut self, range_utf16: Range<usize>, actual_range: &mut Option<Range<usize>>, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<String>

Source§

fn selected_text_range( &mut self, _ignore_disabled_input: bool, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<UTF16Selection>

Source§

fn marked_text_range( &self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<Range<usize>>

Source§

fn unmark_text(&mut self, _window: &mut Window, _cx: &mut Context<'_, Self>)

Source§

fn replace_text_in_range( &mut self, range_utf16: Option<Range<usize>>, new_text: &str, _window: &mut Window, cx: &mut Context<'_, Self>, )

Source§

fn replace_and_mark_text_in_range( &mut self, range_utf16: Option<Range<usize>>, new_text: &str, new_selected_range_utf16: Option<Range<usize>>, _window: &mut Window, cx: &mut Context<'_, Self>, )

Source§

fn bounds_for_range( &mut self, _range_utf16: Range<usize>, _bounds: Bounds<Pixels>, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<Bounds<Pixels>>

Source§

fn character_index_for_point( &mut self, point: Point<Pixels>, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<usize>

Source§

fn accepts_text_input( &self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> bool

Source§

impl Focusable for EditorState

Source§

fn focus_handle(&self, _: &App) -> FocusHandle

Returns the focus handle associated with this view.
Source§

impl Render for EditorState

Source§

fn render( &mut self, _: &mut Window, cx: &mut Context<'_, Self>, ) -> impl IntoElement

Render this view into an element tree.

Auto Trait Implementations§

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

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<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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