From 8f31aed3f12f02304bd874737da49f137a54845f Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Mon, 17 Jan 2022 13:43:35 -0700 Subject: [PATCH] move tmux-cc crate to be module inside termwiz refs: #1090 --- Cargo.lock | 17 +++-------------- mux/Cargo.toml | 1 - mux/src/tmux.rs | 2 +- mux/src/tmux_commands.rs | 2 +- termwiz/Cargo.toml | 4 +++- termwiz/src/escape/mod.rs | 2 +- termwiz/src/escape/parser/mod.rs | 7 ++++--- termwiz/src/lib.rs | 1 + .../src/lib.rs => termwiz/src/tmux_cc/mod.rs | 2 +- {tmux-cc/src => termwiz/src/tmux_cc}/tmux.pest | 0 tmux-cc/Cargo.toml | 17 ----------------- 11 files changed, 15 insertions(+), 40 deletions(-) rename tmux-cc/src/lib.rs => termwiz/src/tmux_cc/mod.rs (99%) rename {tmux-cc/src => termwiz/src/tmux_cc}/tmux.pest (100%) delete mode 100644 tmux-cc/Cargo.toml diff --git a/Cargo.lock b/Cargo.lock index ef4c879fd..aeaae3c9f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2321,7 +2321,6 @@ dependencies = [ "termwiz", "textwrap 0.14.2", "thiserror", - "tmux-cc", "unicode-segmentation", "url", "wezterm-ssh", @@ -4103,7 +4102,10 @@ dependencies = [ "num-derive", "num-traits", "ordered-float", + "pest", + "pest_derive", "pretty_assertions", + "pretty_env_logger", "regex", "semver 0.11.0", "serde", @@ -4112,7 +4114,6 @@ dependencies = [ "terminfo", "termios 0.3.3", "thiserror", - "tmux-cc", "ucd-trie", "unicode-segmentation", "varbincode", @@ -4219,18 +4220,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" -[[package]] -name = "tmux-cc" -version = "0.1.0" -dependencies = [ - "anyhow", - "log", - "pest", - "pest_derive", - "pretty_assertions", - "pretty_env_logger", -] - [[package]] name = "toml" version = "0.5.8" diff --git a/mux/Cargo.toml b/mux/Cargo.toml index aff652ddd..e51efa99b 100644 --- a/mux/Cargo.toml +++ b/mux/Cargo.toml @@ -37,7 +37,6 @@ terminfo = "0.7" termwiz = { path = "../termwiz" } textwrap = "0.14" thiserror = "1.0" -tmux-cc = { path = "../tmux-cc" } unicode-segmentation = "1.8" url = "2" wezterm-ssh = { path = "../wezterm-ssh" } diff --git a/mux/src/tmux.rs b/mux/src/tmux.rs index c1364f4d7..887703ed4 100644 --- a/mux/src/tmux.rs +++ b/mux/src/tmux.rs @@ -9,7 +9,7 @@ use std::cell::RefCell; use std::collections::{HashMap, HashSet, VecDeque}; use std::rc::Rc; use std::sync::{Arc, Condvar, Mutex}; -use tmux_cc::*; +use termwiz::tmux_cc::*; #[derive(PartialEq, Eq, Debug, Copy, Clone)] enum State { diff --git a/mux/src/tmux_commands.rs b/mux/src/tmux_commands.rs index 85b5fd5f1..bfe984b61 100644 --- a/mux/src/tmux_commands.rs +++ b/mux/src/tmux_commands.rs @@ -13,7 +13,7 @@ use std::fmt::Debug; use std::fmt::Write; use std::rc::Rc; use std::sync::{Arc, Condvar, Mutex}; -use tmux_cc::*; +use termwiz::tmux_cc::*; pub(crate) trait TmuxCommand: Send + Debug { fn get_command(&self) -> String; diff --git a/termwiz/Cargo.toml b/termwiz/Cargo.toml index 3ae791bf0..6fb74491a 100644 --- a/termwiz/Cargo.toml +++ b/termwiz/Cargo.toml @@ -26,13 +26,14 @@ log = "0.4" memmem = "0.1" num-traits = "0.2" ordered-float = "2.10" +pest = "2.1" +pest_derive = "2.1" regex = "1" semver = "0.11" serde = {version="1.0", features = ["rc", "derive"], optional=true} sha2 = "0.9" terminfo = "0.7" thiserror = "1.0" -tmux-cc = {version = "0.1", path = "../tmux-cc"} unicode-segmentation = "1.8" ucd-trie = "0.1" vtparse = { version="0.6", path="../vtparse" } @@ -46,6 +47,7 @@ docs = ["widgets", "use_serde"] [dev-dependencies] varbincode = "0.1" pretty_assertions = "0.6" +pretty_env_logger = "0.4" [dependencies.num-derive] features = ["full-syntax"] diff --git a/termwiz/src/escape/mod.rs b/termwiz/src/escape/mod.rs index 42bd4abe0..7237ab222 100644 --- a/termwiz/src/escape/mod.rs +++ b/termwiz/src/escape/mod.rs @@ -6,9 +6,9 @@ //! semantic meaning to them. It can also encode the semantic values as //! escape sequences. It provides encoding and decoding functionality //! only; it does not provide terminal emulation facilities itself. +use crate::tmux_cc::Event; use num_derive::*; use std::fmt::{Display, Error as FmtError, Formatter, Write as FmtWrite}; -use tmux_cc::Event; pub mod apc; pub mod csi; diff --git a/termwiz/src/escape/parser/mod.rs b/termwiz/src/escape/parser/mod.rs index 94445af05..ff48f240f 100644 --- a/termwiz/src/escape/parser/mod.rs +++ b/termwiz/src/escape/parser/mod.rs @@ -4,12 +4,12 @@ use crate::escape::{ Action, DeviceControlMode, EnterDeviceControlMode, Esc, OperatingSystemCommand, ShortDeviceControl, Sixel, SixelData, CSI, }; +use crate::tmux_cc::Event; use log::error; use num_traits::FromPrimitive; use regex::bytes::Regex; use std::borrow::BorrowMut; use std::cell::RefCell; -use tmux_cc::Event; use vtparse::{CsiParam, VTActor, VTParser}; struct SixelBuilder { @@ -55,7 +55,7 @@ struct ParseState { sixel: Option, dcs: Option, get_tcap: Option, - tmux_state: Option>, + tmux_state: Option>, } /// The `Parser` struct holds the state machine that is used to decode @@ -251,7 +251,8 @@ impl<'a, F: FnMut(Action)> VTActor for Performer<'a, F> { } else { if byte == b'p' && params == [1000] { // into tmux_cc mode - self.state.borrow_mut().tmux_state = Some(RefCell::new(tmux_cc::Parser::new())); + self.state.borrow_mut().tmux_state = + Some(RefCell::new(crate::tmux_cc::Parser::new())); } (self.callback)(Action::DeviceControl(DeviceControlMode::Enter(Box::new( EnterDeviceControlMode { diff --git a/termwiz/src/lib.rs b/termwiz/src/lib.rs index a01276d40..a05ae4866 100644 --- a/termwiz/src/lib.rs +++ b/termwiz/src/lib.rs @@ -63,6 +63,7 @@ mod readbuf; pub mod render; pub mod surface; pub mod terminal; +pub mod tmux_cc; #[cfg(feature = "widgets")] pub mod widgets; diff --git a/tmux-cc/src/lib.rs b/termwiz/src/tmux_cc/mod.rs similarity index 99% rename from tmux-cc/src/lib.rs rename to termwiz/src/tmux_cc/mod.rs index f3b52eaa0..218fa8040 100644 --- a/tmux-cc/src/lib.rs +++ b/termwiz/src/tmux_cc/mod.rs @@ -10,7 +10,7 @@ pub type TmuxSessionId = u64; mod parser { use pest_derive::Parser; #[derive(Parser)] - #[grammar = "tmux.pest"] + #[grammar = "tmux_cc/tmux.pest"] pub struct TmuxParser; } diff --git a/tmux-cc/src/tmux.pest b/termwiz/src/tmux_cc/tmux.pest similarity index 100% rename from tmux-cc/src/tmux.pest rename to termwiz/src/tmux_cc/tmux.pest diff --git a/tmux-cc/Cargo.toml b/tmux-cc/Cargo.toml deleted file mode 100644 index cee3204da..000000000 --- a/tmux-cc/Cargo.toml +++ /dev/null @@ -1,17 +0,0 @@ -[package] -name = "tmux-cc" -version = "0.1.0" -authors = ["Wez Furlong "] -edition = "2018" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -anyhow = "1.0" -log = "0.4" -pest = "2.1" -pest_derive = "2.1" - -[dev-dependencies] -pretty_env_logger = "0.4" -pretty_assertions = "0.6"