This commit is contained in:
John Smith 2023-06-21 01:10:18 -04:00
parent 1c8ecab2b6
commit ebeba23c5d
3 changed files with 28 additions and 44 deletions

31
Cargo.lock generated
View File

@ -1502,7 +1502,7 @@ dependencies = [
"flexi_logger", "flexi_logger",
"lazy_static", "lazy_static",
"log", "log",
"time 0.3.22", "time 0.3.9",
"unicode-width", "unicode-width",
] ]
@ -1544,7 +1544,7 @@ dependencies = [
"owning_ref", "owning_ref",
"serde_json", "serde_json",
"serde_yaml", "serde_yaml",
"time 0.3.22", "time 0.3.9",
"tokio 1.28.2", "tokio 1.28.2",
"toml 0.7.4", "toml 0.7.4",
"unicode-segmentation", "unicode-segmentation",
@ -2055,7 +2055,7 @@ dependencies = [
"regex", "regex",
"rustversion", "rustversion",
"thiserror", "thiserror",
"time 0.3.22", "time 0.3.9",
] ]
[[package]] [[package]]
@ -5311,7 +5311,7 @@ checksum = "acee08041c5de3d5048c8b3f6f13fafb3026b24ba43c6a695a0c76179b844369"
dependencies = [ dependencies = [
"log", "log",
"termcolor", "termcolor",
"time 0.3.22", "time 0.3.9",
] ]
[[package]] [[package]]
@ -5662,24 +5662,16 @@ dependencies = [
[[package]] [[package]]
name = "time" name = "time"
version = "0.3.22" version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea9e1b3cf1243ae005d9e74085d4d542f3125458f3a81af210d901dcd7411efd" checksum = "c2702e08a7a860f005826c6815dcac101b19b5eb330c27fe4a5928fec1d20ddd"
dependencies = [ dependencies = [
"itoa", "itoa",
"libc", "libc",
"num_threads", "num_threads",
"serde", "time-macros 0.2.4",
"time-core",
"time-macros 0.2.9",
] ]
[[package]]
name = "time-core"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb"
[[package]] [[package]]
name = "time-macros" name = "time-macros"
version = "0.1.1" version = "0.1.1"
@ -5692,12 +5684,9 @@ dependencies = [
[[package]] [[package]]
name = "time-macros" name = "time-macros"
version = "0.2.9" version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b" checksum = "42657b1a6f4d817cda8e7a0ace261fe0cc946cf3a80314390b22cc61ae080792"
dependencies = [
"time-core",
]
[[package]] [[package]]
name = "time-macros-impl" name = "time-macros-impl"
@ -6009,7 +5998,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09d48f71a791638519505cefafe162606f706c25592e4bde4d97600c0195312e" checksum = "09d48f71a791638519505cefafe162606f706c25592e4bde4d97600c0195312e"
dependencies = [ dependencies = [
"crossbeam-channel", "crossbeam-channel",
"time 0.3.22", "time 0.3.9",
"tracing-subscriber", "tracing-subscriber",
] ]

@ -1 +1 @@
Subproject commit effa60cea24e99f294865ed325ffc57612d72785 Subproject commit 1eaa0814e0dd7e585b50c5d4e6e7cb9474d7a758

View File

@ -345,18 +345,19 @@ impl UI {
return; return;
} }
// run command // run command
cursive_flexi_logger_view::push_to_log(StyledString::styled(
cursive_flexi_logger_view::parse_lines_to_log(
ColorStyle::primary().into(),
format!("> {}", text), format!("> {}", text),
ColorStyle::primary(), );
));
match Self::run_command(s, text) { match Self::run_command(s, text) {
Ok(_) => {} Ok(_) => {}
Err(e) => { Err(e) => {
let color = *Self::inner_mut(s).log_colors.get(&Level::Error).unwrap(); let color = *Self::inner_mut(s).log_colors.get(&Level::Error).unwrap();
cursive_flexi_logger_view::push_to_log(StyledString::styled( cursive_flexi_logger_view::parse_lines_to_log(
color.into(),
format!(" Error: {}", e), format!(" Error: {}", e),
color, );
));
} }
} }
// save to history unless it's a duplicate // save to history unless it's a duplicate
@ -459,16 +460,16 @@ impl UI {
// X11/Wayland/other system copy // X11/Wayland/other system copy
if clipboard.set_text(text.as_ref()).is_ok() { if clipboard.set_text(text.as_ref()).is_ok() {
let color = *Self::inner_mut(s).log_colors.get(&Level::Info).unwrap(); let color = *Self::inner_mut(s).log_colors.get(&Level::Info).unwrap();
cursive_flexi_logger_view::push_to_log(StyledString::styled( cursive_flexi_logger_view::parse_lines_to_log(
color.into(),
format!(">> Copied: {}", text.as_ref()), format!(">> Copied: {}", text.as_ref()),
color, );
));
} else { } else {
let color = *Self::inner_mut(s).log_colors.get(&Level::Warn).unwrap(); let color = *Self::inner_mut(s).log_colors.get(&Level::Warn).unwrap();
cursive_flexi_logger_view::push_to_log(StyledString::styled( cursive_flexi_logger_view::parse_lines_to_log(
color.into(),
format!(">> Could not copy to clipboard"), format!(">> Could not copy to clipboard"),
color, );
));
} }
} else { } else {
// OSC52 clipboard copy for terminals // OSC52 clipboard copy for terminals
@ -484,10 +485,10 @@ impl UI {
{ {
if std::io::stdout().flush().is_ok() { if std::io::stdout().flush().is_ok() {
let color = *Self::inner_mut(s).log_colors.get(&Level::Info).unwrap(); let color = *Self::inner_mut(s).log_colors.get(&Level::Info).unwrap();
cursive_flexi_logger_view::push_to_log(StyledString::styled( cursive_flexi_logger_view::parse_lines_to_log(
color.into(),
format!(">> Copied: {}", text.as_ref()), format!(">> Copied: {}", text.as_ref()),
color, );
));
} }
} }
} }
@ -1024,13 +1025,7 @@ impl UISender {
{ {
let inner = self.inner.lock(); let inner = self.inner.lock();
let color = *inner.log_colors.get(&log_color).unwrap(); let color = *inner.log_colors.get(&log_color).unwrap();
let mut starting_style: Style = color.into(); cursive_flexi_logger_view::parse_lines_to_log(color.into(), event);
for line in event.lines() {
let (spanned_string, end_style) =
cursive::utils::markup::ansi::parse_with_starting_style(starting_style, line);
cursive_flexi_logger_view::push_to_log(spanned_string);
starting_style = end_style;
}
} }
let _ = self.cb_sink.send(Box::new(UI::update_cb)); let _ = self.cb_sink.send(Box::new(UI::update_cb));
} }