Skip to content

Commit

Permalink
rename from Style to StyleBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
ynqa committed Feb 25, 2024
1 parent ca1fe6a commit 4f28c1d
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 36 deletions.
8 changes: 4 additions & 4 deletions src/preset/checkbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
crossterm::style::{Attribute, Attributes, Color, ContentStyle},
error::Result,
render::{Renderable, State},
style::Style,
style::StyleBuilder,
text, Prompt,
};

Expand All @@ -30,16 +30,16 @@ impl Checkbox {
Self {
title_renderer: text::Renderer {
text: Default::default(),
style: Style::new()
style: StyleBuilder::new()
.attrs(Attributes::from(Attribute::Bold))
.build(),
},
checkbox_renderer: checkbox::Renderer {
checkbox: checkbox::Checkbox::from_iter(items),
cursor: String::from("❯ "),
mark: '■',
active_item_style: Style::new().fgc(Color::DarkCyan).build(),
inactive_item_style: Style::new().build(),
active_item_style: StyleBuilder::new().fgc(Color::DarkCyan).build(),
inactive_item_style: StyleBuilder::new().build(),
lines: Default::default(),
},
}
Expand Down
16 changes: 8 additions & 8 deletions src/preset/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
error::Result,
json::{self, JsonNode, JsonPathSegment},
render::{Renderable, State},
style::Style,
style::StyleBuilder,
text, Prompt,
};

Expand All @@ -23,22 +23,22 @@ impl Json {
Self {
title_renderer: text::Renderer {
text: Default::default(),
style: Style::new()
style: StyleBuilder::new()
.attrs(Attributes::from(Attribute::Bold))
.build(),
},
json_renderer: json::Renderer {
json: json::JsonTree::new(root),
curly_brackets_style: Style::new()
curly_brackets_style: StyleBuilder::new()
.attrs(Attributes::from(Attribute::Bold))
.build(),
square_brackets_style: Style::new()
square_brackets_style: StyleBuilder::new()
.attrs(Attributes::from(Attribute::Bold))
.build(),
key_style: Style::new().fgc(Color::DarkBlue).build(),
string_value_style: Style::new().fgc(Color::DarkGreen).build(),
number_value_style: Style::new().build(),
boolean_value_style: Style::new().build(),
key_style: StyleBuilder::new().fgc(Color::DarkBlue).build(),
string_value_style: StyleBuilder::new().fgc(Color::DarkGreen).build(),
number_value_style: StyleBuilder::new().build(),
boolean_value_style: StyleBuilder::new().build(),
lines: Default::default(),
indent: 2,
},
Expand Down
8 changes: 4 additions & 4 deletions src/preset/listbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
error::Result,
listbox,
render::{Renderable, State},
style::Style,
style::StyleBuilder,
text, Prompt,
};

Expand All @@ -29,15 +29,15 @@ impl Listbox {
Self {
title_renderer: text::Renderer {
text: Default::default(),
style: Style::new()
style: StyleBuilder::new()
.attrs(Attributes::from(Attribute::Bold))
.build(),
},
listbox_renderer: listbox::Renderer {
listbox: listbox::Listbox::from_iter(items),
cursor: String::from("❯ "),
active_item_style: Style::new().fgc(Color::DarkCyan).build(),
inactive_item_style: Style::new().build(),
active_item_style: StyleBuilder::new().fgc(Color::DarkCyan).build(),
inactive_item_style: StyleBuilder::new().build(),
lines: Default::default(),
},
}
Expand Down
14 changes: 7 additions & 7 deletions src/preset/qs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
error::Result,
listbox::{self, Listbox},
render::{Renderable, State},
style::Style,
style::StyleBuilder,
text,
text_editor::{self, Mode, Suggest},
Prompt,
Expand Down Expand Up @@ -53,7 +53,7 @@ impl QuerySelector {
Self {
title_renderer: text::Renderer {
text: Default::default(),
style: Style::new()
style: StyleBuilder::new()
.attrs(Attributes::from(Attribute::Bold))
.build(),
},
Expand All @@ -63,17 +63,17 @@ impl QuerySelector {
suggest: Default::default(),
prefix: String::from("❯❯ "),
mask: None,
prefix_style: Style::new().fgc(Color::DarkGreen).build(),
active_char_style: Style::new().bgc(Color::DarkCyan).build(),
inactive_char_style: Style::new().build(),
prefix_style: StyleBuilder::new().fgc(Color::DarkGreen).build(),
active_char_style: StyleBuilder::new().bgc(Color::DarkCyan).build(),
inactive_char_style: StyleBuilder::new().build(),
edit_mode: Default::default(),
lines: Default::default(),
},
listbox_renderer: listbox::Renderer {
listbox: Listbox::from_iter(items),
cursor: String::from("❯ "),
active_item_style: Style::new().fgc(Color::DarkCyan).build(),
inactive_item_style: Style::new().build(),
active_item_style: StyleBuilder::new().fgc(Color::DarkCyan).build(),
inactive_item_style: StyleBuilder::new().build(),
lines: Default::default(),
},
filter: Box::new(filter),
Expand Down
12 changes: 6 additions & 6 deletions src/preset/readline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
},
error::Result,
render::{Renderable, State},
style::Style,
style::StyleBuilder,
text,
text_editor::{self, History, Mode, Suggest},
validate::Validator,
Expand Down Expand Up @@ -37,7 +37,7 @@ impl Default for Readline {
Self {
title_renderer: text::Renderer {
text: Default::default(),
style: Style::new()
style: StyleBuilder::new()
.attrs(Attributes::from(Attribute::Bold))
.build(),
},
Expand All @@ -47,15 +47,15 @@ impl Default for Readline {
suggest: Default::default(),
prefix: String::from("❯❯ "),
mask: Default::default(),
prefix_style: Style::new().fgc(Color::DarkGreen).build(),
active_char_style: Style::new().bgc(Color::DarkCyan).build(),
inactive_char_style: Style::new().build(),
prefix_style: StyleBuilder::new().fgc(Color::DarkGreen).build(),
active_char_style: StyleBuilder::new().bgc(Color::DarkCyan).build(),
inactive_char_style: StyleBuilder::new().build(),
edit_mode: Default::default(),
lines: Default::default(),
},
error_message_renderer: text::Renderer {
text: Default::default(),
style: Style::new()
style: StyleBuilder::new()
.fgc(Color::DarkRed)
.attrs(Attributes::from(Attribute::Bold))
.build(),
Expand Down
8 changes: 4 additions & 4 deletions src/preset/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
crossterm::style::{Attribute, Attributes, Color, ContentStyle},
error::Result,
render::{Renderable, State},
style::Style,
style::StyleBuilder,
text,
tree::{self, Node},
Prompt,
Expand All @@ -27,16 +27,16 @@ impl Tree {
Self {
title_renderer: text::Renderer {
text: Default::default(),
style: Style::new()
style: StyleBuilder::new()
.attrs(Attributes::from(Attribute::Bold))
.build(),
},
tree_renderer: tree::Renderer {
tree: tree::Tree::new(root),
folded_symbol: String::from("▶︎ "),
unfolded_symbol: String::from("▼ "),
active_item_style: Style::new().fgc(Color::DarkCyan).build(),
inactive_item_style: Style::new().build(),
active_item_style: StyleBuilder::new().fgc(Color::DarkCyan).build(),
inactive_item_style: StyleBuilder::new().build(),
lines: Default::default(),
indent: 2,
},
Expand Down
6 changes: 3 additions & 3 deletions src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ use crate::crossterm::style::{Attributes, Color, ContentStyle};
/// It provides a fluent interface for setting these properties,
/// and a method to build a `ContentStyle` that can be applied to text.
#[derive(Default)]
pub struct Style {
pub struct StyleBuilder {
foreground_color: Option<Color>,
background_color: Option<Color>,
underline_color: Option<Color>,
attributes: Attributes,
}

impl Style {
impl StyleBuilder {
/// Creates a new `Style` instance with default values.
pub fn new() -> Self {
Style::default()
StyleBuilder::default()
}

/// Sets the foreground color of the style.
Expand Down

0 comments on commit 4f28c1d

Please sign in to comment.