Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
ec3fd26
started themes settings UI
lukepistrol Mar 30, 2022
dd2129b
added selection state for themes
lukepistrol Mar 30, 2022
dadfe27
Merge branch 'main' into feature/prefs-themes
lukepistrol Mar 30, 2022
871540b
Added shadows, added color picker dummies
lukepistrol Mar 30, 2022
95e9b4b
Merge branch 'CodeEditApp:main' into feature/prefs-themes
Mar 30, 2022
5c340b0
Implementing theme files (json). Implementing new UI for theme and te…
lukepistrol Mar 31, 2022
ca712b7
updates
lukepistrol Mar 31, 2022
4f19516
Merge branch 'CodeEditApp:main' into feature/prefs-themes
Mar 31, 2022
e297a34
Quickfix - no themes loaded
lukepistrol Mar 31, 2022
3e8c02d
adjusted window tint of preview icons
lukepistrol Mar 31, 2022
b9cd31a
added terminal color support for themes.
lukepistrol Mar 31, 2022
e48c035
updated theme model
lukepistrol Mar 31, 2022
91ab407
Merge branch 'CodeEditApp:main' into feature/prefs-themes
Mar 31, 2022
e92bf9d
Merge branch 'CodeEditApp:main' into feature/prefs-themes
Apr 1, 2022
c5fe3e6
implemented `~/.codeedit/preferences.json
lukepistrol Apr 1, 2022
4be1ee1
create `~/.codeedit/`directory if non-existent
lukepistrol Apr 1, 2022
79311f8
implemented remaining terminal settings to `~/.codeedit/preferences.j…
lukepistrol Apr 1, 2022
ffac43f
documentation added
lukepistrol Apr 1, 2022
dfef953
fix lint errors
lukepistrol Apr 1, 2022
490bb0c
updated file headers
lukepistrol Apr 1, 2022
3c11c87
removed commented code
lukepistrol Apr 1, 2022
58e3783
Merge branch 'main' into feature/prefs-themes
lukepistrol Apr 1, 2022
5430ab7
implemented theme overrides, themes can be reset
lukepistrol Apr 2, 2022
3f95eee
Merge branch 'main' into feature/prefs-themes
lukepistrol Apr 2, 2022
6f04c3e
implemented remaining terminal color options
lukepistrol Apr 2, 2022
3d788a0
themes can now be deleted
lukepistrol Apr 2, 2022
e4acdaa
added list view of themes
lukepistrol Apr 2, 2022
837c91f
added documentation
lukepistrol Apr 2, 2022
4bd3186
added editor font selector (not yet functional)
lukepistrol Apr 2, 2022
2baa494
Merge branch 'main' into feature/prefs-themes
lukepistrol Apr 2, 2022
2965217
added context menu to list items, added help descriptions, disabled n…
lukepistrol Apr 2, 2022
9785f92
fix default theme not appearing in folder, theme cannot be deleted if…
lukepistrol Apr 2, 2022
e3a6754
removed `swiftlint:disable`
lukepistrol Apr 2, 2022
4730e5a
remove overrides when deleting a theme
lukepistrol Apr 2, 2022
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
12 changes: 12 additions & 0 deletions CodeEdit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
0485EB2527E7B9C800138301 /* Overlays in Frameworks */ = {isa = PBXBuildFile; productRef = 0485EB2427E7B9C800138301 /* Overlays */; };
20D2A95527F72E6800E7ECF6 /* Accounts in Frameworks */ = {isa = PBXBuildFile; productRef = 20D2A95427F72E6800E7ECF6 /* Accounts */; };
2803257127F3CF1F009C7DC2 /* AppPreferences in Frameworks */ = {isa = PBXBuildFile; productRef = 2803257027F3CF1F009C7DC2 /* AppPreferences */; };
28069DA427F5BCF70016BC47 /* default-dark.json in Resources */ = {isa = PBXBuildFile; fileRef = 28069DA327F5BCDD0016BC47 /* default-dark.json */; };
2806CBD427EE9FC0003E5523 /* ProjectNavigatorContextMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2806CBD327EE9FC0003E5523 /* ProjectNavigatorContextMenu.swift */; };
2813F93827ECC4AA00E305E4 /* FindNavigatorResultList.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7E201B327E9989900CB86D0 /* FindNavigatorResultList.swift */; };
2813F93927ECC4C300E305E4 /* NavigatorSidebar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 287776E627E3413200D46668 /* NavigatorSidebar.swift */; };
Expand Down Expand Up @@ -87,6 +88,7 @@
0485EB1C27E7338100138301 /* QuickOpenItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuickOpenItem.swift; sourceTree = "<group>"; };
0485EB1E27E7458B00138301 /* WorkspaceCodeFileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WorkspaceCodeFileView.swift; sourceTree = "<group>"; };
0485EB2227E7791400138301 /* QuickOpenPreviewView.swift */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.swift; path = QuickOpenPreviewView.swift; sourceTree = "<group>"; tabWidth = 4; };
28069DA327F5BCDD0016BC47 /* default-dark.json */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = text.json; path = "default-dark.json"; sourceTree = "<group>"; tabWidth = 2; };
2806CBD327EE9FC0003E5523 /* ProjectNavigatorContextMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProjectNavigatorContextMenu.swift; sourceTree = "<group>"; };
286471AA27ED51FD0039369D /* ProjectNavigator.swift */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.swift; path = ProjectNavigator.swift; sourceTree = "<group>"; tabWidth = 4; };
286620A427E4AB6900E18C2B /* BreadcrumbsComponent.swift */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.swift; path = BreadcrumbsComponent.swift; sourceTree = "<group>"; tabWidth = 4; };
Expand Down Expand Up @@ -181,6 +183,14 @@
path = "Quick Open";
sourceTree = "<group>";
};
28069DA527F5BD320016BC47 /* DefaultThemes */ = {
isa = PBXGroup;
children = (
28069DA327F5BCDD0016BC47 /* default-dark.json */,
);
path = DefaultThemes;
sourceTree = "<group>";
};
286471AC27ED52950039369D /* ProjectNavigator */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -278,6 +288,7 @@
043C321927E32295006AE443 /* MainMenu.xib */,
B673FDAC27E8296A00795864 /* PressActionsModifier.swift */,
B658FB3127DA9E0F00EA4DBD /* WorkspaceView.swift */,
28069DA527F5BD320016BC47 /* DefaultThemes */,
);
path = CodeEdit;
sourceTree = "<group>";
Expand Down Expand Up @@ -454,6 +465,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
28069DA427F5BCF70016BC47 /* default-dark.json in Resources */,
B658FB3727DA9E1000EA4DBD /* Preview Assets.xcassets in Resources */,
D7211D4727E06BFE008F2ED7 /* Localizable.strings in Resources */,
B658FB3427DA9E1000EA4DBD /* Assets.xcassets in Resources */,
Expand Down
16 changes: 10 additions & 6 deletions CodeEdit/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject {
}

func applicationDidFinishLaunching(_ notification: Notification) {
if let appearanceString = UserDefaults.standard.string(forKey: Appearances.storageKey) {
Appearances(rawValue: appearanceString)?.applyAppearance()
}
AppPreferencesModel.shared.preferences.general.appAppearance.applyAppearance()

DispatchQueue.main.async {
if NSApp.windows.isEmpty {
Expand Down Expand Up @@ -77,8 +75,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject {
}

func handleOpen() {
let behavior = ReopenBehavior(rawValue: UserDefaults.standard.string(forKey: ReopenBehavior.storageKey)
?? ReopenBehavior.default.rawValue) ?? ReopenBehavior.default
let behavior = AppPreferencesModel.shared.preferences.general.reopenBehavior

switch behavior {
case .welcome:
Expand Down Expand Up @@ -174,7 +171,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject {
title: "Themes",
toolbarIcon: NSImage(systemSymbolName: "paintbrush", accessibilityDescription: nil)!
) {
PreferencesThemeView()
ThemePreferencesView()
},
Preferences.Pane(
identifier: Preferences.PaneIdentifier("TextEditing"),
Expand All @@ -183,6 +180,13 @@ class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject {
) {
PreferencesTextEditingView()
},
Preferences.Pane(
identifier: Preferences.PaneIdentifier("Terminal"),
title: "Terminal",
toolbarIcon: NSImage(systemSymbolName: "terminal", accessibilityDescription: nil)!
) {
PreferencesTerminalView()
},
Preferences.Pane(
identifier: Preferences.PaneIdentifier("KeyBindings"),
title: "Key Bindings",
Expand Down
7 changes: 4 additions & 3 deletions CodeEdit/Breadcrumbs/BreadcrumbsComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import WorkspaceClient
import AppPreferences

struct BreadcrumbsComponent: View {
@AppStorage(FileIconStyle.storageKey)
var iconStyle: FileIconStyle = .default

@StateObject
private var prefs: AppPreferencesModel = .shared

@ObservedObject
var workspace: WorkspaceDocument
Expand Down Expand Up @@ -51,7 +52,7 @@ struct BreadcrumbsComponent: View {
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 12)
.foregroundStyle(iconStyle == .color ? color : .secondary)
.foregroundStyle(prefs.preferences.general.fileIconStyle == .color ? color : .secondary)
.onAppear {
self.position = NSPoint(
x: geometry.frame(in: .global).minX,
Expand Down
124 changes: 124 additions & 0 deletions CodeEdit/DefaultThemes/default-dark.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
{
"type" : "dark",
"license" : "MIT",
"author" : "CodeEdit",
"description" : "CodeEdit default dark theme.",
"name" : "Default (Dark)",
"distributionURL" : "https:\/\/github.com\/CodeEditApp\/CodeEdit",
"version" : "0.0.1",
"editor" : {
"strings" : {
"color" : "#f0907f"
},
"comments" : {
"color" : "#97be71"
},
"numbers" : {
"color" : "#d6c775"
},
"commands" : {
"color" : "#c6a3f9"
},
"lineHighlight" : {
"color" : "#303030"
},
"values" : {
"color" : "#70c1e2"
},
"background" : {
"color" : "#1e1e1e"
},
"keywords" : {
"color" : "#ef8bb6"
},
"text" : {
"color" : "#DDDDDD"
},
"insertionPoint" : {
"color" : "#DDDDDD"
},
"selection" : {
"color" : "#8b8b8b"
},
"types" : {
"color" : "#93c7bc"
},
"variables" : {
"color" : "#70c1e2"
},
"attributes" : {
"color" : "#93c7bc"
},
"characters" : {
"color" : "#93c7bc"
},
"invisibles" : {
"color" : "#636363"
}
},
"terminal" : {
"text" : {
"color" : "#ffffff"
},
"boldText" : {
"color" : "#ffffff"
},
"cursor" : {
"color" : "#ffffff"
},
"background" : {
"color" : "#1e1e1e"
},
"selection" : {
"color" : "#8b8b8b"
},
"black" : {
"color" : "#000000"
},
"red" : {
"color" : "#990000"
},
"green" : {
"color" : "#00a600"
},
"yellow" : {
"color" : "#999900"
},
"blue" : {
"color" : "#0000b2"
},
"magenta" : {
"color" : "#b200b2"
},
"cyan" : {
"color" : "#00a6b2"
},
"white" : {
"color" : "#bfbfbf"
},
"brightBlack" : {
"color" : "#666666"
},
"brightRed" : {
"color" : "#e50000"
},
"brightGreen" : {
"color" : "#00d900"
},
"brightYellow" : {
"color" : "#e5e500"
},
"brightBlue" : {
"color" : "#0000ff"
},
"brightMagenta" : {
"color" : "#e500e5"
},
"brightCyan" : {
"color" : "#00e5e5"
},
"brightWhite" : {
"color" : "#e5e5e5"
}
}
}
2 changes: 1 addition & 1 deletion CodeEdit/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@
</dict>
</array>
<key>GitHash</key>
<string>aec92088b4c2e9e20f29a7592e6e787cd72f3b8f</string>
<string>e3a67545e65e3719f05ef880787360c7551564e9</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ import AppPreferences
/// Displays a File or Folder in the ``ProjectNavigator``.
///
struct ProjectNavigatorItem: View {
@AppStorage(FileIconStyle.storageKey)
var iconStyle: FileIconStyle = .default

@StateObject
private var prefs: AppPreferencesModel = .shared

/// The `FileItem` for this view
var item: WorkspaceClient.FileItem
Expand Down Expand Up @@ -93,6 +94,6 @@ struct ProjectNavigatorItem: View {

/// Returns a color depending on the set icon color style in preferences
private var iconColor: Color {
return iconStyle == .color ? item.iconColor : .secondary
return prefs.preferences.general.fileIconStyle == .color ? item.iconColor : .secondary
}
}
6 changes: 3 additions & 3 deletions CodeEdit/TabBar/TabBarItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ struct TabBarItem: View {
@Environment(\.colorScheme)
var colorScheme

@AppStorage(FileIconStyle.storageKey)
private var iconStyle: FileIconStyle = .default
@StateObject
private var prefs: AppPreferencesModel = .shared

@State
var isHovering: Bool = false
Expand Down Expand Up @@ -106,7 +106,7 @@ struct TabBarItem: View {
.resizable()
.aspectRatio(contentMode: .fit)
.foregroundColor(
iconStyle == .color ? item.iconColor : .secondary
prefs.preferences.general.fileIconStyle == .color ? item.iconColor : .secondary
)
.frame(width: 12, height: 12)
Text(item.url.lastPathComponent)
Expand Down
8 changes: 4 additions & 4 deletions CodeEdit/Welcome/WelcomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ struct WelcomeView: View {
@State
var isHoveringClose: Bool = false

@AppStorage(ReopenBehavior.storageKey)
var behavior: ReopenBehavior = .welcome
@StateObject
private var prefs: AppPreferencesModel = .shared

var dismissWindow: () -> Void

Expand Down Expand Up @@ -187,9 +187,9 @@ struct WelcomeView: View {
HStack {
Spacer()
Toggle("Show this window when CodeEdit launches", isOn: .init(get: {
return self.behavior == .welcome
return prefs.preferences.general.reopenBehavior == .welcome
}, set: { new in
self.behavior = new ? .welcome : .openPanel
prefs.preferences.general.reopenBehavior = new ? .welcome : .openPanel
}))
.toggleStyle(.checkbox)
Spacer()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// Color+HEX.swift
//
//
// Created by Lukas Pistrol on 23.03.22.
//

import SwiftUI

public extension Color {

init(hex: String) {
let hex = hex.trimmingCharacters(in: CharacterSet.alphanumerics.inverted)
var int: UInt64 = 0
Scanner(string: hex).scanHexInt64(&int)
self.init(hex: Int(int))
}

init(hex: Int) {
let red = (hex >> 16) & 0xFF
let green = (hex >> 8) & 0xFF
let blue = hex & 0xFF
self.init(.sRGB, red: Double(red) / 255, green: Double(green) / 255, blue: Double(blue) / 255, opacity: 1)
}

var hex: Int {
guard let components = cgColor?.components, components.count >= 3 else { return 0 }

let red = lround((Double(components[0]) * 255.0)) << 16
let green = lround((Double(components[1]) * 255.0)) << 8
let blue = lround((Double(components[2]) * 255.0))

return red | green | blue
}

var hexString: String {
let color = self.hex

return "#" + String(format: "%06x", color)
}
}
Loading