Skip to content

Commit

Permalink
Merge pull request #175 from blacknon/0.3.18
Browse files Browse the repository at this point in the history
0.3.18
  • Loading branch information
blacknon authored Nov 15, 2024
2 parents 3d89efc + e7cf3f9 commit 117837e
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions hwatch.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions src/ansi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
12 changes: 9 additions & 3 deletions src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -179,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_TIMESTAMP ... timestamp width
// WIDTH_TEXT_INTERVAL ... interval sec width
// 2 ... space
// 1 ... `:`
// self.banner.len() ... banner length
// 1 ... space
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;
Expand Down
9 changes: 6 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.

// v0.3.18
// v0.3.19
// 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でうまいこと処理をする
Expand Down
39 changes: 32 additions & 7 deletions src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 117837e

Please sign in to comment.