Skip to content

Commit eafcc6b

Browse files
authored
Extensions Base (#1274)
* Add local CodeEditKit package Signed-off-by: Wouter01 <[email protected]> * moved foldermonitor and created extensions window Signed-off-by: Wouter01 <[email protected]> * Readded various extension structs Signed-off-by: Wouter01 <[email protected]> * Fixed inspector extensions Signed-off-by: Wouter01 <[email protected]> * fixed regression Signed-off-by: Wouter01 <[email protected]> * update packages Signed-off-by: Wouter01 <[email protected]> * added processidentifier to extension Signed-off-by: Wouter01 <[email protected]> * fixed inspector Signed-off-by: Wouter01 <[email protected]> * added logs to codeedit console Signed-off-by: Wouter01 <[email protected]> * added separate tabs for each extension Signed-off-by: Wouter01 <[email protected]> * small fixes Signed-off-by: Wouter01 <[email protected]> * add hot reloading Signed-off-by: Wouter01 <[email protected]> * Fixed navigator extensions Signed-off-by: Wouter01 <[email protected]> * fir warnings Signed-off-by: Wouter01 <[email protected]> * add CodeEditKit as remote package Signed-off-by: Wouter01 <[email protected]> * fix build issue Signed-off-by: Wouter01 <[email protected]> * config fixes Signed-off-by: Wouter01 <[email protected]> * fix swiftlint Signed-off-by: Wouter01 <[email protected]> * warning fixes Signed-off-by: Wouter01 <[email protected]> * swiftlint fix Signed-off-by: Wouter01 <[email protected]> * test fix Signed-off-by: Wouter01 <[email protected]> * remove swiftlint:disable in Commands+ForEach Signed-off-by: Wouter01 <[email protected]> * improvements for other comments Signed-off-by: Wouter01 <[email protected]> * resolve comments Signed-off-by: Wouter01 <[email protected]> * swiftlint fix Signed-off-by: Wouter01 <[email protected]> --------- Signed-off-by: Wouter01 <[email protected]>
1 parent 0016e3b commit eafcc6b

35 files changed

+1649
-209
lines changed

CodeEdit.xcodeproj/project.pbxproj

+185-31
Large diffs are not rendered by default.

CodeEdit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

+117
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
{
22
"pins" : [
3+
{
4+
"identity" : "anycodable",
5+
"kind" : "remoteSourceControl",
6+
"location" : "https://github.com/Flight-School/AnyCodable",
7+
"state" : {
8+
"revision" : "862808b2070cd908cb04f9aafe7de83d35f81b05",
9+
"version" : "0.6.7"
10+
}
11+
},
12+
{
13+
"identity" : "codeeditkit",
14+
"kind" : "remoteSourceControl",
15+
"location" : "https://github.com/CodeEditApp/CodeEditKit",
16+
"state" : {
17+
"branch" : "dev/foundation",
18+
"revision" : "b0e0c5be9ff5d2cff56bb0cda3df5c0d9c4e029b"
19+
}
20+
},
321
{
422
"identity" : "codeeditlanguages",
523
"kind" : "remoteSourceControl",
@@ -27,6 +45,105 @@
2745
"version" : "0.6.3"
2846
}
2947
},
48+
{
49+
"identity" : "collectionconcurrencykit",
50+
"kind" : "remoteSourceControl",
51+
"location" : "https://github.com/johnsundell/collectionconcurrencykit",
52+
"state" : {
53+
"revision" : "b4f23e24b5a1bff301efc5e70871083ca029ff95",
54+
"version" : "0.2.0"
55+
}
56+
},
57+
{
58+
"identity" : "concurrencyplus",
59+
"kind" : "remoteSourceControl",
60+
"location" : "https://github.com/ChimeHQ/ConcurrencyPlus",
61+
"state" : {
62+
"branch" : "main",
63+
"revision" : "8dc56499412a373d617d50d059116bccf44b9874"
64+
}
65+
},
66+
{
67+
"identity" : "fseventswrapper",
68+
"kind" : "remoteSourceControl",
69+
"location" : "https://github.com/Frizlab/FSEventsWrapper",
70+
"state" : {
71+
"revision" : "e0c59a2ce2775e5f6642da6d19207445f10112d0",
72+
"version" : "1.0.2"
73+
}
74+
},
75+
{
76+
"identity" : "glob",
77+
"kind" : "remoteSourceControl",
78+
"location" : "https://github.com/Bouke/Glob",
79+
"state" : {
80+
"revision" : "deda6e163d2ff2a8d7e138e2c3326dbd71157faf",
81+
"version" : "1.0.5"
82+
}
83+
},
84+
{
85+
"identity" : "grdb.swift",
86+
"kind" : "remoteSourceControl",
87+
"location" : "https://github.com/groue/GRDB.swift.git",
88+
"state" : {
89+
"revision" : "dd7e7f39e8e4d7a22d258d9809a882f914690b01",
90+
"version" : "5.26.1"
91+
}
92+
},
93+
{
94+
"identity" : "jsonrpc",
95+
"kind" : "remoteSourceControl",
96+
"location" : "https://github.com/ChimeHQ/JSONRPC",
97+
"state" : {
98+
"revision" : "afc20d00e38674774f84edc325424a32ae3b9e01",
99+
"version" : "0.7.0"
100+
}
101+
},
102+
{
103+
"identity" : "languageclient",
104+
"kind" : "remoteSourceControl",
105+
"location" : "https://github.com/ChimeHQ/LanguageClient",
106+
"state" : {
107+
"revision" : "92beeecd0bb783da52227839ba6c55e43fc866ec",
108+
"version" : "0.5.1"
109+
}
110+
},
111+
{
112+
"identity" : "languageserverprotocol",
113+
"kind" : "remoteSourceControl",
114+
"location" : "https://github.com/ChimeHQ/LanguageServerProtocol",
115+
"state" : {
116+
"revision" : "192bcfdcf7a013da49c6fa1b95de66254ce7c614",
117+
"version" : "0.9.1"
118+
}
119+
},
120+
{
121+
"identity" : "logstream",
122+
"kind" : "remoteSourceControl",
123+
"location" : "https://github.com/CodeEditApp/LogStream",
124+
"state" : {
125+
"revision" : "afd2422c65c12822f26606408b4e39b9549c5e1a",
126+
"version" : "1.2.1"
127+
}
128+
},
129+
{
130+
"identity" : "processenv",
131+
"kind" : "remoteSourceControl",
132+
"location" : "https://github.com/ChimeHQ/ProcessEnv",
133+
"state" : {
134+
"revision" : "29487b6581bb785c372c611c943541ef4309d051",
135+
"version" : "0.3.1"
136+
}
137+
},
138+
{
139+
"identity" : "processservice",
140+
"kind" : "remoteSourceControl",
141+
"location" : "https://github.com/ChimeHQ/ProcessService",
142+
"state" : {
143+
"revision" : "369fb0379983d3b43c7d7ad62c4e91ee020e347c",
144+
"version" : "0.2.6"
145+
}
146+
},
30147
{
31148
"identity" : "rearrange",
32149
"kind" : "remoteSourceControl",

CodeEdit.xcodeproj/xcshareddata/xcschemes/CodeEdit.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1410"
3+
LastUpgradeVersion = "1430"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

CodeEdit/CodeEditApp.swift

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ struct CodeEditApp: App {
2424
WelcomeWindow()
2525
.keyboardShortcut("1", modifiers: [.command, .shift])
2626

27+
ExtensionManagerWindow()
28+
.keyboardShortcut("2", modifiers: [.command, .shift])
29+
2730
AboutWindow()
2831

2932
SettingsWindow()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
//
2+
// SegmentedControlImproved.swift
3+
// CodeEdit
4+
//
5+
// Created by Wouter Hennen on 22/05/2023.
6+
//
7+
8+
import SwiftUI
9+
10+
extension ButtonStyle where Self == XcodeButtonStyle {
11+
static func xcodeButton(
12+
isActive: Bool,
13+
prominent: Bool,
14+
isHovering: Bool,
15+
namespace: Namespace.ID = Namespace().wrappedValue
16+
) -> XcodeButtonStyle {
17+
XcodeButtonStyle(isActive: isActive, prominent: prominent, isHovering: isHovering, namespace: namespace)
18+
}
19+
}
20+
21+
struct XcodeButtonStyle: ButtonStyle {
22+
var isActive: Bool
23+
var prominent: Bool
24+
var isHovering: Bool
25+
var namespace: Namespace.ID
26+
27+
@Environment(\.controlSize) var controlSize
28+
29+
@Environment(\.colorScheme) var colorScheme
30+
31+
@Environment(\.controlActiveState) private var activeState
32+
33+
func makeBody(configuration: Configuration) -> some View {
34+
configuration.label
35+
.padding(.horizontal, controlSizePadding.horizontal)
36+
.padding(.vertical, controlSizePadding.vertical)
37+
.font(fontSize)
38+
.foregroundColor(isActive ? .white : .primary)
39+
.opacity(textOpacity)
40+
.background {
41+
if isActive {
42+
RoundedRectangle(cornerRadius: 5)
43+
.foregroundColor(.accentColor)
44+
.opacity(configuration.isPressed ? (prominent ? 0.75 : 0.5) : (prominent ? 1 : 0.75))
45+
.matchedGeometryEffect(id: "xcodebuttonbackground", in: namespace)
46+
47+
} else if isHovering {
48+
RoundedRectangle(cornerRadius: 5)
49+
.foregroundColor(.gray)
50+
.opacity(0.2)
51+
.transition(.opacity)
52+
.animation(.easeInOut, value: isHovering)
53+
}
54+
}
55+
.opacity(activeState == .inactive ? 0.6 : 1)
56+
.animation(.interpolatingSpring(stiffness: 600, damping: 50), value: isActive)
57+
}
58+
59+
var fontSize: Font {
60+
switch controlSize {
61+
case .mini:
62+
return .footnote
63+
case .small, .regular:
64+
return .subheadline
65+
default:
66+
return .callout
67+
}
68+
}
69+
70+
var controlSizePadding: (vertical: CGFloat, horizontal: CGFloat) {
71+
switch controlSize {
72+
case .mini:
73+
return (1, 2)
74+
case .small:
75+
return (2, 4)
76+
case .regular:
77+
return (3, 8)
78+
case .large:
79+
return (6, 12)
80+
@unknown default:
81+
return (4, 8)
82+
}
83+
}
84+
85+
private var textOpacity: Double {
86+
if prominent {
87+
return activeState != .inactive ? 1 : isActive ? 1 : 0.3
88+
} else {
89+
return activeState != .inactive ? 1 : isActive ? 0.5 : 0.3
90+
}
91+
}
92+
}
93+
94+
private struct MyTag: _ViewTraitKey {
95+
static var defaultValue: AnyHashable? = Optional<Int>.none
96+
}
97+
98+
extension View {
99+
func segmentedTag<Value: Hashable>(_ value: Value) -> some View {
100+
_trait(MyTag.self, value)
101+
}
102+
}
103+
104+
struct SegmentedControlV2<Selection: Hashable, Content: View>: View {
105+
@Binding var selection: Selection
106+
var prominent: Bool
107+
@ViewBuilder var content: Content
108+
109+
@State private var hoveringOver: Selection?
110+
111+
@Namespace var namespace
112+
113+
var body: some View {
114+
content.variadic { children in
115+
HStack(spacing: 8) {
116+
ForEach(children, id: \.id) { option in
117+
let tag: Selection? = option[MyTag.self].flatMap { $0 as? Selection }
118+
Button {
119+
hoveringOver = nil
120+
if let tag {
121+
selection = tag
122+
}
123+
} label: {
124+
option
125+
}
126+
.buttonStyle(
127+
.xcodeButton(
128+
isActive: tag == selection,
129+
prominent: prominent,
130+
isHovering: tag == hoveringOver,
131+
namespace: namespace
132+
)
133+
)
134+
.onHover { hover in
135+
hoveringOver = hover ? tag : nil
136+
}
137+
.animation(.interpolatingSpring(stiffness: 600, damping: 50), value: selection)
138+
}
139+
}
140+
}
141+
}
142+
}

CodeEdit/Features/Documents/Controllers/CodeEditDocumentController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ final class CodeEditDocumentController: NSDocumentController {
9292

9393
override func clearRecentDocuments(_ sender: Any?) {
9494
super.clearRecentDocuments(sender)
95-
UserDefaults.standard.set([], forKey: "recentProjectPaths")
95+
UserDefaults.standard.set([Any](), forKey: "recentProjectPaths")
9696
}
9797
}
9898

0 commit comments

Comments
 (0)