pub struct Editor { /* private fields */ }Implementations§
Source§impl Editor
impl Editor
Sourcepub fn anchors(&self) -> &[Anchor]
pub fn anchors(&self) -> &[Anchor]
This editor’s snapshot of crate::Document::anchors.
Sourcepub fn anchor_at(&self, at: Point<Pixels>) -> Option<AnchorId>
pub fn anchor_at(&self, at: Point<Pixels>) -> Option<AnchorId>
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: AnchorId) -> Option<Bounds<Pixels>>
pub fn anchor_bounds(&self, id: AnchorId) -> Option<Bounds<Pixels>>
Where to float a thread, mirroring Self::selection_bounds.
Sourcepub fn anchor_tops(&self) -> Vec<(AnchorId, Pixels)>
pub fn anchor_tops(&self) -> Vec<(AnchorId, Pixels)>
How far down the editor each anchor’s first line sits, from the editor’s own top, in document order. A detached anchor sits where its words were.
Read from last frame’s layout. An anchor whose line has not been built gets the top of its block, guessed until the block is measured; the editor repaints when a guess moves.
Sourcepub fn set_washes(
&mut self,
washes: Vec<(Selection, Annotation)>,
cx: &mut Context<'_, Self>,
)
pub fn set_washes( &mut self, washes: Vec<(Selection, Annotation)>, cx: &mut Context<'_, Self>, )
Wash washes from the next frame on, over the anchors’ own. They are
positions in Self::doc as it stands, and are not mapped through
edits: an app that keeps them current sets them again.
pub fn washes(&self) -> &[(Selection, Annotation)]
Source§impl Editor
impl Editor
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>)
Sourcepub fn set_language(
&mut self,
ix: usize,
language: Option<String>,
cx: &mut Context<'_, Self>,
)
pub fn set_language( &mut self, ix: usize, language: Option<String>, cx: &mut Context<'_, Self>, )
Tag a fenced block with the language it holds, or None for plain.
Sourcepub fn set_block(
&mut self,
ix: usize,
kind: BlockKind,
cx: &mut Context<'_, Self>,
)
pub fn set_block( &mut self, ix: usize, kind: BlockKind, cx: &mut Context<'_, Self>, )
Turn the caret’s block into kind — what the slash menu and the block
menu both do.
Sourcepub fn toggle_quote(
&mut self,
ix: usize,
alert: Option<QuoteKind>,
cx: &mut Context<'_, Self>,
)
pub fn toggle_quote( &mut self, ix: usize, alert: Option<QuoteKind>, cx: &mut Context<'_, Self>, )
Put the block at ix in a quote with alert, or take it out of the one
it is in — see markdown::Doc::toggle_quote.
Sourcepub fn set_code(&mut self, ix: usize, code: String, cx: &mut Context<'_, Self>)
pub fn set_code(&mut self, ix: usize, code: String, cx: &mut Context<'_, Self>)
Replace a fenced block’s code, as one undo step — what a painted fence
writes through markdown::Fence::rewrite.
Sourcepub fn place_block(
&mut self,
ix: usize,
kind: BlockKind,
cx: &mut Context<'_, Self>,
)
pub fn place_block( &mut self, ix: usize, kind: BlockKind, cx: &mut Context<'_, Self>, )
Turn the block at ix into kind and put the caret after it — what a
crate::SlashAction::Run row does with a block the caret cannot sit
in.
The block is replaced as given, not converted: nothing of what it held
carries over.
Sourcepub fn relink(&mut self, from: &str, to: &str, cx: &mut Context<'_, Self>)
pub fn relink(&mut self, from: &str, to: &str, cx: &mut Context<'_, Self>)
Point every picture at from to to: an image block’s URL, or in
source mode each ](from) and ](<from>) in the text. One undo step,
and the caret keeps its place in the text around it. Nothing pointing
at from is no edit.
Sourcepub fn toggle_task(&mut self, ix: usize, cx: &mut Context<'_, Self>)
pub fn toggle_task(&mut self, ix: usize, cx: &mut Context<'_, Self>)
Check or uncheck the task block at ix. Does nothing to a block that
is not one.
An edit like any other: one undo step, and the caret stays where it was, so toggling a box across the document does not move whatever is being typed.
Sourcepub fn add_row(&mut self, ix: usize, row: usize, cx: &mut Context<'_, Self>)
pub fn add_row(&mut self, ix: usize, row: usize, cx: &mut Context<'_, Self>)
Put an empty row in table ix before row (Part::Cell
numbering) and the caret in its first cell.
Sourcepub fn add_column(
&mut self,
ix: usize,
column: usize,
cx: &mut Context<'_, Self>,
)
pub fn add_column( &mut self, ix: usize, column: usize, cx: &mut Context<'_, Self>, )
Put an empty column in table ix before column and the caret in it,
on the caret’s row when the caret is in this table.
Sourcepub fn remove_row(&mut self, ix: usize, row: usize, cx: &mut Context<'_, Self>)
pub fn remove_row(&mut self, ix: usize, row: usize, cx: &mut Context<'_, Self>)
Take body row row out of table ix. Does nothing to the header row.
Sourcepub fn remove_column(
&mut self,
ix: usize,
column: usize,
cx: &mut Context<'_, Self>,
)
pub fn remove_column( &mut self, ix: usize, column: usize, cx: &mut Context<'_, Self>, )
Take column out of table ix. Does nothing to the last column.
Source§impl Editor
impl Editor
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. In Mode::Source it is the text being
edited, exactly as it stands.
Sourcepub fn formatting(&self) -> Formatting
pub fn formatting(&self) -> Formatting
What a toolbar needs to light itself. See Formatting.
Sourcepub fn set_mode(&mut self, mode: Mode, cx: &mut Context<'_, Self>)
pub fn set_mode(&mut self, mode: Mode, cx: &mut Context<'_, Self>)
Switch between the document and its markdown, carrying the caret across.
One undo step, and one the history knows the mode of: stepping back over a switch puts the document back in the form it was edited in.
Anchors cross with it, into the coordinates of the form switched to. One with an end that cannot be placed there comes out detached.
Sourcepub fn toggle_source(&mut self, cx: &mut Context<'_, Self>)
pub fn toggle_source(&mut self, cx: &mut Context<'_, Self>)
Mode::Source if the document is in blocks, and back again — what a
toggle in the app’s own chrome calls.
Sourcepub fn source_lines(&self) -> usize
pub fn source_lines(&self) -> usize
Lines in the source, counting the empty one after a trailing newline.
Only meaningful in Mode::Source, as Self::source_text is.
Source§impl Editor
impl Editor
Sourcepub fn press(
&mut self,
position: Point<Pixels>,
click_count: usize,
modifiers: Modifiers,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
pub fn press( &mut self, position: Point<Pixels>, click_count: usize, modifiers: Modifiers, window: &mut Window, cx: &mut Context<'_, Self>, )
Press at position as if on the document: menus close, the editor
takes focus, and the caret goes to the nearest place a caret can be —
below the last block, above the first, or beside a line.
For a host whose own frame around the editor should behave as the page. A
press the editor’s box already took is marked with
Window::prevent_default, and this ignores one so marked.
Source§impl Editor
impl Editor
Source§impl Editor
impl Editor
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.
Source§impl Editor
impl Editor
Sourcepub fn new(source: &str, cx: &mut Context<'_, Self>) -> Self
pub fn new(source: &str, cx: &mut Context<'_, Self>) -> Self
An editor on a document of its own.
Sourcepub fn for_document(
document: Entity<Document>,
cx: &mut Context<'_, Self>,
) -> Self
pub fn for_document( document: Entity<Document>, cx: &mut Context<'_, Self>, ) -> Self
An editor on document, beside any others already on it.
Sourcepub fn with_chrome(self, chrome: Chrome) -> Self
pub fn with_chrome(self, chrome: Chrome) -> Self
Which of the editor’s own affordances to paint. See Chrome.
Sourcepub fn with_image_overlay(self, overlay: ImageOverlay) -> Self
pub fn with_image_overlay(self, overlay: ImageOverlay) -> Self
Adds an app-provided hover control to pictures in rich mode.
Sourcepub fn set_image_overlay(
&mut self,
overlay: Option<ImageOverlay>,
cx: &mut Context<'_, Self>,
)
pub fn set_image_overlay( &mut self, overlay: Option<ImageOverlay>, cx: &mut Context<'_, Self>, )
Replaces or removes the picture hover control.
Sourcepub fn with_image_overlay_corner(self, corner: ImageOverlayCorner) -> Self
pub fn with_image_overlay_corner(self, corner: ImageOverlayCorner) -> Self
Positions picture hover controls; bottom-right by default.
Sourcepub fn set_image_overlay_corner(
&mut self,
corner: ImageOverlayCorner,
cx: &mut Context<'_, Self>,
)
pub fn set_image_overlay_corner( &mut self, corner: ImageOverlayCorner, cx: &mut Context<'_, Self>, )
Repositions the picture hover control.
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 set_text_size(&mut self, points: f32, cx: &mut Context<'_, Self>)
pub fn set_text_size(&mut self, points: f32, cx: &mut Context<'_, Self>)
Update the configured base size without changing the temporary zoom.
Sourcepub fn text_size(&self) -> Option<f32>
pub fn text_size(&self) -> Option<f32>
The base the app set, if any. Add
crate::AppExt::editor_text_size_adjustment for what is on
screen.
Sourcepub fn with_base(self, dir: impl Into<PathBuf>) -> Self
pub fn with_base(self, dir: impl Into<PathBuf>) -> Self
Resolve relative image paths against dir — the document’s own folder,
for a document that keeps its pictures beside it. The stored URL stays
as written.
Sourcepub fn set_base(&mut self, dir: Option<PathBuf>, cx: &mut Context<'_, Self>)
pub fn set_base(&mut self, dir: Option<PathBuf>, cx: &mut Context<'_, Self>)
Change or clear the directory relative image paths resolve against.
Sourcepub fn base(&self) -> Option<&Path>
pub fn base(&self) -> Option<&Path>
The directory relative image paths resolve against, if one is set.
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 and a drag held past its top or bottom scrolls it.
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 select_to_top(
&mut self,
selection: Selection,
cx: &mut Context<'_, Self>,
)
pub fn select_to_top( &mut self, selection: Selection, cx: &mut Context<'_, Self>, )
Self::select, scrolling the caret’s row to the top of the scroll
box — what a jump to a heading wants, from either side of it.
Sourcepub fn layouts(&self) -> &BlockLayouts
pub fn layouts(&self) -> &BlockLayouts
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.
Where everything landed last frame — blocks, pictures, a fence’s
language label, and the row rects of any range.
Handed out whole rather than a method per question: an app placing
chrome of its own asks the geometry, and which question it needs is not
this crate’s to guess. See markdown::BlockLayouts.
pub fn selection_bounds(&self) -> Option<Bounds<Pixels>>
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 !Freeze for Editor
impl !RefUnwindSafe for Editor
impl !Send for Editor
impl !Sync for Editor
impl !UnwindSafe 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