From e62fea5efddb20fd1bc518e0d733a86f6858fa73 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Thu, 2 Nov 2023 13:38:25 -0600 Subject: [PATCH] SyntaxEditor: Support using two-face syntax definitions --- Cargo.toml | 9 +++++---- src/edit/syntect.rs | 12 ++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b04f5fa85e..a662f71f4e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,19 +11,20 @@ rust-version = "1.65" [dependencies] fontdb = { version = "0.15.0", default-features = false } +hashbrown = { version = "0.14.1", optional = true, default-features = false } libm = "0.2.8" log = "0.4.20" +rangemap = "1.4.0" +rustc-hash = { version = "1.1.0", default-features = false } rustybuzz = { version = "0.11.0", default-features = false, features = ["libm"] } +self_cell = "1.0.1" swash = { version = "0.1.8", optional = true } syntect = { version = "5.1.0", optional = true } sys-locale = { version = "0.3.1", optional = true } +two-face = { version = "0.3.0", optional = true } unicode-linebreak = "0.1.5" unicode-script = "0.5.5" unicode-segmentation = "1.10.1" -rangemap = "1.4.0" -hashbrown = { version = "0.14.1", optional = true, default-features = false } -rustc-hash = { version = "1.1.0", default-features = false } -self_cell = "1.0.1" [dependencies.unicode-bidi] version = "0.3.13" diff --git a/src/edit/syntect.rs b/src/edit/syntect.rs index ec55671682..9ba06dd8c3 100644 --- a/src/edit/syntect.rs +++ b/src/edit/syntect.rs @@ -22,6 +22,7 @@ pub struct SyntaxSystem { impl SyntaxSystem { /// Create a new [`SyntaxSystem`] + #[cfg(not(feature = "two-face"))] pub fn new() -> Self { Self { //TODO: store newlines in buffer @@ -29,6 +30,17 @@ impl SyntaxSystem { theme_set: ThemeSet::load_defaults(), } } + + /// Create a new [`SyntaxSystem`] using `[two-face]` definitions + #[cfg(feature = "two-face")] + pub fn new() -> Self { + Self { + //TODO: store newlines in buffer + syntax_set: two_face::syntax::extra_no_newlines(), + //TODO: use two-face themes + theme_set: ThemeSet::load_defaults(), + } + } } /// A wrapper of [`Editor`] with syntax highlighting provided by [`SyntaxSystem`]