Skip to content

Commit

Permalink
Merge pull request #166 from sachaos/disable-mouse-capture
Browse files Browse the repository at this point in the history
Add option to disable mouse capture
  • Loading branch information
sachaos authored Nov 28, 2024
2 parents b8e3515 + c2e11da commit b9a57a8
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 37 deletions.
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 21 additions & 21 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ no_shell = false
shell = "zsh"
shell_options = ""
skip_empty_diffs = false
disable_mouse = true

[keymap]
timemachine_go_to_past = "Down"
Expand Down
9 changes: 6 additions & 3 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub struct App<S: Store> {
shell: Option<(String, Vec<String>)>,
store: S,
read_only: bool,
disable_mouse: bool,
}

impl<S: Store> App<S> {
Expand Down Expand Up @@ -134,8 +135,9 @@ impl<S: Store> App<S> {
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,
Expand All @@ -160,6 +162,7 @@ impl<S: Store> App<S> {
showing_execution_id: None,
diff_mode,
shell,
disable_mouse,
})
}

Expand Down Expand Up @@ -211,7 +214,7 @@ impl<S: Store> App<S> {
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() {
Expand Down
3 changes: 3 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ 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",
Expand Down
6 changes: 6 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ pub struct General {
pub shell_options: Option<String>,
#[serde(default)]
pub skip_empty_diffs: Option<bool>,
#[serde(default)]
pub disable_mouse: Option<bool>,
}

impl From<OldGeneral> for General {
Expand All @@ -53,6 +55,7 @@ impl From<OldGeneral> for General {
shell: value.shell,
shell_options: value.shell_options,
skip_empty_diffs: value.skip_empty_diffs,
disable_mouse: value.disable_mouse,
}
}
}
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion src/old_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub struct General {
pub shell: Option<String>,
pub shell_options: Option<String>,
pub skip_empty_diffs: Option<bool>,
pub disable_mouse: Option<bool>,
}

#[derive(Debug, Serialize, Deserialize, Default)]
Expand Down Expand Up @@ -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));
}
}
4 changes: 2 additions & 2 deletions src/termtext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl Converter {
self.style = self.original_style;
}

pub fn convert(&mut self, text: &Vec<u8>) -> Text {
pub fn convert(&mut self, text: &[u8]) -> Text {
let mut statemachine = Parser::<DefaultCharAccumulator>::new();
let mut performer = Converter::new(self.style);

Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit b9a57a8

Please sign in to comment.