aboutsummaryrefslogtreecommitdiff
path: root/vendor/anstyle-parse/examples
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-07-19 15:37:58 +0300
committerValentin Popov <valentin@popov.link>2024-07-19 15:37:58 +0300
commita990de90fe41456a23e58bd087d2f107d321f3a1 (patch)
tree15afc392522a9e85dc3332235e311b7d39352ea9 /vendor/anstyle-parse/examples
parent3d48cd3f81164bbfc1a755dc1d4a9a02f98c8ddd (diff)
downloadfparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.tar.xz
fparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.zip
Deleted vendor folder
Diffstat (limited to 'vendor/anstyle-parse/examples')
-rw-r--r--vendor/anstyle-parse/examples/parselog.rs78
1 files changed, 0 insertions, 78 deletions
diff --git a/vendor/anstyle-parse/examples/parselog.rs b/vendor/anstyle-parse/examples/parselog.rs
deleted file mode 100644
index ed89650..0000000
--- a/vendor/anstyle-parse/examples/parselog.rs
+++ /dev/null
@@ -1,78 +0,0 @@
-//! Parse input from stdin and log actions on stdout
-use std::io::{self, Read};
-
-use anstyle_parse::{DefaultCharAccumulator, Params, Parser, Perform};
-
-/// A type implementing Perform that just logs actions
-struct Log;
-
-impl Perform for Log {
- fn print(&mut self, c: char) {
- println!("[print] {:?}", c);
- }
-
- fn execute(&mut self, byte: u8) {
- println!("[execute] {:02x}", byte);
- }
-
- fn hook(&mut self, params: &Params, intermediates: &[u8], ignore: bool, c: u8) {
- println!(
- "[hook] params={:?}, intermediates={:?}, ignore={:?}, char={:?}",
- params, intermediates, ignore, c
- );
- }
-
- fn put(&mut self, byte: u8) {
- println!("[put] {:02x}", byte);
- }
-
- fn unhook(&mut self) {
- println!("[unhook]");
- }
-
- fn osc_dispatch(&mut self, params: &[&[u8]], bell_terminated: bool) {
- println!(
- "[osc_dispatch] params={:?} bell_terminated={}",
- params, bell_terminated
- );
- }
-
- fn csi_dispatch(&mut self, params: &Params, intermediates: &[u8], ignore: bool, c: u8) {
- println!(
- "[csi_dispatch] params={:#?}, intermediates={:?}, ignore={:?}, char={:?}",
- params, intermediates, ignore, c
- );
- }
-
- fn esc_dispatch(&mut self, intermediates: &[u8], ignore: bool, byte: u8) {
- println!(
- "[esc_dispatch] intermediates={:?}, ignore={:?}, byte={:02x}",
- intermediates, ignore, byte
- );
- }
-}
-
-fn main() {
- let input = io::stdin();
- let mut handle = input.lock();
-
- let mut statemachine = Parser::<DefaultCharAccumulator>::new();
- let mut performer = Log;
-
- let mut buf = [0; 2048];
-
- loop {
- match handle.read(&mut buf) {
- Ok(0) => break,
- Ok(n) => {
- for byte in &buf[..n] {
- statemachine.advance(&mut performer, *byte);
- }
- }
- Err(err) => {
- println!("err: {}", err);
- break;
- }
- }
- }
-}