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

A value borrowed together with an FontSystem

Implementations§

source§

impl<'a> BorrowedWithFontSystem<'a, Buffer>

source

pub fn shape_until(&mut self, lines: i32) -> i32

Pre-shape lines in the buffer, up to lines, return actual number of layout lines

source

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

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

source

pub fn shape_until_scroll(&mut self)

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: f32, height: f32)

Set the current buffer dimensions

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, shaping: Shaping)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)),
    ],
    Shaping::Advanced,
);
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<'a, T: Edit> BorrowedWithFontSystem<'a, T>

source

pub fn buffer_mut(&mut self) -> BorrowedWithFontSystem<'_, Buffer>

Get the internal Buffer, mutably

source

pub fn shape_as_needed(&mut self)

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

source

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

Draw 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<'a, T> Deref for BorrowedWithFontSystem<'a, T>

§

type Target = T

The resulting type after dereferencing.
source§

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

Dereferences the value.
source§

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

source§

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

Mutably dereferences the value.

Auto Trait Implementations§

§

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.