1 | //! # ANSI Escape Sequences provider & parser |
2 | //! |
3 | //! ## Sequences provider |
4 | //! |
5 | //! The `anes` crate provides ANSI escape sequences you can use to control the terminal |
6 | //! cursor (show, hide, ...), colors (foreground, background), display attributes (bold, ...) |
7 | //! and many others. |
8 | //! |
9 | //! Every sequence implements the standard library [`Display`](https://doc.rust-lang.org/std/fmt/trait.Display.html) |
10 | //! trait. It means that these sequences can be used in macros like |
11 | //! [`format!`](https://doc.rust-lang.org/std/macro.format.html) or |
12 | //! [`write!`](https://doc.rust-lang.org/std/macro.write.html). |
13 | //! |
14 | //! Ask if you need more sequences or use the [`sequence!`](macro.sequence.html) macro to create |
15 | //! your own sequences. |
16 | //! |
17 | //! |
18 | //! ### Terminal Support |
19 | //! |
20 | //! Not all ANSI escape sequences are supported by all terminals. You can use the |
21 | //! [interactive-test](https://github.com/zrzka/anes-rs/tree/master/interactive-test) to test them. |
22 | //! |
23 | //! ### Examples |
24 | //! |
25 | //! Retrieve the sequence as a `String`: |
26 | //! |
27 | //! ```rust |
28 | //! use anes::SaveCursorPosition; |
29 | //! |
30 | //! let string = format!("{}" , SaveCursorPosition); |
31 | //! assert_eq!(&string, " \x1B7" ); |
32 | //! ``` |
33 | //! |
34 | //! Execute the sequence on the standard output: |
35 | //! |
36 | //! ```rust |
37 | //! use std::io::{Result, Write}; |
38 | //! |
39 | //! use anes::execute; |
40 | //! |
41 | //! fn main() -> Result<()> { |
42 | //! let mut stdout = std::io::stdout(); |
43 | //! execute!(&mut stdout, anes::ResetAttributes) |
44 | //! } |
45 | //! ``` |
46 | //! |
47 | //! ## Sequences parser |
48 | //! |
49 | //! Parser isn't available with default features. You have to enable `parser` feature if you'd like to use it. |
50 | //! You can learn more about this feature in the [`parser`](parser/index.html) module documentation. |
51 | #![warn (rust_2018_idioms)] |
52 | #![deny (unused_imports, unused_must_use)] |
53 | |
54 | // Keep it first to load all the macros before other modules. |
55 | #[macro_use ] |
56 | mod macros; |
57 | |
58 | pub use self::sequences::{ |
59 | attribute::{Attribute, ResetAttributes, SetAttribute}, |
60 | buffer::{ |
61 | ClearBuffer, ClearLine, ScrollBufferDown, ScrollBufferUp, SwitchBufferToAlternate, |
62 | SwitchBufferToNormal, |
63 | }, |
64 | color::{Color, SetBackgroundColor, SetForegroundColor}, |
65 | cursor::{ |
66 | DisableCursorBlinking, EnableCursorBlinking, HideCursor, MoveCursorDown, MoveCursorLeft, |
67 | MoveCursorRight, MoveCursorTo, MoveCursorToColumn, MoveCursorToNextLine, |
68 | MoveCursorToPreviousLine, MoveCursorUp, ReportCursorPosition, RestoreCursorPosition, |
69 | SaveCursorPosition, ShowCursor, |
70 | }, |
71 | terminal::{DisableMouseEvents, EnableMouseEvents, ResizeTextArea}, |
72 | }; |
73 | |
74 | #[cfg (feature = "parser" )] |
75 | pub mod parser; |
76 | mod sequences; |
77 | |