1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//! Platform-independent terminal interface
//!
//! Two distinct interfaces to operating system terminal devices are provided,
//! each abstracting over the differences between Unix terminals and Windows console.
//!
//! The [`Terminal`] interface treats the terminal as a line-by-line
//! output device. Methods exist to add color and style attributes to text,
//! and to make relative movements of the cursor.
//!
//! The [`Screen`] interface treats the entire terminal window as a drawable
//! buffer. Methods exist to set the cursor position and to write text with
//! color and style attributes.
//!
//! ## Concurrency
//!
//! Each interface uses internal locking mechanisms to allow sharing of the
//! terminal interface between threads while maintaining coherence of read/write
//! operations.
//!
//! See the documentation for [`Terminal`] and [`Screen`] for further details.
//!
//! [`Screen`]: screen/struct.Screen.html
//! [`Terminal`]: terminal/struct.Terminal.html
//! [`refresh`]: screen/struct.Screen.html#method.refresh

#![deny(missing_docs)]

#[macro_use] extern crate bitflags;
extern crate smallstr;
extern crate unicode_normalization;
extern crate unicode_width;

#[cfg(unix)] extern crate libc;
#[cfg(unix)] extern crate nix;
#[cfg(unix)] extern crate terminfo;

#[cfg(windows)] extern crate winapi;

pub use screen::{Screen, ScreenReadGuard, ScreenWriteGuard};
pub use sequence::{FindResult, SequenceMap};
pub use signal::{Signal, SignalSet};
pub use terminal::{
    Color, Cursor, CursorMode, Size, Style,
    Event, Key, MouseEvent, MouseInput, MouseButton, ModifierState,
    PrepareConfig, PrepareState,
    Terminal, TerminalReadGuard, TerminalWriteGuard,
};

#[macro_use] mod buffer;
mod priv_util;
pub mod screen;
pub mod sequence;
pub mod signal;
pub mod terminal;
pub mod util;

#[cfg(unix)]
#[path = "unix/mod.rs"]
mod sys;

#[cfg(windows)]
#[path = "windows/mod.rs"]
mod sys;

#[cfg(unix)]
pub use sys::ext as unix;

#[cfg(windows)]
pub use sys::ext as windows;

#[cfg(test)]
mod test {
    use screen::Screen;
    use terminal::Terminal;

    fn assert_has_traits<T: 'static + Send + Sync>() {}

    #[test]
    fn test_traits() {
        assert_has_traits::<Terminal>();
        assert_has_traits::<Screen>();
    }
}