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

..--

benches/25-Apr-2025-2918

examples/25-Apr-2025-206153

src/25-Apr-2025-2,5891,375

tests/25-Apr-2025-508470

.cargo-checksum.jsonD25-Apr-20252.9 KiB11

Android.bpD25-Apr-20251.8 KiB8579

Cargo.lockD25-Apr-202517 KiB660583

Cargo.tomlD25-Apr-20251.4 KiB7261

LICENSED25-Apr-202510.6 KiB202169

LICENSE-APACHED25-Apr-202510.6 KiB202169

LICENSE-MITD25-Apr-20251,023 2421

METADATAD25-Apr-2025364 1817

MODULE_LICENSE_APACHE2D25-Apr-20250

README.mdD25-Apr-20253.1 KiB13093

TEST_MAPPINGD25-Apr-2025123 1110

cargo_embargo.jsonD25-Apr-202576 87

README.md

1[![Stable Status][actions-stable-badge]][actions-link]
2[![Beta Status][actions-beta-badge]][actions-link]
3[![Nightly Status][actions-nightly-badge]][actions-link]
4[![crates.io][crates-badge]][crates-link]
5[![docs.rs][docs-badge]][docs-link]
6[![MIT][mit-license-badge]][mit-license-link]
7[![Apache 2.0][apache-license-badge]][apache-license-link]
8![LOC][loc-badge]
9
10# ANSI Escape Sequences provider & parser
11
12A Rust library which provides an ANSI escape sequences (or codes, whatever you like more)
13and a parser allowing you to parse data from the STDIN (or `/dev/tty`) in the raw mode.
14
15## Sequences provider
16
17### Terminal support
18
19Not all ANSI escape sequences are supported by all terminals. You can use the
20[interactive-test](https://github.com/zrzka/anes-rs/tree/master/interactive-test) to test them.
21Checkout the repository and then:
22
23```bash
24$ cd anes-rs
25$ cargo run --bin interactive-test
26```
27
28### Examples
29
30<details>
31<summary>
32Click to show Cargo.toml.
33</summary>
34
35```toml
36[dependencies]
37anes = "0.1"
38```
39
40</details>
41<p></p>
42
43
44An example how to retrieve the ANSI escape sequence as a `String`:
45
46```rust
47use anes::SaveCursorPosition;
48
49fn main() {
50    let string = format!("{}", SaveCursorPosition);
51    assert_eq!(&string, "\x1B7");
52}
53```
54
55An example how to use the ANSI escape sequence:
56
57```rust
58use std::io::{Result, Write};
59
60use anes::execute;
61
62fn main() -> Result<()> {
63    let mut stdout = std::io::stdout();
64    execute!(
65        &mut stdout,
66        anes::SaveCursorPosition,
67        anes::MoveCursorTo(10, 10),
68        anes::RestoreCursorPosition
69    )?;
70    Ok(())
71}
72```
73
74## Sequences parser
75
76You have to enable `parser` feature in order to use the parser. It's disabled by default.
77
78### Examples
79
80<details>
81<summary>
82Click to show Cargo.toml.
83</summary>
84
85```toml
86[dependencies]
87anes = { version = "0.1", features = ["parser"] }
88```
89
90</details>
91<p></p>
92
93An example how to parse cursor position:
94
95```rust
96use anes::parser::{Parser, Sequence};
97
98let mut parser = Parser::default();
99parser.advance(b"\x1B[20;10R", false);
100
101assert_eq!(Some(Sequence::CursorPosition(10, 20)), parser.next());
102assert!(parser.next().is_none());
103```
104
105## License
106
107The ANES crate is dual-licensed under [Apache 2.0][apache-license-link] and
108[MIT][mit-license-link] terms.
109
110Copyrights in the ANES project are retained by their contributors. No
111copyright assignment is required to contribute to the ANES project.
112
113[actions-stable-badge]: https://github.com/zrzka/anes-rs/workflows/stable/badge.svg
114[actions-beta-badge]: https://github.com/zrzka/anes-rs/workflows/beta/badge.svg
115[actions-nightly-badge]: https://github.com/zrzka/anes-rs/workflows/nightly/badge.svg
116[actions-link]: https://github.com/zrzka/anes-rs/actions
117
118[crates-badge]: https://img.shields.io/crates/v/anes.svg
119[crates-link]: https://crates.io/crates/anes
120
121[docs-badge]: https://docs.rs/anes/badge.svg
122[docs-link]: https://docs.rs/anes
123
124[mit-license-badge]: https://img.shields.io/badge/license-MIT-blue.svg
125[mit-license-link]: ./LICENSE-MIT
126[apache-license-badge]: https://img.shields.io/badge/license-Apache2-blue.svg
127[apache-license-link]: /LICENSE-APACHE
128
129[loc-badge]: https://tokei.rs/b1/github/zrzka/anes-rs?category=code
130