Crate termbox [] [src]

Termbox is a simple library for writing text based user interfaces. It was originally written in C, and this binding was not written by the original author.

Example

extern crate termbox;

use termbox::{
  Termbox,
  Event,
  BLACK,
  WHITE,
  BOLD,
  KEY_ESC,
};

fn main () {
  // Open the terminal
  let mut tb = Termbox::open().unwrap();

  // Clear the screen to black
  tb.set_clear_attributes(BLACK, BLACK);
  tb.clear();

  // Display a message
  tb.put_str(0, 0, "Hello, world!", WHITE | BOLD, BLACK);
  tb.put_str(0, 1, "Press Esc to continue", WHITE, BLACK);
  tb.present();

  // Wait for the user to press Esc
  loop {
    match tb.poll_event() {
      Event::Key(event) => {
        if event.key == KEY_ESC {
          break;
        }
      },
      _ => {},
    }
  }
}

Reexports

pub use self::attributes::*;
pub use self::keys::*;

Modules

attributes

Contains the Attribute type and attribute constants. All constants defined here are valid only for OutputMode::Normal.

keys

Contains the Key type and key constants.

Structs

KeyEvent
MouseEvent

Mouse events are disabled by default. Use Termbox::set_mouse_enabled to enable them.

ResizeEvent
Termbox

The main entry point for all termbox functions. This ensures that the terminal can only be accessed from one thread. Sadly, writing to stdout can potentially interfere with termbox output.

Enums

Error
Event

Represents an event that describes a user input action. Events can be received with Termbox::peek_event or Termbox::poll_event.

InputMode
MouseButton
OutputMode

Type Definitions

Cell

Represents a single character cell in the terminal output.

Coord

Integral type used to represent coordinates in cell space.

Result
Time

Integral type used to define a duration of time in milliseconds. This is used by Termbox::peek_event.