From ddb825ba58ee1179be6fbf5fc0c254b43228721b Mon Sep 17 00:00:00 2001 From: Alexey Shekhirin Date: Fri, 16 Feb 2024 20:02:54 +0000 Subject: [PATCH 01/13] feat: mouse support keybind --- src/app.rs | 60 ++++++++++++++++++++++++++++++++++++++++++--------- src/event.rs | 1 + src/help.rs | 3 ++- src/output.rs | 23 ++++++++++---------- src/view.rs | 8 +++++-- 5 files changed, 71 insertions(+), 24 deletions(-) diff --git a/src/app.rs b/src/app.rs index 386915a..e6754d3 100644 --- a/src/app.rs +++ b/src/app.rs @@ -6,9 +6,18 @@ use crossbeam_channel::{Receiver, Sender}; // module -use crossterm::event::{Event, KeyCode, KeyEvent, KeyEventKind, KeyModifiers, MouseEvent, MouseEventKind, KeyEventState}; +use crossterm::{ + event::{ + DisableMouseCapture, EnableMouseCapture, Event, KeyCode, KeyEvent, KeyEventKind, + KeyEventState, KeyModifiers, MouseEvent, MouseEventKind, + }, + execute, +}; use regex::Regex; -use std::{collections::HashMap, io}; +use std::{ + collections::HashMap, + io::{self, Write}, +}; use tui::{ backend::Backend, layout::{Constraint, Direction, Layout}, @@ -19,6 +28,7 @@ use tui::{ use std::thread; // local module +use crate::common::logging_result; use crate::event::AppEvent; use crate::exec::{exec_after_command, CommandResult}; use crate::header::HeaderArea; @@ -26,7 +36,6 @@ use crate::help::HelpWindow; use crate::history::{History, HistoryArea}; use crate::output; use crate::watch::WatchArea; -use crate::common::logging_result; use crate::Interval; use crate::DEFAULT_TAB_SIZE; @@ -140,6 +149,9 @@ pub struct App<'a> { /// help_window: HelpWindow<'a>, + /// Enable mouse wheel support. + mouse_events: bool, + /// It is a flag value to confirm the done of the app. /// If `true`, exit app. pub done: bool, @@ -154,7 +166,12 @@ pub struct App<'a> { /// Trail at watch view window. impl<'a> App<'a> { /// - pub fn new(tx: Sender, rx: Receiver, interval: Interval) -> Self { + pub fn new( + tx: Sender, + rx: Receiver, + interval: Interval, + mouse_events: bool, + ) -> Self { // method at create new view trail. Self { area: ActiveArea::History, @@ -186,6 +203,8 @@ impl<'a> App<'a> { help_window: HelpWindow::new(), + mouse_events, + done: false, logfile: "".to_string(), tx, @@ -194,7 +213,7 @@ impl<'a> App<'a> { } /// - pub fn run(&mut self, terminal: &mut Terminal) -> io::Result<()> { + pub fn run(&mut self, terminal: &mut Terminal) -> io::Result<()> { self.history_area.next(); let mut update_draw = true; loop { @@ -230,6 +249,16 @@ impl<'a> App<'a> { update_draw = true; } + Ok(AppEvent::ToggleMouseEvents) => { + if self.mouse_events { + execute!(terminal.backend_mut(), DisableMouseCapture)?; + } else { + execute!(terminal.backend_mut(), EnableMouseCapture)?; + } + + self.mouse_events = !self.mouse_events; + } + // get exit event Ok(AppEvent::Exit) => self.done = true, @@ -378,7 +407,7 @@ impl<'a> App<'a> { self.is_filtered, self.is_regex_filter, &self.filtered_text, - self.tab_size + self.tab_size, ), DiffMode::Watch => output::get_watch_diff( @@ -386,7 +415,7 @@ impl<'a> App<'a> { self.line_number, text_src, text_dst, - self.tab_size + self.tab_size, ), DiffMode::Line => output::get_line_diff( @@ -395,7 +424,7 @@ impl<'a> App<'a> { self.is_only_diffline, text_src, text_dst, - self.tab_size + self.tab_size, ), DiffMode::Word => output::get_word_diff( @@ -404,7 +433,7 @@ impl<'a> App<'a> { self.is_only_diffline, text_src, text_dst, - self.tab_size + self.tab_size, ), }; @@ -599,7 +628,7 @@ impl<'a> App<'a> { return false; } - if self.after_command != "".to_string() { + if !self.after_command.is_empty() { let after_command = self.after_command.clone(); let results = self.results.clone(); @@ -919,6 +948,13 @@ impl<'a> App<'a> { state: KeyEventState::NONE, }) => self.toggle_window(), + Event::Key(KeyEvent { + code: KeyCode::Char('m'), + modifiers: KeyModifiers::NONE, + kind: KeyEventKind::Press, + state: KeyEventState::NONE, + }) => self.toggle_mouse_events(), + // q ... exit hwatch. Event::Key(KeyEvent { code: KeyCode::Char('q'), @@ -1108,6 +1144,10 @@ impl<'a> App<'a> { let _ = self.tx.send(AppEvent::Redraw); } + pub fn toggle_mouse_events(&mut self) { + let _ = self.tx.send(AppEvent::ToggleMouseEvents); + } + /// pub fn show_ui(&mut self, visible: bool) { self.show_header = visible; diff --git a/src/event.rs b/src/event.rs index 317b46f..d70baa4 100644 --- a/src/event.rs +++ b/src/event.rs @@ -8,5 +8,6 @@ pub enum AppEvent { OutputUpdate(CommandResult), TerminalEvent(crossterm::event::Event), Redraw, + ToggleMouseEvents, Exit, } diff --git a/src/help.rs b/src/help.rs index 63d1e28..22270e9 100644 --- a/src/help.rs +++ b/src/help.rs @@ -78,6 +78,7 @@ fn gen_help_text<'a>() -> Vec> { Spans::from(" - [d] key ... switch diff mode at None, Watch, Line, and Word mode. "), Spans::from(" - [t] key ... toggle ui (history pane & header both on/off). "), Spans::from(" - [Bkspace] ... toggle history pane. "), + Spans::from(" - [m] key ... toggle mouse wheel support. With this option, copying text with your terminal may be harder. Try holding the Shift key"), // exit hwatch Spans::from(" - [q] key ... exit hwatch."), // change diff @@ -94,7 +95,7 @@ fn gen_help_text<'a>() -> Vec> { Spans::from(" - [-] key ... Decrease interval by .5 seconds."), // change use area Spans::from(" - [Tab] key ... toggle current area at history or watch."), - // filter text inpu + // filter text input Spans::from(" - [/] key ... filter history by string."), Spans::from(" - [*] key ... filter history by regex."), Spans::from(" - [ESC] key ... unfiltering."), diff --git a/src/output.rs b/src/output.rs index 78a23d9..97aa603 100644 --- a/src/output.rs +++ b/src/output.rs @@ -7,14 +7,13 @@ use ansi_parser::{AnsiParser, AnsiSequence, Output}; use difference::{Changeset, Difference}; use heapless::consts::*; use regex::Regex; +use std::borrow::Cow; use std::cmp; +use std::fmt::Write; use tui::{ style::{Color, Modifier, Style}, text::{Span, Spans}, }; -use std::borrow::Cow; -use std::fmt::Write; - // local const use crate::ansi; @@ -69,10 +68,7 @@ fn expand_line_tab(data: &str, tab_size: u16) -> String { result_vec.push(l); } - let rslt = result_vec.join("\n"); - - return rslt - + result_vec.join("\n") } // plane output @@ -229,7 +225,13 @@ pub fn get_plane_output<'a>( // ========== /// -pub fn get_watch_diff<'a>(color: bool, line_number: bool, old: &str, new: &str, tab_size: u16) -> Vec> { +pub fn get_watch_diff<'a>( + color: bool, + line_number: bool, + old: &str, + new: &str, + tab_size: u16, +) -> Vec> { // let old_text = &expand_line_tab(old, tab_size); let new_text = &expand_line_tab(new, tab_size); @@ -259,7 +261,6 @@ pub fn get_watch_diff<'a>(color: bool, line_number: bool, old: &str, new: &str, let old_line = old_vec[i]; let new_line = new_vec[i]; - let mut line_data = match color { false => get_watch_diff_line(&old_line, &new_line), true => get_watch_diff_line_with_ansi(&old_line, &new_line), @@ -418,7 +419,7 @@ pub fn get_line_diff<'a>( is_only_diffline: bool, old: &str, new: &str, - tab_size: u16 + tab_size: u16, ) -> Vec> { let old_text = &expand_line_tab(old, tab_size); let new_text = &expand_line_tab(new, tab_size); @@ -568,7 +569,7 @@ pub fn get_word_diff<'a>( is_only_diffline: bool, old: &str, new: &str, - tab_size: u16 + tab_size: u16, ) -> Vec> { let old_text = &expand_line_tab(old, tab_size); let new_text = &expand_line_tab(new, tab_size); diff --git a/src/view.rs b/src/view.rs index 0775e2e..eb04323 100644 --- a/src/view.rs +++ b/src/view.rs @@ -9,7 +9,11 @@ use crossterm::{ execute, terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, }; -use std::{error::Error, io, sync::{Arc, RwLock}}; +use std::{ + error::Error, + io, + sync::{Arc, RwLock}, +}; use tui::{backend::CrosstermBackend, Terminal}; // local module @@ -139,7 +143,7 @@ impl View { } // Create App - let mut app = App::new(tx, rx, self.interval.clone()); + let mut app = App::new(tx, rx, self.interval.clone(), self.mouse_events); // set after command app.set_after_command(self.after_command.clone()); From 0be0e6e324420bfd0408f629e4ecf0f785db5a8b Mon Sep 17 00:00:00 2001 From: Alexey Shekhirin Date: Mon, 19 Feb 2024 21:39:08 +0000 Subject: [PATCH 02/13] add comment --- src/help.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/help.rs b/src/help.rs index 22270e9..e19abc6 100644 --- a/src/help.rs +++ b/src/help.rs @@ -78,7 +78,7 @@ fn gen_help_text<'a>() -> Vec> { Spans::from(" - [d] key ... switch diff mode at None, Watch, Line, and Word mode. "), Spans::from(" - [t] key ... toggle ui (history pane & header both on/off). "), Spans::from(" - [Bkspace] ... toggle history pane. "), - Spans::from(" - [m] key ... toggle mouse wheel support. With this option, copying text with your terminal may be harder. Try holding the Shift key"), + Spans::from(" - [m] key ... toggle mouse wheel support. With this option, copying text with your terminal may be harder. Try holding the Shift key."), // exit hwatch Spans::from(" - [q] key ... exit hwatch."), // change diff From 0fb17b189650b240c859a99da7a4c9249fe669f9 Mon Sep 17 00:00:00 2001 From: blacknon Date: Mon, 4 Mar 2024 13:49:49 +0900 Subject: [PATCH 03/13] update. create branch --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/main.rs | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ffcd60b..c41192a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -639,7 +639,7 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hwatch" -version = "0.3.10" +version = "0.3.11" dependencies = [ "ansi-parser", "async-std", diff --git a/Cargo.toml b/Cargo.toml index a465fc1..baec831 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.10" +version = "0.3.11" [dependencies] # TODO: [ansi-parser](https://crates.io/crates/ansi-parser)のバージョンアップ対応が必要になるので、その対応待ち. PRはmargeされたのでいい加減アップデートされてもいいと思うのだが…. diff --git a/src/main.rs b/src/main.rs index 75bf6af..5c3a47e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,8 @@ // that can be found in the LICENSE file. // v0.3.11 + +// v0.3.12 // TODO(blacknon): セキュリティのため、heaplessのバージョンを上げる // TODO(blakcnon): batch modeの実装. // TODO(blacknon): 任意時点間のdiffが行えるようにする. @@ -119,8 +121,8 @@ fn build_app() -> clap::Command<'static> { .allow_invalid_utf8(true) .multiple_values(true) .required(true), - ) + // -- flags -- // Enable batch mode option // [-b,--batch] From b41ee31f45df15b76638bf4bf9868f1cfa1093af Mon Sep 17 00:00:00 2001 From: blacknon Date: Mon, 4 Mar 2024 16:56:59 +0900 Subject: [PATCH 04/13] update. #97. Looks like the condition was incorrect in the `word diff`. --- src/output.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/output.rs b/src/output.rs index 97aa603..ff6e1a0 100644 --- a/src/output.rs +++ b/src/output.rs @@ -704,7 +704,7 @@ pub fn get_word_diff<'a>( let mut lines_data = vec![]; // check lines. - if i > 0 { + if diffs.len() > i { let after_diffs = &diffs[i + 1]; lines_data = get_word_diff_remline(color, after_diffs, diff_data.to_string()) From 9a1070b3dc0788d81499fb1593edb4f21dc60451 Mon Sep 17 00:00:00 2001 From: blacknon Date: Mon, 4 Mar 2024 19:43:36 +0900 Subject: [PATCH 05/13] update. before annotations delete. --- Cargo.lock | 256 +++++++++++++++++++++++++++++++++++++++++++------ Cargo.toml | 2 +- src/ansi.rs | 9 +- src/app.rs | 2 +- src/header.rs | 14 +-- src/help.rs | 50 +++++----- src/history.rs | 2 +- src/output.rs | 51 +++++----- src/watch.rs | 10 +- 9 files changed, 298 insertions(+), 98 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c41192a..0aa5335 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,18 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if 1.0.0", + "once_cell", + "version_check 0.9.4", + "zerocopy", +] + [[package]] name = "aho-corasick" version = "0.7.18" @@ -11,6 +23,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" + [[package]] name = "ansi-parser" version = "0.8.0" @@ -175,6 +193,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" + [[package]] name = "block-buffer" version = "0.9.0" @@ -222,6 +246,15 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" +[[package]] +name = "castaway" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a17ed5635fc8536268e5d4de1e22e81ac34419e5f052d4d51f4e01dcc263fcc" +dependencies = [ + "rustversion", +] + [[package]] name = "cc" version = "1.0.73" @@ -260,7 +293,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2dbdf4bdacb33466e854ce889eee8dfd5729abf7ccd7664d0a2d60cd384440b" dependencies = [ "atty", - "bitflags", + "bitflags 1.3.2", "clap_lex", "indexmap", "lazy_static", @@ -278,6 +311,19 @@ dependencies = [ "os_str_bytes", ] +[[package]] +name = "compact_str" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f86b9c4c00838774a6d902ef931eff7470720c51d90c2e32cfe15dc304737b3f" +dependencies = [ + "castaway", + "cfg-if 1.0.0", + "itoa", + "ryu", + "static_assertions", +] + [[package]] name = "concurrent-queue" version = "1.2.2" @@ -322,21 +368,37 @@ version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a84cda67535339806297f1b331d6dd6320470d2a0fe65381e79ee9e156dd3d13" dependencies = [ - "bitflags", + "bitflags 1.3.2", + "crossterm_winapi", + "libc", + "mio", + "parking_lot", + "signal-hook 0.3.17", + "signal-hook-mio", + "winapi", +] + +[[package]] +name = "crossterm" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" +dependencies = [ + "bitflags 2.4.2", "crossterm_winapi", "libc", "mio", "parking_lot", - "signal-hook 0.3.14", + "signal-hook 0.3.17", "signal-hook-mio", "winapi", ] [[package]] name = "crossterm_winapi" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ae1b35a484aa10e07fe0638d02301c5ad24de82d310ccbd2f3693da5f09bf1c" +checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" dependencies = [ "winapi", ] @@ -348,7 +410,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f877be4f7c9f246b183111634f75baa039715e3f46ce860677d3b19a69fb229c" dependencies = [ "quote", - "syn", + "syn 1.0.96", ] [[package]] @@ -397,6 +459,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "either" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" + [[package]] name = "event-listener" version = "2.5.2" @@ -500,7 +568,7 @@ checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.96", ] [[package]] @@ -610,6 +678,16 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +[[package]] +name = "hashbrown" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +dependencies = [ + "ahash", + "allocator-api2", +] + [[package]] name = "heapless" version = "0.5.6" @@ -622,6 +700,12 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + [[package]] name = "hermit-abi" version = "0.1.19" @@ -646,7 +730,7 @@ dependencies = [ "chrono", "clap", "crossbeam-channel", - "crossterm", + "crossterm 0.26.1", "ctrlc", "difference", "futures", @@ -668,9 +752,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6012d540c5baa3589337a98ce73408de9b5a25ec9fc2c6fd6be8f0d39e0ca5a" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.11.2", ] +[[package]] +name = "indoc" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8" + [[package]] name = "instant" version = "0.1.12" @@ -680,6 +770,15 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.2" @@ -736,6 +835,15 @@ dependencies = [ "value-bag", ] +[[package]] +name = "lru" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" +dependencies = [ + "hashbrown 0.14.3", +] + [[package]] name = "memchr" version = "2.5.0" @@ -766,7 +874,7 @@ version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if 1.0.0", "libc", ] @@ -799,7 +907,7 @@ checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.96", ] [[package]] @@ -833,9 +941,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.12.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "opaque-debug" @@ -887,6 +995,12 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + [[package]] name = "pest" version = "2.1.3" @@ -967,9 +1081,9 @@ checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" [[package]] name = "proc-macro2" -version = "1.0.39" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] @@ -982,9 +1096,9 @@ checksum = "acbb3ede7a8f9a8ab89e714637f2cf40001b58f21340d4242b2f11533e65fa8d" [[package]] name = "quote" -version = "1.0.18" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -1042,13 +1156,20 @@ dependencies = [ [[package]] name = "ratatui" -version = "0.20.1" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcc0d032bccba900ee32151ec0265667535c230169f5a011154cdcd984e16829" +checksum = "bcb12f8fbf6c62614b0d56eb352af54f6a22410c3b079eb53ee93c7b97dd31d8" dependencies = [ - "bitflags", + "bitflags 2.4.2", "cassowary", - "crossterm", + "compact_str", + "crossterm 0.27.0", + "indoc", + "itertools", + "lru", + "paste", + "stability", + "strum", "unicode-segmentation", "unicode-width", ] @@ -1059,7 +1180,7 @@ version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -1090,6 +1211,12 @@ version = "0.6.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64" +[[package]] +name = "rustversion" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" + [[package]] name = "ryu" version = "1.0.10" @@ -1134,7 +1261,7 @@ checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.96", ] [[package]] @@ -1179,9 +1306,9 @@ dependencies = [ [[package]] name = "signal-hook" -version = "0.3.14" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a253b5e89e2698464fc26b545c9edceb338e18a89effeeecfea192c3025be29d" +checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801" dependencies = [ "libc", "signal-hook-registry", @@ -1195,7 +1322,7 @@ checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af" dependencies = [ "libc", "mio", - "signal-hook 0.3.14", + "signal-hook 0.3.17", ] [[package]] @@ -1235,18 +1362,56 @@ dependencies = [ "winapi", ] +[[package]] +name = "stability" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebd1b177894da2a2d9120208c3386066af06a488255caabc5de8ddca22dbc3ce" +dependencies = [ + "quote", + "syn 1.0.96", +] + [[package]] name = "stable_deref_trait" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "strsim" version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "strum" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "723b93e8addf9aa965ebe2d11da6d7540fa2283fcea14b3371ff055f7ba13f5f" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a3417fc93d76740d974a01654a09777cb500428cc874ca9f45edfe0c4d4cd18" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.52", +] + [[package]] name = "syn" version = "1.0.96" @@ -1258,6 +1423,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "termcolor" version = "1.1.3" @@ -1297,7 +1473,7 @@ checksum = "31ef6892cc0348a9b3b8c377addba91e0f6365863d92354bf27559dca81ee8c5" dependencies = [ "anyhow", "base64", - "bitflags", + "bitflags 1.3.2", "cfg-if 1.0.0", "filedescriptor", "hex", @@ -1344,7 +1520,7 @@ checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.96", ] [[package]] @@ -1469,7 +1645,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn", + "syn 1.0.96", "wasm-bindgen-shared", ] @@ -1503,7 +1679,7 @@ checksum = "99ec0dc7a4756fffc231aab1b9f2f578d23cd391390ab27f952ae0c9b3ece20b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.96", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1606,3 +1782,23 @@ name = "windows_x86_64_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" + +[[package]] +name = "zerocopy" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", +] diff --git a/Cargo.toml b/Cargo.toml index baec831..18a95f7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ futures = "0.3.21" question = "0.2.2" # tui = {version = "0.19.0", default-features = false, features = ['crossterm']} -ratatui = {version = "0.20.1", default-features = false, features = ['crossterm']} +ratatui = {version = "0.26.1", default-features = false, features = ['crossterm']} regex = "1.3.0" serde = "1.0.104" diff --git a/src/ansi.rs b/src/ansi.rs index c8ded23..1fa536e 100644 --- a/src/ansi.rs +++ b/src/ansi.rs @@ -9,7 +9,8 @@ use termwiz::escape::{ Action, ControlCode, }; use tui::style::{Color, Modifier, Style}; -use tui::text::{Span, Spans, Text}; +use tui::text::{Span,Text}; +use tui::prelude::Line; /// Converts ANSI-escaped strings to tui-rs compatible text pub fn bytes_to_text<'a, B: AsRef<[u8]>>(bytes: B) -> Text<'a> { @@ -17,7 +18,7 @@ pub fn bytes_to_text<'a, B: AsRef<[u8]>>(bytes: B) -> Text<'a> { let parsed = parser.parse_as_vec(bytes.as_ref()); // each span will be a line - let mut spans = Vec::::new(); + let mut spans = Vec::::new(); // create span buffer let mut span_style = Style::default(); @@ -39,7 +40,7 @@ pub fn bytes_to_text<'a, B: AsRef<[u8]>>(bytes: B) -> Text<'a> { span_text = String::new(); // finish the current line - spans.push(Spans::from(current_line)); + spans.push(Line::from(current_line)); current_line = Vec::new(); } Action::CSI(CSI::Sgr(sgr)) => { @@ -134,7 +135,7 @@ pub fn bytes_to_text<'a, B: AsRef<[u8]>>(bytes: B) -> Text<'a> { // finish the current span current_line.push(Span::styled(span_text, span_style)); // finish the current line - spans.push(Spans::from(current_line)); + spans.push(Line::from(current_line)); } spans.into() diff --git a/src/app.rs b/src/app.rs index e6754d3..bddc2a5 100644 --- a/src/app.rs +++ b/src/app.rs @@ -268,7 +268,7 @@ impl<'a> App<'a> { } /// - pub fn draw(&mut self, f: &mut Frame) { + pub fn draw(&mut self, f: &mut Frame) { self.define_subareas(f.size()); if self.show_header { diff --git a/src/header.rs b/src/header.rs index 9b14b22..0082335 100644 --- a/src/header.rs +++ b/src/header.rs @@ -9,9 +9,11 @@ use tui::{ backend::Backend, style::{Color, Modifier, Style}, - text::{Span, Spans}, + text::Span, + widgets::Paragraph, Frame, + prelude::Line, }; // local module @@ -40,7 +42,7 @@ pub struct HeaderArea<'a> { exec_status: bool, /// - data: Vec>, + data: Vec>, /// line_number: bool, @@ -85,7 +87,7 @@ impl<'a> HeaderArea<'a> { timestamp: "".to_string(), exec_status: true, - data: vec![Spans::from("")], + data: vec![Line::from("")], ansi_color: false, line_number: false, banner: "".to_string(), @@ -249,7 +251,7 @@ impl<'a> HeaderArea<'a> { }; // Create 1st line. - self.data.push(Spans::from(vec![ + self.data.push(Line::from(vec![ Span::raw("Every "), Span::styled( format!("{:>wid$}", interval, wid = 9), @@ -271,7 +273,7 @@ impl<'a> HeaderArea<'a> { ])); // Create 2nd line - self.data.push(Spans::from(vec![ + self.data.push(Line::from(vec![ // filter keyword Span::styled(self.input_prompt.clone(), Style::default().fg(Color::Gray)), Span::styled(filter_keyword, filter_keyword_style), @@ -320,7 +322,7 @@ impl<'a> HeaderArea<'a> { ])); } - pub fn draw(&mut self, frame: &mut Frame) { + pub fn draw(&mut self, frame: &mut Frame) { let block = Paragraph::new(self.data.clone()); frame.render_widget(block, self.area); } diff --git a/src/help.rs b/src/help.rs index e19abc6..16668fb 100644 --- a/src/help.rs +++ b/src/help.rs @@ -6,14 +6,14 @@ use tui::{ backend::Backend, layout::{Constraint, Direction, Layout, Rect}, style::{Color, Style}, - text::Spans, + prelude::Line, widgets::{Block, Borders, Clear, Paragraph}, Frame, }; pub struct HelpWindow<'a> { /// - data: Vec>, + data: Vec>, /// position: i16, @@ -28,7 +28,7 @@ impl<'a> HelpWindow<'a> { } /// - pub fn draw(&mut self, f: &mut Frame) { + pub fn draw(&mut self, f: &mut Frame) { let title = "help"; let size = f.size(); @@ -68,37 +68,37 @@ impl<'a> HelpWindow<'a> { } /// -fn gen_help_text<'a>() -> Vec> { +fn gen_help_text<'a>() -> Vec> { // set help messages. let text = vec![ - Spans::from(" - [h] key ... show this help message."), + Line::from(" - [h] key ... show this help message."), // toggle - Spans::from(" - [c] key ... toggle color mode."), - Spans::from(" - [n] key ... toggle line number."), - Spans::from(" - [d] key ... switch diff mode at None, Watch, Line, and Word mode. "), - Spans::from(" - [t] key ... toggle ui (history pane & header both on/off). "), - Spans::from(" - [Bkspace] ... toggle history pane. "), - Spans::from(" - [m] key ... toggle mouse wheel support. With this option, copying text with your terminal may be harder. Try holding the Shift key."), + Line::from(" - [c] key ... toggle color mode."), + Line::from(" - [n] key ... toggle line number."), + Line::from(" - [d] key ... switch diff mode at None, Watch, Line, and Word mode. "), + Line::from(" - [t] key ... toggle ui (history pane & header both on/off). "), + Line::from(" - [Bkspace] ... toggle history pane. "), + Line::from(" - [m] key ... toggle mouse wheel support. With this option, copying text with your terminal may be harder. Try holding the Shift key."), // exit hwatch - Spans::from(" - [q] key ... exit hwatch."), + Line::from(" - [q] key ... exit hwatch."), // change diff - Spans::from(" - [0] key ... disable diff."), - Spans::from(" - [1] key ... switch Watch type diff."), - Spans::from(" - [2] key ... switch Line type diff."), - Spans::from(" - [3] key ... switch Word type diff."), + Line::from(" - [0] key ... disable diff."), + Line::from(" - [1] key ... switch Watch type diff."), + Line::from(" - [2] key ... switch Line type diff."), + Line::from(" - [3] key ... switch Word type diff."), // change output - Spans::from(" - [F1] key ... change output mode as stdout."), - Spans::from(" - [F2] key ... change output mode as stderr."), - Spans::from(" - [F3] key ... change output mode as output(stdout/stderr set.)"), + Line::from(" - [F1] key ... change output mode as stdout."), + Line::from(" - [F2] key ... change output mode as stderr."), + Line::from(" - [F3] key ... change output mode as output(stdout/stderr set.)"), // change interval - Spans::from(" - [+] key ... Increase interval by .5 seconds."), - Spans::from(" - [-] key ... Decrease interval by .5 seconds."), + Line::from(" - [+] key ... Increase interval by .5 seconds."), + Line::from(" - [-] key ... Decrease interval by .5 seconds."), // change use area - Spans::from(" - [Tab] key ... toggle current area at history or watch."), + Line::from(" - [Tab] key ... toggle current area at history or watch."), // filter text input - Spans::from(" - [/] key ... filter history by string."), - Spans::from(" - [*] key ... filter history by regex."), - Spans::from(" - [ESC] key ... unfiltering."), + Line::from(" - [/] key ... filter history by string."), + Line::from(" - [*] key ... filter history by regex."), + Line::from(" - [ESC] key ... unfiltering."), ]; text diff --git a/src/history.rs b/src/history.rs index a7aad20..499ce4c 100644 --- a/src/history.rs +++ b/src/history.rs @@ -82,7 +82,7 @@ impl HistoryArea { self.state.select(Some(0)); } - pub fn draw(&mut self, frame: &mut Frame) { + pub fn draw(&mut self, frame: &mut Frame) { // insert latest timestamp const LATEST_COLOR: Color = Color::Blue; let draw_data = &self.data; diff --git a/src/output.rs b/src/output.rs index ff6e1a0..c60b1c4 100644 --- a/src/output.rs +++ b/src/output.rs @@ -12,7 +12,8 @@ use std::cmp; use std::fmt::Write; use tui::{ style::{Color, Modifier, Style}, - text::{Span, Spans}, + text::Span, + prelude::Line, }; // local const @@ -82,7 +83,7 @@ pub fn get_plane_output<'a>( is_regex_filter: bool, filtered_text: &str, tab_size: u16, -) -> Vec> { +) -> Vec> { let text = &expand_line_tab(base_text, tab_size); // set result `output_data`. @@ -123,7 +124,7 @@ pub fn get_plane_output<'a>( { if before_range_count > 0 { let line_data = line_span.clone(); - output_data.push(Spans::from(line_data)); + output_data.push(Line::from(line_data)); line_span = vec![]; counter += 1; } @@ -150,7 +151,7 @@ pub fn get_plane_output<'a>( } let line_data = line_span.clone(); - output_data.push(Spans::from(line_data)); + output_data.push(Line::from(line_data)); line_span = vec![]; counter += 1; } @@ -183,7 +184,7 @@ pub fn get_plane_output<'a>( } last_str_line_span.push(Span::from(String::from(last_str_line))); - output_data.push(Spans::from(last_str_line_span)); + output_data.push(Line::from(last_str_line_span)); counter += 1; } @@ -213,7 +214,7 @@ pub fn get_plane_output<'a>( line_span.push(Span::from(String::from(l))); } - output_data.push(Spans::from(line_span)); + output_data.push(Line::from(line_span)); counter += 1; } } @@ -231,7 +232,7 @@ pub fn get_watch_diff<'a>( old: &str, new: &str, tab_size: u16, -) -> Vec> { +) -> Vec> { // let old_text = &expand_line_tab(old, tab_size); let new_text = &expand_line_tab(new, tab_size); @@ -285,10 +286,10 @@ pub fn get_watch_diff<'a>( } /// -fn get_watch_diff_line<'a>(old_line: &str, new_line: &str) -> Spans<'a> { +fn get_watch_diff_line<'a>(old_line: &str, new_line: &str) -> Line<'a> { // If the contents are the same line. if old_line == new_line { - return Spans::from(String::from(new_line)); + return Line::from(String::from(new_line)); } // Decompose lines by character. @@ -339,11 +340,11 @@ fn get_watch_diff_line<'a>(old_line: &str, new_line: &str) -> Spans<'a> { // NOTE: NBSP used as tui-rs trims regular spaces. _result.push(Span::styled(space.to_string(), Style::default())); - Spans::from(_result) + Line::from(_result) } /// -fn get_watch_diff_line_with_ansi<'a>(old_line: &str, new_line: &str) -> Spans<'a> { +fn get_watch_diff_line_with_ansi<'a>(old_line: &str, new_line: &str) -> Line<'a> { // If the contents are the same line. if old_line == new_line { let new_spans = ansi::bytes_to_text(format!("{new_line}\n").as_bytes()); @@ -406,7 +407,7 @@ fn get_watch_diff_line_with_ansi<'a>(old_line: &str, new_line: &str) -> Spans<'a _result.push(Span::styled(space, Style::default())); // - Spans::from(_result) + Line::from(_result) } // line diff @@ -420,7 +421,7 @@ pub fn get_line_diff<'a>( old: &str, new: &str, tab_size: u16, -) -> Vec> { +) -> Vec> { let old_text = &expand_line_tab(old, tab_size); let new_text = &expand_line_tab(new, tab_size); @@ -456,10 +457,10 @@ pub fn get_line_diff<'a>( colored_span.push(x); } } - Spans::from(colored_span) + Line::from(colored_span) } else { // to string => rs-tui span. - Spans::from(format!(" {line}\n")) + Line::from(format!(" {line}\n")) }; if line_number { @@ -489,13 +490,13 @@ pub fn get_line_diff<'a>( let mut data = if color { // ansi color code => parse and delete. to rs-tui span(green). let strip_str = get_ansi_strip_str(&line); - Spans::from(Span::styled( + Line::from(Span::styled( format!("+ {strip_str}\n"), Style::default().fg(Color::Green), )) } else { // to string => rs-tui span. - Spans::from(Span::styled( + Line::from(Span::styled( format!("+ {line}\n"), Style::default().fg(Color::Green), )) @@ -525,13 +526,13 @@ pub fn get_line_diff<'a>( let mut data = if color { // ansi color code => parse and delete. to rs-tui span(green). let strip_str = get_ansi_strip_str(&line); - Spans::from(Span::styled( + Line::from(Span::styled( format!("- {strip_str}\n"), Style::default().fg(Color::Red), )) } else { // to string => rs-tui span. - Spans::from(Span::styled( + Line::from(Span::styled( format!("- {line}\n"), Style::default().fg(Color::Red), )) @@ -570,7 +571,7 @@ pub fn get_word_diff<'a>( old: &str, new: &str, tab_size: u16, -) -> Vec> { +) -> Vec> { let old_text = &expand_line_tab(old, tab_size); let new_text = &expand_line_tab(new, tab_size); @@ -606,10 +607,10 @@ pub fn get_word_diff<'a>( colored_span.push(x); } } - Spans::from(colored_span) + Line::from(colored_span) } else { // to string => rs-tui span. - Spans::from(format!(" {line}\n")) + Line::from(format!(" {line}\n")) }; if line_number { @@ -682,7 +683,7 @@ pub fn get_word_diff<'a>( ); } - result.push(Spans::from(data.clone())); + result.push(Line::from(data.clone())); // add new_counter new_counter += 1; @@ -738,7 +739,7 @@ pub fn get_word_diff<'a>( ); } - result.push(Spans::from(data.clone())); + result.push(Line::from(data.clone())); // add old_counter old_counter += 1; @@ -954,7 +955,7 @@ fn get_word_diff_remline<'a>( } /// -fn get_word_diff_line_to_spans<'a>( +fn get_word_diff_line_to_Line<'a>( color: bool, style: Style, diff_str: &str, diff --git a/src/watch.rs b/src/watch.rs index 4b39e5a..232d529 100644 --- a/src/watch.rs +++ b/src/watch.rs @@ -5,7 +5,7 @@ use tui::{ backend::Backend, style::Style, - text::Spans, + prelude::Line, widgets::{Paragraph, Wrap}, Frame, }; @@ -16,7 +16,7 @@ pub struct WatchArea<'a> { area: tui::layout::Rect, /// - pub data: Vec>, + pub data: Vec>, /// position: i16, @@ -30,7 +30,7 @@ impl<'a> WatchArea<'a> { Self { area: tui::layout::Rect::new(0, 0, 0, 0), - data: vec![Spans::from("")], + data: vec![Line::from("")], position: 0, } @@ -42,12 +42,12 @@ impl<'a> WatchArea<'a> { } /// - pub fn update_output(&mut self, data: Vec>) { + pub fn update_output(&mut self, data: Vec>) { self.data = data; } /// - pub fn draw(&mut self, frame: &mut Frame) { + pub fn draw(&mut self, frame: &mut Frame) { let block = Paragraph::new(self.data.clone()) .style(Style::default()) .wrap(Wrap { trim: false }) From e9ba25673cc3cae55d8b6d5cf5ffaa8d0795b6b7 Mon Sep 17 00:00:00 2001 From: blacknon Date: Tue, 5 Mar 2024 00:20:33 +0900 Subject: [PATCH 06/13] update. ratatui version to 0.26.1 --- src/app.rs | 2 +- src/header.rs | 3 +-- src/help.rs | 3 +-- src/history.rs | 5 ++--- src/output.rs | 24 ++++++++++++------------ src/watch.rs | 3 +-- 6 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/app.rs b/src/app.rs index bddc2a5..511e82f 100644 --- a/src/app.rs +++ b/src/app.rs @@ -268,7 +268,7 @@ impl<'a> App<'a> { } /// - pub fn draw(&mut self, f: &mut Frame) { + pub fn draw(&mut self, f: &mut Frame) { self.define_subareas(f.size()); if self.show_header { diff --git a/src/header.rs b/src/header.rs index 0082335..ceed7bd 100644 --- a/src/header.rs +++ b/src/header.rs @@ -7,7 +7,6 @@ // TODO: 幅調整系の数字をconstにする(生数字で雑計算だとわけわからん) use tui::{ - backend::Backend, style::{Color, Modifier, Style}, text::Span, @@ -322,7 +321,7 @@ impl<'a> HeaderArea<'a> { ])); } - pub fn draw(&mut self, frame: &mut Frame) { + pub fn draw(&mut self, frame: &mut Frame) { let block = Paragraph::new(self.data.clone()); frame.render_widget(block, self.area); } diff --git a/src/help.rs b/src/help.rs index 16668fb..47f8327 100644 --- a/src/help.rs +++ b/src/help.rs @@ -3,7 +3,6 @@ // that can be found in the LICENSE file. use tui::{ - backend::Backend, layout::{Constraint, Direction, Layout, Rect}, style::{Color, Style}, prelude::Line, @@ -28,7 +27,7 @@ impl<'a> HelpWindow<'a> { } /// - pub fn draw(&mut self, f: &mut Frame) { + pub fn draw(&mut self, f: &mut Frame) { let title = "help"; let size = f.size(); diff --git a/src/history.rs b/src/history.rs index 499ce4c..035a3be 100644 --- a/src/history.rs +++ b/src/history.rs @@ -3,7 +3,6 @@ // that can be found in the LICENSE file. use tui::{ - backend::Backend, layout::Constraint, style::{Color, Modifier, Style}, text::Span, @@ -82,7 +81,7 @@ impl HistoryArea { self.state.select(Some(0)); } - pub fn draw(&mut self, frame: &mut Frame) { + pub fn draw(&mut self, frame: &mut Frame) { // insert latest timestamp const LATEST_COLOR: Color = Color::Blue; let draw_data = &self.data; @@ -118,7 +117,7 @@ impl HistoryArea { }, false => base_selected_style.fg(Color::DarkGray), }; - let table = Table::new(rows) + let table = Table::new(rows, [Constraint::Length(crate::HISTORY_WIDTH)]) .block(Block::default()) .highlight_style(selected_style) .highlight_symbol(">>") diff --git a/src/output.rs b/src/output.rs index c60b1c4..959dd2a 100644 --- a/src/output.rs +++ b/src/output.rs @@ -208,7 +208,7 @@ pub fn get_plane_output<'a>( let data = ansi::bytes_to_text(format!("{l}\n").as_bytes()); for d in data.lines { - line_span.extend(d.0); + line_span.extend(d.spans); } } else { line_span.push(Span::from(String::from(l))); @@ -268,7 +268,7 @@ pub fn get_watch_diff<'a>( }; if line_number { - line_data.0.insert( + line_data.spans.insert( 0, Span::styled( format!("{counter:>header_width$} | "), @@ -453,7 +453,7 @@ pub fn get_line_diff<'a>( let mut colored_span = vec![Span::from(" ")]; let colored_data = ansi::bytes_to_text(format!("{line}\n").as_bytes()); for d in colored_data.lines { - for x in d.0 { + for x in d.spans { colored_span.push(x); } } @@ -464,7 +464,7 @@ pub fn get_line_diff<'a>( }; if line_number { - data.0.insert( + data.spans.insert( 0, Span::styled( format!("{new_counter:>header_width$} | "), @@ -503,7 +503,7 @@ pub fn get_line_diff<'a>( }; if line_number { - data.0.insert( + data.spans.insert( 0, Span::styled( format!("{new_counter:>header_width$} | "), @@ -539,7 +539,7 @@ pub fn get_line_diff<'a>( }; if line_number { - data.0.insert( + data.spans.insert( 0, Span::styled( format!("{old_counter:>header_width$} | "), @@ -603,7 +603,7 @@ pub fn get_word_diff<'a>( let mut colored_span = vec![Span::from(" ")]; let colored_data = ansi::bytes_to_text(format!("{line}\n").as_bytes()); for d in colored_data.lines { - for x in d.0 { + for x in d.spans { colored_span.push(x); } } @@ -614,7 +614,7 @@ pub fn get_word_diff<'a>( }; if line_number { - data.0.insert( + data.spans.insert( 0, Span::styled( format!("{new_counter:>header_width$} | "), @@ -705,8 +705,8 @@ pub fn get_word_diff<'a>( let mut lines_data = vec![]; // check lines. - if diffs.len() > i { - let after_diffs = &diffs[i + 1]; + if diffs.len() > i { + let after_diffs: &Difference = &diffs[i + 1]; lines_data = get_word_diff_remline(color, after_diffs, diff_data.to_string()) } else { @@ -955,7 +955,7 @@ fn get_word_diff_remline<'a>( } /// -fn get_word_diff_line_to_Line<'a>( +fn get_word_diff_line_to_spans<'a>( color: bool, style: Style, diff_str: &str, @@ -1016,7 +1016,7 @@ fn gen_ansi_all_set_str<'b>(text: &str) -> Vec>> { // parse ansi text to tui text. let data = ansi::bytes_to_text(format!("{append_text}\n").as_bytes()); if let Some(d) = data.into_iter().next() { - for x in d.0 { + for x in d.spans { processed_text.push(x); } } diff --git a/src/watch.rs b/src/watch.rs index 232d529..0e39b95 100644 --- a/src/watch.rs +++ b/src/watch.rs @@ -3,7 +3,6 @@ // that can be found in the LICENSE file. use tui::{ - backend::Backend, style::Style, prelude::Line, widgets::{Paragraph, Wrap}, @@ -47,7 +46,7 @@ impl<'a> WatchArea<'a> { } /// - pub fn draw(&mut self, frame: &mut Frame) { + pub fn draw(&mut self, frame: &mut Frame) { let block = Paragraph::new(self.data.clone()) .style(Style::default()) .wrap(Wrap { trim: false }) From 9c405a5bf8599e35e608c423d122fcc00137df8b Mon Sep 17 00:00:00 2001 From: blacknon Date: Tue, 5 Mar 2024 00:21:45 +0900 Subject: [PATCH 07/13] update. #97. Looks like the condition was incorrect in the `word diff`. Test and make additional modifications. --- src/output.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/output.rs b/src/output.rs index 959dd2a..c9d5af8 100644 --- a/src/output.rs +++ b/src/output.rs @@ -705,7 +705,7 @@ pub fn get_word_diff<'a>( let mut lines_data = vec![]; // check lines. - if diffs.len() > i { + if diffs.len() > i + 1 { let after_diffs: &Difference = &diffs[i + 1]; lines_data = get_word_diff_remline(color, after_diffs, diff_data.to_string()) From f212c8e05520be21e3f5d1642b03fe6a43fc1d30 Mon Sep 17 00:00:00 2001 From: blacknon Date: Tue, 5 Mar 2024 00:48:16 +0900 Subject: [PATCH 08/13] update. package version up. --- Cargo.lock | 508 +++++++++++++++++++++++++++-------------------------- Cargo.toml | 22 +-- 2 files changed, 274 insertions(+), 256 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0aa5335..c510f49 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,7 +8,7 @@ version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "once_cell", "version_check 0.9.4", "zerocopy", @@ -16,9 +16,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "0.7.18" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] @@ -29,6 +29,21 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "ansi-parser" version = "0.8.0" @@ -127,9 +142,9 @@ dependencies = [ [[package]] name = "async-std" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52580991739c5cdb36cde8b2a516371c0a3b70dda36d916cc08b82372916808c" +checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d" dependencies = [ "async-channel", "async-global-executor", @@ -144,7 +159,6 @@ dependencies = [ "kv-log-macro", "log", "memchr", - "num_cpus", "once_cell", "pin-project-lite", "pin-utils", @@ -183,9 +197,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "base64" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "bitflags" @@ -257,15 +271,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.73" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +checksum = "a0ba8f7aaa012f30d5b2861462f6708eccd49c3c39863fe083a308035f63d723" [[package]] name = "cfg-if" @@ -275,28 +283,29 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.19" +version = "0.4.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +checksum = "5bc015644b92d5890fab7489e49d21f879d5c990186827d42ec511919404f38b" dependencies = [ - "libc", - "num-integer", + "android-tzdata", + "iana-time-zone", + "js-sys", "num-traits", - "time", - "winapi", + "wasm-bindgen", + "windows-targets", ] [[package]] name = "clap" -version = "3.1.18" +version = "3.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2dbdf4bdacb33466e854ce889eee8dfd5729abf7ccd7664d0a2d60cd384440b" +checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" dependencies = [ "atty", "bitflags 1.3.2", "clap_lex", "indexmap", - "lazy_static", + "once_cell", "strsim", "termcolor", "textwrap", @@ -304,9 +313,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.2.0" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a37c35f1112dad5e6e0b1adaff798507497a18fceeb30cceb3bae7d1427b9213" +checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" dependencies = [ "os_str_bytes", ] @@ -318,7 +327,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f86b9c4c00838774a6d902ef931eff7470720c51d90c2e32cfe15dc304737b3f" dependencies = [ "castaway", - "cfg-if 1.0.0", + "cfg-if", "itoa", "ryu", "static_assertions", @@ -333,6 +342,12 @@ dependencies = [ "cache-padded", ] +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + [[package]] name = "cpufeatures" version = "0.2.2" @@ -344,39 +359,18 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.4" +version = "0.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53" +checksum = "ab3db02a9c5b5121e1e42fbdb1aeb65f5e02624cc58c43f2884c6ccac0b82f95" dependencies = [ - "cfg-if 1.0.0", "crossbeam-utils", ] [[package]] name = "crossbeam-utils" -version = "0.8.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" -dependencies = [ - "cfg-if 1.0.0", - "lazy_static", -] - -[[package]] -name = "crossterm" -version = "0.26.1" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a84cda67535339806297f1b331d6dd6320470d2a0fe65381e79ee9e156dd3d13" -dependencies = [ - "bitflags 1.3.2", - "crossterm_winapi", - "libc", - "mio", - "parking_lot", - "signal-hook 0.3.17", - "signal-hook-mio", - "winapi", -] +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" [[package]] name = "crossterm" @@ -415,12 +409,12 @@ dependencies = [ [[package]] name = "ctrlc" -version = "3.2.2" +version = "3.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b37feaa84e6861e00a1f5e5aa8da3ee56d605c9992d33e082786754828e20865" +checksum = "b467862cc8610ca6fc9a1532d7777cee0804e678ab45410897b9396495994a0b" dependencies = [ "nix", - "winapi", + "windows-sys 0.52.0", ] [[package]] @@ -440,11 +434,10 @@ dependencies = [ [[package]] name = "dirs" -version = "2.0.2" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" dependencies = [ - "cfg-if 0.1.10", "dirs-sys", ] @@ -499,9 +492,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "futures" -version = "0.3.21" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f73fe65f54d1e12b726f517d3e2135ca3125a437b6d998caf1962961f7172d9e" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" dependencies = [ "futures-channel", "futures-core", @@ -514,9 +507,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.21" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", "futures-sink", @@ -524,15 +517,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.21" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-executor" -version = "0.3.21" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9420b90cfa29e327d0429f19be13e7ddb68fa1cccb09d65e5706b8c7a749b8a6" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" dependencies = [ "futures-core", "futures-task", @@ -541,9 +534,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.21" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-lite" @@ -562,32 +555,32 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.21" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 1.0.96", + "syn 2.0.52", ] [[package]] name = "futures-sink" -version = "0.3.21" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.21" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-util" -version = "0.3.21" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-channel", "futures-core", @@ -629,24 +622,13 @@ dependencies = [ "version_check 0.9.4", ] -[[package]] -name = "getrandom" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - [[package]] name = "getrandom" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "libc", "wasi 0.10.2+wasi-snapshot-preview1", ] @@ -674,9 +656,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.11.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" @@ -730,7 +712,7 @@ dependencies = [ "chrono", "clap", "crossbeam-channel", - "crossterm 0.26.1", + "crossterm", "ctrlc", "difference", "futures", @@ -745,14 +727,37 @@ dependencies = [ "termwiz", ] +[[package]] +name = "iana-time-zone" +version = "0.1.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "indexmap" -version = "1.8.2" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6012d540c5baa3589337a98ce73408de9b5a25ec9fc2c6fd6be8f0d39e0ca5a" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", - "hashbrown 0.11.2", + "hashbrown 0.12.3", ] [[package]] @@ -767,7 +772,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] [[package]] @@ -811,9 +816,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.126" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "lock_api" @@ -831,7 +836,7 @@ version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "value-bag", ] @@ -846,9 +851,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.5.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "memmem" @@ -865,17 +870,17 @@ dependencies = [ "libc", "log", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys", + "windows-sys 0.36.1", ] [[package]] name = "nix" -version = "0.24.3" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" +checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ - "bitflags 1.3.2", - "cfg-if 1.0.0", + "bitflags 2.4.2", + "cfg-if", "libc", ] @@ -891,9 +896,9 @@ dependencies = [ [[package]] name = "nom" -version = "5.1.2" +version = "5.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af" +checksum = "08959a387a676302eebf4ddbcbc611da04285579f76f88ee0506c63b1a61dd4b" dependencies = [ "memchr", "version_check 0.9.4", @@ -910,16 +915,6 @@ dependencies = [ "syn 1.0.96", ] -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.15" @@ -929,16 +924,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "num_cpus" -version = "1.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "once_cell" version = "1.19.0" @@ -947,24 +932,24 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "opaque-debug" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "ordered-float" -version = "2.10.0" +version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7940cf2ca942593318d07fcf2596cdca60a85c9e7fab408a5e21a4f9dcd40d87" +checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c" dependencies = [ "num-traits", ] [[package]] name = "os_str_bytes" -version = "6.1.0" +version = "6.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa" +checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" [[package]] name = "parking" @@ -988,11 +973,11 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-sys", + "windows-sys 0.36.1", ] [[package]] @@ -1003,27 +988,28 @@ checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] name = "pest" -version = "2.1.3" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +checksum = "dbc7bc69c062e492337d74d59b120c274fd3d261b6bf6d3207d499b4b379c41a" dependencies = [ + "thiserror", "ucd-trie", ] [[package]] name = "phf" -version = "0.8.0" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12" +checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" dependencies = [ "phf_shared", ] [[package]] name = "phf_codegen" -version = "0.8.0" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbffee61585b0411840d3ece935cce9cb6321f01c45477d30066498cd5e1a815" +checksum = "e8d39688d359e6b34654d328e262234662d16cc0f60ec8dcbe5e718709342a5a" dependencies = [ "phf_generator", "phf_shared", @@ -1031,9 +1017,9 @@ dependencies = [ [[package]] name = "phf_generator" -version = "0.8.0" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17367f0cc86f2d25802b2c26ee58a7b23faeccf78a396094c13dced0d0182526" +checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" dependencies = [ "phf_shared", "rand", @@ -1041,9 +1027,9 @@ dependencies = [ [[package]] name = "phf_shared" -version = "0.8.0" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c00cf8b9eafe68dde5e9eaa2cef8ee84a9336a47d566ec55ca16589633b65af7" +checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" dependencies = [ "siphasher", ] @@ -1066,19 +1052,13 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "685404d509889fade3e86fe3a5803bca2ec09b0c0778d5ada6ec8bf7a8de5259" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "libc", "log", "wepoll-ffi", "winapi", ] -[[package]] -name = "ppv-lite86" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" - [[package]] name = "proc-macro2" version = "1.0.78" @@ -1105,54 +1085,18 @@ dependencies = [ [[package]] name = "rand" -version = "0.7.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ - "getrandom 0.1.16", - "libc", - "rand_chacha", - "rand_core", - "rand_hc", - "rand_pcg", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86", "rand_core", ] [[package]] name = "rand_core" -version = "0.5.1" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom 0.1.16", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core", -] - -[[package]] -name = "rand_pcg" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" -dependencies = [ - "rand_core", -] +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" [[package]] name = "ratatui" @@ -1163,7 +1107,7 @@ dependencies = [ "bitflags 2.4.2", "cassowary", "compact_str", - "crossterm 0.27.0", + "crossterm", "indoc", "itertools", "lru", @@ -1189,16 +1133,28 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom 0.2.6", + "getrandom", "redox_syscall", "thiserror", ] [[package]] name = "regex" -version = "1.5.6" +version = "1.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" dependencies = [ "aho-corasick", "memchr", @@ -1207,9 +1163,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.26" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "rustversion" @@ -1249,26 +1205,29 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.137" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +dependencies = [ + "serde_derive", +] [[package]] name = "serde_derive" -version = "1.0.137" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 1.0.96", + "syn 2.0.52", ] [[package]] name = "serde_json" -version = "1.0.81" +version = "1.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c" +checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" dependencies = [ "itoa", "ryu", @@ -1282,7 +1241,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" dependencies = [ "block-buffer", - "cfg-if 1.0.0", + "cfg-if", "cpufeatures", "digest", "opaque-debug", @@ -1436,22 +1395,22 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.1.3" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" dependencies = [ "winapi-util", ] [[package]] name = "terminfo" -version = "0.7.3" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76971977e6121664ec1b960d1313aacfa75642adc93b9d4d53b247bd4cb1747e" +checksum = "da31aef70da0f6352dbcb462683eb4dd2bfad01cf3fc96cf204547b9a839a585" dependencies = [ "dirs", "fnv", - "nom 5.1.2", + "nom 5.1.3", "phf", "phf_codegen", ] @@ -1474,7 +1433,7 @@ dependencies = [ "anyhow", "base64", "bitflags 1.3.2", - "cfg-if 1.0.0", + "cfg-if", "filedescriptor", "hex", "lazy_static", @@ -1499,9 +1458,9 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.15.0" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" +checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" [[package]] name = "thiserror" @@ -1523,16 +1482,6 @@ dependencies = [ "syn 1.0.96", ] -[[package]] -name = "time" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "typenum" version = "1.15.0" @@ -1565,9 +1514,9 @@ checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" [[package]] name = "utf8parse" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "936e4b492acfd135421d8dca4b1aa80a7bfc26e702ef3af710e0752684df5372" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "value-bag" @@ -1593,9 +1542,9 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "vtparse" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36ce903972602c84dd48f488cdce39edcba03a93b7ca67b146ae862568f48c5c" +checksum = "6d9b2acfb050df409c972a37d3b8e08cdea3bddb0c09db9d53137e504cfabed0" dependencies = [ "utf8parse", ] @@ -1606,12 +1555,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - [[package]] name = "wasi" version = "0.10.2+wasi-snapshot-preview1" @@ -1630,7 +1573,7 @@ version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27370197c907c55e3f1a9fbe26f44e937fe6451368324e009cba39e139dc08ad" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "wasm-bindgen-macro", ] @@ -1655,7 +1598,7 @@ version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f741de44b75e14c35df886aff5f1eb73aa114fa5d4d00dcd37b5e01259bf3b2" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "js-sys", "wasm-bindgen", "web-sys", @@ -1727,9 +1670,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ "winapi", ] @@ -1740,49 +1683,124 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets", +] + [[package]] name = "windows-sys" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" dependencies = [ - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_msvc", + "windows_aarch64_msvc 0.36.1", + "windows_i686_gnu 0.36.1", + "windows_i686_msvc 0.36.1", + "windows_x86_64_gnu 0.36.1", + "windows_x86_64_msvc 0.36.1", ] +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.52.4", + "windows_i686_gnu 0.52.4", + "windows_i686_msvc 0.52.4", + "windows_x86_64_gnu 0.52.4", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.52.4", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" + [[package]] name = "windows_aarch64_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" + [[package]] name = "windows_i686_gnu" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" +[[package]] +name = "windows_i686_gnu" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" + [[package]] name = "windows_i686_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" +[[package]] +name = "windows_i686_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" + [[package]] name = "windows_x86_64_gnu" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" + [[package]] name = "windows_x86_64_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" + [[package]] name = "zerocopy" version = "0.7.32" diff --git a/Cargo.toml b/Cargo.toml index 18a95f7..7135965 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,25 +12,25 @@ version = "0.3.11" # TODO: [ansi-parser](https://crates.io/crates/ansi-parser)のバージョンアップ対応が必要になるので、その対応待ち. PRはmargeされたのでいい加減アップデートされてもいいと思うのだが…. # ansi-parser = {version = "0.9.0", path = "../ansi-parser"} ansi-parser = "0.8.0" -async-std = {version = "1.11"} -chrono = "0.4.19" +async-std = {version = "1.12"} +chrono = "0.4.34" clap = {version = "3.1.18", features = ["cargo"]} -crossbeam-channel = "0.5.4" -crossterm = "0.26.1" -ctrlc = {version = "3.0", features = ["termination"]} +crossbeam-channel = "0.5.12" +crossterm = "0.27.0" +ctrlc = {version = "3.4.2", features = ["termination"]} difference = "2.0" -futures = "0.3.21" +futures = "0.3.30" question = "0.2.2" # tui = {version = "0.19.0", default-features = false, features = ['crossterm']} ratatui = {version = "0.26.1", default-features = false, features = ['crossterm']} -regex = "1.3.0" -serde = "1.0.104" -serde_derive = "1.0.104" -serde_json = "1.0.44" +regex = "1.10.3" +serde = "1.0.197" +serde_derive = "1.0.197" +serde_json = "1.0.114" shell-words = "1.1.0" -termwiz = "0.15.0" # TODO: ansi-parserのバージョンアップグレードの対応が必要になるので、その対応をしたらバージョンアップが必要. heapless = "0.5.6" +termwiz = "0.15.0" From 6ecc48b93c892ec7355e386ef609aa834ea7fe19 Mon Sep 17 00:00:00 2001 From: blacknon Date: Tue, 5 Mar 2024 01:31:02 +0900 Subject: [PATCH 09/13] update. Added line_count (https://docs.rs/ratatui/latest/ratatui/widgets/struct.Paragraph.html#method.line_count), which is a prerequisite for Issue #96. --- Cargo.lock | 77 +++++++++++++++++++++++++++++++--------------------- Cargo.toml | 15 +++++----- src/main.rs | 3 +- src/watch.rs | 11 ++++++-- 4 files changed, 64 insertions(+), 42 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c510f49..204e1c8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -56,9 +56,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.57" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f9b8508dccb7687a1d6c4ce66b2b0ecef467c94667de27d8d7fe1f8d2a9cdc" +checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" [[package]] name = "as-slice" @@ -350,9 +350,9 @@ checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "cpufeatures" -version = "0.2.2" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] @@ -624,13 +624,13 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.6" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if", "libc", - "wasi 0.10.2+wasi-snapshot-preview1", + "wasi", ] [[package]] @@ -820,6 +820,17 @@ version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +[[package]] +name = "libredox" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +dependencies = [ + "bitflags 2.4.2", + "libc", + "redox_syscall 0.4.1", +] + [[package]] name = "lock_api" version = "0.4.7" @@ -869,7 +880,7 @@ checksum = "713d550d9b44d89174e066b7a6217ae06234c10cb47819a88290d2b353c31799" dependencies = [ "libc", "log", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "windows-sys 0.36.1", ] @@ -975,7 +986,7 @@ checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.2.13", "smallvec", "windows-sys 0.36.1", ] @@ -988,10 +999,11 @@ checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] name = "pest" -version = "2.4.0" +version = "2.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbc7bc69c062e492337d74d59b120c274fd3d261b6bf6d3207d499b4b379c41a" +checksum = "56f8023d0fb78c8e03784ea1c7f3fa36e68a723138990b8d5a47d916b651e7a8" dependencies = [ + "memchr", "thiserror", "ucd-trie", ] @@ -1127,14 +1139,23 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "redox_users" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" dependencies = [ "getrandom", - "redox_syscall", + "libredox", "thiserror", ] @@ -1295,9 +1316,9 @@ dependencies = [ [[package]] name = "siphasher" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" [[package]] name = "slab" @@ -1464,22 +1485,22 @@ checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" [[package]] name = "thiserror" -version = "1.0.31" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" +checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.31" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" +checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", - "syn 1.0.96", + "syn 2.0.52", ] [[package]] @@ -1490,9 +1511,9 @@ checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" [[package]] name = "ucd-trie" -version = "0.1.3" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" +checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" [[package]] name = "unicode-ident" @@ -1508,9 +1529,9 @@ checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" [[package]] name = "unicode-width" -version = "0.1.9" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" [[package]] name = "utf8parse" @@ -1555,12 +1576,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" -[[package]] -name = "wasi" -version = "0.10.2+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" diff --git a/Cargo.toml b/Cargo.toml index 7135965..931dd07 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,25 +12,24 @@ version = "0.3.11" # TODO: [ansi-parser](https://crates.io/crates/ansi-parser)のバージョンアップ対応が必要になるので、その対応待ち. PRはmargeされたのでいい加減アップデートされてもいいと思うのだが…. # ansi-parser = {version = "0.9.0", path = "../ansi-parser"} ansi-parser = "0.8.0" + +# TODO: ansi-parserのバージョンアップグレードの対応が必要になるので、その対応をしたらバージョンアップが必要. +heapless = "0.5.6" +termwiz = "0.15.0" + async-std = {version = "1.12"} chrono = "0.4.34" -clap = {version = "3.1.18", features = ["cargo"]} +clap = {version = "3.2.25", features = ["cargo"]} crossbeam-channel = "0.5.12" crossterm = "0.27.0" ctrlc = {version = "3.4.2", features = ["termination"]} difference = "2.0" futures = "0.3.30" question = "0.2.2" - -# tui = {version = "0.19.0", default-features = false, features = ['crossterm']} -ratatui = {version = "0.26.1", default-features = false, features = ['crossterm']} - regex = "1.10.3" serde = "1.0.197" serde_derive = "1.0.197" serde_json = "1.0.114" shell-words = "1.1.0" -# TODO: ansi-parserのバージョンアップグレードの対応が必要になるので、その対応をしたらバージョンアップが必要. -heapless = "0.5.6" -termwiz = "0.15.0" +ratatui = {version = "0.26.1", default-features = false, features = ['crossterm', 'unstable-rendered-line-info']} diff --git a/src/main.rs b/src/main.rs index 5c3a47e..a18a28d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,9 +3,9 @@ // that can be found in the LICENSE file. // v0.3.11 +// TODO(blacknon): セキュリティのため、heaplessのバージョンを上げる // v0.3.12 -// TODO(blacknon): セキュリティのため、heaplessのバージョンを上げる // TODO(blakcnon): batch modeの実装. // TODO(blacknon): 任意時点間のdiffが行えるようにする. // TODO(blacknon): filtering時に、`指定したキーワードで差分が発生した場合のみ`を対象にするような機能にする @@ -15,6 +15,7 @@ // TODO(blacknon): マニュアル(manのデータ)を自動作成させる // https://github.com/rust-cli/man // TODO(blacknon): errorとの比較を行わない(正常終了時のみを比較対象とし、errorの履歴をスキップしてdiffする)キーバインドの追加(なんかのmode?) +// => outputごとに分離して比較できる仕組みにする方式で対処? // TODO(blacknon): ライフタイムの名称をちゃんと命名する。 // TODO(blacknon): エラーなどのメッセージ表示領域の作成 // TODO(blacknon): diffのライブラリをsimilarに切り替える? diff --git a/src/watch.rs b/src/watch.rs index 0e39b95..3f0a8d6 100644 --- a/src/watch.rs +++ b/src/watch.rs @@ -19,6 +19,9 @@ pub struct WatchArea<'a> { /// position: i16, + + /// + lines: i16, } /// Watch Area Object Trait @@ -32,6 +35,8 @@ impl<'a> WatchArea<'a> { data: vec![Line::from("")], position: 0, + + lines: 0, } } @@ -51,6 +56,7 @@ impl<'a> WatchArea<'a> { .style(Style::default()) .wrap(Wrap { trim: false }) .scroll((self.position as u16, 0)); + self.lines = block.line_count(self.area.width) as i16; frame.render_widget(block, self.area); } @@ -63,7 +69,8 @@ impl<'a> WatchArea<'a> { /// pub fn scroll_down(&mut self, num: i16) { // get area data size - let data_size = self.data.len() as i16; - self.position = std::cmp::min(self.position + num, data_size - 1); + // let data_size = self.data.len() as i16; + // self.position = std::cmp::min(self.position + num, data_size - 1); + self.position = std::cmp::min(self.position + num, self.lines - 1); } } From addaf4546fb236fc6517b163fc08a246b790e6c2 Mon Sep 17 00:00:00 2001 From: blacknon Date: Tue, 5 Mar 2024 01:54:50 +0900 Subject: [PATCH 10/13] update. --- src/main.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main.rs b/src/main.rs index a18a28d..cd7503c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,6 +6,11 @@ // TODO(blacknon): セキュリティのため、heaplessのバージョンを上げる // v0.3.12 +// TODO(blacknon): pagedown/pageupスクロールの実装 +// TODO(blacknon): scrollで一番↓まで行くとき、ページの一番下がターミナルの最終行になるように変更する +// TODO(blacknon): issueの中で簡単に実装できそうなやつ + +// v0.3.13 // TODO(blakcnon): batch modeの実装. // TODO(blacknon): 任意時点間のdiffが行えるようにする. // TODO(blacknon): filtering時に、`指定したキーワードで差分が発生した場合のみ`を対象にするような機能にする From 68dd99171186c9de3e9284be9f1b1ad0987e1cb5 Mon Sep 17 00:00:00 2001 From: blacknon Date: Tue, 5 Mar 2024 04:48:54 +0900 Subject: [PATCH 11/13] update. version up wizterm and heapless. --- Cargo.lock | 438 ++++++++++++++++++++++++++++++++++++++++++++-------- Cargo.toml | 6 +- src/ansi.rs | 8 +- src/main.rs | 3 +- 4 files changed, 386 insertions(+), 69 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 204e1c8..d08dbbe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,16 +44,6 @@ dependencies = [ "libc", ] -[[package]] -name = "ansi-parser" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcb2392079bf27198570d6af79ecbd9ec7d8f16d3ec6b60933922fdb66287127" -dependencies = [ - "heapless", - "nom 4.2.3", -] - [[package]] name = "anyhow" version = "1.0.80" @@ -91,7 +81,7 @@ checksum = "871f9bb5e0a22eeb7e8cf16641feb87c9dc67032ccf8ff49e772eb9941d3a965" dependencies = [ "async-task", "concurrent-queue", - "fastrand", + "fastrand 1.7.0", "futures-lite", "once_cell", "slab", @@ -172,6 +162,12 @@ version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "30696a84d817107fc028e049980e09d5e140e8da8f1caeb17e8e950658a3cea9" +[[package]] +name = "atomic" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59bdb34bc650a32731b31bd8f0829cc15d24a708ee31559e0bb34f2bc320cba" + [[package]] name = "atomic-waker" version = "1.0.0" @@ -197,9 +193,24 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "base64" -version = "0.13.1" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "bit-set" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" [[package]] name = "bitflags" @@ -215,9 +226,9 @@ checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "block-buffer" -version = "0.9.0" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array 0.14.5", ] @@ -231,7 +242,7 @@ dependencies = [ "async-channel", "async-task", "atomic-waker", - "fastrand", + "fastrand 1.7.0", "futures-lite", "once_cell", ] @@ -383,7 +394,7 @@ dependencies = [ "libc", "mio", "parking_lot", - "signal-hook 0.3.17", + "signal-hook", "signal-hook-mio", "winapi", ] @@ -397,6 +408,26 @@ dependencies = [ "winapi", ] +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array 0.14.5", + "typenum", +] + +[[package]] +name = "csscolorparser" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb2a7d3066da2de787b7f032c736763eb7ae5d355f81a68bab2675a96008b0bf" +dependencies = [ + "lab", + "phf", +] + [[package]] name = "ctor" version = "0.1.22" @@ -413,10 +444,16 @@ version = "3.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b467862cc8610ca6fc9a1532d7777cee0804e678ab45410897b9396495994a0b" dependencies = [ - "nix", + "nix 0.27.1", "windows-sys 0.52.0", ] +[[package]] +name = "deltae" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5729f5117e208430e437df2f4843f5e5952997175992d1414f94c57d61e270b4" + [[package]] name = "difference" version = "2.0.0" @@ -425,11 +462,12 @@ checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" [[package]] name = "digest" -version = "0.9.0" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "generic-array 0.14.5", + "block-buffer", + "crypto-common", ] [[package]] @@ -458,12 +496,41 @@ version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +[[package]] +name = "errno" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "euclid" +version = "0.22.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f253bc5c813ca05792837a0ff4b3a580336b224512d48f7eda1d7dd9210787" +dependencies = [ + "num-traits", +] + [[package]] name = "event-listener" version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77f3309417938f28bf8228fcff79a4a37103981e3e186d2ccd19c74b38f4eb71" +[[package]] +name = "fancy-regex" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b95f7c0680e4142284cf8b22c14a476e87d61b004a3a0861872b32ef7ead40a2" +dependencies = [ + "bit-set", + "regex", +] + [[package]] name = "fastrand" version = "1.7.0" @@ -473,6 +540,12 @@ dependencies = [ "instant", ] +[[package]] +name = "fastrand" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" + [[package]] name = "filedescriptor" version = "0.8.2" @@ -484,6 +557,18 @@ dependencies = [ "winapi", ] +[[package]] +name = "finl_unicode" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6" + +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + [[package]] name = "fnv" version = "1.0.7" @@ -544,7 +629,7 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" dependencies = [ - "fastrand", + "fastrand 1.7.0", "futures-core", "futures-io", "memchr", @@ -672,12 +757,12 @@ dependencies = [ [[package]] name = "heapless" -version = "0.5.6" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74911a68a1658cfcfb61bc0ccfbd536e3b6e906f8c2f7883ee50157e3e2184f1" +checksum = "634bd4d29cbf24424d0a4bfcbf80c6960129dc24424752a7d1d1390607023422" dependencies = [ "as-slice", - "generic-array 0.13.3", + "generic-array 0.14.5", "hash32", "stable_deref_trait", ] @@ -707,7 +792,6 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" name = "hwatch" version = "0.3.11" dependencies = [ - "ansi-parser", "async-std", "chrono", "clap", @@ -717,6 +801,7 @@ dependencies = [ "difference", "futures", "heapless", + "hwatch-ansi-parser", "question", "ratatui", "regex", @@ -727,6 +812,16 @@ dependencies = [ "termwiz", ] +[[package]] +name = "hwatch-ansi-parser" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f79b25b14f15196ed2543a380d24eb102b6292855bb36f475a959b015f4882a2" +dependencies = [ + "heapless", + "nom 4.2.3", +] + [[package]] name = "iana-time-zone" version = "0.1.60" @@ -808,6 +903,12 @@ dependencies = [ "log", ] +[[package]] +name = "lab" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf36173d4167ed999940f804952e6b08197cae5ad5d572eb4db150ce8ad5d58f" + [[package]] name = "lazy_static" version = "1.4.0" @@ -831,6 +932,12 @@ dependencies = [ "redox_syscall 0.4.1", ] +[[package]] +name = "linux-raw-sys" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" + [[package]] name = "lock_api" version = "0.4.7" @@ -860,6 +967,16 @@ dependencies = [ "hashbrown 0.14.3", ] +[[package]] +name = "mac_address" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4863ee94f19ed315bf3bc00299338d857d4b5bc856af375cc97d237382ad3856" +dependencies = [ + "nix 0.23.2", + "winapi", +] + [[package]] name = "memchr" version = "2.7.1" @@ -872,6 +989,30 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a64a92489e2744ce060c349162be1c5f33c6969234104dbd99ddb5feb08b8c15" +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + +[[package]] +name = "memoffset" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" +dependencies = [ + "autocfg", +] + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "mio" version = "0.8.3" @@ -884,6 +1025,32 @@ dependencies = [ "windows-sys 0.36.1", ] +[[package]] +name = "nix" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f3790c00a0150112de0f4cd161e3d7fc4b2d8a5542ffc35f099a2562aecb35c" +dependencies = [ + "bitflags 1.3.2", + "cc", + "cfg-if", + "libc", + "memoffset 0.6.5", +] + +[[package]] +name = "nix" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" +dependencies = [ + "bitflags 1.3.2", + "cfg-if", + "libc", + "memoffset 0.7.1", + "pin-utils", +] + [[package]] name = "nix" version = "0.27.1" @@ -907,12 +1074,12 @@ dependencies = [ [[package]] name = "nom" -version = "5.1.3" +version = "7.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08959a387a676302eebf4ddbcbc611da04285579f76f88ee0506c63b1a61dd4b" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" dependencies = [ "memchr", - "version_check 0.9.4", + "minimal-lexical", ] [[package]] @@ -941,17 +1108,11 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "opaque-debug" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" - [[package]] name = "ordered-float" -version = "2.10.1" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c" +checksum = "a76df7075c7d4d01fdcb46c912dd17fba5b60c78ea480b475f2b6ab6f666584e" dependencies = [ "num-traits", ] @@ -1008,12 +1169,47 @@ dependencies = [ "ucd-trie", ] +[[package]] +name = "pest_derive" +version = "2.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0d24f72393fd16ab6ac5738bc33cdb6a9aa73f8b902e8fe29cf4e67d7dd1026" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc17e2a6c7d0a492f0158d7a4bd66cc17280308bbaff78d5bef566dca35ab80" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn 2.0.52", +] + +[[package]] +name = "pest_meta" +version = "2.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "934cd7631c050f4674352a6e835d5f6711ffbfb9345c2fc0107155ac495ae293" +dependencies = [ + "once_cell", + "pest", + "sha2", +] + [[package]] name = "phf" version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" dependencies = [ + "phf_macros", "phf_shared", ] @@ -1037,6 +1233,19 @@ dependencies = [ "rand", ] +[[package]] +name = "phf_macros" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b" +dependencies = [ + "phf_generator", + "phf_shared", + "proc-macro2", + "quote", + "syn 2.0.52", +] + [[package]] name = "phf_shared" version = "0.11.2" @@ -1188,6 +1397,19 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +[[package]] +name = "rustix" +version = "0.38.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" +dependencies = [ + "bitflags 2.4.2", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + [[package]] name = "rustversion" version = "1.0.14" @@ -1257,15 +1479,13 @@ dependencies = [ [[package]] name = "sha2" -version = "0.9.9" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ - "block-buffer", "cfg-if", "cpufeatures", "digest", - "opaque-debug", ] [[package]] @@ -1274,16 +1494,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" -[[package]] -name = "signal-hook" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e31d442c16f047a671b5a71e2161d6e68814012b7f5379d269ebd915fac2729" -dependencies = [ - "libc", - "signal-hook-registry", -] - [[package]] name = "signal-hook" version = "0.3.17" @@ -1302,7 +1512,7 @@ checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af" dependencies = [ "libc", "mio", - "signal-hook 0.3.17", + "signal-hook", ] [[package]] @@ -1414,6 +1624,18 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "tempfile" +version = "3.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +dependencies = [ + "cfg-if", + "fastrand 2.0.1", + "rustix", + "windows-sys 0.52.0", +] + [[package]] name = "termcolor" version = "1.4.1" @@ -1425,13 +1647,13 @@ dependencies = [ [[package]] name = "terminfo" -version = "0.7.5" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da31aef70da0f6352dbcb462683eb4dd2bfad01cf3fc96cf204547b9a839a585" +checksum = "666cd3a6681775d22b200409aad3b089c5b99fb11ecdd8a204d9d62f8148498f" dependencies = [ "dirs", "fnv", - "nom 5.1.3", + "nom 7.1.3", "phf", "phf_codegen", ] @@ -1447,33 +1669,45 @@ dependencies = [ [[package]] name = "termwiz" -version = "0.15.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31ef6892cc0348a9b3b8c377addba91e0f6365863d92354bf27559dca81ee8c5" +checksum = "5a75313e21da5d4406ea31402035b3b97aa74c04356bdfafa5d1043ab4e551d1" dependencies = [ "anyhow", "base64", - "bitflags 1.3.2", - "cfg-if", + "bitflags 2.4.2", + "fancy-regex", "filedescriptor", + "finl_unicode", + "fixedbitset", "hex", "lazy_static", "libc", "log", "memmem", + "nix 0.26.4", "num-derive", "num-traits", "ordered-float", - "regex", + "pest", + "pest_derive", + "phf", "semver", "sha2", - "signal-hook 0.1.17", + "signal-hook", + "siphasher", + "tempfile", "terminfo", "termios", "thiserror", "ucd-trie", "unicode-segmentation", "vtparse", + "wezterm-bidi", + "wezterm-blob-leases", + "wezterm-color-types", + "wezterm-dynamic", + "wezterm-input-types", "winapi", ] @@ -1539,6 +1773,16 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +[[package]] +name = "uuid" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" +dependencies = [ + "atomic", + "getrandom", +] + [[package]] name = "value-bag" version = "1.0.0-alpha.9" @@ -1667,6 +1911,78 @@ dependencies = [ "cc", ] +[[package]] +name = "wezterm-bidi" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c0a6e355560527dd2d1cf7890652f4f09bb3433b6aadade4c9b5ed76de5f3ec" +dependencies = [ + "log", + "wezterm-dynamic", +] + +[[package]] +name = "wezterm-blob-leases" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5a5e0adf7eed68976410def849a4bdab6f6e9f6163f152de9cb89deea9e60b" +dependencies = [ + "getrandom", + "mac_address", + "once_cell", + "sha2", + "thiserror", + "uuid", +] + +[[package]] +name = "wezterm-color-types" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7de81ef35c9010270d63772bebef2f2d6d1f2d20a983d27505ac850b8c4b4296" +dependencies = [ + "csscolorparser", + "deltae", + "lazy_static", + "wezterm-dynamic", +] + +[[package]] +name = "wezterm-dynamic" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfb128bacfa86734e07681fb6068e34c144698e84ee022d6e009145d1abb77b5" +dependencies = [ + "log", + "ordered-float", + "strsim", + "thiserror", + "wezterm-dynamic-derive", +] + +[[package]] +name = "wezterm-dynamic-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c9f5ef318442d07b3d071f9f43ea40b80992f87faee14bb4d017b6991c307f0" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.96", +] + +[[package]] +name = "wezterm-input-types" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7012add459f951456ec9d6c7e6fc340b1ce15d6fc9629f8c42853412c029e57e" +dependencies = [ + "bitflags 1.3.2", + "euclid", + "lazy_static", + "wezterm-dynamic", +] + [[package]] name = "winapi" version = "0.3.9" diff --git a/Cargo.toml b/Cargo.toml index 931dd07..e6191dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,11 +11,11 @@ version = "0.3.11" [dependencies] # TODO: [ansi-parser](https://crates.io/crates/ansi-parser)のバージョンアップ対応が必要になるので、その対応待ち. PRはmargeされたのでいい加減アップデートされてもいいと思うのだが…. # ansi-parser = {version = "0.9.0", path = "../ansi-parser"} -ansi-parser = "0.8.0" +hwatch-ansi-parser = "0.9.0" # TODO: ansi-parserのバージョンアップグレードの対応が必要になるので、その対応をしたらバージョンアップが必要. -heapless = "0.5.6" -termwiz = "0.15.0" +heapless = "0.6.1" +termwiz = "0.22.0" async-std = {version = "1.12"} chrono = "0.4.34" diff --git a/src/ansi.rs b/src/ansi.rs index 1fa536e..d143547 100644 --- a/src/ansi.rs +++ b/src/ansi.rs @@ -109,19 +109,19 @@ pub fn bytes_to_text<'a, B: AsRef<[u8]>>(bytes: B) -> Text<'a> { ColorSpec::Default => span_style = span_style.fg(Color::Reset), ColorSpec::PaletteIndex(i) => span_style = span_style.fg(Color::Indexed(i)), ColorSpec::TrueColor(rgb) => { - let rgb_tuple = rgb.to_tuple_rgb8(); + let rgb_tuple = rgb.to_srgb_u8(); span_style = - span_style.fg(Color::Rgb(rgb_tuple.0, rgb_tuple.1, rgb_tuple.2)); + span_style.bg(Color::Rgb(rgb_tuple.0, rgb_tuple.1, rgb_tuple.2)); } }, Sgr::Background(c) => match c { ColorSpec::Default => span_style = span_style.bg(Color::Reset), ColorSpec::PaletteIndex(i) => span_style = span_style.bg(Color::Indexed(i)), ColorSpec::TrueColor(rgb) => { - let rgb_tuple = rgb.to_tuple_rgb8(); + let rgb_tuple = rgb.to_srgb_u8(); span_style = span_style.bg(Color::Rgb(rgb_tuple.0, rgb_tuple.1, rgb_tuple.2)); - } + }, }, _ => {} } diff --git a/src/main.rs b/src/main.rs index cd7503c..babb121 100644 --- a/src/main.rs +++ b/src/main.rs @@ -32,7 +32,8 @@ // - どっちにしてもデータがあるなら、stdout/stderrのとこだけで比較するような何かがあればいい??? // crate -extern crate ansi_parser; +// extern crate ansi_parser; +extern crate hwatch_ansi_parser as ansi_parser; extern crate async_std; extern crate chrono; extern crate crossbeam_channel; From 6695b35046eb3dc662bc6aa2b039e2bd18037f16 Mon Sep 17 00:00:00 2001 From: blacknon Date: Tue, 5 Mar 2024 04:51:28 +0900 Subject: [PATCH 12/13] update. change copyright year. --- Cargo.toml | 9 +++------ src/ansi.rs | 2 +- src/app.rs | 2 +- src/common.rs | 2 +- src/event.rs | 2 +- src/exec.rs | 2 +- src/header.rs | 2 +- src/help.rs | 2 +- src/history.rs | 2 +- src/main.rs | 2 +- src/output.rs | 2 +- src/view.rs | 2 +- src/watch.rs | 2 +- 13 files changed, 15 insertions(+), 18 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e6191dd..6426dca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,13 +9,9 @@ repository = "https://github.com/blacknon/hwatch" version = "0.3.11" [dependencies] -# TODO: [ansi-parser](https://crates.io/crates/ansi-parser)のバージョンアップ対応が必要になるので、その対応待ち. PRはmargeされたのでいい加減アップデートされてもいいと思うのだが…. -# ansi-parser = {version = "0.9.0", path = "../ansi-parser"} -hwatch-ansi-parser = "0.9.0" - -# TODO: ansi-parserのバージョンアップグレードの対応が必要になるので、その対応をしたらバージョンアップが必要. +# TODO: ansi-parserが正式にバージョンアップしたらそちらに切り替える heapless = "0.6.1" -termwiz = "0.22.0" +hwatch-ansi-parser = "0.9.0" async-std = {version = "1.12"} chrono = "0.4.34" @@ -31,5 +27,6 @@ serde = "1.0.197" serde_derive = "1.0.197" serde_json = "1.0.114" shell-words = "1.1.0" +termwiz = "0.22.0" ratatui = {version = "0.26.1", default-features = false, features = ['crossterm', 'unstable-rendered-line-info']} diff --git a/src/ansi.rs b/src/ansi.rs index d143547..2ea7560 100644 --- a/src/ansi.rs +++ b/src/ansi.rs @@ -1,4 +1,4 @@ -// Copyright (c) 2022 Blacknon. +// Copyright (c) 2024 Blacknon. // This code from https://github.com/blacknon/ansi4tui/blob/master/src/lib.rs use termwiz::cell::{Blink, Intensity, Underline}; diff --git a/src/app.rs b/src/app.rs index 511e82f..7cb66b9 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1,4 +1,4 @@ -// Copyright (c) 2022 Blacknon. All rights reserved. +// Copyright (c) 2024 Blacknon. All rights reserved. // Use of this source code is governed by an MIT license // that can be found in the LICENSE file. diff --git a/src/common.rs b/src/common.rs index 9976274..ce3e099 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,4 +1,4 @@ -// Copyright (c) 2022 Blacknon. All rights reserved. +// Copyright (c) 2024 Blacknon. All rights reserved. // Use of this source code is governed by an MIT license // that can be found in the LICENSE file. diff --git a/src/event.rs b/src/event.rs index d70baa4..9d2357c 100644 --- a/src/event.rs +++ b/src/event.rs @@ -1,4 +1,4 @@ -// Copyright (c) 2022 Blacknon. All rights reserved. +// Copyright (c) 2024 Blacknon. All rights reserved. // Use of this source code is governed by an MIT license // that can be found in the LICENSE file. diff --git a/src/exec.rs b/src/exec.rs index d4f43cc..3d35578 100644 --- a/src/exec.rs +++ b/src/exec.rs @@ -1,4 +1,4 @@ -// Copyright (c) 2022 Blacknon. All rights reserved. +// Copyright (c) 2024 Blacknon. All rights reserved. // Use of this source code is governed by an MIT license // that can be found in the LICENSE file. diff --git a/src/header.rs b/src/header.rs index ceed7bd..0614670 100644 --- a/src/header.rs +++ b/src/header.rs @@ -1,4 +1,4 @@ -// Copyright (c) 2022 Blacknon. All rights reserved. +// Copyright (c) 2024 Blacknon. All rights reserved. // Use of this source code is governed by an MIT license // that can be found in the LICENSE file. diff --git a/src/help.rs b/src/help.rs index 47f8327..f762c7e 100644 --- a/src/help.rs +++ b/src/help.rs @@ -1,4 +1,4 @@ -// Copyright (c) 2022 Blacknon. All rights reserved. +// Copyright (c) 2024 Blacknon. All rights reserved. // Use of this source code is governed by an MIT license // that can be found in the LICENSE file. diff --git a/src/history.rs b/src/history.rs index 035a3be..7d4164b 100644 --- a/src/history.rs +++ b/src/history.rs @@ -1,4 +1,4 @@ -// Copyright (c) 2022 Blacknon. All rights reserved. +// Copyright (c) 2024 Blacknon. All rights reserved. // Use of this source code is governed by an MIT license // that can be found in the LICENSE file. diff --git a/src/main.rs b/src/main.rs index babb121..1c3cd5e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -// Copyright (c) 2022 Blacknon. All rights reserved. +// Copyright (c) 2024 Blacknon. All rights reserved. // Use of this source code is governed by an MIT license // that can be found in the LICENSE file. diff --git a/src/output.rs b/src/output.rs index c9d5af8..628d498 100644 --- a/src/output.rs +++ b/src/output.rs @@ -1,4 +1,4 @@ -// Copyright (c) 2022 Blacknon. All rights reserved. +// Copyright (c) 2024 Blacknon. All rights reserved. // Use of this source code is governed by an MIT license // that can be found in the LICENSE file. diff --git a/src/view.rs b/src/view.rs index eb04323..dcbafa9 100644 --- a/src/view.rs +++ b/src/view.rs @@ -1,4 +1,4 @@ -// Copyright (c) 2022 Blacknon. All rights reserved. +// Copyright (c) 2024 Blacknon. All rights reserved. // Use of this source code is governed by an MIT license // that can be found in the LICENSE file. diff --git a/src/watch.rs b/src/watch.rs index 3f0a8d6..27efd5d 100644 --- a/src/watch.rs +++ b/src/watch.rs @@ -1,4 +1,4 @@ -// Copyright (c) 2022 Blacknon. All rights reserved. +// Copyright (c) 2024 Blacknon. All rights reserved. // Use of this source code is governed by an MIT license // that can be found in the LICENSE file. From c75aa348b7861bd0ac062c416563d20a73a5fb2c Mon Sep 17 00:00:00 2001 From: blacknon Date: Tue, 5 Mar 2024 04:56:17 +0900 Subject: [PATCH 13/13] update. delete commentout. --- src/main.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1c3cd5e..e57d2c9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,9 +2,6 @@ // Use of this source code is governed by an MIT license // that can be found in the LICENSE file. -// v0.3.11 -// TODO(blacknon): セキュリティのため、heaplessのバージョンを上げる - // v0.3.12 // TODO(blacknon): pagedown/pageupスクロールの実装 // TODO(blacknon): scrollで一番↓まで行くとき、ページの一番下がターミナルの最終行になるように変更する