From 517e2e4bf4488d51ace086fb31a8d92ed375ab58 Mon Sep 17 00:00:00 2001 From: pml68 Date: Sat, 8 Feb 2025 01:11:50 +0100 Subject: feat: add highlight color for Other and Custom `Scope` variants --- src/panes/code_view.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/panes') diff --git a/src/panes/code_view.rs b/src/panes/code_view.rs index 7712d4d..956eb87 100644 --- a/src/panes/code_view.rs +++ b/src/panes/code_view.rs @@ -1,12 +1,23 @@ +use iced::advanced::text::highlighter::Format; use iced::widget::{button, pane_grid, row, text, text_editor, Space}; use iced::{Alignment, Background, Border, Font, Length, Theme}; -use iced_custom_highlighter::{Highlight, Highlighter, Settings}; +use iced_custom_highlighter::{Highlight, Highlighter, Scope, Settings}; use super::style; use crate::icon::copy; use crate::types::{DesignerPage, Message}; use crate::widget::tip; +fn highlight_style(theme: &Theme, scope: &Scope) -> Format { + match scope { + Scope::Custom { .. } | Scope::Other => Format { + color: Some(theme.extended_palette().primary.strong.color), + font: None, + }, + _ => Highlight::default_style(theme, scope), + } +} + pub fn view( editor_content: &text_editor::Content, theme: Theme, @@ -33,7 +44,7 @@ pub fn view( .on_action(Message::EditorAction) .font(Font::MONOSPACE) .highlight_with::( - Settings::new(vec![], Highlight::default_style, theme, "rs"), + Settings::new(vec![], highlight_style, theme, "rs"), Highlight::to_format, ) .style(|theme, _| { -- cgit v1.2.3