pub struct Yogurt { /* private fields */ }
Expand description
Yet Another Data Storage U Struct. Main struct for methods.
Unless a method specifies it flushes the buffer, calling the flush
method will be required for the changes to take effect.
Implementations
sourceimpl Yogurt
impl Yogurt
Output to the terminal.
sourcepub fn print(&mut self, displ: impl Display) -> Result<()>
pub fn print(&mut self, displ: impl Display) -> Result<()>
Print a string to the cursor location.
sourcepub fn mv(&mut self, point: impl Into<Point>) -> Result<()>
pub fn mv(&mut self, point: impl Into<Point>) -> Result<()>
Move the cursor to the specified point.
sourcepub fn mv_print(
&mut self,
point: impl Into<Point>,
displ: impl Display
) -> Result<()>
pub fn mv_print(
&mut self,
point: impl Into<Point>,
displ: impl Display
) -> Result<()>
Move the cursor to the specified point and print.
sourcepub fn draw_box(
&mut self,
up_corner: impl Into<Point>,
down_corner: impl Into<Point>,
chars: [char; 8]
) -> Result<()>
pub fn draw_box(
&mut self,
up_corner: impl Into<Point>,
down_corner: impl Into<Point>,
chars: [char; 8]
) -> Result<()>
Draw a box with the provided characters.
You can use the constants
BORDER
or ROUND_BORDER
instead of defining
your own.
Example of defining custom border:
let my_super_cool_border =
['┌', '─', '┐',
'│', '│',
'└', '─', '┘'];
An example can be found by running $ cargo run --example=border
.
sourcepub fn enter_alt(&mut self) -> Result<()>
pub fn enter_alt(&mut self) -> Result<()>
Enter “alternate mode.” See also leave_alt
.
In alternate mode, the following things are true:
- input will be avaliable imideately to the program (not line buffered)
- special keys will not be processed (
^C
won’t do anything!) - newline will not be proccessed
- an “alternate screen” will be entered, which has no scroll area and any changes made to the screen will not be preserved when switching back to the main screen.
In effect, alternate mode just enters an alternate screen and enables terminal raw mode.
This function also flushes the buffer.
sourceimpl Yogurt
impl Yogurt
Styling of text and cursor.
sourcepub fn cursor_on(&mut self, cursor: CursorAttr) -> Result<()>
pub fn cursor_on(&mut self, cursor: CursorAttr) -> Result<()>
Turn on a cursor attribute.
sourcepub fn cursor_off(&mut self, cursor: CursorAttr) -> Result<()>
pub fn cursor_off(&mut self, cursor: CursorAttr) -> Result<()>
Turn off a cursor attribute. Turning off a cursor shape resets it to Block
.
sourceimpl Yogurt
impl Yogurt
Functions for getting input from the user.
sourcepub fn read_event(&mut self, dur: Duration) -> Result<Option<Event>>
pub fn read_event(&mut self, dur: Duration) -> Result<Option<Event>>
Read an event. Will error if not in alt-mode. Duration is how long to wait for an event before returning.
sourcepub fn block_event(&mut self) -> Result<Event>
pub fn block_event(&mut self) -> Result<Event>
Like read_event
, except instead of exiting with None
after dur
has passed, it blocks the thread.