iced_custom_highlighter
A custom syntax highlighter for iced.
It uses the colors from your app's Theme, based on a styling method (like default_style)
two-face is used for providing extra syntaxes. More info
Example
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: Option<Theme>,
}
#[derive(Debug, Clone)]
enum Message {
Edit(text_editor::Action),
ChangeTheme(Theme),
}
fn view(state: &State) -> Element<'_, Message> {
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),
pick_list(
state.theme.clone(),
Theme::ALL,
Theme::to_string
)
.on_select(Message::ChangeTheme),
].into()
}
fn update(state: &mut State, message: Message) {
match message {
Message::Edit(action) => {
state.content.perform(action);
}
Message::ChangeTheme(theme) => {
state.theme = Some(theme);
}
}
}
Contributing
You can send issues, feature requests, patches etc. to contact@pml68.dev.
