From 80f4acf91e00956ccfa6b642b02af16bfcf3d2ce Mon Sep 17 00:00:00 2001 From: blacknon Date: Thu, 14 Nov 2024 00:03:37 +0900 Subject: [PATCH 1/8] update --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/header.rs | 1 - src/main.rs | 7 +++++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 55feabb..d239280 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1064,7 +1064,7 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hwatch" -version = "0.3.17" +version = "0.3.18" dependencies = [ "ansi-parser", "ansi_term", diff --git a/Cargo.toml b/Cargo.toml index 240e2d7..025cf56 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ keywords = ["watch", "command", "monitoring"] license-file = "LICENSE" name = "hwatch" repository = "https://github.com/blacknon/hwatch" -version = "0.3.17" +version = "0.3.18" [dependencies] ansi-parser = "0.9.0" diff --git a/src/header.rs b/src/header.rs index 03f1b31..935a9a4 100644 --- a/src/header.rs +++ b/src/header.rs @@ -3,7 +3,6 @@ // that can be found in the LICENSE file. // TODO: commandの表示を単色ではなく、Syntax highlightしたカラーリングに書き換える??(v0.3.9) -// TODO: input内容の表示 // TODO: 幅調整系の数字をconstにする(生数字で雑計算だとわけわからん) use tui::{ diff --git a/src/main.rs b/src/main.rs index a8d77f3..51f296d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,12 +6,15 @@ // TODO(blacknon): watchウィンドウの表示を折り返しだけではなく、横方向にスクロールして出力するモードも追加する // TODO(blacknon): コマンドが終了していなくても、インターバル間隔でコマンドを実行する // (パラレルで実行してもよいコマンドじゃないといけないよ、という機能か。投げっぱなしにしてintervalで待つようにするオプションを付ける) -// TODO(blacknon): DiffModeをInterfaceで取り扱うようにし、historyへの追加や検索時のhitなどについてもInterface側で取り扱えるようにする。(DiffModeのPlugin化の布石) +// TODO(blacknon): DiffModeをInterfaceで取り扱うようにし、historyへの追加や検索時のhitなどについてもInterface側で取り扱えるようにする。 +// - DiffModeのPlugin化の布石としての対応 +// - これができたら、数字ごとの差分をわかりやすいように表示させたり、jsonなどの形式が決まってる場合にはそこだけdiffさせるような仕組みにも簡単に対応できると想定 +// TODO(blacknon): [[FR] Pause/freeze command execution](https://github.com/blacknon/hwatch/issues/133) +// TODO(blacknon): Github Actionsをきれいにする // v0.3.xx // TODO(blacknon): [FR: add "completion" subcommand](https://github.com/blacknon/hwatch/issues/107) // TODO(blacknon): [[FR] add precise interval option](https://github.com/blacknon/hwatch/issues/111) -// TODO(blacknon): [[FR] Pause/freeze command execution](https://github.com/blacknon/hwatch/issues/133) // TODO(blacknon): filter modeのハイライト表示の色を環境変数で定義できるようにする // TODO(blacknon): filter modeの検索ヒット数を表示する(どうやってやろう…?というより、どこに表示させよう…?) // TODO(blacknon): Windowsのバイナリをパッケージマネジメントシステムでインストール可能になるよう、Releaseでうまいこと処理をする From de9efb18eacb1ade27f239712fb3e6b520621069 Mon Sep 17 00:00:00 2001 From: blacknon Date: Thu, 14 Nov 2024 18:33:39 +0900 Subject: [PATCH 2/8] update comments. --- src/main.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main.rs b/src/main.rs index 51f296d..5bb504e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,10 @@ // that can be found in the LICENSE file. // v0.3.18 +// - https://github.com/blacknon/hwatch/issues/171 +// - https://github.com/blacknon/hwatch/issues/172 + +// v0.3.19 // TODO(blacknon): watchウィンドウの表示を折り返しだけではなく、横方向にスクロールして出力するモードも追加する // TODO(blacknon): コマンドが終了していなくても、インターバル間隔でコマンドを実行する // (パラレルで実行してもよいコマンドじゃないといけないよ、という機能か。投げっぱなしにしてintervalで待つようにするオプションを付ける) From 113a14820ff32ac91dfb73ec151ed3b419ac9de2 Mon Sep 17 00:00:00 2001 From: blacknon Date: Thu, 14 Nov 2024 23:33:11 +0900 Subject: [PATCH 3/8] update. --- src/header.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/header.rs b/src/header.rs index 935a9a4..7bcfeec 100644 --- a/src/header.rs +++ b/src/header.rs @@ -178,8 +178,15 @@ impl<'a> HeaderArea<'a> { // Value for width calculation. let command_width: usize; let timestamp_width: usize; - if WIDTH_TEXT_INTERVAL + (1 + self.banner.len() + 1 + WIDTH_TIMESTAMP) < width { - command_width = width - 2 - 1 - WIDTH_TEXT_INTERVAL - self.banner.len() - 1 - WIDTH_TIMESTAMP; + // WIDTH_TEXT_INTERVAL ... interval sec width + // 2 ... space + // 1 ... `:` + // self.banner.len() ... banner length + // 1 ... space + // WIDTH_TIMESTAMP ... timestamp width + let command_width_offset = WIDTH_TEXT_INTERVAL + (2 + 1 + self.banner.len() + 1 + WIDTH_TIMESTAMP); + if command_width_offset < width { + command_width = width - command_width_offset; timestamp_width = WIDTH_TIMESTAMP; } else { command_width = 0; From c36979abe0265e5de0635200196ec182dcce22db Mon Sep 17 00:00:00 2001 From: blacknon Date: Thu, 14 Nov 2024 23:33:49 +0900 Subject: [PATCH 4/8] update. replace comment. --- src/header.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/header.rs b/src/header.rs index 7bcfeec..c1962f9 100644 --- a/src/header.rs +++ b/src/header.rs @@ -178,12 +178,12 @@ impl<'a> HeaderArea<'a> { // Value for width calculation. let command_width: usize; let timestamp_width: usize; + // WIDTH_TIMESTAMP ... timestamp width // WIDTH_TEXT_INTERVAL ... interval sec width // 2 ... space // 1 ... `:` // self.banner.len() ... banner length // 1 ... space - // WIDTH_TIMESTAMP ... timestamp width let command_width_offset = WIDTH_TEXT_INTERVAL + (2 + 1 + self.banner.len() + 1 + WIDTH_TIMESTAMP); if command_width_offset < width { command_width = width - command_width_offset; From 9d1a5bbd7b7e17f9af9a2a2331c9c97351e7c51b Mon Sep 17 00:00:00 2001 From: blacknon Date: Fri, 15 Nov 2024 00:18:33 +0900 Subject: [PATCH 5/8] update. plain+watch diff bugfix. --- src/main.rs | 1 + src/output.rs | 39 ++++++++++++++++++++++++++++++++------- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5bb504e..d990cbe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,6 +5,7 @@ // v0.3.18 // - https://github.com/blacknon/hwatch/issues/171 // - https://github.com/blacknon/hwatch/issues/172 +// - color mode + line/word diffのとき、最終行が出てこない?? // v0.3.19 // TODO(blacknon): watchウィンドウの表示を折り返しだけではなく、横方向にスクロールして出力するモードも追加する diff --git a/src/output.rs b/src/output.rs index acad372..1aee7e5 100644 --- a/src/output.rs +++ b/src/output.rs @@ -295,7 +295,11 @@ impl Printer { let mut counter = 1; // split line - for l in text.split('\n') { + for mut l in text.split('\n') { + if l.is_empty() { + l = "\u{200B}"; + } + let mut line = vec![]; if self.is_line_number { @@ -327,25 +331,46 @@ impl Printer { /// generate output at DiffMOde::Watch fn gen_watch_diff_output<'a>(&mut self, dest: &str, src: &str) -> PrintData<'a> { // tab expand dest - let mut text_dest = dest.to_string(); + let mut text_dest_str = dest.to_string(); if !self.is_batch { - text_dest = expand_line_tab(dest, self.tab_size); + text_dest_str = expand_line_tab(dest, self.tab_size); if !self.is_color { - text_dest = ansi::escape_ansi(&text_dest); + text_dest_str = ansi::escape_ansi(&text_dest_str); + } + } + + let mut text_dest: String = "".to_string(); + for mut l in text_dest_str.lines() { + if l.is_empty() { + l = "\u{200B}"; } + + text_dest.push_str(l); + text_dest.push_str("\n"); } // tab expand src - let mut text_src = src.to_string(); + let mut text_src_str = src.to_string(); if !self.is_batch { - text_src = expand_line_tab(src, self.tab_size); + text_src_str = expand_line_tab(src, self.tab_size); if !self.is_color { - text_src = ansi::escape_ansi(&text_src); + text_src_str = ansi::escape_ansi(&text_src_str); } } + let mut text_src: String = "".to_string(); + for mut l in text_src_str.lines() { + if l.is_empty() { + l = "\u{200B}"; + } + + text_src.push_str(l); + text_src.push_str("\n"); + } + + // create text vector let mut vec_src: Vec<&str> = text_src.lines().collect(); let mut vec_dest: Vec<&str> = text_dest.lines().collect(); From bba135c18caa225066fa3e02544a035901cf45c0 Mon Sep 17 00:00:00 2001 From: blacknon Date: Fri, 15 Nov 2024 00:29:28 +0900 Subject: [PATCH 6/8] update. line+word diff bugfix --- src/ansi.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ansi.rs b/src/ansi.rs index 08dc3b9..4cfb1c9 100644 --- a/src/ansi.rs +++ b/src/ansi.rs @@ -136,10 +136,13 @@ pub fn bytes_to_text<'a, B: AsRef<[u8]>>(bytes: B) -> Text<'a> { } } - // push any remaining data - if !current_line.is_empty() { + if !span_text.is_empty() { // finish the current span current_line.push(Span::styled(span_text, span_style)); + } + + // push any remaining data + if !current_line.is_empty() { // finish the current line spans.push(Line::from(current_line)); } From ec5c6d66c359da2442d1caa6916d784413f71a32 Mon Sep 17 00:00:00 2001 From: blacknon Date: Fri, 15 Nov 2024 12:11:14 +0900 Subject: [PATCH 7/8] update. delete comment. --- src/main.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index d990cbe..3473163 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,11 +2,6 @@ // Use of this source code is governed by an MIT license // that can be found in the LICENSE file. -// v0.3.18 -// - https://github.com/blacknon/hwatch/issues/171 -// - https://github.com/blacknon/hwatch/issues/172 -// - color mode + line/word diffのとき、最終行が出てこない?? - // v0.3.19 // TODO(blacknon): watchウィンドウの表示を折り返しだけではなく、横方向にスクロールして出力するモードも追加する // TODO(blacknon): コマンドが終了していなくても、インターバル間隔でコマンドを実行する From e7cf3f92230a70105cbfc21d7deea82bfabb426d Mon Sep 17 00:00:00 2001 From: blacknon Date: Fri, 15 Nov 2024 12:13:23 +0900 Subject: [PATCH 8/8] update hwatch.spec --- hwatch.spec | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hwatch.spec b/hwatch.spec index 18b3c4b..a894f9d 100644 --- a/hwatch.spec +++ b/hwatch.spec @@ -52,6 +52,9 @@ $HOME/.cargo/bin/cargo test --release --locked --all-features /etc/bash_completion.d/%{name}.bash %changelog +* Fri Nov 15 2024 blacknon - 0.3.18-1 + - fix hwatch 0.3.17 freezes in a narrow terminal #171 + - fix hwatch 0.3.17 no longer prints blank lines. #172 * Wed Nov 13 2024 blacknon - 0.3.17-1 - Bugfix. Fixed the filter keyword not supporting multi-byte characters. - Bugfix. Fixed freezes in a narrow terminal when used with `--no-help-banner` (issue #169)