Trait console_traits::Console
[−]
[src]
pub trait Console { type Error; fn get_width(&self) -> Col; fn get_height(&self) -> Row; fn set_col(&mut self, col: Col) -> Result<(), Self::Error>; fn set_row(&mut self, row: Row) -> Result<(), Self::Error>; fn set_pos(&mut self, pos: Position) -> Result<(), Self::Error>; fn get_pos(&self) -> Position; fn set_control_char_mode(&mut self, mode: ControlCharMode); fn get_control_char_mode(&self) -> ControlCharMode; fn set_escape_char_mode(&mut self, mode: EscapeCharMode); fn get_escape_char_mode(&self) -> EscapeCharMode; fn scroll_screen(&mut self) -> Result<(), Self::Error>; fn write_char_at(
&mut self,
ch: char,
pos: Position
) -> Result<(), Self::Error>; fn handle_escape(&mut self, escaped_char: char) -> bool; fn set_pos_unbounded(&mut self, pos: Position) { ... } fn write_string(&mut self, str: &str) -> Result<(), Self::Error> { ... } fn write_char(&mut self, ch: char) -> Result<(), Self::Error> { ... } fn write_string_at(
&mut self,
str: &str,
pos: Position
) -> Result<(), Self::Error> { ... } fn move_cursor_right(&mut self) -> Result<(), Self::Error> { ... } fn is_special(&self, ch: char) -> Option<SpecialChar> { ... } }
Abstraction for our console. We can move the cursor around and write text to it.
Associated Types
type Error
Required Methods
fn get_width(&self) -> Col
Gets the last col on the screen.
fn get_height(&self) -> Row
Gets the last row on the screen.
fn set_col(&mut self, col: Col) -> Result<(), Self::Error>
Set the horizontal position for the next text output.
fn set_row(&mut self, row: Row) -> Result<(), Self::Error>
Set the vertical position for the next text output.
fn set_pos(&mut self, pos: Position) -> Result<(), Self::Error>
Set the horizontal and vertical position for the next text output.
fn get_pos(&self) -> Position
Get the current screen position.
fn set_control_char_mode(&mut self, mode: ControlCharMode)
Set the control char mode
fn get_control_char_mode(&self) -> ControlCharMode
Get the current control char mode
fn set_escape_char_mode(&mut self, mode: EscapeCharMode)
Set the escape char mode
fn get_escape_char_mode(&self) -> EscapeCharMode
Get the current escape char mode
fn scroll_screen(&mut self) -> Result<(), Self::Error>
Called when the screen needs to scroll up one row.
fn write_char_at(&mut self, ch: char, pos: Position) -> Result<(), Self::Error>
Write a single Unicode char to the screen at the given position without updating the current position.
fn handle_escape(&mut self, escaped_char: char) -> bool
Called when they've used an escape character in the string. Currently you can only escape a single byte. The escape character is '\u{001B}' This function returns 'true' when the escape sequence is complete.
Provided Methods
fn set_pos_unbounded(&mut self, pos: Position)
Set the horizontal and vertical position for the next text output. Don't bounds check the value, we've already done it.
fn write_string(&mut self, str: &str) -> Result<(), Self::Error>
Write a string to the screen at the given position. Updates the current position to the end of the string. Strings will wrap across the end of the screen and scroll the screen if they reach the bottom.
fn write_char(&mut self, ch: char) -> Result<(), Self::Error>
Write a single Unicode char to the screen at the current position.
fn write_string_at(
&mut self,
str: &str,
pos: Position
) -> Result<(), Self::Error>
&mut self,
str: &str,
pos: Position
) -> Result<(), Self::Error>
Write a string to the screen at the given position. Updates the current position to the end of the string. Strings will wrap across the end of the screen and scroll the screen if they reach the bottom.
fn move_cursor_right(&mut self) -> Result<(), Self::Error>
Move the current cursor right one position. Wraps at the end of the line. Returns Ok(true) if the screen needs to scroll, or Ok(false) if it does not.
fn is_special(&self, ch: char) -> Option<SpecialChar>
Check if a char is special