• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.github/H03-May-2022-120103

docs/H03-May-2022-8352

examples/H03-May-2022-551401

src/H03-May-2022-7,8994,913

.cargo-checksum.jsonH A D03-May-202289 11

.cargo_vcs_info.jsonH A D28-Dec-202074 65

.gitignoreH A D28-Dec-202063 65

.travis.ymlH A D28-Dec-20201,004 4335

CHANGELOG.mdH A D28-Dec-202029.4 KiB625480

Cargo.lockH A D28-Dec-202020.7 KiB842754

Cargo.tomlH A D28-Dec-20202.1 KiB9074

Cargo.toml.orig-cargoH A D28-Dec-20201.7 KiB8169

LICENSEH A D28-Dec-20201.1 KiB2217

README.mdH A D28-Dec-20206.6 KiB201156

README.md

1<h1 align="center"><img width="440" src="docs/crossterm_full.png" /></h1>
2
3[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Z8QK6XU749JB2) ![Travis][s7] [![Latest Version][s1]][l1] [![MIT][s2]][l2] [![docs][s3]][l3] ![Lines of Code][s6] [![Join us on Discord][s5]][l5]
4
5# Cross-platform Terminal Manipulation Library
6
7Crossterm is a pure-rust, terminal manipulation library that makes it possible to write cross-platform text-based interfaces (see [features](#features)). It supports all UNIX and Windows terminals down to Windows 7 (not all terminals are tested,
8see [Tested Terminals](#tested-terminals) for more info).
9
10## Table of Contents
11
12* [Features](#features)
13    * [Tested Terminals](#tested-terminals)
14* [Getting Started](#getting-started)
15    * [Feature Flags](#feature-flags)
16* [Other Resources](#other-resources)
17* [Used By](#used-by)
18* [Contributing](#contributing)
19
20## Features
21
22- Cross-platform
23- Multi-threaded (send, sync)
24- Detailed documentation
25- Few dependencies
26- Full control over writing and flushing output buffer
27- Is tty
28- Cursor
29    - Move the cursor N times (up, down, left, right)
30    - Move to previous / next line
31    - Move to column
32    - Set/get the cursor position
33    - Store the cursor position and restore to it later
34    - Hide/show the cursor
35    - Enable/disable cursor blinking (not all terminals do support this feature)
36- Styled output
37    - Foreground color (16 base colors)
38    - Background color (16 base colors)
39    - 256 (ANSI) color support (Windows 10 and UNIX only)
40    - RGB color support (Windows 10 and UNIX only)
41    - Text attributes like bold, italic, underscore, crossed, etc
42- Terminal
43    - Clear (all lines, current line, from cursor down and up, until new line)
44    - Scroll up, down
45    - Set/get the terminal size
46    - Exit current process
47    - Alternate screen
48    - Raw screen
49    - Set terminal title
50    - Enable/disable line wrapping
51- Event
52    - Input Events
53    - Mouse Events (press, release, position, button, drag)
54    - Terminal Resize Events
55    - Advanced modifier (SHIFT | ALT | CTRL) support for both mouse and key events and
56    - futures Stream  (feature 'event-stream')
57    - Poll/read API
58
59<!--
60WARNING: Do not change following heading title as it's used in the URL by other crates!
61-->
62
63### Tested Terminals
64
65- Console Host
66    - Windows 10 (Pro)
67    - Windows 8.1 (N)
68- Ubuntu Desktop Terminal
69    - Ubuntu 17.10
70    - Pop!_OS ( Ubuntu ) 20.04
71- (Arch, Manjaro) KDE Konsole
72- (Arch) Kitty
73- Linux Mint
74
75This crate supports all UNIX terminals and Windows terminals down to Windows 7; however, not all of the
76terminals have been tested. If you have used this library for a terminal other than the above list without
77issues, then feel free to add it to the above list - I really would appreciate it!
78
79## Getting Started
80_see the [examples directory](examples/) and [documentation](https://docs.rs/crossterm/) for more advanced examples._
81
82<details>
83<summary>
84Click to show Cargo.toml.
85</summary>
86
87```toml
88[dependencies]
89crossterm = "0.18"
90```
91
92</details>
93<p></p>
94
95```rust
96use std::io::{stdout, Write};
97
98use crossterm::{
99    execute,
100    style::{Color, Print, ResetColor, SetBackgroundColor, SetForegroundColor},
101    ExecutableCommand, Result,
102    event,
103};
104
105fn main() -> Result<()> {
106    // using the macro
107    execute!(
108        stdout(),
109        SetForegroundColor(Color::Blue),
110        SetBackgroundColor(Color::Red),
111        Print("Styled text here."),
112        ResetColor
113    )?;
114
115    // or using functions
116    stdout()
117        .execute(SetForegroundColor(Color::Blue))?
118        .execute(SetBackgroundColor(Color::Red))?
119        .execute(Print("Styled text here."))?
120        .execute(ResetColor)?;
121
122    Ok(())
123}
124```
125
126Checkout this [list](https://docs.rs/crossterm/0.14.0/crossterm/index.html#supported-commands) with all possible commands.
127
128### Feature Flags
129
130To optional feature flags.
131
132```toml
133[dependencies.crossterm]
134version = "0.17"
135features = ["event-stream"]
136```
137
138| Feature | Description |
139| :----- | :----- |
140| `event-stream` | `futures::Stream` producing `Result<Event>`.|
141
142### Dependency Justification
143
144| Dependency | Used for | Included |
145| :----- | :----- | :-----
146| `bitflags` | `KeyModifiers`, those are differ based on input.| always
147| `lazy_static` | original console color, original terminal mode, saved cursor position, supports ANSI on windows, single event reader per application.| always
148| `parking_lot` | used for an RW LOCK. | always
149| `libc` | UNIX terminal_size/raw modes/set_title and several other lowlevel functionality. | UNIX only
150| `Mio` | event readiness polling, waking up poller | UNIX only
151| `signal-hook`| signalhook is used to handle terminal resize SIGNAL with Mio. | UNIX only
152| `winapi`| Used for low-level windows system calls which ANSI codes can't replace| windows only
153| `futures`| Can be used to for async stream of events | only with a feature flag
154| `serde`| Se/dese/realizing of events | only with a feature flag
155
156
157### Other Resources
158
159- [API documentation](https://docs.rs/crossterm/)
160- [Deprecated examples repository](https://github.com/crossterm-rs/examples)
161
162## Used By
163
164- [Broot](https://dystroy.org/broot/)
165- [Cursive](https://github.com/gyscos/Cursive)
166- [TUI](https://github.com/fdehau/tui-rs)
167- [Rust-sloth](https://github.com/ecumene/rust-sloth)
168
169## Contributing
170
171We highly appreciate when anyone contributes to this crate. Before you do, please,
172read the [Contributing](docs/CONTRIBUTING.md) guidelines.
173
174## Authors
175
176* **Timon Post** - *Project Owner & creator*
177
178## License
179
180This project, `crossterm` and all its sub-crates: `crossterm_screen`, `crossterm_cursor`, `crossterm_style`,
181`crossterm_input`, `crossterm_terminal`, `crossterm_winapi`, `crossterm_utils` are licensed under the MIT
182License - see the [LICENSE](https://github.com/crossterm-rs/crossterm/blob/master/LICENSE) file for details.
183
184[s1]: https://img.shields.io/crates/v/crossterm.svg
185[l1]: https://crates.io/crates/crossterm
186
187[s2]: https://img.shields.io/badge/license-MIT-blue.svg
188[l2]: ./LICENSE
189
190[s3]: https://docs.rs/crossterm/badge.svg
191[l3]: https://docs.rs/crossterm/
192
193[s3]: https://docs.rs/crossterm/badge.svg
194[l3]: https://docs.rs/crossterm/
195
196[s5]: https://img.shields.io/discord/560857607196377088.svg?logo=discord
197[l5]: https://discord.gg/K4nyTDB
198
199[s6]: https://tokei.rs/b1/github/crossterm-rs/crossterm?category=code
200[s7]: https://travis-ci.org/crossterm-rs/crossterm.svg?branch=master
201