Enum Keypress

Keys that can be returned by Term::read.

Variants

Implementation for Term

Method new

fn new() -> Term

Creates a new Term instance.

This can be used to manipulate the terminal for full screen applications.

Method clear

fn clear(&mut self)

Clears the screen.

Method move

fn move(&mut self, col: uint, row: uint)

Moves the cursor to (col, row).

Method fg_color

fn fg_color(&mut self, color: info::Color)

Changes the currently active foreground color to color.

Method bg_color

fn bg_color(&mut self, color: info::Color)

Changes the currently active background color to color.

Method reset_color

fn reset_color(&mut self)

Resets the foreground and background colors to the default.

Method underline

fn underline(&mut self, enabled: bool)

Enables or disables underline mode.

Method standout

fn standout(&mut self, enabled: bool)

Enables or disables standout mode.

Method reverse

fn reverse(&mut self, enabled: bool)

Enables or disables reverse mode.

Method bold

fn bold(&mut self, enabled: bool)

Enables or disables bold mode.

Method cursor

fn cursor(&mut self, enabled: bool)

Enables or disables visible cursor mode.

Method alternate_screen

fn alternate_screen(&mut self, enabled: bool)

Switches to or from the alternate screen.

This is used to provide a separate place to do all of the drawing for a full screen app, so that at the end of the application, the terminal will be restored to the original state.

Method write

fn write(&mut self, text: &str)

Write a string to the terminal.

Due to buffering, using io::print() will not work properly. All text written to the terminal must go through the Term object, or the state of the screen will likely end up incorrect.

Method flush

fn flush(&mut self)

Flush the data written so far to the terminal.

This is also done implicitly before every call to read, so there's not usually a reason to do it manually, other than edge cases such as timed animations.

Method read

fn read(&mut self) -> Option<Keypress>

Read a keypress from the terminal.

Returns Some(Keypress) if a key was read, and None if stdin reaches eof.

Note that most special keys are actually sequences of multiple characters. This means that if a prefix of a special character key sequence was read, it has to wait to see if there are more characters coming, or if that character was the only key. Since most of these multi-character sequences start with escape, there will be a delay in reading a single KeyEscape keypress.

Also, other special keys are represented as control keys, so for instance, ^J will likely return KeyReturn instead of KeyCtrl('j').

Implementation of Drop for Term

Method finalize

fn finalize(&self)