Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new custom code editor #147

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
disabled_rules:
- todo
- todo
- trailing_comma
9 changes: 0 additions & 9 deletions CodeEdit.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
{
"object": {
"pins": [
{
"package": "CodeEditor",
"repositoryURL": "https://github.com/ZeeZide/CodeEditor.git",
"state": {
"branch": null,
"revision": "5856fac22b0a2174dbdea212784567c8c9cd1129",
"version": "1.2.0"
}
},
{
"package": "Highlightr",
"repositoryURL": "https://github.com/raspu/Highlightr",
Expand Down
216 changes: 0 additions & 216 deletions CodeEdit/ContentView.swift

This file was deleted.

3 changes: 3 additions & 0 deletions CodeEdit/Documents/WorkspaceCodeFileView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ struct WorkspaceCodeFileView: View {

@ViewBuilder var body: some View {
if let item = workspace.openFileItems.first(where: { file in
if file.id == workspace.selectedId {
print("Item loaded is: ", file.url)
}
return file.id == workspace.selectedId
}) {
if let codeFile = workspace.openedCodeFiles[item] {
Expand Down
2 changes: 1 addition & 1 deletion CodeEdit/Documents/WorkspaceDocument.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class WorkspaceDocument: NSDocument, ObservableObject, NSToolbarDelegate {
openedCodeFiles[item] = codeFile
}
selectedId = item.id

Swift.print("Opening file for item: ", item.url)
self.windowControllers.first?.window?.subtitle = item.url.lastPathComponent
} catch let err {
Swift.print(err)
Expand Down
9 changes: 6 additions & 3 deletions CodeEdit/Quick Open/QuickOpenPreviewView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import SwiftUI
import WorkspaceClient
import CodeFile
import CodeEditor

struct QuickOpenPreviewView: View {
var item: WorkspaceClient.FileItem
Expand All @@ -18,8 +17,12 @@ struct QuickOpenPreviewView: View {

var body: some View {
VStack {
if loaded {
ThemedCodeView($content, language: .init(url: item.url), editable: false)
if let codeFile = try? CodeFileDocument(
for: item.url,
withContentsOf: item.url,
ofType: "public.source-code"
), loaded {
CodeFileView(codeFile: codeFile, editable: false)
} else if let error = error {
Text(error)
} else {
Expand Down
16 changes: 8 additions & 8 deletions CodeEdit/Settings/GeneralSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

import SwiftUI
import CodeFile
import CodeEditor

// MARK: - View

struct GeneralSettingsView: View {
@AppStorage(Appearances.storageKey) var appearance: Appearances = .default
@AppStorage(ReopenBehavior.storageKey) var reopenBehavior: ReopenBehavior = .default
@AppStorage(FileIconStyle.storageKey) var fileIconStyle: FileIconStyle = .default
@AppStorage(CodeEditorTheme.storageKey) var editorTheme: CodeEditor.ThemeName = .atelierSavannaAuto
@AppStorage(FileIconStyle.storageKey) var fileIconStyle: FileIconStyle = .default
@AppStorage(CodeFileView.Theme.storageKey) var editorTheme: CodeFileView.Theme = .atelierSavannaAuto

var body: some View {
Form {
Picker("Appearance".localized(), selection: $appearance) {
Expand Down Expand Up @@ -50,18 +50,18 @@ struct GeneralSettingsView: View {

Picker("Editor Theme".localized(), selection: $editorTheme) {
Text("Atelier Savanna (Auto)")
.tag(CodeEditor.ThemeName.atelierSavannaAuto)
.tag(CodeFileView.Theme.atelierSavannaAuto)
Text("Atelier Savanna Dark")
.tag(CodeEditor.ThemeName.atelierSavannaDark)
.tag(CodeFileView.Theme.atelierSavannaDark)
Text("Atelier Savanna Light")
.tag(CodeEditor.ThemeName.atelierSavannaLight)
.tag(CodeFileView.Theme.atelierSavannaLight)
// TODO: Pojoaque does not seem to work (does not change from previous selection)
// Text("Pojoaque")
// .tag(CodeEditor.ThemeName.pojoaque)
Text("Agate")
.tag(CodeEditor.ThemeName.agate)
.tag(CodeFileView.Theme.agate)
Text("Ocean")
.tag(CodeEditor.ThemeName.ocean)
.tag(CodeFileView.Theme.ocean)
}
}
.padding()
Expand Down
18 changes: 12 additions & 6 deletions CodeEdit/WorkspaceView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,17 @@ struct WorkspaceView: View {
NavigatorSidebar(workspace: workspace, windowController: windowController)
.frame(minWidth: 250)
HSplitView {
WorkspaceCodeFileView(windowController: windowController,
workspace: workspace)
.frame(maxWidth: .infinity, maxHeight: .infinity)
InspectorSidebar(workspace: workspace, windowController: windowController)
.frame(minWidth: 250, maxWidth: .infinity, maxHeight: .infinity)
WorkspaceCodeFileView(
windowController: windowController,
workspace: workspace
)
.frame(maxWidth: .infinity, maxHeight: .infinity)

InspectorSidebar(
workspace: workspace,
windowController: windowController
)
.frame(minWidth: 250, maxWidth: .infinity, maxHeight: .infinity)
}
} else {
EmptyView()
Expand All @@ -56,7 +62,7 @@ struct WorkspaceView: View {
}
}

struct ContentView_Previews: PreviewProvider {
struct WorkspaceView_Previews: PreviewProvider {
static var previews: some View {
WorkspaceView(windowController: NSWindowController(), workspace: .init())
}
Expand Down
Loading