From c7dda4d2aae3f0802e1a44662db9f888e1d184d4 Mon Sep 17 00:00:00 2001 From: Alvie Stoddard Date: Sat, 15 Aug 2026 15:01:08 -0700 Subject: [PATCH] Switch bar sections with Command-Left/Right Cycles Clipboard and each Pinboard tab in the same order the tab bar presents them, independent of card navigation (plain arrows still move the card selection). --- Sources/Pesty/AppController.swift | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Sources/Pesty/AppController.swift b/Sources/Pesty/AppController.swift index 6d3f395..d751356 100644 --- a/Sources/Pesty/AppController.swift +++ b/Sources/Pesty/AppController.swift @@ -524,9 +524,15 @@ final class AppController: NSObject, NSApplicationDelegate, NSWindowDelegate { return nil case kVK_Return, kVK_ANSI_KeypadEnter: pasteSelected(); return nil - case kVK_LeftArrow, kVK_UpArrow: + case kVK_LeftArrow: + if cmd { moveBarSection(by: -1) } else { store.moveSelection(by: -1) } + return nil + case kVK_RightArrow: + if cmd { moveBarSection(by: 1) } else { store.moveSelection(by: 1) } + return nil + case kVK_UpArrow: store.moveSelection(by: -1); return nil - case kVK_RightArrow, kVK_DownArrow: + case kVK_DownArrow: store.moveSelection(by: 1); return nil case kVK_Delete: if cmd { deleteEffectiveSelection(); return nil } @@ -565,6 +571,19 @@ final class AppController: NSObject, NSApplicationDelegate, NSWindowDelegate { return event } + /// Cycles the same sources, in the same order, that the tab bar presents. + /// The plus button is intentionally excluded: it creates a new pinboard + /// rather than representing a navigable section. + private func moveBarSection(by delta: Int) { + let sources: [BarSource] = [.history] + store.pinboards.map { .pinboard($0.id) } + guard !sources.isEmpty else { return } + + let currentIndex = sources.firstIndex(of: store.source) ?? 0 + let nextIndex = (currentIndex + delta % sources.count + sources.count) % sources.count + store.source = sources[nextIndex] + store.selectFirst() + } + private static func quickPasteDigit(for keyCode: Int) -> Int? { switch keyCode { case kVK_ANSI_1, kVK_ANSI_Keypad1: return 1