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_text_size(self, points: f32) -> Self
pub fn with_text_size(self, points: f32) -> Self
Open the document at a size of its own, in points — the app’s settings field for prose. Unset, it is set at the app’s own text size.
The base, not the current size: cmd-+ moves a shared adjustment over
this, and cmd-0 clears that adjustment to come back here.
Sourcepub fn text_size(&self) -> Option<f32>
pub fn text_size(&self) -> Option<f32>
The base the app set, if any. Add
text_size_adjustment for what is on
screen.
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 select(&mut self, selection: Selection, cx: &mut Context<'_, Self>)
pub fn select(&mut self, selection: Selection, cx: &mut Context<'_, Self>)
Put the selection somewhere — what a thread in a sidebar does when it is clicked, and what a caret restored with a document needs.
Clamped, because the caller’s range came from somewhere the document may have moved on from.
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 anchors(&self) -> &[Anchor]
pub fn anchors(&self) -> &[Anchor]
The comment ranges, mapped up to date with the document.
A range that reads Anchor::detached lost the words it pointed at.
It is kept rather than dropped, because whether that means “outdated” or
“resolved” is the app’s question.
Sourcepub fn set_anchors(&mut self, anchors: Vec<Anchor>, cx: &mut Context<'_, Self>)
pub fn set_anchors(&mut self, anchors: Vec<Anchor>, cx: &mut Context<'_, Self>)
Hand over the whole list — the app keeps the threads, this keeps their ranges. One entry point rather than add/remove/update, since the app is already holding the list that decides all three.
Sourcepub fn comment_at(&self, at: Point<Pixels>) -> Option<CommentId>
pub fn comment_at(&self, at: Point<Pixels>) -> Option<CommentId>
The comment under a point in window coordinates — the space
Self::anchor_bounds answers in and the press handler resolves in.
The last match wins, so the newer of two overlapping ranges is the one a click opens.
Sourcepub fn anchor_bounds(&self, id: CommentId) -> Option<Bounds<Pixels>>
pub fn anchor_bounds(&self, id: CommentId) -> Option<Bounds<Pixels>>
Where to float a thread, mirroring Self::selection_bounds.
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§fn text_input_configuration(
&mut self,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
) -> TextInputConfiguration
fn text_input_configuration( &mut self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> TextInputConfiguration
InputHandler::text_input_configuration for detailsSource§fn text_input_editable_range(
&mut self,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
) -> Option<Range<usize>>
fn text_input_editable_range( &mut self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<Range<usize>>
InputHandler::text_input_editable_range for detailsimpl EventEmitter<EditorEvent> for Editor
Source§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