fix theme usage

This commit is contained in:
Stephan Dilly 2020-06-14 10:19:36 +02:00
parent fcb474b8a2
commit 36d9d13df4

View file

@ -105,18 +105,21 @@ impl DrawableComponent for TextInputComponent {
) -> Result<()> { ) -> Result<()> {
if self.visible { if self.visible {
let mut txt: Vec<tui::widgets::Text> = Vec::new(); let mut txt: Vec<tui::widgets::Text> = Vec::new();
if self.msg.is_empty() { if self.msg.is_empty() {
txt.push(Text::styled( txt.push(Text::styled(
self.default_msg.as_str(), self.default_msg.as_str(),
self.theme.text(false, false), self.theme.text(false, false),
)); ));
} else { } else {
let style = self.theme.text(true, false);
// the portion of the text before the cursor is added // the portion of the text before the cursor is added
// if the cursor is not at the first character // if the cursor is not at the first character
if self.cursor_position > 0 { if self.cursor_position > 0 {
txt.push(Text::styled( txt.push(Text::styled(
&self.msg[..self.cursor_position], &self.msg[..self.cursor_position],
Style::default(), style,
)); ));
} }
@ -128,7 +131,7 @@ impl DrawableComponent for TextInputComponent {
// a whitespace is used to underline // a whitespace is used to underline
" " " "
}, },
Style::default().modifier(Modifier::UNDERLINED), style.modifier(Modifier::UNDERLINED),
)); ));
// the final portion of the text is added if there is // the final portion of the text is added if there is
@ -137,7 +140,7 @@ impl DrawableComponent for TextInputComponent {
if pos < self.msg.len() { if pos < self.msg.len() {
txt.push(Text::styled( txt.push(Text::styled(
&self.msg[pos..], &self.msg[pos..],
Style::default(), style,
)); ));
} }
} }