From d43996d04976f598c3c2167e7ba771486e019348 Mon Sep 17 00:00:00 2001 From: cool-mist Date: Tue, 22 Jul 2025 00:21:27 +0530 Subject: [PATCH] Better controls, mark unread --- src/ui/articles.rs | 30 ++++++++++-------------------- src/ui/controls.rs | 2 ++ 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/ui/articles.rs b/src/ui/articles.rs index 68bfe99..0372706 100644 --- a/src/ui/articles.rs +++ b/src/ui/articles.rs @@ -60,20 +60,20 @@ impl<'a> Widget for ArticlesWidget<'a> { let mut lines = Vec::new(); let id = Span::styled( format!("{:>3}. ", idx + 1), - get_channel_id_style(current_highlighted), + get_article_id_style(current_highlighted), ); let title = Span::styled( article.title.clone(), - get_channel_title_style(current_highlighted), + get_article_title_style(current_highlighted), ); - lines.push(Line::from(vec![id, title])); - if let Some(pub_date) = article.pub_date { - let pub_date_text = format!("Published: {}", pub_date); - let pub_date_span = Span::styled(pub_date_text, get_channel_pub_date_style(false)); - lines.push(Line::from(vec![pub_date_span])); - } + let unread = if article.unread { + Span::styled(" (unread)", Style::default().fg(Color::Red)) + } else { + Span::raw("") + }; + lines.push(Line::from(vec![id, title, unread])); let para = Paragraph::new(lines) .block(Block::default()) .style(get_channel_list_item_block_style(current_highlighted)) @@ -83,7 +83,7 @@ impl<'a> Widget for ArticlesWidget<'a> { } } -fn get_channel_id_style(highlighted: bool) -> Style { +fn get_article_id_style(highlighted: bool) -> Style { if highlighted { Style::default() .fg(Color::Black) @@ -103,17 +103,7 @@ fn get_channel_list_item_block_style(highlighted: bool) -> Style { } } -fn get_channel_pub_date_style(highlighted: bool) -> Style { - if highlighted { - Style::default() - .fg(Color::Black) - .add_modifier(Modifier::BOLD) - } else { - Style::default() - } -} - -fn get_channel_title_style(highlighted: bool) -> Style { +fn get_article_title_style(highlighted: bool) -> Style { if highlighted { Style::default() .fg(Color::Black) diff --git a/src/ui/controls.rs b/src/ui/controls.rs index b0394b4..21ade21 100644 --- a/src/ui/controls.rs +++ b/src/ui/controls.rs @@ -32,6 +32,8 @@ pub fn parse_ui_action(raw_event: Event) -> UiAction { return match key_event.code { KeyCode::Char('l') => UiAction::FocusPaneRight, KeyCode::Char('h') => UiAction::FocusPaneLeft, + KeyCode::Char('k') => UiAction::FocusEntryUp, + KeyCode::Char('j') => UiAction::FocusEntryDown, KeyCode::Char('d') => UiAction::ToggleDebug, KeyCode::Char('q') => UiAction::Exit, KeyCode::Enter => UiAction::OpenArticle,