Skip to content

Commit

Permalink
allow any string types for setting placeholder text
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Oct 1, 2023
1 parent 9fdbbd4 commit 2031e5b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/popup_placeholder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fn main() -> io::Result<()> {
// set placeholder

textarea.set_placeholder_style(Style::default());
textarea.set_placeholder("prompt message".to_string());
textarea.set_placeholder("prompt message");
loop {
term.draw(|f| {
f.render_widget(textarea.widget(), area);
Expand Down
2 changes: 1 addition & 1 deletion examples/ratatui_popup_placeholder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn main() -> io::Result<()> {
};
textarea.set_style(Style::default().fg(Color::Yellow));
textarea.set_placeholder_style(Style::default());
textarea.set_placeholder("prompt message".to_string());
textarea.set_placeholder("prompt message");
loop {
term.draw(|f| {
f.render_widget(textarea.widget(), area);
Expand Down
4 changes: 2 additions & 2 deletions src/textarea.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1239,8 +1239,8 @@ impl<'a> TextArea<'a> {
}

/// sets the placeholder text
pub fn set_placeholder(&mut self, placeholder: String) {
self.placeholder = placeholder;
pub fn set_placeholder(&mut self, placeholder: impl Into<String>) {
self.placeholder = placeholder.into();
}

pub fn set_placeholder_style(&mut self, style: Style) {
Expand Down

0 comments on commit 2031e5b

Please sign in to comment.