Area

Struct Area 

Source
pub struct Area { /* private fields */ }
Expand description

A type erased RawUi::Area

This struct is accessed by calling RwArea::read or RwData::write.

Implementations§

Source§

impl Area

Source

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

Sets the width of the RawArea

Source

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

Sets the height of the RawArea

Source

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

Hides the RawArea

Source

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

Reveals the RawArea

Source

pub fn set_as_active(&mut self)

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, opts: PrintOpts, text: &Text) -> Result<f32, Text>

What width the given Text would occupy, if unwrapped

Source

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

Prints the Text via an Iterator

Source

pub fn print_with<'a>( &self, 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) -> PrintInfo

The current printing information of the area

Source

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

Sets a previously acquired PrintInfo to the area

Source

pub fn print_iter<'a>( &self, 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, 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(&mut self, 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( &mut self, 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( &mut self, 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, text: &Text, opts: PrintOpts) -> TwoPoints

Scrolls the Area to the given TwoPoints

Source

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

Scrolls the Area to the given TwoPoints

Source

pub fn has_changed(&self) -> bool

Wether this Area has changed since last being printed

Source

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

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

Source

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

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

Source

pub fn top_left(&self) -> Coord

The top left Coord of this Area

Source

pub fn bottom_right(&self) -> Coord

The bottom right Coord of this Area

Source

pub fn width(&self) -> f32

Gets the width of the area

Source

pub fn height(&self) -> f32

Gets the height of the area

Source

pub fn coord_at_points( &self, 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, 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) -> 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, other: &Area) -> bool

Wether this Area is the same as another

Auto Trait Implementations§

§

impl Freeze for Area

§

impl !RefUnwindSafe for Area

§

impl !Send for Area

§

impl !Sync for Area

§

impl Unpin for Area

§

impl !UnwindSafe for Area

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> 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> 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.