From 35830ecbc058dc1a6c31d022a7633daa54cf4ff0 Mon Sep 17 00:00:00 2001 From: Erik Kundt Date: Thu, 20 Jun 2024 14:43:01 +0200 Subject: [PATCH] bin: Adjust to new textarea --- bin/commands/inbox/select.rs | 52 ++++++++++++++++++---------------- bin/commands/issue/select.rs | 52 ++++++++++++++++++---------------- bin/commands/patch/select.rs | 54 +++++++++++++++++++----------------- 3 files changed, 85 insertions(+), 73 deletions(-) diff --git a/bin/commands/inbox/select.rs b/bin/commands/inbox/select.rs index da768227..8dc7903c 100644 --- a/bin/commands/inbox/select.rs +++ b/bin/commands/inbox/select.rs @@ -26,7 +26,7 @@ use tui::store; use tui::store::StateValue; use tui::ui::span; use tui::ui::widget::container::{Column, Container, Footer, FooterProps, Header, HeaderProps}; -use tui::ui::widget::text::{TextArea, TextAreaProps}; +use tui::ui::widget::input::{TextArea, TextAreaProps}; use tui::ui::widget::window::{Page, PageProps, Shortcuts, ShortcutsProps, Window, WindowProps}; use tui::ui::widget::{ToWidget, Widget}; use tui::{BoxedAny, Channel, Exit, PageStack}; @@ -83,6 +83,7 @@ impl BrowserState { #[derive(Clone, Debug)] pub struct HelpState { scroll: usize, + cursor: (usize, usize), } #[derive(Clone, Debug)] @@ -196,7 +197,10 @@ impl TryFrom<&Context> for State { search, show_search: false, }, - help: HelpState { scroll: 0 }, + help: HelpState { + scroll: 0, + cursor: (0, 0), + }, }) } } @@ -219,6 +223,7 @@ pub enum Message { LeavePage, ScrollHelp { scroll: usize, + cursor: (usize, usize), }, } @@ -273,8 +278,9 @@ impl store::State for State { self.pages.pop(); None } - Message::ScrollHelp { scroll } => { + Message::ScrollHelp { scroll, cursor } => { self.help.scroll = scroll; + self.help.cursor = cursor; None } } @@ -378,13 +384,13 @@ fn help_page(_state: &State, channel: &Channel) -> Widget Text<'static> { Line::raw(""), Line::from(vec![ Span::raw(format!("{key:>10}", key = "↑,k")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("move cursor one line up").gray().dim(), ]), Line::from(vec![ Span::raw(format!("{key:>10}", key = "↓,j")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("move cursor one line down").gray().dim(), ]), Line::from(vec![ Span::raw(format!("{key:>10}", key = "PageUp")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("move cursor one page up").gray().dim(), ]), Line::from(vec![ Span::raw(format!("{key:>10}", key = "PageDown")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("move cursor one page down").gray().dim(), ]), Line::from(vec![ Span::raw(format!("{key:>10}", key = "Home")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("move cursor to the first line").gray().dim(), ]), Line::from(vec![ Span::raw(format!("{key:>10}", key = "End")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("move cursor to the last line").gray().dim(), ]), Line::raw(""), @@ -469,32 +475,32 @@ fn help_text() -> Text<'static> { Line::raw(""), Line::from(vec![ Span::raw(format!("{key:>10}", key = "enter")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("Select notification (if --mode id)").gray().dim(), ]), Line::from(vec![ Span::raw(format!("{key:>10}", key = "enter")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("Show notification").gray().dim(), ]), Line::from(vec![ Span::raw(format!("{key:>10}", key = "c")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("Clear notifications").gray().dim(), ]), Line::from(vec![ Span::raw(format!("{key:>10}", key = "/")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("Search").gray().dim(), ]), Line::from(vec![ Span::raw(format!("{key:>10}", key = "?")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("Show help").gray().dim(), ]), Line::from(vec![ Span::raw(format!("{key:>10}", key = "Esc")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("Quit / cancel").gray().dim(), ]), Line::raw(""), @@ -502,18 +508,16 @@ fn help_text() -> Text<'static> { Line::raw(""), Line::from(vec![ Span::raw(format!("{key:>10}", key = "Pattern")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("is: | is:patch | is:issue | ") .gray() .dim(), ]), Line::from(vec![ Span::raw(format!("{key:>10}", key = "Example")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("is:unseen is:patch Print").gray().dim(), ]), - Line::raw(""), - Line::raw(""), ] .to_vec(), ) diff --git a/bin/commands/issue/select.rs b/bin/commands/issue/select.rs index 7621f009..ba068e49 100644 --- a/bin/commands/issue/select.rs +++ b/bin/commands/issue/select.rs @@ -21,7 +21,7 @@ use tui::store; use tui::store::StateValue; use tui::ui::span; use tui::ui::widget::container::{Column, Container, Footer, FooterProps, Header, HeaderProps}; -use tui::ui::widget::text::{TextArea, TextAreaProps}; +use tui::ui::widget::input::{TextArea, TextAreaProps}; use tui::ui::widget::window::{Page, PageProps, Shortcuts, ShortcutsProps, Window, WindowProps}; use tui::ui::widget::{ToWidget, Widget}; @@ -77,6 +77,7 @@ impl BrowserState { #[derive(Clone, Debug)] pub struct HelpState { scroll: usize, + cursor: (usize, usize), } #[derive(Clone, Debug)] @@ -115,7 +116,10 @@ impl TryFrom<&Context> for State { search, show_search: false, }, - help: HelpState { scroll: 0 }, + help: HelpState { + scroll: 0, + cursor: (0, 0), + }, }) } } @@ -138,6 +142,7 @@ pub enum Message { LeavePage, ScrollHelp { scroll: usize, + cursor: (usize, usize), }, } @@ -192,8 +197,9 @@ impl store::State for State { self.pages.pop(); None } - Message::ScrollHelp { scroll } => { + Message::ScrollHelp { scroll, cursor } => { self.help.scroll = scroll; + self.help.cursor = cursor; None } } @@ -297,13 +303,13 @@ fn help_page(_state: &State, channel: &Channel) -> Widget Text<'static> { Line::from( [ Span::raw(format!("{key:>10}", key = "↑,k")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("move cursor one line up").gray().dim(), ] .to_vec(), @@ -364,7 +370,7 @@ fn help_text() -> Text<'static> { Line::from( [ Span::raw(format!("{key:>10}", key = "↓,j")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("move cursor one line down").gray().dim(), ] .to_vec(), @@ -372,7 +378,7 @@ fn help_text() -> Text<'static> { Line::from( [ Span::raw(format!("{key:>10}", key = "PageUp")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("move cursor one page up").gray().dim(), ] .to_vec(), @@ -380,7 +386,7 @@ fn help_text() -> Text<'static> { Line::from( [ Span::raw(format!("{key:>10}", key = "PageDown")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("move cursor one page down").gray().dim(), ] .to_vec(), @@ -388,7 +394,7 @@ fn help_text() -> Text<'static> { Line::from( [ Span::raw(format!("{key:>10}", key = "Home")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("move cursor to the first line").gray().dim(), ] .to_vec(), @@ -396,7 +402,7 @@ fn help_text() -> Text<'static> { Line::from( [ Span::raw(format!("{key:>10}", key = "End")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("move cursor to the last line").gray().dim(), ] .to_vec(), @@ -407,7 +413,7 @@ fn help_text() -> Text<'static> { Line::from( [ Span::raw(format!("{key:>10}", key = "enter")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("Select issue (if --mode id)").gray().dim(), ] .to_vec(), @@ -415,7 +421,7 @@ fn help_text() -> Text<'static> { Line::from( [ Span::raw(format!("{key:>10}", key = "enter")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("Show issue").gray().dim(), ] .to_vec(), @@ -423,7 +429,7 @@ fn help_text() -> Text<'static> { Line::from( [ Span::raw(format!("{key:>10}", key = "e")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("Edit patch").gray().dim(), ] .to_vec(), @@ -431,7 +437,7 @@ fn help_text() -> Text<'static> { Line::from( [ Span::raw(format!("{key:>10}", key = "/")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("Search").gray().dim(), ] .to_vec(), @@ -439,7 +445,7 @@ fn help_text() -> Text<'static> { Line::from( [ Span::raw(format!("{key:>10}", key = "?")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("Show help").gray().dim(), ] .to_vec(), @@ -447,7 +453,7 @@ fn help_text() -> Text<'static> { Line::from( [ Span::raw(format!("{key:>10}", key = "Esc")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("Quit / cancel").gray().dim(), ] .to_vec(), @@ -458,7 +464,7 @@ fn help_text() -> Text<'static> { Line::from( [ Span::raw(format!("{key:>10}", key = "Pattern")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("is: | is:authored | is:assigned | authors:[, ...] | assignees:[, ...] | ") .gray() .dim(), @@ -468,13 +474,11 @@ fn help_text() -> Text<'static> { Line::from( [ Span::raw(format!("{key:>10}", key = "Example")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("is:solved is:authored alias").gray().dim(), ] .to_vec(), ), - Line::raw(""), - Line::raw(""), ] .to_vec()) } diff --git a/bin/commands/patch/select.rs b/bin/commands/patch/select.rs index 67957c65..8c160647 100644 --- a/bin/commands/patch/select.rs +++ b/bin/commands/patch/select.rs @@ -19,7 +19,7 @@ use termion::event::Key; use tui::store; use tui::ui::span; use tui::ui::widget::container::{Column, Container, Footer, FooterProps, Header, HeaderProps}; -use tui::ui::widget::text::{TextArea, TextAreaProps}; +use tui::ui::widget::input::{TextArea, TextAreaProps}; use tui::ui::widget::window::{Page, PageProps, Shortcuts, ShortcutsProps, Window, WindowProps}; use tui::ui::widget::{ToWidget, Widget}; @@ -74,6 +74,7 @@ impl BrowserState { #[derive(Clone, Debug)] pub struct HelpState { scroll: usize, + cursor: (usize, usize), } #[derive(Clone, Debug)] @@ -112,7 +113,10 @@ impl TryFrom<&Context> for State { search, show_search: false, }, - help: HelpState { scroll: 0 }, + help: HelpState { + scroll: 0, + cursor: (0, 0), + }, }) } } @@ -135,6 +139,7 @@ pub enum Message { LeavePage, ScrollHelp { scroll: usize, + cursor: (usize, usize), }, } @@ -189,8 +194,9 @@ impl store::State for State { self.pages.pop(); None } - Message::ScrollHelp { scroll } => { + Message::ScrollHelp { scroll, cursor } => { self.help.scroll = scroll; + self.help.cursor = cursor; None } } @@ -295,13 +301,13 @@ fn help_page(_state: &State, channel: &Channel) -> Widget Text<'static> { Line::raw(""), Line::from(vec![ Span::raw(format!("{key:>10}", key = "↑,k")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("move cursor one line up").gray().dim(), ]), Line::from(vec![ Span::raw(format!("{key:>10}", key = "↓,j")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("move cursor one line down").gray().dim(), ]), Line::from(vec![ Span::raw(format!("{key:>10}", key = "PageUp")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("move cursor one page up").gray().dim(), ]), Line::from(vec![ Span::raw(format!("{key:>10}", key = "PageDown")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("move cursor one page down").gray().dim(), ]), Line::from(vec![ Span::raw(format!("{key:>10}", key = "Home")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("move cursor to the first line").gray().dim(), ]), Line::from(vec![ Span::raw(format!("{key:>10}", key = "End")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("move cursor to the last line").gray().dim(), ]), Line::raw(""), @@ -386,37 +392,37 @@ fn help_text() -> Text<'static> { Line::raw(""), Line::from(vec![ Span::raw(format!("{key:>10}", key = "enter")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("Select patch (if --mode id)").gray().dim(), ]), Line::from(vec![ Span::raw(format!("{key:>10}", key = "enter")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("Show patch").gray().dim(), ]), Line::from(vec![ Span::raw(format!("{key:>10}", key = "c")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("Checkout patch").gray().dim(), ]), Line::from(vec![ Span::raw(format!("{key:>10}", key = "d")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("Show patch diff").gray().dim(), ]), Line::from(vec![ Span::raw(format!("{key:>10}", key = "/")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("Search").gray().dim(), ]), Line::from(vec![ Span::raw(format!("{key:>10}", key = "?")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("Show help").gray().dim(), ]), Line::from(vec![ Span::raw(format!("{key:>10}", key = "Esc")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("Quit / cancel").gray().dim(), ]), Line::raw(""), @@ -424,18 +430,16 @@ fn help_text() -> Text<'static> { Line::raw(""), Line::from(vec![ Span::raw(format!("{key:>10}", key = "Pattern")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("is: | is:authored | authors:[, ] | ") .gray() .dim(), ]), Line::from(vec![ Span::raw(format!("{key:>10}", key = "Example")).gray(), - Span::raw(" "), + Span::raw(": "), Span::raw("is:open is:authored improve").gray().dim(), ]), - Line::raw(""), - Line::raw(""), ] .to_vec(), )