Struct BorrowedWithFontSystem

Source
pub struct BorrowedWithFontSystem<'a, T> { /* private fields */ }
Expand description

A value borrowed together with an FontSystem

Implementations§

Source§

impl BorrowedWithFontSystem<'_, Buffer>

Source

pub fn shape_until_cursor(&mut self, cursor: Cursor, prune: bool)

Shape lines until cursor, also scrolling to include cursor in view

Source

pub fn shape_until_scroll(&mut self, prune: bool)

Shape lines until scroll

Source

pub fn line_shape(&mut self, line_i: usize) -> Option<&ShapeLine>

Shape the provided line index and return the result

Source

pub fn line_layout(&mut self, line_i: usize) -> Option<&[LayoutLine]>

Lay out the provided line index and return the result

Source

pub fn set_metrics(&mut self, metrics: Metrics)

Set the current Metrics

§Panics

Will panic if metrics.font_size is zero.

Source

pub fn set_wrap(&mut self, wrap: Wrap)

Set the current Wrap

Source

pub fn set_size(&mut self, width_opt: Option<f32>, height_opt: Option<f32>)

Set the current buffer dimensions

Source

pub fn set_metrics_and_size( &mut self, metrics: Metrics, width_opt: Option<f32>, height_opt: Option<f32>, )

Set the current Metrics and buffer dimensions at the same time

§Panics

Will panic if metrics.font_size is zero.

Source

pub fn set_tab_width(&mut self, tab_width: u16)

Set tab width (number of spaces between tab stops)

Source

pub fn set_text(&mut self, text: &str, attrs: Attrs<'_>, shaping: Shaping)

Set text of buffer, using provided attributes for each line by default

Source

pub fn set_rich_text<'r, 's, I>( &mut self, spans: I, default_attrs: Attrs<'_>, shaping: Shaping, alignment: Option<Align>, )
where I: IntoIterator<Item = (&'s str, Attrs<'r>)>,

Set text of buffer, using an iterator of styled spans (pairs of text and attributes)

let mut buffer = Buffer::new_empty(Metrics::new(32.0, 44.0));
let mut buffer = buffer.borrow_with(&mut font_system);
let attrs = Attrs::new().family(Family::Serif);
buffer.set_rich_text(
    [
        ("hello, ", attrs),
        ("cosmic\ntext", attrs.family(Family::Monospace)),
    ],
    attrs,
    Shaping::Advanced,
    None,
);
Source

pub fn cursor_motion( &mut self, cursor: Cursor, cursor_x_opt: Option<i32>, motion: Motion, ) -> Option<(Cursor, Option<i32>)>

Apply a Motion to a Cursor

Source

pub fn draw<F>(&mut self, cache: &mut SwashCache, color: Color, f: F)
where F: FnMut(i32, i32, u32, u32, Color),

Draw the buffer

Source§

impl BorrowedWithFontSystem<'_, Editor<'_>>

Source

pub fn draw<F>( &mut self, cache: &mut SwashCache, text_color: Color, cursor_color: Color, selection_color: Color, selected_text_color: Color, f: F, )
where F: FnMut(i32, i32, u32, u32, Color),

Source§

impl BorrowedWithFontSystem<'_, SyntaxEditor<'_, '_>>

Source

pub fn load_text<P: AsRef<Path>>( &mut self, path: P, attrs: Attrs<'_>, ) -> Result<()>

Load text from a file, and also set syntax to the best option

§Errors

Returns an io::Error if reading the file fails

Source

pub fn draw<F>(&mut self, cache: &mut SwashCache, f: F)
where F: FnMut(i32, i32, u32, u32, Color),

Source§

impl BorrowedWithFontSystem<'_, ViEditor<'_, '_>>

Source

pub fn load_text<P: AsRef<Path>>( &mut self, path: P, attrs: Attrs<'_>, ) -> Result<()>

Load text from a file, and also set syntax to the best option

§Errors

Returns an io::Error if reading the file fails

Source

pub fn draw<F>(&mut self, cache: &mut SwashCache, f: F)
where F: FnMut(i32, i32, u32, u32, Color),

Source§

impl<'buffer, E: Edit<'buffer>> BorrowedWithFontSystem<'_, E>

Source

pub fn with_buffer_mut<F: FnOnce(&mut BorrowedWithFontSystem<'_, Buffer>) -> T, T>( &mut self, f: F, ) -> T

Get the internal Buffer, mutably

Source

pub fn set_tab_width(&mut self, tab_width: u16)

Set the current tab width. A tab_width of 0 is not allowed, and will be ignored

Source

pub fn shape_as_needed(&mut self, prune: bool)

Shape lines until scroll, after adjusting scroll if the cursor moved

Source

pub fn action(&mut self, action: Action)

Perform an Action on the editor

Trait Implementations§

Source§

impl<'a, T: Debug> Debug for BorrowedWithFontSystem<'a, T>

Source§

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

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

impl<T> Deref for BorrowedWithFontSystem<'_, T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T> DerefMut for BorrowedWithFontSystem<'_, T>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<'a, T> Freeze for BorrowedWithFontSystem<'a, T>

§

impl<'a, T> !RefUnwindSafe for BorrowedWithFontSystem<'a, T>

§

impl<'a, T> Send for BorrowedWithFontSystem<'a, T>
where T: Send,

§

impl<'a, T> Sync for BorrowedWithFontSystem<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for BorrowedWithFontSystem<'a, T>

§

impl<'a, T> !UnwindSafe for BorrowedWithFontSystem<'a, T>

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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> Formattable for T
where T: Deref, <T as Deref>::Target: Formattable,

Source§

impl<T> Parsable for T
where T: Deref, <T as Deref>::Target: Parsable,