diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/config.rs | 2 | ||||
-rw-r--r-- | src/main.rs | 4 | ||||
-rw-r--r-- | src/term.rs | 13 | ||||
-rw-r--r-- | src/tui/views.rs | 24 |
4 files changed, 24 insertions, 19 deletions
diff --git a/src/config.rs b/src/config.rs index d5dfe22..c783647 100644 --- a/src/config.rs +++ b/src/config.rs @@ -92,7 +92,7 @@ impl Config { /// Get project directory pub fn project_dir() -> Result<ProjectDirs> { - ProjectDirs::from("io", "Sam Tay", "so").ok_or_else(|| Error::ProjectDir) + ProjectDirs::from("io", "Sam Tay", "so").ok_or(Error::ProjectDir) } // TODO consider switching to .toml to be consistent with colors.toml diff --git a/src/main.rs b/src/main.rs index 8a139af..130a53b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,8 +17,8 @@ use tui::markdown::Markdown; fn main() -> Result<()> { // Tokio runtime - let mut rt = Runtime::new()?; - rt.block_on(run()) + Runtime::new()? + .block_on(run()) .and_then(|qs| { // Run TUI qs.map(tui::run); diff --git a/src/term.rs b/src/term.rs index 86c0f4c..ff537c4 100644 --- a/src/term.rs +++ b/src/term.rs @@ -4,7 +4,7 @@ use crossterm::terminal::ClearType; use crossterm::{cursor, execute, terminal}; use futures::Future; use std::io::{stderr, Write}; -use termimad::{CompoundStyle, MadSkin}; +use termimad::{CompoundStyle, LineStyle, MadSkin}; use tokio::sync::{ oneshot, oneshot::{error::TryRecvError, Receiver, Sender}, @@ -39,9 +39,14 @@ struct Spinner { impl Term { pub fn new() -> Self { - let mut skin = MadSkin::default(); - skin.inline_code = CompoundStyle::with_fg(Color::Cyan); - skin.code_block.compound_style = CompoundStyle::with_fg(Color::Cyan); + let skin = MadSkin { + inline_code: CompoundStyle::with_fg(Color::Cyan), + code_block: LineStyle { + compound_style: CompoundStyle::with_fg(Color::Cyan), + ..Default::default() + }, + ..Default::default() + }; Term { skin } } diff --git a/src/tui/views.rs b/src/tui/views.rs index 7d1593d..62b8af1 100644 --- a/src/tui/views.rs +++ b/src/tui/views.rs @@ -88,13 +88,13 @@ impl<T: View> ViewWrapper for ListViewT<T> { // Always take arrow keys, its jarring to have them move pane focus fn wrap_on_event(&mut self, event: Event) -> EventResult { - let should_consume = match event { + let should_consume = matches!( + event, Event::Key(Key::Right) - | Event::Key(Key::Left) - | Event::Key(Key::Down) - | Event::Key(Key::Up) => true, - _ => false, - }; + | Event::Key(Key::Left) + | Event::Key(Key::Down) + | Event::Key(Key::Up) + ); match self.view.on_event(event) { EventResult::Ignored if should_consume => EventResult::Consumed(None), @@ -210,13 +210,13 @@ impl<T: View> ViewWrapper for MdViewT<T> { // Always take arrow keys, its jarring to have them move pane focus fn wrap_on_event(&mut self, event: Event) -> EventResult { - let should_consume = match event { + let should_consume = matches!( + event, Event::Key(Key::Right) - | Event::Key(Key::Left) - | Event::Key(Key::Down) - | Event::Key(Key::Up) => true, - _ => false, - }; + | Event::Key(Key::Left) + | Event::Key(Key::Down) + | Event::Key(Key::Up) + ); match self.view.on_event(event) { EventResult::Ignored if should_consume => EventResult::Consumed(None), |