aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPolesznyák Márk <contact@pml68.dev>2026-03-12 20:36:57 +0100
committerPolesznyák Márk <contact@pml68.dev>2026-03-13 10:15:35 +0100
commitf4485376a0bd95e13f868beba047838157c5e800 (patch)
tree513735e0a412ef12d3f593a008604c76fe436c71
parentchore: bump MSRV to match iced's (diff)
downloadiced_custom_highlighter-f4485376a0bd95e13f868beba047838157c5e800.tar.gz
chore: necessary updates for iced-rs/iced@6690731
-rw-r--r--Cargo.toml2
-rw-r--r--README.md35
-rw-r--r--src/lib.rs61
3 files changed, 44 insertions, 54 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 2538008..2cdbb72 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,7 +14,7 @@ rust-version = "1.92"
syntect = { version = "5.3", default-features = false, features = [
"regex-fancy",
] }
-two-face = { version = "0.4", default-features = false, features = [
+two-face = { version = "0.5", default-features = false, features = [
"syntect-fancy",
] }
diff --git a/README.md b/README.md
index 2ca543c..a1b425b 100644
--- a/README.md
+++ b/README.md
@@ -11,14 +11,14 @@ It uses the colors from your app's Theme, based on a styling method (like `defau
# Example
```rust
-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};
#[derive(Default)]
struct State {
content: text_editor::Content,
- theme: Theme,
+ theme: Option<Theme>,
}
#[derive(Debug, Clone)]
@@ -28,22 +28,21 @@ enum Message {
}
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,
- Some(state.theme),
- 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) {
@@ -53,7 +52,7 @@ fn update(state: &mut State, message: Message) {
}
Message::ChangeTheme(theme) => {
- state.theme = theme;
+ state.theme = Some(theme);
}
}
}
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,
};