зеркало из
https://github.com/glebtv/tui-textarea.git
synced 2026-09-09 00:35:51 +03:00
allow any string types for setting placeholder text
Этот коммит содержится в:
@@ -38,7 +38,7 @@ fn main() -> io::Result<()> {
|
|||||||
// set placeholder
|
// set placeholder
|
||||||
|
|
||||||
textarea.set_placeholder_style(Style::default());
|
textarea.set_placeholder_style(Style::default());
|
||||||
textarea.set_placeholder("prompt message".to_string());
|
textarea.set_placeholder("prompt message");
|
||||||
loop {
|
loop {
|
||||||
term.draw(|f| {
|
term.draw(|f| {
|
||||||
f.render_widget(textarea.widget(), area);
|
f.render_widget(textarea.widget(), area);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ fn main() -> io::Result<()> {
|
|||||||
};
|
};
|
||||||
textarea.set_style(Style::default().fg(Color::Yellow));
|
textarea.set_style(Style::default().fg(Color::Yellow));
|
||||||
textarea.set_placeholder_style(Style::default());
|
textarea.set_placeholder_style(Style::default());
|
||||||
textarea.set_placeholder("prompt message".to_string());
|
textarea.set_placeholder("prompt message");
|
||||||
loop {
|
loop {
|
||||||
term.draw(|f| {
|
term.draw(|f| {
|
||||||
f.render_widget(textarea.widget(), area);
|
f.render_widget(textarea.widget(), area);
|
||||||
|
|||||||
@@ -1239,8 +1239,8 @@ impl<'a> TextArea<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// sets the placeholder text
|
/// sets the placeholder text
|
||||||
pub fn set_placeholder(&mut self, placeholder: String) {
|
pub fn set_placeholder(&mut self, placeholder: impl Into<String>) {
|
||||||
self.placeholder = placeholder;
|
self.placeholder = placeholder.into();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_placeholder_style(&mut self, style: Style) {
|
pub fn set_placeholder_style(&mut self, style: Style) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user