From 0d5e6636405dbe332c33c0fb82c7ccccb20f96cb Mon Sep 17 00:00:00 2001 From: Ruben Beltran del Rio Date: Sun, 14 Dec 2025 20:21:24 +0100 Subject: Use wmap-parser-swift and tree-sitter-wmap for parsing and highlighting. --- Map/Presentation/Theme/Color+theme.swift | 3 --- Map/Presentation/Theme/Dimensions.swift | 11 +--------- Map/Presentation/Theme/Font+theme.swift | 6 ------ Map/Presentation/Theme/NSColor+theme.swift | 34 +++++++++++++++++++++++++++++- Map/Presentation/Theme/NSFont+theme.swift | 18 ---------------- 5 files changed, 34 insertions(+), 38 deletions(-) (limited to 'Map/Presentation/Theme') diff --git a/Map/Presentation/Theme/Color+theme.swift b/Map/Presentation/Theme/Color+theme.swift index e0addca..dcc84cb 100644 --- a/Map/Presentation/Theme/Color+theme.swift +++ b/Map/Presentation/Theme/Color+theme.swift @@ -25,10 +25,7 @@ extension Color { static let lightPorcelainGreen = Color("Light Porcelain Green") static let naplesYellow = Color("Naples Yellow") static let hermosaPink = Color("Hermosa Pink") - static let neutralGray = Color("Neutral Gray") static let lightNeutralGray = Color("Light Neutral Gray") - static let darkNeutralGray = Color("Dark Neutral Gray") - static let darkerNeutralGray = Color("Darker Neutral Gray") // MARK: - General diff --git a/Map/Presentation/Theme/Dimensions.swift b/Map/Presentation/Theme/Dimensions.swift index 57bd8b8..b7c1faf 100644 --- a/Map/Presentation/Theme/Dimensions.swift +++ b/Map/Presentation/Theme/Dimensions.swift @@ -20,7 +20,6 @@ struct Dimensions { struct FontSize { static let body: CGFloat = 13 - static let title: CGFloat = 32 static let caption: CGFloat = 11 static let smallControl: CGFloat = 11 @@ -38,19 +37,10 @@ struct Dimensions { struct LineHeight { static let body: CGFloat = 18 - static let title: CGFloat = 38 static let caption: CGFloat = 18 - static let smallControl: CGFloat = 18 - - static var editor: CGFloat { - let fontSize = UserDefaults.standard.double(forKey: "editorFontSize") - let actualSize = fontSize > 0 ? fontSize : 14 - return actualSize >= 16 ? 38 : 18 - } struct Map { static let note: CGFloat = 18 - static let axisLabel: CGFloat = 18 static let vertexLabel: CGFloat = 18 } } @@ -109,6 +99,7 @@ struct Dimensions { struct Toolbar { static let radius: CGFloat = 8.0 + static let glassRadius: CGFloat = 24.0 static let size: CGFloat = 16.0 static let width: CGFloat = 60.0 static let height: CGFloat = 40.0 diff --git a/Map/Presentation/Theme/Font+theme.swift b/Map/Presentation/Theme/Font+theme.swift index 4660e48..bb1d8f6 100644 --- a/Map/Presentation/Theme/Font+theme.swift +++ b/Map/Presentation/Theme/Font+theme.swift @@ -31,18 +31,12 @@ extension Font { static let emphasized = Font.ronzino(size: Dimensions.FontSize.body).weight(.medium) } - struct Title { - static let emphasized = Font.libertinus(size: Dimensions.FontSize.title).weight(.medium) - } - struct Caption { - static let regular = Font.ronzino(size: Dimensions.FontSize.caption).weight(.regular) static let emphasized = Font.ronzino(size: Dimensions.FontSize.caption).weight(.medium) } struct SmallControl { static let regular = Font.ronzino(size: Dimensions.FontSize.smallControl).weight(.regular) - static let emphasized = Font.ronzino(size: Dimensions.FontSize.smallControl).weight(.medium) } struct Map { diff --git a/Map/Presentation/Theme/NSColor+theme.swift b/Map/Presentation/Theme/NSColor+theme.swift index 7e53717..21db412 100644 --- a/Map/Presentation/Theme/NSColor+theme.swift +++ b/Map/Presentation/Theme/NSColor+theme.swift @@ -29,11 +29,43 @@ extension NSColor { .withAlphaComponent( 0.3) static let error = (NSColor(named: "Jasper Red") ?? .textColor) + + static func colorForSyntax(_ captureName: String) -> NSColor { + switch captureName { + case ("variable.component_label"): + return .Theme.Syntax.vertex + case ("number.real_number"): + return .Theme.Syntax.number + case ("punctuation.position"): + return .Theme.Syntax.punctuation + case ("punctuation.shape"): + return .Theme.Syntax.punctuation + case ("punctuation.dependency_type"): + return .Theme.Syntax.punctuation + case ("parameter.optional"): + return .Theme.Syntax.option + case ("operator.sign"): + return .Theme.Syntax.option + case ("keyword.evolution"): + return .Theme.Syntax.symbol + case ("keyword.inertia"): + return .Theme.Syntax.symbol + case ("keyword.stage"): + return .Theme.Syntax.symbol + case ("keyword.stage_number"): + return .Theme.Syntax.symbol + case ("keyword.note"): + return .Theme.Syntax.symbol + case ("keyword.group"): + return .Theme.Syntax.symbol + default: + return .Theme.Syntax.text + } + } } struct UI { static let background = NSColor(named: "Background") ?? .windowBackgroundColor - static let border = NSColor(named: "Border") ?? .separatorColor } } } diff --git a/Map/Presentation/Theme/NSFont+theme.swift b/Map/Presentation/Theme/NSFont+theme.swift index cd119f2..712cc1d 100644 --- a/Map/Presentation/Theme/NSFont+theme.swift +++ b/Map/Presentation/Theme/NSFont+theme.swift @@ -16,30 +16,12 @@ import AppKit extension NSFont { - static func libertinus(size: CGFloat) -> NSFont { - return NSFont(name: "Libertinus Serif", size: size) ?? .systemFont(ofSize: size) - } - static func ronzino(size: CGFloat) -> NSFont { return NSFont(name: "Ronzino", size: size) ?? .systemFont(ofSize: size) } public struct Theme { - struct Body { - @MainActor static let regular = NSFont.ronzino(size: Dimensions.FontSize.body) - @MainActor static let emphasized = NSFont.ronzino(size: Dimensions.FontSize.body) - } - - struct Title { - @MainActor static let emphasized = NSFont.libertinus(size: Dimensions.FontSize.title) - } - - struct Caption { - @MainActor static let regular = NSFont.ronzino(size: Dimensions.FontSize.caption) - @MainActor static let emphasized = NSFont.ronzino(size: Dimensions.FontSize.caption) - } - struct SmallControl { @MainActor static let regular = NSFont.ronzino(size: Dimensions.FontSize.smallControl) @MainActor static let emphasized = NSFont.ronzino(size: Dimensions.FontSize.smallControl) -- cgit