pub struct Terminal {
pub window: Window,
pub cursor: Cursor,
/* private fields */
}
Expand description
An instance of a graphical terminal emulator.
Fields§
§window: Window
The terminal’s own window.
cursor: Cursor
The cursor of the terminal.
Implementations§
source§impl Terminal
impl Terminal
Private methods of Terminal
.
sourcepub fn get_text_dimensions(&self) -> (usize, usize)
pub fn get_text_dimensions(&self) -> (usize, usize)
Gets the width and height of the text displayable in number of characters.
source§impl Terminal
impl Terminal
Public methods of Terminal
.
sourcepub fn new() -> Result<Terminal, &'static str>
pub fn new() -> Result<Terminal, &'static str>
Creates a new terminal and adds it to the window manager wm_mutex
sourcepub fn print_to_terminal(&mut self, s: String)
pub fn print_to_terminal(&mut self, s: String)
Adds a string to be printed to the terminal to the terminal scrollback buffer.
Note that one needs to call refresh_display
to get things actually printed.
sourcepub fn refresh_display(&mut self) -> Result<(), &'static str>
pub fn refresh_display(&mut self) -> Result<(), &'static str>
Actually refresh the screen. Currently it’s expensive.
sourcepub fn insert_char(
&mut self,
c: char,
offset_from_end: usize
) -> Result<(), &'static str>
pub fn insert_char( &mut self, c: char, offset_from_end: usize ) -> Result<(), &'static str>
Insert a character to the terminal.
Arguments
c
: the new character to insert.offset_from_end
: the position to insert the character. It represents the distance relative to the end of the whole output in the terminal in number of characters.
Examples
terminal.insert_char(char, 0)
will appendchar
to the end of existing text.terminal.insert_char(char, 5)
will insertchar
right before the last 5 characters.
After invoke this function, one must call refresh_display
to get the updates actually showed on the screen.
sourcepub fn remove_char(
&mut self,
offset_from_end: usize
) -> Result<(), &'static str>
pub fn remove_char( &mut self, offset_from_end: usize ) -> Result<(), &'static str>
Remove a character from the terminal.
Arguments
offset_from_end
: the position of the character to remove. It represents the distance relative to the end of the whole output in the terminal in number of characters.offset_from_end == 0
is invalid here.
Examples
terminal.remove_char(1)
will remove the last character in the screen.
After invoke this function, one must call refresh_display
to get the updates actually showed on the screen.
sourcepub fn move_screen_to_begin(&mut self) -> Result<(), &'static str>
pub fn move_screen_to_begin(&mut self) -> Result<(), &'static str>
Scroll the screen to the very beginning.
sourcepub fn move_screen_to_end(&mut self) -> Result<(), &'static str>
pub fn move_screen_to_end(&mut self) -> Result<(), &'static str>
Scroll the screen to the very end.
sourcepub fn move_screen_line_up(&mut self) -> Result<(), &'static str>
pub fn move_screen_line_up(&mut self) -> Result<(), &'static str>
Scroll the screen a line up.
sourcepub fn move_screen_line_down(&mut self) -> Result<(), &'static str>
pub fn move_screen_line_down(&mut self) -> Result<(), &'static str>
Scroll the screen a line down.
sourcepub fn move_screen_page_up(&mut self) -> Result<(), &'static str>
pub fn move_screen_page_up(&mut self) -> Result<(), &'static str>
Scroll the screen a page up.
sourcepub fn move_screen_page_down(&mut self) -> Result<(), &'static str>
pub fn move_screen_page_down(&mut self) -> Result<(), &'static str>
Scroll the screen a page down.
sourcepub fn get_event(&mut self) -> Option<Event>
pub fn get_event(&mut self) -> Option<Event>
Gets an event from the window’s event queue.
Returns None
if no events have been sent to this window.
sourcepub fn display_cursor(&mut self) -> Result<(), &'static str>
pub fn display_cursor(&mut self) -> Result<(), &'static str>
Display the cursor of the terminal.
sourcepub fn get_cursor_offset_from_end(&self) -> usize
pub fn get_cursor_offset_from_end(&self) -> usize
Gets the position of the cursor relative to the end of text in number of characters.
sourcepub fn update_cursor_pos(&mut self, offset_from_end: usize, underlying_char: u8)
pub fn update_cursor_pos(&mut self, offset_from_end: usize, underlying_char: u8)
Updates the position of a cursor.
Arguments
offset_from_end
: the position of the cursor relative to the end of text in number of characters.underlying_char
: the ASCII code of the underlying character when the cursor is unseen.