pub struct Editor { /* private fields */ }Implementations§
Source§impl Editor
impl Editor
pub fn new(source: &str, cx: &mut Context<'_, Self>) -> Self
Sourcepub fn with_undo_limit(self, limit: usize) -> Self
pub fn with_undo_limit(self, limit: usize) -> Self
How many undo steps to keep. App-wide configuration would be a gpui
global alongside init, not a Theme field — the theme is rebuilt on
every light/dark switch, which would quietly reset anything behavioural
parked in it.
Sourcepub fn with_scroll(self, handle: ScrollHandle) -> Self
pub fn with_scroll(self, handle: ScrollHandle) -> Self
The box the document scrolls in, so typing off the bottom follows the caret down.
The host’s rather than the editor’s: a document goes in whatever pane the app gives it, and the gutter handle, the drop indicator and the menus are all placed absolutely against this editor’s own origin — put the scroll box here and every one of them would be offset twice.
pub fn doc(&self) -> &Doc
pub fn selection(&self) -> Selection
Sourcepub fn selection_bounds(&self) -> Option<Bounds<Pixels>>
pub fn selection_bounds(&self) -> Option<Bounds<Pixels>>
Where the selection sits on screen, in window coordinates, so a host can float a toolbar at it.
The head’s row only — a selection spanning ten blocks wants its bubble
where the pointer left off, not centred over the whole span. None when
nothing is selected or the caret has not painted yet.
Sourcepub fn source(&self) -> String
pub fn source(&self) -> String
The document as markdown — normalized, because that is the form that survives being read back.
Sourcepub fn toggle_mark(&mut self, mark: Mark, cx: &mut Context<'_, Self>)
pub fn toggle_mark(&mut self, mark: Mark, cx: &mut Context<'_, Self>)
Add mark over the selection, or take it away if the whole selection
already carries it. Public because a toolbar reaches the same operation
the key does.
Sourcepub fn move_block(
&mut self,
ix: usize,
delta: isize,
cx: &mut Context<'_, Self>,
)
pub fn move_block( &mut self, ix: usize, delta: isize, cx: &mut Context<'_, Self>, )
Move the caret’s block, children and all, and follow it.
Public because a gutter handle and a menu row reach the same operation
as the key does — one vocabulary, not three paths into Doc.
pub fn duplicate_block(&mut self, ix: usize, cx: &mut Context<'_, Self>)
pub fn remove_block(&mut self, ix: usize, cx: &mut Context<'_, Self>)
Trait Implementations§
Source§impl EntityInputHandler for Editor
Typed text and IME arrive here. Offsets are within the caret’s block, which
is the unit the platform is told about — a block is a paragraph’s worth of
text, so a candidate window never has to be anchored across one.
impl EntityInputHandler for Editor
Typed text and IME arrive here. Offsets are within the caret’s block, which is the unit the platform is told about — a block is a paragraph’s worth of text, so a candidate window never has to be anchored across one.
Source§fn bounds_for_range(
&mut self,
range: Range<usize>,
_: Bounds<Pixels>,
_: &mut Window,
_: &mut Context<'_, Self>,
) -> Option<Bounds<Pixels>>
fn bounds_for_range( &mut self, range: Range<usize>, _: Bounds<Pixels>, _: &mut Window, _: &mut Context<'_, Self>, ) -> Option<Bounds<Pixels>>
Where a range paints, so a candidate window opens under the text it is composing rather than at the window’s origin.
Source§fn text_for_range(
&mut self,
range: Range<usize>,
adjusted: &mut Option<Range<usize>>,
_: &mut Window,
_: &mut Context<'_, Self>,
) -> Option<String>
fn text_for_range( &mut self, range: Range<usize>, adjusted: &mut Option<Range<usize>>, _: &mut Window, _: &mut Context<'_, Self>, ) -> Option<String>
InputHandler::text_for_range for detailsSource§fn selected_text_range(
&mut self,
_: bool,
_: &mut Window,
_: &mut Context<'_, Self>,
) -> Option<UTF16Selection>
fn selected_text_range( &mut self, _: bool, _: &mut Window, _: &mut Context<'_, Self>, ) -> Option<UTF16Selection>
InputHandler::selected_text_range for detailsSource§fn marked_text_range(
&self,
_: &mut Window,
_: &mut Context<'_, Self>,
) -> Option<Range<usize>>
fn marked_text_range( &self, _: &mut Window, _: &mut Context<'_, Self>, ) -> Option<Range<usize>>
InputHandler::marked_text_range for detailsSource§fn unmark_text(&mut self, _: &mut Window, _: &mut Context<'_, Self>)
fn unmark_text(&mut self, _: &mut Window, _: &mut Context<'_, Self>)
InputHandler::unmark_text for detailsSource§fn replace_text_in_range(
&mut self,
range: Option<Range<usize>>,
text: &str,
_: &mut Window,
cx: &mut Context<'_, Self>,
)
fn replace_text_in_range( &mut self, range: Option<Range<usize>>, text: &str, _: &mut Window, cx: &mut Context<'_, Self>, )
InputHandler::replace_text_in_range for detailsSource§fn replace_and_mark_text_in_range(
&mut self,
range: Option<Range<usize>>,
text: &str,
marked: Option<Range<usize>>,
_: &mut Window,
cx: &mut Context<'_, Self>,
)
fn replace_and_mark_text_in_range( &mut self, range: Option<Range<usize>>, text: &str, marked: Option<Range<usize>>, _: &mut Window, cx: &mut Context<'_, Self>, )
InputHandler::replace_and_mark_text_in_range for detailsSource§fn character_index_for_point(
&mut self,
point: Point<Pixels>,
_: &mut Window,
_: &mut Context<'_, Self>,
) -> Option<usize>
fn character_index_for_point( &mut self, point: Point<Pixels>, _: &mut Window, _: &mut Context<'_, Self>, ) -> Option<usize>
InputHandler::character_index_for_point for detailsSource§fn paste(
&mut self,
item: ClipboardItem,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
fn paste( &mut self, item: ClipboardItem, window: &mut Window, cx: &mut Context<'_, Self>, )
InputHandler::paste for detailsSource§fn set_selected_text_range(
&mut self,
_range_utf16: Range<usize>,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
)
fn set_selected_text_range( &mut self, _range_utf16: Range<usize>, _window: &mut Window, _cx: &mut Context<'_, Self>, )
InputHandler::set_selected_text_range for detailsSource§fn text_length_utf16(
&mut self,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
) -> Option<usize>
fn text_length_utf16( &mut self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<usize>
InputHandler::text_length_utf16 for detailsSource§fn accepts_text_input(
&self,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
) -> bool
fn accepts_text_input( &self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> bool
InputHandler::accepts_text_input for detailsSource§impl Focusable for Editor
impl Focusable for Editor
Source§fn focus_handle(&self, _: &App) -> FocusHandle
fn focus_handle(&self, _: &App) -> FocusHandle
Auto Trait Implementations§
impl !RefUnwindSafe for Editor
impl !Send for Editor
impl !Sync for Editor
impl !UnwindSafe for Editor
impl Freeze for Editor
impl Unpin for Editor
impl UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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