From 60ba75f1dbab2189ad33a590ea0c6cc0eee3a29a Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Fri, 22 May 2020 18:02:25 +0200 Subject: [PATCH] fix stash msg popup title/msg --- src/components/commit.rs | 6 +++++- src/components/stashmsg.rs | 6 +++++- src/components/textinput.rs | 14 +++++++++++--- src/strings.rs | 2 ++ 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/components/commit.rs b/src/components/commit.rs index 5468179a..8f023a7f 100644 --- a/src/components/commit.rs +++ b/src/components/commit.rs @@ -80,7 +80,11 @@ impl CommitComponent { pub fn new(queue: Queue, theme: &Theme) -> Self { Self { queue, - input: TextInputComponent::new(theme), + input: TextInputComponent::new( + theme, + strings::COMMIT_TITLE, + strings::COMMIT_MSG, + ), } } diff --git a/src/components/stashmsg.rs b/src/components/stashmsg.rs index d603955c..eb9be7de 100644 --- a/src/components/stashmsg.rs +++ b/src/components/stashmsg.rs @@ -96,7 +96,11 @@ impl StashMsgComponent { Self { options: StashingOptions::default(), queue, - input: TextInputComponent::new(theme), + input: TextInputComponent::new( + theme, + strings::STASH_POPUP_TITLE, + strings::STASH_POPUP_MSG, + ), } } } diff --git a/src/components/textinput.rs b/src/components/textinput.rs index 4fe7ba1d..1d418aba 100644 --- a/src/components/textinput.rs +++ b/src/components/textinput.rs @@ -18,6 +18,8 @@ use tui::{ /// primarily a subcomponet for user input of text (used in `CommitComponent`) pub struct TextInputComponent { + title: String, + default_msg: String, msg: String, visible: bool, theme: Theme, @@ -25,11 +27,17 @@ pub struct TextInputComponent { impl TextInputComponent { /// - pub fn new(theme: &Theme) -> Self { + pub fn new( + theme: &Theme, + title: &str, + default_msg: &str, + ) -> Self { Self { msg: String::default(), visible: false, theme: *theme, + title: title.to_string(), + default_msg: default_msg.to_string(), } } @@ -49,7 +57,7 @@ impl DrawableComponent for TextInputComponent { if self.visible { let txt = if self.msg.is_empty() { [Text::Styled( - Cow::from(strings::COMMIT_MSG), + Cow::from(self.default_msg.as_str()), self.theme.text(false, false), )] } else { @@ -62,7 +70,7 @@ impl DrawableComponent for TextInputComponent { let area = ui::centered_rect(60, 20, f.size()); f.render_widget(Clear, area); f.render_widget( - dialog_paragraph(strings::COMMIT_TITLE, txt.iter()), + dialog_paragraph(self.title.as_str(), txt.iter()), area, ); } diff --git a/src/strings.rs b/src/strings.rs index ee07859e..a08f9ef8 100644 --- a/src/strings.rs +++ b/src/strings.rs @@ -12,6 +12,8 @@ pub static CMD_SPLITTER: &str = " "; pub static MSG_TITLE_ERROR: &str = "Error"; pub static COMMIT_TITLE: &str = "Commit"; pub static COMMIT_MSG: &str = "type commit message.."; +pub static STASH_POPUP_TITLE: &str = "Stash"; +pub static STASH_POPUP_MSG: &str = "type name (optional)"; pub static RESET_TITLE: &str = "Reset"; pub static RESET_MSG: &str = "confirm file reset?";