commit | 62112dbef66f6a9423a65c1e68958756cc3eaff5 | [log] [tgz] |
---|---|---|
author | James Farrell <[email protected]> | Tue May 21 15:04:05 2024 +0000 |
committer | Automerger Merge Worker <[email protected]> | Tue May 21 15:04:05 2024 +0000 |
tree | 60cd04acaec91becf48ea46a21a19a72c4a2092b | |
parent | 99cfe039f8076ed2d9b9b7f424751f3f0b55d19c [diff] | |
parent | dd26146267e5e5eded42784e9a8be0e940e6729f [diff] |
Update Android.bp by running cargo_embargo am: 5276092d37 am: dd26146267 Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/anes/+/3094839 Change-Id: I3e99fdf0c1329aed83b874295836a380485b62eb Signed-off-by: Automerger Merge Worker <[email protected]>
A Rust library which provides an ANSI escape sequences (or codes, whatever you like more) and a parser allowing you to parse data from the STDIN (or /dev/tty
) in the raw mode.
Not all ANSI escape sequences are supported by all terminals. You can use the interactive-test to test them. Checkout the repository and then:
$ cd anes-rs $ cargo run --bin interactive-test
[dependencies] anes = "0.1"
An example how to retrieve the ANSI escape sequence as a String
:
use anes::SaveCursorPosition; fn main() { let string = format!("{}", SaveCursorPosition); assert_eq!(&string, "\x1B7"); }
An example how to use the ANSI escape sequence:
use std::io::{Result, Write}; use anes::execute; fn main() -> Result<()> { let mut stdout = std::io::stdout(); execute!( &mut stdout, anes::SaveCursorPosition, anes::MoveCursorTo(10, 10), anes::RestoreCursorPosition )?; Ok(()) }
You have to enable parser
feature in order to use the parser. It's disabled by default.
[dependencies] anes = { version = "0.1", features = ["parser"] }
An example how to parse cursor position:
use anes::parser::{Parser, Sequence}; let mut parser = Parser::default(); parser.advance(b"\x1B[20;10R", false); assert_eq!(Some(Sequence::CursorPosition(10, 20)), parser.next()); assert!(parser.next().is_none());
The ANES crate is dual-licensed under Apache 2.0 and MIT terms.
Copyrights in the ANES project are retained by their contributors. No copyright assignment is required to contribute to the ANES project.