aboutsummaryrefslogtreecommitdiff
path: root/Map/Presentation/Base Components
diff options
context:
space:
mode:
Diffstat (limited to 'Map/Presentation/Base Components')
-rw-r--r--Map/Presentation/Base Components/EvolutionPicker/EvolutionPicker.swift2
-rw-r--r--Map/Presentation/Base Components/EvolutionPicker/GlassEvolutionPicker.swift2
-rw-r--r--Map/Presentation/Base Components/MapRender/MapBackground.swift2
-rw-r--r--Map/Presentation/Base Components/MapRender/MapGroup.swift2
-rw-r--r--Map/Presentation/Base Components/MapRender/MapGroups.swift2
-rw-r--r--Map/Presentation/Base Components/MapRender/MapIntertias.swift2
-rw-r--r--Map/Presentation/Base Components/MapRender/MapMask.swift2
-rw-r--r--Map/Presentation/Base Components/MapRender/MapVertices.swift4
-rw-r--r--Map/Presentation/Base Components/MapTextEditor/HoverView.swift4
-rw-r--r--Map/Presentation/Base Components/MapTextEditor/MapTextEditor.swift35
10 files changed, 30 insertions, 27 deletions
diff --git a/Map/Presentation/Base Components/EvolutionPicker/EvolutionPicker.swift b/Map/Presentation/Base Components/EvolutionPicker/EvolutionPicker.swift
index 83d5009..5983745 100644
--- a/Map/Presentation/Base Components/EvolutionPicker/EvolutionPicker.swift
+++ b/Map/Presentation/Base Components/EvolutionPicker/EvolutionPicker.swift
@@ -20,7 +20,7 @@ struct EvolutionPicker: View {
@State var isHovered = false
@Binding var selectedEvolution: StageType
-
+
var body: some View {
Button(
diff --git a/Map/Presentation/Base Components/EvolutionPicker/GlassEvolutionPicker.swift b/Map/Presentation/Base Components/EvolutionPicker/GlassEvolutionPicker.swift
index 72a572a..6d2f6c4 100644
--- a/Map/Presentation/Base Components/EvolutionPicker/GlassEvolutionPicker.swift
+++ b/Map/Presentation/Base Components/EvolutionPicker/GlassEvolutionPicker.swift
@@ -20,7 +20,7 @@ struct GlassEvolutionPicker: View {
@State var isShowingMenu = false
@Binding var selectedEvolution: StageType
-
+
var body: some View {
Button(
diff --git a/Map/Presentation/Base Components/MapRender/MapBackground.swift b/Map/Presentation/Base Components/MapRender/MapBackground.swift
index 710d549..d1e48d8 100644
--- a/Map/Presentation/Base Components/MapRender/MapBackground.swift
+++ b/Map/Presentation/Base Components/MapRender/MapBackground.swift
@@ -20,7 +20,7 @@ struct MapBackground: View {
let mapSize: CGSize
let stages: [Double]
-
+
var body: some View {
ZStack(alignment: .topLeading) {
PatternView(
diff --git a/Map/Presentation/Base Components/MapRender/MapGroup.swift b/Map/Presentation/Base Components/MapRender/MapGroup.swift
index ca5e954..ccec52f 100644
--- a/Map/Presentation/Base Components/MapRender/MapGroup.swift
+++ b/Map/Presentation/Base Components/MapRender/MapGroup.swift
@@ -91,6 +91,6 @@ struct MapGroup: View {
Vertex(id: 0, label: "A Circle", position: CGPoint(x: 50.0, y: 50.0)),
Vertex(id: 1, label: "A Square", position: CGPoint(x: 10.0, y: 20.0), shape: .square),
Vertex(id: 2, label: "A triangle", position: CGPoint(x: 25, y: 32.0), shape: .triangle),
- Vertex(id: 3, label: "An X", position: CGPoint(x: 70.0, y: 70.0), shape: .xMark),
+ Vertex(id: 3, label: "An X", position: CGPoint(x: 70.0, y: 70.0), shape: .xMark)
], color: .red)
}
diff --git a/Map/Presentation/Base Components/MapRender/MapGroups.swift b/Map/Presentation/Base Components/MapRender/MapGroups.swift
index 149ea65..8676f1a 100644
--- a/Map/Presentation/Base Components/MapRender/MapGroups.swift
+++ b/Map/Presentation/Base Components/MapRender/MapGroups.swift
@@ -40,7 +40,7 @@ struct MapGroups: View {
Vertex(id: 0, label: "A Circle", position: CGPoint(x: 50.0, y: 50.0)),
Vertex(id: 1, label: "A Square", position: CGPoint(x: 10.0, y: 20.0), shape: .square),
Vertex(id: 2, label: "A triangle", position: CGPoint(x: 25, y: 32.0), shape: .triangle),
- Vertex(id: 3, label: "An X", position: CGPoint(x: 70.0, y: 70.0), shape: .xMark),
+ Vertex(id: 3, label: "An X", position: CGPoint(x: 70.0, y: 70.0), shape: .xMark)
]
])
}
diff --git a/Map/Presentation/Base Components/MapRender/MapIntertias.swift b/Map/Presentation/Base Components/MapRender/MapIntertias.swift
index 91ec6f9..9e013c6 100644
--- a/Map/Presentation/Base Components/MapRender/MapIntertias.swift
+++ b/Map/Presentation/Base Components/MapRender/MapIntertias.swift
@@ -50,6 +50,6 @@ struct MapIntertias: View {
mapSize: CGSize(width: 400.0, height: 400.0), vertexSize: CGSize(width: 25.0, height: 25.0),
inertias: [
Inertia(id: 0, position: CGPoint(x: 50.0, y: 50.0)),
- Inertia(id: 1, position: CGPoint(x: 10.0, y: 20.0)),
+ Inertia(id: 1, position: CGPoint(x: 10.0, y: 20.0))
])
}
diff --git a/Map/Presentation/Base Components/MapRender/MapMask.swift b/Map/Presentation/Base Components/MapRender/MapMask.swift
index c4ba055..05070bf 100644
--- a/Map/Presentation/Base Components/MapRender/MapMask.swift
+++ b/Map/Presentation/Base Components/MapRender/MapMask.swift
@@ -65,7 +65,7 @@ struct MapMask: View {
Vertex(id: 0, label: "A Circle", position: CGPoint(x: 50.0, y: 50.0)),
Vertex(id: 1, label: "A Square", position: CGPoint(x: 10.0, y: 20.0), shape: .square),
Vertex(id: 2, label: "A triangle", position: CGPoint(x: 25, y: 32.0), shape: .triangle),
- Vertex(id: 3, label: "An X", position: CGPoint(x: 70.0, y: 70.0), shape: .xMark),
+ Vertex(id: 3, label: "An X", position: CGPoint(x: 70.0, y: 70.0), shape: .xMark)
],
labelPositions: [:])
}
diff --git a/Map/Presentation/Base Components/MapRender/MapVertices.swift b/Map/Presentation/Base Components/MapRender/MapVertices.swift
index a3558fa..0ab7fab 100644
--- a/Map/Presentation/Base Components/MapRender/MapVertices.swift
+++ b/Map/Presentation/Base Components/MapRender/MapVertices.swift
@@ -23,7 +23,7 @@ struct MapVertices: View {
let padding = CGFloat(5.0)
@State private var offset = CGSize.zero
- @State private var draggingVertex: Vertex? = nil
+ @State private var draggingVertex: Vertex?
var onDragVertex: (Vertex, CGFloat, CGFloat) -> Void = { _, _, _ in }
@@ -156,7 +156,7 @@ struct MapVertices: View {
Vertex(id: 0, label: "A Circle", position: CGPoint(x: 50.0, y: 50.0)),
Vertex(id: 1, label: "A Square", position: CGPoint(x: 10.0, y: 20.0), shape: .square),
Vertex(id: 2, label: "A triangle", position: CGPoint(x: 25, y: 32.0), shape: .triangle),
- Vertex(id: 3, label: "An X", position: CGPoint(x: 70.0, y: 70.0), shape: .xMark),
+ Vertex(id: 3, label: "An X", position: CGPoint(x: 70.0, y: 70.0), shape: .xMark)
],
labelPositions: [:])
}
diff --git a/Map/Presentation/Base Components/MapTextEditor/HoverView.swift b/Map/Presentation/Base Components/MapTextEditor/HoverView.swift
index eeccec3..69ebfc0 100644
--- a/Map/Presentation/Base Components/MapTextEditor/HoverView.swift
+++ b/Map/Presentation/Base Components/MapTextEditor/HoverView.swift
@@ -49,7 +49,7 @@ class HoverView: NSView {
box.topAnchor.constraint(equalTo: topAnchor),
box.leadingAnchor.constraint(equalTo: leadingAnchor),
box.trailingAnchor.constraint(equalTo: trailingAnchor),
- box.bottomAnchor.constraint(equalTo: bottomAnchor),
+ box.bottomAnchor.constraint(equalTo: bottomAnchor)
])
let label = NSTextField(labelWithString: message)
@@ -89,7 +89,7 @@ class HoverView: NSView {
button.leadingAnchor.constraint(equalTo: label.trailingAnchor, constant: 8),
button.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -8),
- heightAnchor.constraint(equalToConstant: 32),
+ heightAnchor.constraint(equalToConstant: 32)
])
}
diff --git a/Map/Presentation/Base Components/MapTextEditor/MapTextEditor.swift b/Map/Presentation/Base Components/MapTextEditor/MapTextEditor.swift
index 99fa684..2850c57 100644
--- a/Map/Presentation/Base Components/MapTextEditor/MapTextEditor.swift
+++ b/Map/Presentation/Base Components/MapTextEditor/MapTextEditor.swift
@@ -13,12 +13,11 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see https://map.tranquil.systems.
import Cocoa
-import SwiftUI
-import WmapParser
import SwiftTreeSitter
import SwiftTreeSitterLayer
+import SwiftUI
import TreeSitterWmap
-
+import WmapParser
class MapTextEditorController: NSViewController {
@@ -63,7 +62,7 @@ class MapTextEditorController: NSViewController {
self.highlightRanges = highlightRanges
self.selectedRange = selectedRange
super.init(nibName: nil, bundle: nil)
-
+
if let wmapConfiguration = try? LanguageConfiguration(tree_sitter_wmap(), name: "wmap") {
let languageConfiguration = LanguageLayer.Configuration(languageProvider: { name in
switch name {
@@ -71,7 +70,8 @@ class MapTextEditorController: NSViewController {
default: return nil
}
})
- self.rootLayer = try? LanguageLayer(languageConfig: wmapConfiguration, configuration: languageConfiguration)
+ self.rootLayer = try? LanguageLayer(
+ languageConfig: wmapConfiguration, configuration: languageConfiguration)
}
}
@@ -83,7 +83,7 @@ class MapTextEditorController: NSViewController {
override func loadView() {
let scrollView = NSTextView.scrollableTextView()
let textView = scrollView.documentView as! NSTextView
-
+
scrollView.translatesAutoresizingMaskIntoConstraints = false
textView.backgroundColor = .Theme.UI.background
@@ -105,14 +105,16 @@ class MapTextEditorController: NSViewController {
textView.textContainer?.containerSize = NSSize(
width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude)
// Allow text view to grow horizontally
- textView.maxSize = NSSize(width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude)
+ textView.maxSize = NSSize(
+ width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude)
// Enable horizontal scrollbar when soft wrap is disabled
scrollView.hasHorizontalScroller = true
scrollView.horizontalScrollElasticity = .none
} else {
textView.textContainer?.widthTracksTextView = true
// Reset max size for wrapping
- textView.maxSize = NSSize(width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude)
+ textView.maxSize = NSSize(
+ width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude)
// Hide horizontal scrollbar when soft wrap is enabled
scrollView.hasHorizontalScroller = false
scrollView.horizontalScrollElasticity = .automatic
@@ -291,7 +293,7 @@ class MapTextEditorController: NSViewController {
NSLayoutConstraint.activate([
hoverView.leadingAnchor.constraint(equalTo: textView.leadingAnchor, constant: hoverX),
- hoverView.topAnchor.constraint(equalTo: textView.topAnchor, constant: hoverY),
+ hoverView.topAnchor.constraint(equalTo: textView.topAnchor, constant: hoverY)
])
self.hoverView = hoverView
@@ -356,7 +358,8 @@ class MapTextEditorController: NSViewController {
}
private func applyTreeSitterHighlighting(textStorage: NSTextStorage, range: NSRange) {
- guard let highlights = try? rootLayer?.highlights(in: range, provider: text.predicateTextProvider)
+ guard
+ let highlights = try? rootLayer?.highlights(in: range, provider: text.predicateTextProvider)
else { return }
for highlight in highlights {
@@ -367,11 +370,12 @@ class MapTextEditorController: NSViewController {
// Check for missing components
if UserDefaults.standard.bool(forKey: "useSmartEditor"),
- let parsedMap,
- highlight.name == "variable.component_label" {
+ let parsedMap,
+ highlight.name == "variable.component_label" {
// Extract the component label text from the range
- let componentText = (textStorage.string as NSString).substring(with: highlight.range).trimmingCharacters(in: .whitespacesAndNewlines)
+ let componentText = (textStorage.string as NSString).substring(with: highlight.range)
+ .trimmingCharacters(in: .whitespacesAndNewlines)
// Check if this component exists in the parsed map
let componentExists = parsedMap.components.contains(where: {
@@ -408,8 +412,7 @@ extension MapTextEditorController: NSTextViewDelegate {
}
}
- func textView(_ view: NSTextView, shouldChangeTextIn: NSRange, replacementString: String?) -> Bool
- {
+ func textView(_ view: NSTextView, shouldChangeTextIn: NSRange, replacementString: String?) -> Bool {
let range = Range(shouldChangeTextIn, in: view.string)
let target = view.string[range!]
@@ -458,7 +461,7 @@ extension MapTextEditorController: NSTextStorageDelegate {
}
private func colorizeText(textStorage: NSTextStorage) {
- let range = NSMakeRange(0, textStorage.length)
+ let range = NSRange(location: 0, length: textStorage.length)
colorizeTextRange(textStorage: textStorage, range: range)
}