diff --git a/TODO.md b/TODO.md index 1cf60b7..f8035c0 100644 --- a/TODO.md +++ b/TODO.md @@ -33,8 +33,10 @@ - [x] support for images is implemented but do we really want that in the core? it's quite heavy - [x] shrink entry names that are too long (from the middle) +- [ ] more syntaxes for the previewer https://www.sublimetext.com/docs/syntax.html#include-syntax +- [ ] more preview colorschemes -## feature ideas +## features - [x] environment variables - [x] aliases diff --git a/crates/television/channels/text.rs b/crates/television/channels/text.rs index 015b3f1..db78d43 100644 --- a/crates/television/channels/text.rs +++ b/crates/television/channels/text.rs @@ -110,11 +110,7 @@ impl Channel { ); let injector = matcher.injector(); let load_handle = tokio::spawn(async move { - let mut lines_in_mem = 0; - for entry in entries { - if lines_in_mem > MAX_LINES_IN_MEM { - break; - } + for entry in entries.into_iter().take(MAX_LINES_IN_MEM) { injector.push( CandidateLine::new( entry.display_name().into(), @@ -125,7 +121,6 @@ impl Channel { cols[0] = c.line.clone().into(); }, ); - lines_in_mem += 1; } }); @@ -224,7 +219,7 @@ impl OnAir for Channel { .matched_items( offset ..(num_entries + offset) - .min(snapshot.matched_item_count()), + .min(snapshot.matched_item_count()), ) .map(move |item| { snapshot.pattern().column_pattern(0).indices( @@ -243,11 +238,11 @@ impl OnAir for Channel { display_path.clone() + &item.data.line_number.to_string(), PreviewType::Files, ) - .with_display_name(display_path) - .with_value(line) - .with_value_match_ranges(indices.map(|i| (i, i + 1)).collect()) - .with_icon(FileIcon::from(item.data.path.as_path())) - .with_line_number(item.data.line_number) + .with_display_name(display_path) + .with_value(line) + .with_value_match_ranges(indices.map(|i| (i, i + 1)).collect()) + .with_icon(FileIcon::from(item.data.path.as_path())) + .with_line_number(item.data.line_number) }) .collect() } @@ -369,7 +364,7 @@ fn try_inject_lines( if (bytes_read == 0) || is_not_text(&buffer).unwrap_or(false) || proportion_of_printable_ascii_characters(&buffer) - < PRINTABLE_ASCII_THRESHOLD + < PRINTABLE_ASCII_THRESHOLD { return None; } diff --git a/crates/television/television.rs b/crates/television/television.rs index af9ceb7..b9837c0 100644 --- a/crates/television/television.rs +++ b/crates/television/television.rs @@ -333,14 +333,11 @@ impl Television { } } } - Action::CopyEntryToClipboard => match self.mode { - Mode::Channel => { - if let Some(entry) = self.get_selected_entry(None) { - let mut ctx = ClipboardContext::new().unwrap(); - ctx.set_contents(entry.name).unwrap(); - } + Action::CopyEntryToClipboard => if self.mode == Mode::Channel { + if let Some(entry) = self.get_selected_entry(None) { + let mut ctx = ClipboardContext::new().unwrap(); + ctx.set_contents(entry.name).unwrap(); } - _ => {} }, Action::ToggleSendToChannel => match self.mode { Mode::Channel | Mode::RemoteControl => { diff --git a/crates/television/ui/layout.rs b/crates/television/ui/layout.rs index af6620f..0bf83a6 100644 --- a/crates/television/ui/layout.rs +++ b/crates/television/ui/layout.rs @@ -30,6 +30,7 @@ pub struct Layout { } impl Layout { + #[allow(clippy::too_many_arguments)] pub fn new( help_bar_left: Rect, help_bar_middle: Rect, diff --git a/crates/television/ui/preview.rs b/crates/television/ui/preview.rs index 2b250a1..86dc4e0 100644 --- a/crates/television/ui/preview.rs +++ b/crates/television/ui/preview.rs @@ -98,7 +98,7 @@ impl Television { let preview_block = self.build_preview_paragraph( preview_inner_block, inner, - &preview, + preview, selected_entry .line_number .map(|l| u16::try_from(l).unwrap_or(0)), @@ -174,9 +174,9 @@ impl Television { self.preview_scroll.unwrap_or(0), self.preview_pane_height, ) - .block(preview_block) - .alignment(Alignment::Left) - .scroll((self.preview_scroll.unwrap_or(0), 0)) + .block(preview_block) + .alignment(Alignment::Left) + .scroll((self.preview_scroll.unwrap_or(0), 0)) } // meta PreviewContent::Loading => self diff --git a/crates/television_derive/src/lib.rs b/crates/television_derive/src/lib.rs index 5e9520a..e4a23a0 100644 --- a/crates/television_derive/src/lib.rs +++ b/crates/television_derive/src/lib.rs @@ -4,7 +4,7 @@ use quote::quote; /// This macro generates a `CliChannel` enum and the necessary glue code /// to convert into a `TelevisionChannel` member: /// -/// ```rust +/// ```ignore /// use crate::channels::{TelevisionChannel, OnAir}; /// use television_derive::ToCliChannel; /// use crate::channels::{files, text}; @@ -122,7 +122,7 @@ fn impl_cli_channel(ast: &syn::DeriveInput) -> TokenStream { /// and forwards the method calls to the corresponding channel variants. /// /// Example: -/// ```rust +/// ```ignore /// use television_derive::Broadcast; /// use crate::channels::{TelevisionChannel, OnAir}; /// use crate::channels::{files, text};