Add save command and keyboard shortcuts to editor.

This commit is contained in:
Corey Johnson
2012-03-07 12:43:29 -08:00
parent fabe8fd609
commit f6414c543c
2 changed files with 56 additions and 4 deletions

View File

@@ -46,6 +46,7 @@ class Editor extends View
bindKeys: ->
window.keymap.bindKeys '*:not(.editor *)',
'meta-s': 'save'
right: 'move-right'
left: 'move-left'
down: 'move-down'
@@ -56,7 +57,7 @@ class Editor extends View
'shift-down': 'select-down'
enter: 'newline'
backspace: 'backspace'
delete: 'delete'
'delete': 'delete'
'meta-x': 'cut'
'meta-c': 'copy'
'meta-v': 'paste'
@@ -65,6 +66,7 @@ class Editor extends View
'alt-meta-w': 'toggle-soft-wrap'
'alt-meta-f': 'fold-selection'
@on 'save', => @save()
@on 'move-right', => @moveCursorRight()
@on 'move-left', => @moveCursorLeft()
@on 'move-down', => @moveCursorDown()
@@ -237,6 +239,13 @@ class Editor extends View
@removeClass 'soft-wrap'
$(window).off 'resize', @_setMaxLineLength
save: ->
if not @buffer.path
path = $native.saveDialog()
return if not path
@buffer.path = path
@buffer.save()
clipScreenPosition: (screenPosition, options={}) ->
@renderer.clipScreenPosition(screenPosition, options)