Progress on keyboard shortcuts. Add link to Technotes in Help menu. Fix #266.

This commit is contained in:
Brent Simmons 2017-12-20 21:23:48 -08:00
parent ac3947b164
commit 70000c1d31
9 changed files with 66 additions and 6 deletions

View File

@ -25,6 +25,7 @@
844B5B691FEA20DF00C7C76A /* SidebarKeyboardShortcuts.plist in Resources */ = {isa = PBXBuildFile; fileRef = 844B5B681FEA20DF00C7C76A /* SidebarKeyboardShortcuts.plist */; };
84513F901FAA63950023A1A9 /* FeedListControlsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84513F8F1FAA63950023A1A9 /* FeedListControlsView.swift */; };
845213231FCA5B11003B6E93 /* ImageDownloader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 845213221FCA5B10003B6E93 /* ImageDownloader.swift */; };
845479881FEB77C000AD8B59 /* TimelineKeyboardShortcuts.plist in Resources */ = {isa = PBXBuildFile; fileRef = 845479871FEB77C000AD8B59 /* TimelineKeyboardShortcuts.plist */; };
845A29091FC74B8E007B49E3 /* SingleFaviconDownloader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 845A29081FC74B8E007B49E3 /* SingleFaviconDownloader.swift */; };
845A29221FC9251E007B49E3 /* SidebarCellLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 845A29211FC9251E007B49E3 /* SidebarCellLayout.swift */; };
845A29241FC9255E007B49E3 /* SidebarCellAppearance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 845A29231FC9255E007B49E3 /* SidebarCellAppearance.swift */; };
@ -431,6 +432,7 @@
844B5B681FEA20DF00C7C76A /* SidebarKeyboardShortcuts.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = SidebarKeyboardShortcuts.plist; sourceTree = "<group>"; };
84513F8F1FAA63950023A1A9 /* FeedListControlsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedListControlsView.swift; sourceTree = "<group>"; };
845213221FCA5B10003B6E93 /* ImageDownloader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageDownloader.swift; sourceTree = "<group>"; };
845479871FEB77C000AD8B59 /* TimelineKeyboardShortcuts.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = TimelineKeyboardShortcuts.plist; sourceTree = "<group>"; };
845A29081FC74B8E007B49E3 /* SingleFaviconDownloader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SingleFaviconDownloader.swift; sourceTree = "<group>"; };
845A29211FC9251E007B49E3 /* SidebarCellLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SidebarCellLayout.swift; sourceTree = "<group>"; };
845A29231FC9255E007B49E3 /* SidebarCellAppearance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SidebarCellAppearance.swift; sourceTree = "<group>"; };
@ -616,6 +618,7 @@
isa = PBXGroup;
children = (
844B5B5A1FEA00FB00C7C76A /* TimelineKeyboardDelegate.swift */,
845479871FEB77C000AD8B59 /* TimelineKeyboardShortcuts.plist */,
);
path = Keyboard;
sourceTree = "<group>";
@ -1357,6 +1360,7 @@
849A97951ED9EF7A007D329B /* IndeterminateProgressWindow.xib in Resources */,
844B5B651FEA11F200C7C76A /* GlobalKeyboardShortcuts.plist in Resources */,
849A978F1ED9EE72007D329B /* DefaultFeeds.plist in Resources */,
845479881FEB77C000AD8B59 /* TimelineKeyboardShortcuts.plist in Resources */,
849A979D1ED9EFEB007D329B /* template.html in Resources */,
849A97A91ED9F9AA007D329B /* AddFeedSheet.xib in Resources */,
84AFBB3E1FBE770200BA41CF /* PanicButtonWindow.xib in Resources */,

View File

@ -409,7 +409,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
@IBAction func openWebsite(_ sender: AnyObject) {
Browser.open("//ranchero.com/evergreen/", inBackground: false)
Browser.open("https://ranchero.com/evergreen/", inBackground: false)
}
@IBAction func openRepository(_ sender: AnyObject) {
@ -422,6 +422,11 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
Browser.open("https://github.com/brentsimmons/Evergreen/issues", inBackground: false)
}
@IBAction func openTechnotes(_ sender: Any?) {
Browser.open("https://github.com/brentsimmons/Evergreen/tree/master/Technotes", inBackground: false)
}
@IBAction func showHelp(_ sender: AnyObject) {
Browser.open("https://ranchero.com/evergreen/help/1.0/", inBackground: false)

View File

@ -522,6 +522,12 @@
<action selector="openBugTracker:" target="Ady-hI-5gd" id="fZQ-ng-gIm"/>
</connections>
</menuItem>
<menuItem title="Technotes" id="Ou5-Cc-iCb">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="openTechnotes:" target="Ady-hI-5gd" id="M7A-Qg-mH8"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>

View File

@ -58,7 +58,7 @@
<key>key</key>
<string>l</string>
<key>action</key>
<string>markReadAndGoToNextUnread:</string>
<string>markAllAsReadAndGoToNextUnread:</string>
</dict>
<dict>
<key>key</key>

View File

@ -186,6 +186,12 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
timelineViewController?.markSelectedArticlesAsUnread(sender)
}
@IBAction func markAllAsReadAndGoToNextUnread(_ sender: Any?) {
markAllAsRead(sender)
nextUnread(sender)
}
@IBAction func markUnreadAndGoToNextUnread(_ sender: Any?) {
markUnread(sender)
@ -212,6 +218,16 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
appDelegate.markEverywhereAsRead(with: window!)
}
@IBAction func navigateToTimeline(_ sender: Any?) {
timelineViewController?.focus()
}
@IBAction func navigateToSidebar(_ sender: Any?) {
sidebarViewController?.focus()
}
}
// MARK: - Private

View File

@ -14,13 +14,30 @@ import RSCore
@objc final class TimelineKeyboardDelegate: NSObject, KeyboardDelegate {
@IBOutlet weak var timelineViewController: TimelineViewController?
let shortcuts: Set<KeyboardShortcut>
override init() {
let f = Bundle.main.path(forResource: "TimelineKeyboardShortcuts", ofType: "plist")!
let rawShortcuts = NSArray(contentsOfFile: f)! as! [[String: Any]]
self.shortcuts = Set(rawShortcuts.flatMap { KeyboardShortcut(dictionary: $0) })
super.init()
}
func keydown(_ event: NSEvent, in view: NSView) -> Bool {
return MainWindowKeyboardHandler.shared.keydown(event, in: view)
if MainWindowKeyboardHandler.shared.keydown(event, in: view) {
return true
}
let key = KeyboardKey(with: event)
guard let matchingShortcut = KeyboardShortcut.findMatchingShortcut(in: shortcuts, key: key) else {
return false
}
matchingShortcut.perform(with: view)
return true
}
}

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>key</key>
<string>[leftarrow]</string>
<key>action</key>
<string>navigateToSidebar:</string>
</dict>
</array>
</plist>

View File

@ -45,7 +45,7 @@
<tr class="backgroundColorRow"><td>Mark all as read, go to next unread</td><td>l (lowercase L)</td></tr>
<tr><td>Mark as unread, go to next unread</td><td>m</td></tr>
<tr class="backgroundColorRow"><td>Mark as unread</td><td>u</td></tr>
<tr><td>Open in browser</td><td>b or rightArrow or return or enter</td></tr>
<tr><td>Open in browser</td><td>b or return or enter</td></tr>
<tr class="backgroundColorRow"><td>Move focus to Subscriptions</td><td>leftArrow</td></tr>
<tr><td>Previous subscription</td><td>a</td></tr>
<tr class="backgroundColorRow"><td>Next subscription</td><td>z</td></tr>

View File

@ -20,7 +20,7 @@ public struct KeyboardConstant {
public extension String {
public var keyboardIntegerValue: Int {
return Int(utf8[utf8.startIndex])
return Int(utf16[utf16.startIndex])
}
}