Skip to main content

Editor

Struct Editor 

Source
pub struct Editor(/* private fields */);
Expand description

A multi-line text editor.

Implementations§

Source§

impl Editor

Source

pub fn new() -> Self

Creates a new empty Editor.

Source

pub fn buffer(&self) -> &Buffer

Returns the buffer of the Editor.

Source

pub fn downgrade(&self) -> Weak

Creates a Weak reference to the Editor.

This is useful to avoid cloning the Editor when referential guarantees are unnecessary. For instance, when creating a rendering tree.

Trait Implementations§

Source§

impl Debug for Editor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Editor

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Editor for Editor

Source§

type Font = Font

The font of the Editor.
Source§

fn with_text(text: &str) -> Self

Creates a new Editor laid out with the given text.
Source§

fn is_empty(&self) -> bool

Returns true if the Editor has no contents.
Source§

fn line(&self, index: usize) -> Option<Line<'_>>

Returns the text of the given line in the Editor, if it exists.
Source§

fn line_count(&self) -> usize

Returns the amount of lines in the Editor.
Source§

fn copy(&self) -> Option<String>

Returns the current selected text of the Editor.
Source§

fn selection(&self) -> Selection

Returns the current Selection of the Editor.
Source§

fn cursor(&self) -> Cursor

Returns the current Cursor of the Editor.
Source§

fn perform(&mut self, action: Action)

Performs an Action on the Editor.
Source§

fn move_to(&mut self, cursor: Cursor)

Moves the cursor to the given position.
Source§

fn bounds(&self) -> Size

Returns the current boundaries of the Editor.
Source§

fn min_bounds(&self) -> Size

Returns the minimum boundaries to fit the current contents of the Editor.
Source§

fn hint_factor(&self) -> Option<f32>

Returns the hint factor of the Editor.
Source§

fn update( &mut self, new_bounds: Size, new_font: Font, new_size: Pixels, new_line_height: LineHeight, new_wrapping: Wrapping, new_hint_factor: Option<f32>, new_highlighter: &mut impl Highlighter, )

Updates the Editor with some new attributes.
Source§

fn highlight<H: Highlighter>( &mut self, font: Self::Font, highlighter: &mut H, format_highlight: impl Fn(&H::Highlight) -> Format<Self::Font>, )

Runs a text Highlighter in the Editor.
Source§

impl PartialEq for Editor

Source§

fn eq(&self, other: &Editor) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Editor

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSync for T
where T: Sync,