aboutsummaryrefslogtreecommitdiff
path: root/README.md
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 /README.md
parentchore: bump MSRV to match iced's (diff)
downloadiced_custom_highlighter-f4485376a0bd95e13f868beba047838157c5e800.tar.gz
chore: necessary updates for iced-rs/iced@6690731
Diffstat (limited to '')
-rw-r--r--README.md35
1 files changed, 17 insertions, 18 deletions
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);
}
}
}