skim_tuikit/lib.rs
1//!
2//! ## Tuikit
3//! Tuikit is a TUI library for writing terminal UI applications. Highlights:
4//!
5//! - Thread safe.
6//! - Support non-fullscreen mode as well as fullscreen mode.
7//! - Support `Alt` keys, mouse events, etc.
8//! - Buffering for efficient rendering.
9//!
10//! Tuikit is modeld after [termbox](https://github.com/nsf/termbox) which views the
11//! terminal as a table of fixed-size cells and input being a stream of structured
12//! messages.
13//!
14//! ## Usage
15//!
16//! In your `Cargo.toml` add the following:
17//!
18//! ```toml
19//! [dependencies]
20//! tuikit = "*"
21//! ```
22//!
23//! Here is an example:
24//!
25//! ```no_run
26//! use skim_tuikit::attr::*;
27//! use skim_tuikit::term::{Term, TermHeight};
28//! use skim_tuikit::event::{Event, Key};
29//! use std::cmp::{min, max};
30//!
31//! let term: Term<()> = Term::with_height(TermHeight::Percent(30)).unwrap();
32//! let mut row = 1;
33//! let mut col = 0;
34//!
35//! let _ = term.print(0, 0, "press arrow key to move the text, (q) to quit");
36//! let _ = term.present();
37//!
38//! while let Ok(ev) = term.poll_event() {
39//! let _ = term.clear();
40//! let _ = term.print(0, 0, "press arrow key to move the text, (q) to quit");
41//!
42//! let (width, height) = term.term_size().unwrap();
43//! match ev {
44//! Event::Key(Key::ESC) | Event::Key(Key::Char('q')) => break,
45//! Event::Key(Key::Up) => row = max(row-1, 1),
46//! Event::Key(Key::Down) => row = min(row+1, height-1),
47//! Event::Key(Key::Left) => col = max(col, 1)-1,
48//! Event::Key(Key::Right) => col = min(col+1, width-1),
49//! _ => {}
50//! }
51//!
52//! let attr = Attr{ fg: Color::RED, ..Attr::default() };
53//! let _ = term.print_with_attr(row, col, "Hello World! 你好!今日は。", attr);
54//! let _ = term.set_cursor(row, col);
55//! let _ = term.present();
56//! }
57//! ```
58pub mod attr;
59pub mod canvas;
60pub mod cell;
61mod color;
62pub mod draw;
63pub mod error;
64pub mod event;
65pub mod input;
66pub mod key;
67mod macros;
68pub mod output;
69pub mod prelude;
70pub mod raw;
71pub mod screen;
72use skim_common::spinlock;
73mod sys;
74pub mod term;
75pub mod widget;
76
77#[macro_use]
78extern crate log;
79
80use crate::error::TuikitError;
81
82pub type Result<T> = std::result::Result<T, TuikitError>;