summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpml68 <contact@pml68.dev>2025-02-08 01:11:50 +0100
committerpml68 <contact@pml68.dev>2025-02-08 01:11:50 +0100
commit517e2e4bf4488d51ace086fb31a8d92ed375ab58 (patch)
tree8a35d22660c17584f26c6ade486ab6d2d158b06d
parentfeat: set custom `Style` on `TextEditor` (diff)
downloadiced-builder-517e2e4bf4488d51ace086fb31a8d92ed375ab58.tar.gz
feat: add highlight color for Other and Custom `Scope` variants
-rw-r--r--.cargo/config.toml3
-rw-r--r--src/panes/code_view.rs15
2 files changed, 16 insertions, 2 deletions
diff --git a/.cargo/config.toml b/.cargo/config.toml
index feb6aad..669a8c7 100644
--- a/.cargo/config.toml
+++ b/.cargo/config.toml
@@ -1,3 +1,6 @@
[alias]
lint = "clippy --no-deps -- -D warnings"
lint-all = "clippy --no-deps -- -D clippy::pedantic"
+
+[build]
+rustflags = ["-Z", "threads=6"]
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<Font> {
+ 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::<Highlighter>(
- Settings::new(vec![], Highlight::default_style, theme, "rs"),
+ Settings::new(vec![], highlight_style, theme, "rs"),
Highlight::to_format,
)
.style(|theme, _| {