diff --git a/src/components/log_search_popup.rs b/src/components/log_search_popup.rs index 50931467..be8ee4d0 100644 --- a/src/components/log_search_popup.rs +++ b/src/components/log_search_popup.rs @@ -57,6 +57,7 @@ impl LogSearchPopupComponent { false, ); find_text.embed(); + find_text.enabled(true); Self { queue: queue.clone(), @@ -248,6 +249,9 @@ impl LogSearchPopupComponent { Selection::AuthorsSearch => Selection::EnterText, }; } + + self.find_text + .enabled(matches!(self.selection, Selection::EnterText)); } } diff --git a/src/components/textinput.rs b/src/components/textinput.rs index 5052a8e0..1c8bd73d 100644 --- a/src/components/textinput.rs +++ b/src/components/textinput.rs @@ -37,6 +37,7 @@ pub struct TextInputComponent { default_msg: String, msg: String, visible: bool, + selected: Option, show_char_count: bool, theme: SharedTheme, key_config: SharedKeyConfig, @@ -64,6 +65,7 @@ impl TextInputComponent { show_char_count, title: title.to_string(), default_msg: default_msg.to_string(), + selected: None, cursor_position: 0, input_type: InputType::Multiline, current_area: Cell::new(Rect::default()), @@ -102,6 +104,11 @@ impl TextInputComponent { self.embed = true; } + /// + pub fn enabled(&mut self, enable: bool) { + self.selected = Some(enable); + } + /// Move the cursor right one char. fn incr_cursor(&mut self) { if let Some(pos) = self.next_char_position() { @@ -229,7 +236,8 @@ impl TextInputComponent { } fn get_draw_text(&self) -> Text { - let style = self.theme.text(true, false); + let style = + self.theme.text(self.selected.unwrap_or(true), false); let mut txt = Text::default(); // The portion of the text before the cursor is added @@ -367,7 +375,10 @@ impl DrawableComponent for TextInputComponent { let txt = if self.msg.is_empty() { Text::styled( self.default_msg.as_str(), - self.theme.text(false, false), + self.theme.text( + self.selected.unwrap_or_default(), + false, + ), ) } else { self.get_draw_text()