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
d7bade6
Update feature_request.yml
austincondiff Mar 9, 2023
0312073
Update feature_request.yml
austincondiff Mar 9, 2023
513663a
Update feature_request.yml
austincondiff Mar 9, 2023
de404d2
Update feature_request.yml
austincondiff Mar 9, 2023
56930e6
Update feature_request.yml
austincondiff Mar 9, 2023
f4d4008
Update feature_request.yml
austincondiff Mar 9, 2023
8f7552d
Update bug_report.yml
austincondiff Mar 10, 2023
ef4b8e3
Update bug_report.yml
austincondiff Mar 10, 2023
f701ba6
Update bug_report.yml
austincondiff Mar 10, 2023
4d8d241
Update bug_report.yml
austincondiff Mar 10, 2023
085a465
Update pull_request_template.md
austincondiff Mar 10, 2023
b8bf8b8
Update pull_request_template.md
austincondiff Mar 10, 2023
720775f
Update feature_request.yml
austincondiff Mar 10, 2023
9606db7
Update bug_report.yml
austincondiff Mar 10, 2023
7d184d9
Update feature_request.yml
austincondiff Mar 10, 2023
b0fa006
Update pull_request_template.md
austincondiff Mar 10, 2023
dca5c5e
Update .github/pull_request_template.md
austincondiff Mar 10, 2023
08b2494
Update .github/ISSUE_TEMPLATE/bug_report.yml
austincondiff Mar 10, 2023
65dd1ae
Merge branch 'CodeEditApp:main' into main
austincondiff Mar 12, 2023
dd9764d
Merge branch 'CodeEditApp:main' into main
austincondiff Mar 20, 2023
6399b78
Refactored quick open view to not use a navigation view so that it lo…
austincondiff Mar 13, 2023
24040b0
Improved open quickly list items path design
austincondiff Mar 14, 2023
c010879
Cleaned up Open Quickly overlay view. Made UI improvements for comman…
austincondiff Mar 17, 2023
0b246da
Add `OverlayView`
thecoolwinter Mar 18, 2023
d3a9b98
Moved to NSTableView for palette results
Wouter01 Mar 18, 2023
f7ed7b2
Add isEditable back
Wouter01 Mar 18, 2023
f6a8c7f
Reverted custom textfield to swiftui textfield
Wouter01 Mar 18, 2023
b4d24fb
Changed command palette keybinding to ⌘⇧P. Renamed data to options. R…
austincondiff Mar 20, 2023
dddf6aa
Change text color when text is present to make highlighted text stand…
austincondiff Mar 20, 2023
f4557e0
Selecting the first item automatically in the OverlayView
austincondiff Mar 20, 2023
cb6e01b
Merged with latest master
austincondiff Mar 20, 2023
e2a51e9
Merged conflicts, fixed resulting issues, changed keybinding for comm…
austincondiff Mar 20, 2023
42ce1d3
Updated CodeEditTextView version
austincondiff Mar 20, 2023
710b5ed
Fixed build issue
Wouter01 Mar 20, 2023
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
62 changes: 41 additions & 21 deletions CodeEdit.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

177 changes: 177 additions & 0 deletions CodeEdit/Features/CodeEditUI/Views/OverlayView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
//
// OverlayWindow.swift
// CodeEdit
//
// Created by Khan Winter on 3/17/23.
//

import Foundation
import SwiftUI

struct OverlayView<RowView: View, PreviewView: View, Option: Identifiable & Hashable>: View {
@ViewBuilder
let rowViewBuilder: ((Option) -> RowView)

@ViewBuilder
let previewViewBuilder: ((Option) -> PreviewView)?

@Binding
var options: [Option]

@State
var selection: Option?

@Binding
var text: String
let title: String
let image: Image
let showsPreview: Bool
let onRowClick: ((Option) -> Void)
let onClose: (() -> Void)
let alwaysShowOptions: Bool
let optionRowHeight: CGFloat

init(
title: String,
image: Image,
options: Binding<[Option]>,
text: Binding<String>,
alwaysShowOptions: Bool = false,
optionRowHeight: CGFloat = 30,
content: @escaping ((Option) -> RowView),
preview: ((Option) -> PreviewView)? = nil,
onRowClick: @escaping ((Option) -> Void),
onClose: @escaping () -> Void
) {
self.title = title
self.image = image
self._options = options
self._text = text
self.rowViewBuilder = content
self.previewViewBuilder = preview
self.onRowClick = onRowClick
self.onClose = onClose
self.showsPreview = preview != nil
self.alwaysShowOptions = alwaysShowOptions
self.optionRowHeight = optionRowHeight
}

var body: some View {
VStack(spacing: 0) {
VStack {
HStack(alignment: .center, spacing: 0) {
image
.font(.system(size: 18))
.foregroundColor(.secondary)
.padding(.leading, 1)
.padding(.trailing, 10)
TextField(title, text: $text)
.font(.system(size: 20, weight: .light, design: .default))
.textFieldStyle(.plain)
.onSubmit {
if let selection {
onRowClick(selection)
} else {
NSSound.beep()
}
}
.task(id: options) {
if options.isEmpty {
selection = nil
} else {
if !options.isEmpty {
selection = options.first
}
}
}
}
.padding(.vertical, 12)
.padding(.horizontal, 12)
.foregroundColor(.primary.opacity(0.85))
.background(EffectView(.sidebar, blendingMode: .behindWindow))
}
if !text.isEmpty || alwaysShowOptions == true {
Divider()
.padding(0)
HStack(spacing: 0) {
if options.isEmpty {
Text("No matching options")
.font(.system(size: 17))
.foregroundColor(.secondary)
.frame(maxWidth: showsPreview ? 272 : .infinity, maxHeight: .infinity)
} else {
NSTableViewWrapper(
data: options,
rowHeight: optionRowHeight,
selection: $selection,
itemView: rowViewBuilder
)
.frame(maxWidth: showsPreview ? 272 : .infinity)
}
if showsPreview {
Divider()
if options.isEmpty {
Spacer()
.frame(maxWidth: .infinity)
} else {
if let selection, let previewViewBuilder {
previewViewBuilder(selection)
.frame(maxWidth: .infinity)
} else {
Text("Select an option to preview")
.frame(maxWidth: .infinity)
}
}
}
}
}
}
.overlay {
keyHandlers
}
.background(EffectView(.sidebar, blendingMode: .behindWindow))
.edgesIgnoringSafeArea(.vertical)
.frame(
minWidth: 680,
minHeight: text.isEmpty && !alwaysShowOptions ? 19 : 400,
maxHeight: text.isEmpty && !alwaysShowOptions ? 19 : .infinity
)
}

@ViewBuilder
var keyHandlers: some View {
Button {
onClose()
} label: { EmptyView() }
.opacity(0)
.keyboardShortcut(.escape, modifiers: [])
.accessibilityLabel("Close Overlay")
Button {
guard selection != options.first else {
return
}
if let selection, let index = options.firstIndex(of: selection) {
self.selection = options[index-1]
} else {
selection = options.first
}
} label: { EmptyView() }
.opacity(0)
.keyboardShortcut(.upArrow, modifiers: [])
.accessibilityLabel("Select Up")
Button {
guard selection != options.last else {
return
}
if let selection, let index = options.firstIndex(of: selection) {

self.selection = options[index+1]
} else {
selection = options.first
}
} label: { EmptyView() }
.opacity(0)
.keyboardShortcut(.downArrow, modifiers: [])
.accessibilityLabel("Select Down")
}
}
12 changes: 6 additions & 6 deletions CodeEdit/Features/CodeFile/CodeFileView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ struct CodeFileView: View {

private var cancellables = [AnyCancellable]()

private let editable: Bool
private let isEditable: Bool

init(codeFile: CodeFileDocument, editable: Bool = true) {
init(codeFile: CodeFileDocument, isEditable: Bool = true) {
self.codeFile = codeFile
self.editable = editable
self.isEditable = isEditable

codeFile
.$content
Expand Down Expand Up @@ -75,9 +75,10 @@ struct CodeFileView: View {
tabWidth: $prefs.preferences.textEditing.defaultTabWidth,
lineHeight: $prefs.preferences.textEditing.lineHeightMultiple,
wrapLines: $prefs.preferences.textEditing.wrapLinesToEditorWidth,
cursorPosition: codeFile.$cursorPosition,
cursorPosition: $codeFile.cursorPosition,
useThemeBackground: prefs.preferences.theme.useThemeBackground,
contentInsets: edgeInsets.nsEdgeInsets
contentInsets: edgeInsets.nsEdgeInsets,
isEditable: isEditable
)
.id(codeFile.fileURL)
.background {
Expand All @@ -96,7 +97,6 @@ struct CodeFileView: View {

}
}
.disabled(!editable)
// minHeight zero fixes a bug where the app would freeze if the contents of the file are empty.
.frame(minHeight: .zero, maxHeight: .infinity)
.onChange(of: ThemeModel.shared.selectedTheme) { newValue in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ final class CommandPaletteViewModel: ObservableObject {
func reset() {
commandQuery = ""
selected = nil
filteredCommands = []
filteredCommands = CommandManager.shared.commands
}

func fetchMatchingCommands(val: String) {
if val == "" {
self.filteredCommands = []
self.filteredCommands = CommandManager.shared.commands
return
}
self.filteredCommands = CommandManager.shared.commands.filter { $0.title.localizedCaseInsensitiveContains(val) }
Expand Down
Loading