tag | 9ec7fe15c40c1eaa1078b161cae99f064dde6f0b | |
---|---|---|
tagger | The Android Open Source Project <initial-contribution@android.com> | Fri Jan 31 14:33:02 2025 -0800 |
object | c9fddda2aae2be9ace26a7b9c4fbab7e1efa8307 |
aml_ads_351312060 (12761852,com.google.android.adservices,com.google.android.go.adservices)
commit | c9fddda2aae2be9ace26a7b9c4fbab7e1efa8307 | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Thu Aug 15 01:12:37 2024 +0000 |
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Thu Aug 15 01:12:37 2024 +0000 |
tree | 0f15a998d6237d5a38423bc8abf73910c0c6171f | |
parent | d5e2311e81af5c9da359c4880434df25b4e26833 [diff] | |
parent | 93df23bc48924813fdaf3cf7173707b7c4479695 [diff] |
Snap for 12230650 from 93df23bc48924813fdaf3cf7173707b7c4479695 to mainline-adservices-release Change-Id: Ifae8d3d3bc6774c5258ce754fa7425b4c3efc058
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.