[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(target_os = "redox")]
19#[path = "sys/redox/mod.rs"]
20mod sys;
21
22#[cfg(all(unix, not(target_os = "redox")))]
23#[path = "sys/unix/mod.rs"]
24mod sys;
25
26pub use sys::size::terminal_size;
27#[cfg(all(unix, not(target_os = "redox")))]
28pub use sys::size::{terminal_size_fd, terminal_size_pixels, terminal_size_pixels_fd};
29pub use sys::tty::{get_tty, is_tty};
30
31mod r#async;
32pub use r#async::{async_stdin, AsyncReader};
33
34#[macro_use]
35mod macros;
36pub mod clear;
37pub mod color;
38pub mod cursor;
39pub mod event;
40pub mod input;
41pub mod raw;
42pub mod screen;
43pub mod scroll;
44pub mod style;
45
46#[cfg(test)]
47mod test {
48    use std::os::fd::AsFd;
49
50    use super::sys;
51
52    #[test]
53    fn test_get_terminal_attr() {
54        let stdout = std::io::stdout();
55        sys::attr::get_terminal_attr(stdout.as_fd()).unwrap();
56        sys::attr::get_terminal_attr(stdout.as_fd()).unwrap();
57        sys::attr::get_terminal_attr(stdout.as_fd()).unwrap();
58    }
59
60    #[test]
61    fn test_set_terminal_attr() {
62        let stdout = std::io::stdout();
63        let ios = sys::attr::get_terminal_attr(stdout.as_fd()).unwrap();
64        sys::attr::set_terminal_attr(stdout.as_fd(), &ios).unwrap();
65    }
66
67    #[test]
68    fn test_size() {
69        sys::size::terminal_size().unwrap();
70    }
71}