Make command-panel sticky like tree view is (fit into the "tool panel" scheme)

Esc on the command panel just moves focus back to the editor. Ctrl-0 will move focus back to the panel if it is open but not focused.
This commit is contained in:
Nathan Sobo
2012-07-23 11:29:25 -06:00
parent dbfc9d20f7
commit ab47df1987
3 changed files with 42 additions and 32 deletions

View File

@@ -38,6 +38,7 @@ class CommandPanel extends View
@commandInterpreter = new CommandInterpreter()
@history = []
@on 'command-panel:unfocus', => @rootView.focus()
@rootView.on 'command-panel:toggle', => @toggle()
@rootView.on 'command-panel:execute', => @execute()
@rootView.on 'command-panel:find-in-file', => @attach("/")
@@ -50,8 +51,12 @@ class CommandPanel extends View
@miniEditor.on 'move-down', => @navigateForwardInHistory()
toggle: ->
if @parent().length then @detach() else @attach()
false
if @miniEditor.isFocused
@detach()
@rootView.focus()
else
@attach() unless @hasParent()
@miniEditor.focus()
attach: (text='') ->
@rootView.append(this)

View File

@@ -6,7 +6,7 @@ window.keymap.bindKeys '*'
window.keymap.bindKeys '.command-panel .editor input',
'meta-w': 'command-panel:toggle'
escape: 'command-panel:toggle'
escape: 'command-panel:unfocus'
enter: 'command-panel:execute'
window.keymap.bindKeys '.editor',