Skip to main content

TextBox

Struct TextBox 

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

The text box’s state: the text, wrapped, the page on screen and how much of it is revealed.

Implementations§

Source§

impl TextBox

Source

pub fn new( text: &str, width: usize, per_page: usize, widths: &CellWidths, ) -> Self

text wrapped at width cells (word_wrap, a wide character of widths two cells: Ctx::widths), per_page lines a page, on its first page with nothing revealed yet.

Source

pub fn page_lines(&self) -> &[String]

The lines of the page on screen, in full.

Source

pub fn progress(&self) -> f32

How many of the page’s characters are revealed, with the part of the next one typed so far.

Source

pub fn shown(&self) -> usize

How many of the page’s characters are revealed.

Source

pub fn is_revealed(&self) -> bool

Whether the whole page is revealed.

Source

pub fn reveal(&mut self)

Reveals the whole page at once.

Source

pub fn next_page(&mut self) -> bool

Turns to the next page, if there is one: returns whether it did.

Source

pub fn confirm(&mut self) -> Step

What the key that goes on does: reveals the page being typed (Step::Revealed), else turns to the next page (Step::NextPage), else says the box is Step::Done and leaves it as it is (its owner moves on to the next line, or closes it).

Source

pub fn to_last_page(&mut self)

Shows the last page, all of it revealed (the line a choice answers).

Source

pub fn release(&mut self)

The key that goes on is no longer counted as held (the box waits on something else).

Source

pub fn hold(&mut self, held: bool, dt: f32)

dt seconds on, with the key that goes on held or not.

Source

pub fn type_on(&mut self, dt: f32, chars_per_s: Option<f32>)

dt seconds of typing at chars_per_s (None: the whole page at once), faster for the part of them past FAST_FORWARD_DELAY of holding; once the page is revealed, the time it has waited.

Source

pub fn marker_lit(&self) -> bool

Whether the marker that says “press to go on” is lit: it blinks while the page waits.

Trait Implementations§

Source§

impl Clone for TextBox

Source§

fn clone(&self) -> TextBox

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TextBox

Source§

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

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

impl PartialEq for TextBox

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for TextBox

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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.