diff --git a/src/themes/fancy.rs b/src/themes/fancy.rs index 606122a..be0da77 100644 --- a/src/themes/fancy.rs +++ b/src/themes/fancy.rs @@ -62,14 +62,12 @@ impl FancyTheme { } fn fmt_placeholder(&self, placeholder: String) -> String { - let mut chars = placeholder.char_indices(); - let cursor = chars.nth(0).unwrap_or((0, ' ')); - let second = chars.nth(1).unwrap_or((0, ' ')); - let rest = &placeholder[second.0..]; + let input = InputCursor::new(placeholder, 0); + let (_, cursor, right) = input.split(); format!( "{}{}", - Styled::new(cursor.1).rev(), - Styled::new(rest).fg(Color::DarkGrey), + Styled::new(cursor).rev(), + Styled::new(right).fg(Color::DarkGrey), ) } @@ -91,7 +89,7 @@ impl FancyTheme { self.fmt_line(color, input) } PromptInput::Cursor(c) => { - let input = if c.is_empty() { + let input = if c.value().is_empty() { self.fmt_placeholder(placeholder.unwrap_or_default()) } else { self.fmt_cursor(c) diff --git a/src/themes/minimal.rs b/src/themes/minimal.rs index 14d142b..7e76d60 100644 --- a/src/themes/minimal.rs +++ b/src/themes/minimal.rs @@ -36,14 +36,12 @@ impl MinimalTheme { } fn fmt_placeholder(&self, placeholder: String) -> String { - let mut chars = placeholder.char_indices(); - let cursor = chars.nth(0).unwrap_or((0, ' ')); - let second = chars.nth(1).unwrap_or((0, ' ')); - let rest = &placeholder[second.0..]; + let input = InputCursor::new(placeholder, 0); + let (_, cursor, right) = input.split(); format!( "{}{}", - Styled::new(cursor.1).rev(), - Styled::new(rest).fg(Color::DarkGrey), + Styled::new(cursor).rev(), + Styled::new(right).fg(Color::DarkGrey), ) } @@ -62,7 +60,7 @@ impl MinimalTheme { self.fmt_input_layout(input) } PromptInput::Cursor(c) => { - let input = if c.is_empty() { + let input = if c.value().is_empty() { self.fmt_placeholder(placeholder.unwrap_or_default()) } else { self.fmt_cursor(c)