From b9efff07ef381c690d47e0a9b89c90cccac633fe Mon Sep 17 00:00:00 2001 From: pml68 Date: Tue, 4 Feb 2025 22:53:10 +0100 Subject: feat: remove `text_editor::Catalog` constraint, iced_widget dependency --- src/lib.rs | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 03c306e..eb486e7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,10 +1,9 @@ //! A custom syntax highlighter for iced. //! //! It uses the colors from your app's Theme, based on the current [`Scope`] -use iced_widget::core::font::Font; -use iced_widget::core::text::highlighter::{self, Format}; -use iced_widget::text_editor::Catalog; -use iced_widget::Theme; +use iced_core::font::Font; +use iced_core::text::highlighter::{self, Format}; +use iced_core::Theme; use std::ops::Range; use std::str::FromStr; @@ -26,7 +25,7 @@ type ScopeSelectorsResult = core::result::Result< #[derive(Debug)] pub struct Highlighter where - T: Catalog + 'static + Clone + PartialEq, + T: 'static + Clone + PartialEq, { syntax: &'static parsing::SyntaxReference, custom_scopes: Vec, @@ -35,7 +34,7 @@ where current_line: usize, } -impl highlighter::Highlighter +impl highlighter::Highlighter for Highlighter { type Settings = Settings; @@ -149,10 +148,7 @@ impl highlighter::Highlighter /// The settings of a [`Highlighter`]. #[derive(Debug, Clone, PartialEq)] -pub struct Settings -where - T: Catalog, -{ +pub struct Settings { /// Custom scopes used for parsing the code. /// /// It extends [`Scope::ALL`]. @@ -171,7 +167,7 @@ where pub token: String, } -impl Settings { +impl Settings { /// Creates a new [`Settings`] struct with the given values. pub fn new( custom_scopes: Vec, @@ -188,15 +184,12 @@ impl Settings { /// A highlight produced by a [`Highlighter`]. #[derive(Debug)] -pub struct Highlight -where - T: Catalog, -{ +pub struct Highlight { scope: Scope, style: fn(&T, &Scope) -> Format, } -impl Highlight { +impl Highlight { /// Returns the [`Format`] of the [`Highlight`]. /// /// [`Format`]: iced_widget::core::text::highlighter::Format -- cgit v1.2.3