1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-28 11:35:35 +03:00

Add key shortcuts

This commit is contained in:
Tae Won Ha 2019-02-28 13:00:13 +01:00
parent 5bc983a154
commit ef180ede03
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
6 changed files with 64 additions and 29 deletions

View File

@ -220,17 +220,17 @@
<action selector="toggleFileBrowser:" target="-1" id="Ggq-4w-iN7"/>
</connections>
</menuItem>
<menuItem title="Toggle Buffer List" keyEquivalent="2" identifier="com.qvacua.vimr.menuitems.tools.toggle-file-browser" id="OF4-kp-cNF">
<menuItem title="Toggle Buffer List" keyEquivalent="2" identifier="com.qvacua.vimr.menuitems.tools.toggle-buffer-list" id="OF4-kp-cNF">
<connections>
<action selector="toggleBufferList:" target="-1" id="bpT-lI-lYu"/>
</connections>
</menuItem>
<menuItem title="Toggle Markdown Preview" keyEquivalent="3" identifier="com.qvacua.vimr.menuitems.tools.toggle-file-browser" id="rUg-f6-aPa">
<menuItem title="Toggle Markdown Preview" keyEquivalent="3" identifier="com.qvacua.vimr.menuitems.tools.toggle-markdown-preview" id="rUg-f6-aPa">
<connections>
<action selector="toggleMarkdownPreview:" target="-1" id="buC-mL-NpJ"/>
</connections>
</menuItem>
<menuItem title="Toggle HTML Preview" keyEquivalent="4" identifier="com.qvacua.vimr.menuitems.tools.toggle-file-browser" id="RB0-mE-Gdd">
<menuItem title="Toggle HTML Preview" keyEquivalent="4" identifier="com.qvacua.vimr.menuitems.tools.toggle-html-preview" id="RB0-mE-Gdd">
<connections>
<action selector="toggleHtmlPreview:" target="-1" id="KTN-ib-Iv6"/>
</connections>
@ -279,7 +279,8 @@
<action selector="debug1:" target="-1" id="OSW-j0-HVo"/>
</connections>
</menuItem>
<menuItem title="Debug 2" keyEquivalent="2" id="tWe-ll-a9P">
<menuItem title="Debug 2" id="tWe-ll-a9P">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="debug2:" target="-1" id="r0m-FW-POU"/>
</connections>

View File

@ -48,6 +48,11 @@ class BuffersList: NSView,
source
.observeOn(MainScheduler.instance)
.subscribe(onNext: { state in
if state.viewToBeFocused != nil,
case .bufferList = state.viewToBeFocused! {
self.beFirstResponder()
}
let themeChanged = changeTheme(
themePrefChanged: state.appearance.usesTheme != self.usesTheme,
themeChanged: state.appearance.theme.mark != self.lastThemeMark,

View File

@ -111,6 +111,24 @@ let defaultShortcuts: [String: [String: Any]] = [
SRShortcutKeyCode: 18,
SRShortcutModifierFlagsKey: 1048840,
],
"com.qvacua.vimr.menuitems.tools.toggle-buffer-list": [
SRShortcutCharacters: "1",
SRShortcutCharactersIgnoringModifiers: "2",
SRShortcutKeyCode: 19,
SRShortcutModifierFlagsKey: 1048840,
],
"com.qvacua.vimr.menuitems.tools.toggle-markdown-preview": [
SRShortcutCharacters: "1",
SRShortcutCharactersIgnoringModifiers: "3",
SRShortcutKeyCode: 20,
SRShortcutModifierFlagsKey: 1048840,
],
"com.qvacua.vimr.menuitems.tools.toggle-html-preview": [
SRShortcutCharacters: "1",
SRShortcutCharactersIgnoringModifiers: "4",
SRShortcutKeyCode: 21,
SRShortcutModifierFlagsKey: 1048840,
],
"com.qvacua.vimr.menuitems.tools.toggle-tool-buttons": [
SRShortcutCharacters: "\\",
SRShortcutCharactersIgnoringModifiers: "|",

View File

@ -45,6 +45,11 @@ class HtmlPreviewTool: NSView, UiComponent, WKNavigationDelegate {
source
.observeOn(MainScheduler.instance)
.subscribe(onNext: { [unowned self] state in
if state.viewToBeFocused != nil,
case .htmlPreview = state.viewToBeFocused! {
self.beFirstResponder()
}
guard let serverUrl = state.htmlPreview.server, let htmlFileUrl = state.htmlPreview.htmlFile else {
self.monitor = nil
return

View File

@ -123,38 +123,43 @@ extension MainWindow {
}
@IBAction func toggleFileBrowser(_ sender: Any?) {
let fileBrowser = self.fileBrowserContainer
guard let fileBrowser = self.fileBrowserContainer else { return }
self.toggle(tool: fileBrowser, toolType: .fileBrowser)
}
if fileBrowser?.isSelected == true {
if fileBrowser?.view.isFirstResponder == true {
fileBrowser?.toggle()
@IBAction func toggleBufferList(_ sender: Any?) {
guard let bufferList = self.buffersListContainer else { return }
self.toggle(tool: bufferList, toolType: .bufferList)
}
@IBAction func toggleMarkdownPreview(_ sender: Any?) {
guard let markdownPreview = self.previewContainer else { return }
self.toggle(tool: markdownPreview, toolType: .markdownPreview)
}
@IBAction func toggleHtmlPreview(_ sender: Any?) {
guard let htmlPreview = self.htmlPreviewContainer else { return }
self.toggle(tool: htmlPreview, toolType: .htmlPreview)
}
@IBAction func focusNvimView(_: Any?) {
self.emit(self.uuidAction(for: .focus(.neoVimView)))
}
private func toggle(tool: WorkspaceTool, toolType: FocusableView) {
if tool.isSelected == true {
if tool.view.isFirstResponder == true {
tool.toggle()
self.focusNvimView(self)
} else {
self.emit(self.uuidAction(for: .focus(.fileBrowser)))
self.emit(self.uuidAction(for: .focus(toolType)))
}
return
}
fileBrowser?.toggle()
self.emit(self.uuidAction(for: .focus(.fileBrowser)))
}
@IBAction func toggleBufferList(_ sender: Any?) {
}
@IBAction func toggleMarkdownPreview(_ sender: Any?) {
}
@IBAction func toggleHtmlPreview(_ sender: Any?) {
}
@IBAction func focusNvimView(_: Any?) {
// self.window.makeFirstResponder(self.neoVimView)
self.emit(self.uuidAction(for: .focus(.neoVimView)))
tool.toggle()
self.emit(self.uuidAction(for: .focus(toolType)))
}
}

View File

@ -80,7 +80,8 @@ class PreviewTool: NSView, UiComponent, WKNavigationDelegate {
source
.observeOn(MainScheduler.instance)
.subscribe(onNext: { state in
if state.viewToBeFocused != nil, case .markdownPreview = state.viewToBeFocused! {
if state.viewToBeFocused != nil,
case .markdownPreview = state.viewToBeFocused! {
self.beFirstResponder()
}