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
impl TextBox
Sourcepub fn new(
text: &str,
width: usize,
per_page: usize,
widths: &CellWidths,
) -> Self
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.
Sourcepub fn page_lines(&self) -> &[String]
pub fn page_lines(&self) -> &[String]
The lines of the page on screen, in full.
Sourcepub fn progress(&self) -> f32
pub fn progress(&self) -> f32
How many of the page’s characters are revealed, with the part of the next one typed so far.
Sourcepub fn is_revealed(&self) -> bool
pub fn is_revealed(&self) -> bool
Whether the whole page is revealed.
Sourcepub fn next_page(&mut self) -> bool
pub fn next_page(&mut self) -> bool
Turns to the next page, if there is one: returns whether it did.
Sourcepub fn confirm(&mut self) -> Step
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).
Sourcepub fn to_last_page(&mut self)
pub fn to_last_page(&mut self)
Shows the last page, all of it revealed (the line a choice answers).
Sourcepub fn release(&mut self)
pub fn release(&mut self)
The key that goes on is no longer counted as held (the box waits on something else).
Sourcepub fn hold(&mut self, held: bool, dt: f32)
pub fn hold(&mut self, held: bool, dt: f32)
dt seconds on, with the key that goes on held or not.
Sourcepub fn type_on(&mut self, dt: f32, chars_per_s: Option<f32>)
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.
Sourcepub fn marker_lit(&self) -> bool
pub fn marker_lit(&self) -> bool
Whether the marker that says “press to go on” is lit: it blinks while the page waits.