RwArea

Struct RwArea 

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

A type erased RawArea

This type houses the inner Area, and provides type erased access to its functions.

Implementations§

Source§

impl RwArea

Source

pub fn read<'a>(&'a self, pa: &'a Pass) -> &'a Area

Shared access to an Area

You should use this if you want “prolonged” access to the Area’s methods, without necessarily bringing a Pass with you.

Source

pub fn write<'a>(&'a self, pa: &'a mut Pass) -> &'a mut Area

Mutable access to an Area

You should use this if you want “prolonged” access to the Area’s methods, without necessarily bringing a Pass with you.

Source

pub fn read_as<'a, A: RawArea>(&'a self, pa: &'a Pass) -> Option<&'a A>

Attempt to read this as a specific implementation of RawArea

You can use this to deal with individual RawAreas, so you can do a “per Ui” configuration for your Plugin/configuration.

This will return None if the RawArea within is of a different type.

Source

pub fn write_as<'a, A: RawArea>(&'a self, pa: &'a mut Pass) -> Option<&'a mut A>

Attempt to write this as a specific implementation of RawArea

You can use this to deal with individual RawAreas, so you can do a “per Ui” configuration for your Plugin/configuration. This could be used to, for example, place frames around an Area when making use of a terminal Ui, or using some custom css when using a web Ui.

This will return None if the RawArea within is of a different type.

Source

pub fn set_width(&self, pa: &mut Pass, width: f32) -> Result<(), Text>

Sets the width of the RawArea

Source

pub fn set_height(&self, pa: &mut Pass, height: f32) -> Result<(), Text>

Sets the height of the RawArea

Source

pub fn hide(&self, pa: &mut Pass) -> Result<(), Text>

Hides the RawArea

Source

pub fn reveal(&self, pa: &mut Pass) -> Result<(), Text>

Reveals the RawArea

Source

pub fn set_as_active(&self, pa: &mut Pass)

Tells the RawUi that this RawArea is the one that is currently focused.

Should make self the active RawArea while deactivating any other active RawArea.

Source

pub fn width_of_text( &self, pa: &Pass, opts: PrintOpts, text: &Text, ) -> Result<f32, Text>

What width the given Text would occupy, if unwrapped

Source

pub fn print(&self, pa: &Pass, text: &Text, opts: PrintOpts, painter: Painter)

Prints the Text

Source

pub fn print_with<'a>( &self, pa: &Pass, text: &Text, opts: PrintOpts, painter: Painter, f: impl FnMut(&Caret, &Item) + 'a, )

Prints the Text with a callback function

Source

pub fn get_print_info(&self, pa: &Pass) -> PrintInfo

The current printing information of the area

Source

pub fn set_print_info(&self, pa: &mut Pass, info: PrintInfo)

Sets a previously acquired PrintInfo to the area

Source

pub fn print_iter<'a>( &self, pa: &Pass, text: &'a Text, points: TwoPoints, opts: PrintOpts, ) -> Box<dyn Iterator<Item = (Caret, Item)> + 'a>

Returns a printing iterator

Given an iterator of text::Items, returns an iterator which assigns to each of them a Caret. This struct essentially represents where horizontally would this character be printed.

If you want a reverse iterator, see Area::rev_print_iter.

Source

pub fn rev_print_iter<'a>( &self, pa: &Pass, text: &'a Text, points: TwoPoints, opts: PrintOpts, ) -> Box<dyn Iterator<Item = (Caret, Item)> + 'a>

Returns a reversed printing iterator

Given an iterator of text::Items, returns a reversed iterator which assigns to each of them a Caret. This struct essentially represents where horizontally each character would be printed.

If you want a forwards iterator, see Area::print_iter.

Source

pub fn scroll_ver(&self, pa: &mut Pass, text: &Text, dist: i32, opts: PrintOpts)

Scrolls the Text veritcally by an amount

If scroll_beyond is set, then the Text will be allowed to scroll beyond the last line, up until reaching the scrolloff.y value.

Source

pub fn scroll_around_points( &self, pa: &mut Pass, text: &Text, points: TwoPoints, opts: PrintOpts, )

Scrolls the Text on all four directions until the given TwoPoints is within the ScrollOff range

There are two other scrolling methods for Area: scroll_ver and scroll_to_points. The difference between this and scroll_to_points is that this method doesn’t do anything if the TwoPoints is already on screen.

Source

pub fn scroll_to_points( &self, pa: &mut Pass, text: &Text, points: TwoPoints, opts: PrintOpts, )

Scrolls the Text to the visual line of a TwoPoints

This method takes line wrapping into account, so it’s not the same as setting the starting points to the Text::visual_line_start of these TwoPoints.

If scroll_beyond is set, then the Text will be allowed to scroll beyond the last line, up until reaching the scrolloff.y value.

Source

pub fn start_points(&self, pa: &Pass, text: &Text, opts: PrintOpts) -> TwoPoints

Scrolls the Area to the given TwoPoints

Source

pub fn end_points(&self, pa: &Pass, text: &Text, opts: PrintOpts) -> TwoPoints

Scrolls the Area to the given TwoPoints

Source

pub fn has_changed(&self, pa: &Pass) -> bool

Wether this Area has changed since last being printed

Source

pub fn is_master_of(&self, pa: &Pass, other: &Self) -> bool

Whether or not this Area is the “master” of another

Source

pub fn store_cache(&self, pa: &Pass, path: &str) -> Result<(), Text>

Stores the cache of the Area, given a path to associate with this cache

Source

pub fn top_left(&self, pa: &Pass) -> Coord

The top left Coord of this Area

Source

pub fn bottom_right(&self, pa: &Pass) -> Coord

The bottom right Coord of this Area

Source

pub fn width(&self, pa: &Pass) -> f32

Gets the width of the area

Source

pub fn height(&self, pa: &Pass) -> f32

Gets the height of the area

Source

pub fn coord_at_points( &self, pa: &Pass, text: &Text, points: TwoPoints, opts: PrintOpts, ) -> Option<Coord>

The Coord where the given TwoPoints would be printed

Returns None if the TwoPoints are not part of the Text

Source

pub fn points_at_coord( &self, pa: &Pass, text: &Text, coord: Coord, opts: PrintOpts, ) -> Option<TwoPointsPlace>

The TwoPoints where a Coord is found

Returns None if either the RawArea does not contain the given Coord, or if the Coord is in a position where Text is not printed.

Source

pub fn is_active(&self, pa: &Pass) -> bool

Returns true if this is the currently active Area

Only one Area should be active at any given moment.

Source

pub fn area_is_eq(&self, pa: &Pass, other: &RwArea) -> bool

Wether this Area is the same as another

Trait Implementations§

Source§

impl Clone for RwArea

Source§

fn clone(&self) -> RwArea

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl Freeze for RwArea

§

impl !RefUnwindSafe for RwArea

§

impl Send for RwArea

§

impl Sync for RwArea

§

impl Unpin for RwArea

§

impl !UnwindSafe for RwArea

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.