[go: up one dir, main page]

termion/
lib.rs

1//! Termion is a pure Rust, bindless library for low-level handling, manipulating
2//! and reading information about terminals. This provides a full-featured
3//! alternative to Termbox.
4//!
5//! Termion aims to be simple and yet expressive. It is bindless, meaning that it
6//! is not a front-end to some other library (e.g., ncurses or termbox), but a
7//! standalone library directly talking to the TTY.
8//!
9//! Supports Redox, Mac OS X, and Linux (or, in general, ANSI terminals).
10//!
11//! For more information refer to the [README](https://github.com/redox-os/termion).
12#![warn(missing_docs)]
13
14extern crate numtoa;
15#[cfg(feature = "serde")]
16extern crate serde;
17
18#[cfg(unix)]
19#[path = "sys/unix/mod.rs"]
20mod sys;
21
22pub use sys::size::terminal_size;
23#[cfg(unix)]
24pub use sys::size::{terminal_size_fd, terminal_size_pixels, terminal_size_pixels_fd};
25pub use sys::tty::{get_tty, is_tty};
26
27mod r#async;
28pub use r#async::{async_stdin, AsyncReader};
29
30#[macro_use]
31mod macros;
32pub mod clear;
33pub mod color;
34pub mod cursor;
35pub mod event;
36pub mod input;
37pub mod raw;
38pub mod screen;
39pub mod scroll;
40pub mod style;
41
42#[cfg(test)]
43mod test {
44    use std::os::fd::AsFd;
45
46    use super::sys;
47
48    #[test]
49    fn test_get_terminal_attr() {
50        let stdout = std::io::stdout();
51        sys::attr::get_terminal_attr(stdout.as_fd()).unwrap();
52        sys::attr::get_terminal_attr(stdout.as_fd()).unwrap();
53        sys::attr::get_terminal_attr(stdout.as_fd()).unwrap();
54    }
55
56    #[test]
57    fn test_set_terminal_attr() {
58        let stdout = std::io::stdout();
59        let ios = sys::attr::get_terminal_attr(stdout.as_fd()).unwrap();
60        sys::attr::set_terminal_attr(stdout.as_fd(), &ios).unwrap();
61    }
62
63    #[test]
64    fn test_size() {
65        sys::size::terminal_size().unwrap();
66    }
67}