Skip to content

Commit 057cb50

Browse files
committed
trim _string
1 parent 33c1bc8 commit 057cb50

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

src/core/text_editor/render.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ pub struct Renderer {
3030
pub suggest: Suggest,
3131

3232
/// Prompt string displayed before the input text.
33-
pub ps: String,
33+
pub prefix: String,
3434
/// Optional character used for masking the input string (e.g., for password fields).
3535
pub mask: Option<char>,
3636

3737
/// Style applied to the prompt string.
38-
pub ps_style: ContentStyle,
38+
pub prefix_style: ContentStyle,
3939
/// Style applied to the currently selected character.
4040
pub active_char_style: ContentStyle,
4141
/// Style applied to characters that are not currently selected.
@@ -50,7 +50,10 @@ pub struct Renderer {
5050
impl Renderable for Renderer {
5151
fn make_pane(&self, width: u16) -> Pane {
5252
let mut buf = Graphemes::default();
53-
buf.append(&mut Graphemes::new_with_style(&self.ps, self.ps_style));
53+
buf.append(&mut Graphemes::new_with_style(
54+
&self.prefix,
55+
self.prefix_style,
56+
));
5457

5558
let text = match self.mask {
5659
Some(mask) => self.texteditor.masking(mask),

src/preset/queryselect.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ impl QuerySelect {
6161
texteditor: Default::default(),
6262
history: None,
6363
suggest: Default::default(),
64-
ps: String::from("❯❯ "),
64+
prefix: String::from("❯❯ "),
6565
mask: None,
66-
ps_style: Style::new().fgc(Color::DarkGreen).build(),
66+
prefix_style: Style::new().fgc(Color::DarkGreen).build(),
6767
active_char_style: Style::new().bgc(Color::DarkCyan).build(),
6868
inactive_char_style: Style::new().build(),
6969
edit_mode: Default::default(),
@@ -99,14 +99,14 @@ impl QuerySelect {
9999
}
100100

101101
/// Sets the prefix string displayed before the input text in the text editor component.
102-
pub fn prefix_string<T: AsRef<str>>(mut self, ps: T) -> Self {
103-
self.text_editor_renderer.ps = ps.as_ref().to_string();
102+
pub fn prefix<T: AsRef<str>>(mut self, prefix: T) -> Self {
103+
self.text_editor_renderer.prefix = prefix.as_ref().to_string();
104104
self
105105
}
106106

107107
/// Sets the style for the prefix string in the text editor component.
108-
pub fn prefix_string_style(mut self, style: ContentStyle) -> Self {
109-
self.text_editor_renderer.ps_style = style;
108+
pub fn prefix_style(mut self, style: ContentStyle) -> Self {
109+
self.text_editor_renderer.prefix_style = style;
110110
self
111111
}
112112

src/preset/readline.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ impl Default for Readline {
4545
texteditor: Default::default(),
4646
history: Default::default(),
4747
suggest: Default::default(),
48-
ps: String::from("❯❯ "),
48+
prefix: String::from("❯❯ "),
4949
mask: Default::default(),
50-
ps_style: Style::new().fgc(Color::DarkGreen).build(),
50+
prefix_style: Style::new().fgc(Color::DarkGreen).build(),
5151
active_char_style: Style::new().bgc(Color::DarkCyan).build(),
5252
inactive_char_style: Style::new().build(),
5353
edit_mode: Default::default(),
@@ -91,8 +91,8 @@ impl Readline {
9191
}
9292

9393
/// Sets the prefix string displayed before the input text.
94-
pub fn prefix_string<T: AsRef<str>>(mut self, ps: T) -> Self {
95-
self.text_editor_renderer.ps = ps.as_ref().to_string();
94+
pub fn prefix<T: AsRef<str>>(mut self, prefix: T) -> Self {
95+
self.text_editor_renderer.prefix = prefix.as_ref().to_string();
9696
self
9797
}
9898

@@ -103,8 +103,8 @@ impl Readline {
103103
}
104104

105105
/// Sets the style for the prefix string.
106-
pub fn prefix_string_style(mut self, style: ContentStyle) -> Self {
107-
self.text_editor_renderer.ps_style = style;
106+
pub fn prefix_style(mut self, style: ContentStyle) -> Self {
107+
self.text_editor_renderer.prefix_style = style;
108108
self
109109
}
110110

src/preset/readline/confirm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ impl Confirm {
1616
pub fn new<T: AsRef<str>>(text: T) -> Self {
1717
Self(
1818
Readline::default()
19-
.prefix_string(format!("{} (y/n) ", text.as_ref()))
19+
.prefix(format!("{} (y/n) ", text.as_ref()))
2020
.validator(
2121
|text| -> bool {
2222
["yes", "no", "y", "n", "Y", "N"]

0 commit comments

Comments
 (0)