Skip to content

Commit 117837e

Browse files
authored
Merge pull request #175 from blacknon/0.3.18
0.3.18
2 parents 3d89efc + e7cf3f9 commit 117837e

7 files changed

Lines changed: 57 additions & 17 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ keywords = ["watch", "command", "monitoring"]
66
license-file = "LICENSE"
77
name = "hwatch"
88
repository = "https://github.com/blacknon/hwatch"
9-
version = "0.3.17"
9+
version = "0.3.18"
1010

1111
[dependencies]
1212
ansi-parser = "0.9.0"

hwatch.spec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ $HOME/.cargo/bin/cargo test --release --locked --all-features
5252
/etc/bash_completion.d/%{name}.bash
5353

5454
%changelog
55+
* Fri Nov 15 2024 blacknon - 0.3.18-1
56+
- fix hwatch 0.3.17 freezes in a narrow terminal #171
57+
- fix hwatch 0.3.17 no longer prints blank lines. #172
5558
* Wed Nov 13 2024 blacknon - 0.3.17-1
5659
- Bugfix. Fixed the filter keyword not supporting multi-byte characters.
5760
- Bugfix. Fixed freezes in a narrow terminal when used with `--no-help-banner` (issue #169)

src/ansi.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,13 @@ pub fn bytes_to_text<'a, B: AsRef<[u8]>>(bytes: B) -> Text<'a> {
136136
}
137137
}
138138

139-
// push any remaining data
140-
if !current_line.is_empty() {
139+
if !span_text.is_empty() {
141140
// finish the current span
142141
current_line.push(Span::styled(span_text, span_style));
142+
}
143+
144+
// push any remaining data
145+
if !current_line.is_empty() {
143146
// finish the current line
144147
spans.push(Line::from(current_line));
145148
}

src/header.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// that can be found in the LICENSE file.
44

55
// TODO: commandの表示を単色ではなく、Syntax highlightしたカラーリングに書き換える??(v0.3.9)
6-
// TODO: input内容の表示
76
// TODO: 幅調整系の数字をconstにする(生数字で雑計算だとわけわからん)
87

98
use tui::{
@@ -179,8 +178,15 @@ impl<'a> HeaderArea<'a> {
179178
// Value for width calculation.
180179
let command_width: usize;
181180
let timestamp_width: usize;
182-
if WIDTH_TEXT_INTERVAL + (1 + self.banner.len() + 1 + WIDTH_TIMESTAMP) < width {
183-
command_width = width - 2 - 1 - WIDTH_TEXT_INTERVAL - self.banner.len() - 1 - WIDTH_TIMESTAMP;
181+
// WIDTH_TIMESTAMP ... timestamp width
182+
// WIDTH_TEXT_INTERVAL ... interval sec width
183+
// 2 ... space
184+
// 1 ... `:`
185+
// self.banner.len() ... banner length
186+
// 1 ... space
187+
let command_width_offset = WIDTH_TEXT_INTERVAL + (2 + 1 + self.banner.len() + 1 + WIDTH_TIMESTAMP);
188+
if command_width_offset < width {
189+
command_width = width - command_width_offset;
184190
timestamp_width = WIDTH_TIMESTAMP;
185191
} else {
186192
command_width = 0;

src/main.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@
22
// Use of this source code is governed by an MIT license
33
// that can be found in the LICENSE file.
44

5-
// v0.3.18
5+
// v0.3.19
66
// TODO(blacknon): watchウィンドウの表示を折り返しだけではなく、横方向にスクロールして出力するモードも追加する
77
// TODO(blacknon): コマンドが終了していなくても、インターバル間隔でコマンドを実行する
88
// (パラレルで実行してもよいコマンドじゃないといけないよ、という機能か。投げっぱなしにしてintervalで待つようにするオプションを付ける)
9-
// TODO(blacknon): DiffModeをInterfaceで取り扱うようにし、historyへの追加や検索時のhitなどについてもInterface側で取り扱えるようにする。(DiffModeのPlugin化の布石)
9+
// TODO(blacknon): DiffModeをInterfaceで取り扱うようにし、historyへの追加や検索時のhitなどについてもInterface側で取り扱えるようにする。
10+
// - DiffModeのPlugin化の布石としての対応
11+
// - これができたら、数字ごとの差分をわかりやすいように表示させたり、jsonなどの形式が決まってる場合にはそこだけdiffさせるような仕組みにも簡単に対応できると想定
12+
// TODO(blacknon): [[FR] Pause/freeze command execution](https://github.com/blacknon/hwatch/issues/133)
13+
// TODO(blacknon): Github Actionsをきれいにする
1014

1115
// v0.3.xx
1216
// TODO(blacknon): [FR: add "completion" subcommand](https://github.com/blacknon/hwatch/issues/107)
1317
// TODO(blacknon): [[FR] add precise interval option](https://github.com/blacknon/hwatch/issues/111)
14-
// TODO(blacknon): [[FR] Pause/freeze command execution](https://github.com/blacknon/hwatch/issues/133)
1518
// TODO(blacknon): filter modeのハイライト表示の色を環境変数で定義できるようにする
1619
// TODO(blacknon): filter modeの検索ヒット数を表示する(どうやってやろう…?というより、どこに表示させよう…?)
1720
// TODO(blacknon): Windowsのバイナリをパッケージマネジメントシステムでインストール可能になるよう、Releaseでうまいこと処理をする

src/output.rs

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,11 @@ impl Printer {
295295
let mut counter = 1;
296296

297297
// split line
298-
for l in text.split('\n') {
298+
for mut l in text.split('\n') {
299+
if l.is_empty() {
300+
l = "\u{200B}";
301+
}
302+
299303
let mut line = vec![];
300304

301305
if self.is_line_number {
@@ -327,25 +331,46 @@ impl Printer {
327331
/// generate output at DiffMOde::Watch
328332
fn gen_watch_diff_output<'a>(&mut self, dest: &str, src: &str) -> PrintData<'a> {
329333
// tab expand dest
330-
let mut text_dest = dest.to_string();
334+
let mut text_dest_str = dest.to_string();
331335
if !self.is_batch {
332-
text_dest = expand_line_tab(dest, self.tab_size);
336+
text_dest_str = expand_line_tab(dest, self.tab_size);
333337

334338
if !self.is_color {
335-
text_dest = ansi::escape_ansi(&text_dest);
339+
text_dest_str = ansi::escape_ansi(&text_dest_str);
340+
}
341+
}
342+
343+
let mut text_dest: String = "".to_string();
344+
for mut l in text_dest_str.lines() {
345+
if l.is_empty() {
346+
l = "\u{200B}";
336347
}
348+
349+
text_dest.push_str(l);
350+
text_dest.push_str("\n");
337351
}
338352

339353
// tab expand src
340-
let mut text_src = src.to_string();
354+
let mut text_src_str = src.to_string();
341355
if !self.is_batch {
342-
text_src = expand_line_tab(src, self.tab_size);
356+
text_src_str = expand_line_tab(src, self.tab_size);
343357

344358
if !self.is_color {
345-
text_src = ansi::escape_ansi(&text_src);
359+
text_src_str = ansi::escape_ansi(&text_src_str);
346360
}
347361
}
348362

363+
let mut text_src: String = "".to_string();
364+
for mut l in text_src_str.lines() {
365+
if l.is_empty() {
366+
l = "\u{200B}";
367+
}
368+
369+
text_src.push_str(l);
370+
text_src.push_str("\n");
371+
}
372+
373+
349374
// create text vector
350375
let mut vec_src: Vec<&str> = text_src.lines().collect();
351376
let mut vec_dest: Vec<&str> = text_dest.lines().collect();

0 commit comments

Comments
 (0)