restores Helder in all its glory
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
import SwiftUI
|
||||
|
||||
public struct ShortcutRow: Equatable, Sendable {
|
||||
/// Each element is one keycap.
|
||||
public var keys: [String]
|
||||
public var label: String
|
||||
}
|
||||
|
||||
public struct ShortcutGroup: Equatable, Sendable {
|
||||
public var title: String
|
||||
public var rows: [ShortcutRow]
|
||||
}
|
||||
|
||||
/// The keyboard reference the `?` overlay shows. Keep it in step with the keyboard routing.
|
||||
public enum ShortcutCatalog {
|
||||
public static let groups: [ShortcutGroup] = [
|
||||
ShortcutGroup(title: "Navigate", rows: [
|
||||
ShortcutRow(keys: ["⌘", "F"], label: "Search contents and names"),
|
||||
ShortcutRow(keys: ["⌘", "↑↓"], label: "Move through a list"),
|
||||
ShortcutRow(keys: ["↵"], label: "Open the selected item"),
|
||||
ShortcutRow(keys: ["⌘", "←→"], label: "Column left or right"),
|
||||
ShortcutRow(keys: ["↑↓"], label: "Git or Explorer: move the row cursor"),
|
||||
ShortcutRow(keys: ["⇧", "⌘", "O"], label: "Open a recent project"),
|
||||
ShortcutRow(keys: ["⌘", "O"], label: "Open a project folder"),
|
||||
ShortcutRow(keys: ["⇧", "⌘", "N"], label: "Open a new window"),
|
||||
ShortcutRow(keys: ["⌘", "click"], label: "PHP class: declaration and references"),
|
||||
ShortcutRow(keys: ["?"], label: "This list of shortcuts"),
|
||||
]),
|
||||
ShortcutGroup(title: "Agent", rows: [
|
||||
ShortcutRow(keys: ["⌘", "→"], label: "Pass the selection to the agent"),
|
||||
ShortcutRow(keys: ["⌘", "N"], label: "Open the project note"),
|
||||
ShortcutRow(keys: ["⌘", "P"], label: "Pass on the whole note"),
|
||||
]),
|
||||
ShortcutGroup(title: "Git", rows: [
|
||||
ShortcutRow(keys: ["⌘", "C"], label: "Focus the commit message"),
|
||||
ShortcutRow(keys: ["⌘", "↵"], label: "Commit the staged files"),
|
||||
ShortcutRow(keys: ["⌘", "G"], label: "Source Control column on or off"),
|
||||
ShortcutRow(keys: ["⌘", "P"], label: "Push the current branch"),
|
||||
]),
|
||||
ShortcutGroup(title: "File", rows: [
|
||||
ShortcutRow(keys: ["⌘", "S"], label: "Save this file"),
|
||||
ShortcutRow(keys: ["⌘", "M"], label: "Markdown: code or rendered preview"),
|
||||
ShortcutRow(keys: ["⌘", "W"], label: "Close this file, or the window when none is open"),
|
||||
ShortcutRow(keys: ["⌘", "R"], label: "Re-read git and the files from disk"),
|
||||
ShortcutRow(keys: ["⌘", "."], label: "Hidden files on or off"),
|
||||
ShortcutRow(keys: ["⌘", "A"], label: "Select all in this pane"),
|
||||
ShortcutRow(keys: ["⌘", "L"], label: "Fluid columns on or off"),
|
||||
ShortcutRow(keys: ["⌘", "+"], label: "Zoom in"),
|
||||
ShortcutRow(keys: ["⌘", "−"], label: "Zoom out"),
|
||||
ShortcutRow(keys: ["⌘", "0"], label: "Actual size"),
|
||||
ShortcutRow(keys: ["Esc"], label: "Close an overlay or a split view"),
|
||||
]),
|
||||
]
|
||||
}
|
||||
|
||||
/// `?`: the keyboard reference, grouped NAVIGATE / AGENT / GIT / FILE.
|
||||
struct ShortcutsOverlay: View {
|
||||
var onClose: () -> Void
|
||||
|
||||
var body: some View {
|
||||
OverlayShell(.sized(width: 600), onDismiss: onClose) {
|
||||
VStack(spacing: 0) {
|
||||
OverlayHeader(systemImage: "questionmark.circle", title: "Keyboard shortcuts")
|
||||
// Grows with its content, and scrolls only when the window is too short for it.
|
||||
ViewThatFits(in: .vertical) {
|
||||
list
|
||||
ScrollView { list }
|
||||
}
|
||||
}
|
||||
.background(OverlayKeyCatcher { key in
|
||||
guard key == .escape else { return false }
|
||||
onClose()
|
||||
return true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private var list: some View {
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
ForEach(Array(ShortcutCatalog.groups.enumerated()), id: \.offset) { index, group in
|
||||
Text(group.title)
|
||||
.typeRole(Typography.panelLabel)
|
||||
.foregroundStyle(Palette.text4)
|
||||
.padding(.top, index == 0 ? 0 : 16)
|
||||
.padding(.bottom, 8)
|
||||
ForEach(Array(group.rows.enumerated()), id: \.offset) { _, row in
|
||||
HStack(spacing: 14) {
|
||||
HStack(spacing: 4) {
|
||||
ForEach(Array(row.keys.enumerated()), id: \.offset) { _, key in
|
||||
Keycap(key).frame(minWidth: 22)
|
||||
}
|
||||
}
|
||||
.frame(width: 92, alignment: .leading)
|
||||
Text(row.label).typeRole(Typography.row).foregroundStyle(Palette.text2)
|
||||
}
|
||||
.padding(.vertical, 6)
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(EdgeInsets(top: 18, leading: 20, bottom: 22, trailing: 20))
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user