aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs61
1 files changed, 26 insertions, 35 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 441df27..20b3ecc 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -5,7 +5,7 @@
//! # Example
//!
//! ```no_run
-//! use iced::widget::{Column, pick_list, text_editor};
+//! use iced::widget::{column, pick_list, text_editor};
//! use iced::{Element, Theme};
//! use iced_custom_highlighter::{Highlight, Highlighter, Settings};
//!
@@ -22,22 +22,21 @@
//! }
//!
//! fn view(state: &State) -> Element<'_, Message> {
-//! Column::new()
-//! .push(
+//! column![
//! text_editor(&state.content)
-//! .placeholder("Type something here...")
-//! .highlight_with::<Highlighter>(
-//! Settings::new(vec![], Highlight::default_style, "rs"),
-//! Highlight::to_format,
-//! )
-//! .on_action(Message::Edit),
-//! )
-//! .push(pick_list(
-//! Theme::ALL,
-//! state.theme.clone(),
-//! Message::ChangeTheme,
-//! ))
-//! .into()
+//! .placeholder("Type something here...")
+//! .highlight_with::<Highlighter>(
+//! Settings::new(vec![], Highlight::default_style, "rs"),
+//! Highlight::to_format,
+//! )
+//! .on_action(Message::Edit),
+//! pick_list(
+//! state.theme.clone(),
+//! Theme::ALL,
+//! Theme::to_string
+//! )
+//! .on_select(Message::ChangeTheme),
+//! ].into()
//! }
//!
//! fn update(state: &mut State, message: Message) {
@@ -337,34 +336,26 @@ impl Highlight<Theme> {
pub fn default_style(theme: &Theme, scope: &Scope) -> Format<Font> {
let color = match scope {
Scope::Comment | Scope::TagStart => {
- Some(theme.extended_palette().background.weak.color)
+ Some(theme.palette().background.weak.color)
}
Scope::String | Scope::RegExp | Scope::QuotedString => {
- Some(theme.extended_palette().primary.base.color)
+ Some(theme.palette().primary.base.color)
}
Scope::EscapeSequence
| Scope::Exception
| Scope::SupportConstruct
- | Scope::Continuation => {
- Some(theme.extended_palette().danger.base.color)
- }
- Scope::Number => {
- Some(theme.extended_palette().secondary.weak.color)
- }
+ | Scope::Continuation => Some(theme.palette().danger.base.color),
+ Scope::Number => Some(theme.palette().secondary.weak.color),
Scope::Variable
| Scope::VariableStart
| Scope::TagName
| Scope::Import
- | Scope::Brackets => {
- Some(theme.extended_palette().primary.weak.color)
- }
+ | Scope::Brackets => Some(theme.palette().primary.weak.color),
Scope::Keyword
| Scope::KeywordOperator
| Scope::Operator
| Scope::Parantheses
- | Scope::Braces => {
- Some(theme.extended_palette().background.strong.color)
- }
+ | Scope::Braces => Some(theme.palette().background.strong.color),
Scope::Storage
| Scope::StorageModifier
| Scope::StorageType
@@ -373,15 +364,15 @@ impl Highlight<Theme> {
| Scope::VariableFunction
| Scope::FunctionName
| Scope::LibraryFunction => {
- Some(theme.extended_palette().success.base.color)
+ Some(theme.palette().success.base.color)
}
- Scope::QuotedSingle => Some(theme.palette().text),
+ Scope::QuotedSingle => Some(theme.seed().text),
Scope::BuiltinConstant | Scope::UserDefinedConstant => {
- Some(theme.extended_palette().danger.base.color)
+ Some(theme.palette().danger.base.color)
}
- Scope::Invalid => Some(theme.extended_palette().danger.weak.color),
+ Scope::Invalid => Some(theme.palette().danger.weak.color),
Scope::Special | Scope::KeywordOther => {
- Some(theme.extended_palette().danger.strong.color)
+ Some(theme.palette().danger.strong.color)
}
Scope::Other | Scope::Custom { .. } => None,
};