From 2f40739be6ff57d7b52e4e7324dcd6a2abbbe20e Mon Sep 17 00:00:00 2001 From: Takumasa Sakao Date: Fri, 29 Nov 2024 08:23:48 +0900 Subject: [PATCH 1/4] Add option to disable mouse capture --- README.md | 1 + src/app.rs | 8 +++++--- src/cli.rs | 6 ++++++ src/config.rs | 6 ++++++ src/old_config.rs | 6 +++++- 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 566ba6e..877c2a0 100644 --- a/README.md +++ b/README.md @@ -141,6 +141,7 @@ no_shell = false shell = "zsh" shell_options = "" skip_empty_diffs = false +disable_mouse = true [keymap] timemachine_go_to_past = "Down" diff --git a/src/app.rs b/src/app.rs index f51625c..7cf4edc 100644 --- a/src/app.rs +++ b/src/app.rs @@ -52,6 +52,7 @@ pub struct App { shell: Option<(String, Vec)>, store: S, read_only: bool, + disable_mouse: bool, } impl App { @@ -134,8 +135,8 @@ impl App { components.push(Box::new(FpsCounter::new())); } - let default_skip_empty_diffs = config.general.skip_empty_diffs.unwrap_or_default(); - let is_skip_empty_diffs = cli.is_skip_empty_diffs || default_skip_empty_diffs; + let is_skip_empty_diffs = cli.is_skip_empty_diffs || config.general.skip_empty_diffs.unwrap_or_default(); + let disable_mouse = cli.disable_mouse || config.general.disable_mouse.unwrap_or_default(); Ok(Self { store, @@ -160,6 +161,7 @@ impl App { showing_execution_id: None, diff_mode, shell, + disable_mouse, }) } @@ -211,7 +213,7 @@ impl App { let mut tui = tui::Tui::new()? .tick_rate(self.tick_rate) .frame_rate(self.frame_rate); - tui = tui.mouse(true); + tui = tui.mouse(!self.disable_mouse); tui.enter()?; for component in self.components.iter_mut() { diff --git a/src/cli.rs b/src/cli.rs index 5746427..48d9482 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -113,6 +113,12 @@ pub struct Cli { )] pub disable_auto_save: bool, + #[arg( + long = "disable_mouse", + help = "Stop handling mouse events", + )] + pub disable_mouse: bool, + #[arg( long = "load", alias = "lookback", diff --git a/src/config.rs b/src/config.rs index a394e27..927dccb 100644 --- a/src/config.rs +++ b/src/config.rs @@ -44,6 +44,8 @@ pub struct General { pub shell_options: Option, #[serde(default)] pub skip_empty_diffs: Option, + #[serde(default)] + pub disable_mouse: Option, } impl From for General { @@ -53,6 +55,7 @@ impl From for General { shell: value.shell, shell_options: value.shell_options, skip_empty_diffs: value.skip_empty_diffs, + disable_mouse: value.disable_mouse, } } } @@ -161,6 +164,9 @@ impl Config { if self.general.skip_empty_diffs.is_none() { self.general.skip_empty_diffs = default_config.general.skip_empty_diffs; } + if self.general.disable_mouse.is_none() { + self.general.disable_mouse = default_config.general.disable_mouse; + } } pub fn get_style(&self, style: &str) -> Style { diff --git a/src/old_config.rs b/src/old_config.rs index 9701fd2..c9c142b 100644 --- a/src/old_config.rs +++ b/src/old_config.rs @@ -19,6 +19,7 @@ pub struct General { pub shell: Option, pub shell_options: Option, pub skip_empty_diffs: Option, + pub disable_mouse: Option, } #[derive(Debug, Serialize, Deserialize, Default)] @@ -80,8 +81,11 @@ background = "white" let config_str = r#" [general] skip_empty_diffs = true +disable_mouse = true "#; let config = super::OldConfig::new_from_str(config_str).unwrap(); - assert_eq!(config.general.unwrap().skip_empty_diffs, Some(true)); + let general = config.general.unwrap(); + assert_eq!(general.skip_empty_diffs, Some(true)); + assert_eq!(general.disable_mouse, Some(true)); } } From 3ac5e057505f775c791980803c11cb9a557180b5 Mon Sep 17 00:00:00 2001 From: Takumasa Sakao Date: Fri, 29 Nov 2024 08:32:02 +0900 Subject: [PATCH 2/4] Fix fmt --- src/app.rs | 3 ++- src/cli.rs | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/app.rs b/src/app.rs index 7cf4edc..3afe0df 100644 --- a/src/app.rs +++ b/src/app.rs @@ -135,7 +135,8 @@ impl App { components.push(Box::new(FpsCounter::new())); } - let is_skip_empty_diffs = cli.is_skip_empty_diffs || config.general.skip_empty_diffs.unwrap_or_default(); + let is_skip_empty_diffs = + cli.is_skip_empty_diffs || config.general.skip_empty_diffs.unwrap_or_default(); let disable_mouse = cli.disable_mouse || config.general.disable_mouse.unwrap_or_default(); Ok(Self { diff --git a/src/cli.rs b/src/cli.rs index 48d9482..656a9f2 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -113,10 +113,7 @@ pub struct Cli { )] pub disable_auto_save: bool, - #[arg( - long = "disable_mouse", - help = "Stop handling mouse events", - )] + #[arg(long = "disable_mouse", help = "Stop handling mouse events")] pub disable_mouse: bool, #[arg( From 2bba6050ad73122fceb727760e9da69dc8092a0a Mon Sep 17 00:00:00 2001 From: Takumasa Sakao Date: Fri, 29 Nov 2024 08:38:15 +0900 Subject: [PATCH 3/4] Update dependencies --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 42 +++++++++++++++++++++--------------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 89ba802..6803373 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1785,9 +1785,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.164" +version = "0.2.166" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" +checksum = "c2ccc108bbc0b1331bd061864e7cd823c0cab660bbe6970e66e2c0614decde36" [[package]] name = "libredox" @@ -2361,9 +2361,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.132" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" dependencies = [ "itoa", "memchr", @@ -2799,9 +2799,9 @@ dependencies = [ [[package]] name = "tracing" -version = "0.1.40" +version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ "pin-project-lite", "tracing-attributes", @@ -2810,9 +2810,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", @@ -2821,9 +2821,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.32" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" dependencies = [ "once_cell", "valuable", diff --git a/Cargo.toml b/Cargo.toml index fcfa6b9..3d35771 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,44 +12,44 @@ build = "build.rs" [dependencies] ansi-parser = "0.9.1" -ansi-to-tui = "4.0.1" -anstyle = "1.0.7" -anstyle-parse = { version = "0.2.4", features = ["utf8"] } +ansi-to-tui = "4.1.0" +anstyle = "1.0.10" +anstyle-parse = { version = "0.2.6", features = ["utf8"] } better-panic = "0.3.0" chrono = "0.4.38" -clap = { version = "4.5.7", features = ["derive", "cargo", "wrap_help", "unicode", "string", "unstable-styles"] } +clap = { version = "4.5.21", features = ["derive", "cargo", "wrap_help", "unicode", "string", "unstable-styles"] } color-eyre = "0.6.3" -config = "0.14.0" +config = "0.14.1" crossterm = { version = "0.27.0", features = ["serde", "event-stream"] } derive_deref = "1.1.1" directories = "5.0.1" dissimilar = "1.0.9" -futures = "0.3.30" -human-panic = "2.0.1" +futures = "0.3.31" +human-panic = "2.0.2" humantime = "2.1.0" json5 = "0.4.1" -libc = "0.2.155" -log = "0.4.21" -pretty_assertions = "1.4.0" +libc = "0.2.166" +log = "0.4.22" +pretty_assertions = "1.4.1" ratatui = { version = "0.26.3", features = ["serde", "macros"] } rusqlite = { version = "0.32.1", features = ["bundled", "chrono"] } -serde = { version = "1.0.203", features = ["derive"] } -serde_json = "1.0.117" -serde_with = { version = "3.8.1", features = ["chrono_0_4"] } +serde = { version = "1.0.215", features = ["derive"] } +serde_json = "1.0.133" +serde_with = { version = "3.11.0", features = ["chrono_0_4"] } signal-hook = "0.3.17" -similar = "2.5.0" +similar = "2.6.0" strip-ansi-escapes = "0.2.0" -strum = { version = "0.26.2", features = ["derive"] } -tempfile = "3.12.0" -tokio = { version = "1.38.0", features = ["full"] } -tokio-util = "0.7.11" +strum = { version = "0.26.3", features = ["derive"] } +tempfile = "3.14.0" +tokio = { version = "1.41.1", features = ["full"] } +tokio-util = "0.7.12" toml = "0.8.19" -tracing = "0.1.40" +tracing = "0.1.41" tracing-error = "0.2.0" tracing-subscriber = { version = "0.3.18", features = ["env-filter", "serde"] } tui-input = "0.9.0" tui-widget-list = "0.9.0" -unicode-width = "0.1.13" +unicode-width = "0.1.14" [build-dependencies] -vergen = { version = "8.3.1", features = [ "build", "git", "gitoxide", "cargo" ]} +vergen = { version = "8.3.2", features = [ "build", "git", "gitoxide", "cargo" ]} From c2e11da379ffa5ec1090613fd863854823684838 Mon Sep 17 00:00:00 2001 From: Takumasa Sakao Date: Fri, 29 Nov 2024 08:42:50 +0900 Subject: [PATCH 4/4] Fix clippy error --- src/termtext.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/termtext.rs b/src/termtext.rs index b86c5ed..25c0ba5 100644 --- a/src/termtext.rs +++ b/src/termtext.rs @@ -124,7 +124,7 @@ impl Converter { self.style = self.original_style; } - pub fn convert(&mut self, text: &Vec) -> Text { + pub fn convert(&mut self, text: &[u8]) -> Text { let mut statemachine = Parser::::new(); let mut performer = Converter::new(self.style); @@ -180,7 +180,7 @@ impl Perform for Converter { return; } - let is_sgr = byte == b'm' && intermediates.first().is_none(); + let is_sgr = byte == b'm' && intermediates.is_empty(); let style = if is_sgr { if params.is_empty() { self.reset_style();