mirror of
https://github.com/atom/atom.git
synced 2026-02-07 05:05:02 -05:00
Keybinding view is an extension
This commit is contained in:
@@ -4,5 +4,4 @@ window.keymap.bindKeys '*'
|
||||
right: 'move-right'
|
||||
left: 'move-left'
|
||||
down: 'move-down'
|
||||
up: 'move-up'
|
||||
'ctrl-?': 'toggle-keybindings-view'
|
||||
up: 'move-up'
|
||||
5
src/app/keymaps/keybindings-view.coffee
Normal file
5
src/app/keymaps/keybindings-view.coffee
Normal file
@@ -0,0 +1,5 @@
|
||||
window.keymap.bindKeys '*',
|
||||
'ctrl-?': 'keybindings-view:attach'
|
||||
|
||||
window.keymap.bindKeys ".keybindings-view",
|
||||
'escape': 'keybindings-view:detach'
|
||||
@@ -29,7 +29,6 @@ class RootView extends View
|
||||
extensions: null
|
||||
extensionStates: null
|
||||
fontSize: 18
|
||||
keybindingsView: null
|
||||
|
||||
initialize: (pathToOpen) ->
|
||||
@extensions = {}
|
||||
@@ -60,7 +59,6 @@ class RootView extends View
|
||||
|
||||
@on 'increase-font-size', => @setFontSize(@getFontSize() + 1)
|
||||
@on 'decrease-font-size', => @setFontSize(@getFontSize() - 1)
|
||||
@on 'toggle-keybindings-view', => @toggleKeybindingsView()
|
||||
|
||||
afterAttach: (onDom) ->
|
||||
@focus() if onDom
|
||||
@@ -116,22 +114,6 @@ class RootView extends View
|
||||
if not previousActiveEditor or editor.buffer.path != previousActiveEditor.buffer.path
|
||||
@trigger 'active-editor-path-change', editor.buffer.path
|
||||
|
||||
toggleKeybindingsView: ->
|
||||
if @keybindingsView?
|
||||
@keybindingsView.remove()
|
||||
@keybindingsView = null
|
||||
else
|
||||
keybindings = @activeKeybindings()
|
||||
@keybindingsView = $$ ->
|
||||
@div class: 'keybindings-view', =>
|
||||
@ul =>
|
||||
for keystroke, command of keybindings
|
||||
@li =>
|
||||
@span class: 'keystroke', "#{keystroke}"
|
||||
@span "#{command}"
|
||||
|
||||
@append(@keybindingsView)
|
||||
|
||||
activeKeybindings: ->
|
||||
keymap.bindingsForElement(document.activeElement)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user