Skip to content

Commit 30211b2

Browse files
committed
allow visualizing enable state in text
this allows us to show whether the text inpout is currently selected in search popup
1 parent 306ff91 commit 30211b2

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/components/log_search_popup.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ impl LogSearchPopupComponent {
5757
false,
5858
);
5959
find_text.embed();
60+
find_text.enabled(true);
6061

6162
Self {
6263
queue: queue.clone(),
@@ -248,6 +249,9 @@ impl LogSearchPopupComponent {
248249
Selection::AuthorsSearch => Selection::EnterText,
249250
};
250251
}
252+
253+
self.find_text
254+
.enabled(matches!(self.selection, Selection::EnterText));
251255
}
252256
}
253257

src/components/textinput.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ pub struct TextInputComponent {
3737
default_msg: String,
3838
msg: String,
3939
visible: bool,
40+
selected: Option<bool>,
4041
show_char_count: bool,
4142
theme: SharedTheme,
4243
key_config: SharedKeyConfig,
@@ -64,6 +65,7 @@ impl TextInputComponent {
6465
show_char_count,
6566
title: title.to_string(),
6667
default_msg: default_msg.to_string(),
68+
selected: None,
6769
cursor_position: 0,
6870
input_type: InputType::Multiline,
6971
current_area: Cell::new(Rect::default()),
@@ -102,6 +104,11 @@ impl TextInputComponent {
102104
self.embed = true;
103105
}
104106

107+
///
108+
pub fn enabled(&mut self, enable: bool) {
109+
self.selected = Some(enable);
110+
}
111+
105112
/// Move the cursor right one char.
106113
fn incr_cursor(&mut self) {
107114
if let Some(pos) = self.next_char_position() {
@@ -229,7 +236,8 @@ impl TextInputComponent {
229236
}
230237

231238
fn get_draw_text(&self) -> Text {
232-
let style = self.theme.text(true, false);
239+
let style =
240+
self.theme.text(self.selected.unwrap_or(true), false);
233241

234242
let mut txt = Text::default();
235243
// The portion of the text before the cursor is added
@@ -367,7 +375,10 @@ impl DrawableComponent for TextInputComponent {
367375
let txt = if self.msg.is_empty() {
368376
Text::styled(
369377
self.default_msg.as_str(),
370-
self.theme.text(false, false),
378+
self.theme.text(
379+
self.selected.unwrap_or_default(),
380+
false,
381+
),
371382
)
372383
} else {
373384
self.get_draw_text()

0 commit comments

Comments
 (0)