Skip to content

Commit

Permalink
rename from label to prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
ynqa committed Oct 21, 2023
1 parent 072497b commit 68496f3
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion examples/interact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn main() -> Result {
TextEditorBuilder::default()
.style(Style::new().fgc(Color::DarkYellow).build())
.cursor_style(Style::new().bgc(Color::DarkBlue).build())
.label_style(Style::new().fgc(Color::DarkGreen).build())
.prefix_style(Style::new().fgc(Color::DarkGreen).build())
.build_state()?,
ItemPickerBuilder::new(0..100)
.cursor_style(Style::new().fgc(Color::Magenta).build())
Expand Down
16 changes: 8 additions & 8 deletions src/components/builder/text_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use super::super::{text_editor::TextEditor, Mode, State};
pub struct TextEditorBuilder {
history: Option<History>,
suggest: Suggest,
label: String,
label_style: ContentStyle,
prefix: String,
prefix_style: ContentStyle,
style: ContentStyle,
cursor_style: ContentStyle,
mode: Mode,
Expand All @@ -19,13 +19,13 @@ pub struct TextEditorBuilder {
}

impl TextEditorBuilder {
pub fn label<T: AsRef<str>>(mut self, label: T) -> Self {
self.label = label.as_ref().to_string();
pub fn prefix<T: AsRef<str>>(mut self, prefix: T) -> Self {
self.prefix = prefix.as_ref().to_string();
self
}

pub fn label_style(mut self, style: ContentStyle) -> Self {
self.label_style = style;
pub fn prefix_style(mut self, style: ContentStyle) -> Self {
self.prefix_style = style;
self
}

Expand Down Expand Up @@ -69,8 +69,8 @@ impl TextEditorBuilder {
textbuffer: TextBuffer::default(),
history: self.history,
suggest: self.suggest,
label: self.label,
label_style: self.label_style,
prefix: self.prefix,
prefix_style: self.prefix_style,
style: self.style,
cursor_style: self.cursor_style,
mode: self.mode,
Expand Down
8 changes: 4 additions & 4 deletions src/components/text_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ pub struct TextEditor {
pub history: Option<History>,
pub suggest: Suggest,

pub label: String,
pub label_style: ContentStyle,
pub prefix: String,
pub prefix_style: ContentStyle,
pub style: ContentStyle,
pub cursor_style: ContentStyle,
pub mode: Mode,
Expand All @@ -54,8 +54,8 @@ impl Component for TextEditor {
fn make_pane(&self, width: u16) -> Pane {
let mut buf = Graphemes::default();
buf.append(&mut Graphemes::new_with_style(
&self.label,
self.label_style,
&self.prefix,
self.prefix_style,
));
buf.append(&mut self.textbuffer_to_graphemes());

Expand Down
4 changes: 2 additions & 2 deletions src/preset/confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct Confirm {
impl Confirm {
pub fn new<T: AsRef<str>>(text: T) -> Self {
Self {
text_editor: TextEditorBuilder::default().label(format!("{} (y/n) ", text.as_ref())),
text_editor: TextEditorBuilder::default().prefix(format!("{} (y/n) ", text.as_ref())),
error_message: Default::default(),
}
.theme(Theme::default())
Expand All @@ -24,7 +24,7 @@ impl Confirm {
pub fn theme(mut self, theme: Theme) -> Self {
self.text_editor = self
.text_editor
.label_style(theme.label_style)
.prefix_style(theme.prefix_style)
.style(theme.text_style)
.cursor_style(theme.cursor_style);
self.error_message = self.error_message.style(theme.error_message_style);
Expand Down
4 changes: 2 additions & 2 deletions src/preset/password.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ impl Password {
self.title = self.title.style(theme.title_style);
self.text_editor = self
.text_editor
.label(theme.label)
.label_style(theme.label_style)
.prefix(theme.prefix)
.prefix_style(theme.prefix_style)
.style(theme.text_style)
.cursor_style(theme.cursor_style)
.mask(theme.mask);
Expand Down
4 changes: 2 additions & 2 deletions src/preset/readline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ impl Readline {
self.title = self.title.style(theme.title_style);
self.text_editor = self
.text_editor
.label(theme.label)
.label_style(theme.label_style)
.prefix(theme.prefix)
.prefix_style(theme.prefix_style)
.style(theme.text_style)
.cursor_style(theme.cursor_style);
self.error_message = self.error_message.style(theme.error_message_style);
Expand Down
4 changes: 2 additions & 2 deletions src/theme/confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
};

pub struct Theme {
pub label_style: ContentStyle,
pub prefix_style: ContentStyle,
pub text_style: ContentStyle,
pub cursor_style: ContentStyle,
pub error_message_style: ContentStyle,
Expand All @@ -13,7 +13,7 @@ pub struct Theme {
impl Default for Theme {
fn default() -> Self {
Self {
label_style: Style::new().fgc(Color::DarkGreen).build(),
prefix_style: Style::new().fgc(Color::DarkGreen).build(),
text_style: Style::new().build(),
cursor_style: Style::new().bgc(Color::DarkCyan).build(),
error_message_style: Style::new()
Expand Down
8 changes: 4 additions & 4 deletions src/theme/password.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use crate::{

pub struct Theme {
pub title_style: ContentStyle,
pub label: String,
pub label_style: ContentStyle,
pub prefix: String,
pub prefix_style: ContentStyle,
pub text_style: ContentStyle,
pub mask: char,
pub cursor_style: ContentStyle,
Expand All @@ -19,8 +19,8 @@ impl Default for Theme {
title_style: Style::new()
.attrs(Attributes::from(Attribute::Bold))
.build(),
label: String::from("❯❯ "),
label_style: Style::new().fgc(Color::DarkGreen).build(),
prefix: String::from("❯❯ "),
prefix_style: Style::new().fgc(Color::DarkGreen).build(),
text_style: Style::new().build(),
mask: '*',
cursor_style: Style::new().bgc(Color::DarkCyan).build(),
Expand Down
8 changes: 4 additions & 4 deletions src/theme/readline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use crate::{

pub struct Theme {
pub title_style: ContentStyle,
pub label: String,
pub label_style: ContentStyle,
pub prefix: String,
pub prefix_style: ContentStyle,
pub text_style: ContentStyle,
pub cursor_style: ContentStyle,
pub error_message_style: ContentStyle,
Expand All @@ -18,8 +18,8 @@ impl Default for Theme {
title_style: Style::new()
.attrs(Attributes::from(Attribute::Bold))
.build(),
label: String::from("❯❯ "),
label_style: Style::new().fgc(Color::DarkGreen).build(),
prefix: String::from("❯❯ "),
prefix_style: Style::new().fgc(Color::DarkGreen).build(),
text_style: Style::new().build(),
cursor_style: Style::new().bgc(Color::DarkCyan).build(),
error_message_style: Style::new()
Expand Down

0 comments on commit 68496f3

Please sign in to comment.