Meta+s triggers save on Editor.

Still can't save buffers that don't have a url.
This commit is contained in:
Nathan Sobo
2011-12-16 14:42:38 -08:00
committed by Corey Johnson & Nathan Sobo
parent 79fbc0118c
commit c75c3555bb
6 changed files with 60 additions and 11 deletions

View File

@@ -7,21 +7,30 @@ module.exports =
class Editor
aceEditor: null
buffer: null
editorElement: null
constructor: (url) ->
@buffer = new Buffer(url)
@buildAceEditor()
$(document).keydown (event) =>
if String.fromCharCode(event.which) == 'S' and event.metaKey
@save()
destroy: ->
@aceEditor.destroy()
buildAceEditor: ->
editorElement = $("<div class='editor'>")
$('#main').append(editorElement)
@aceEditor = ace.edit editorElement[0]
@editorElement = $("<div class='editor'>")
$('#main').append(@editorElement)
@aceEditor = ace.edit @editorElement[0]
@aceEditor.setSession(new EditSession(@buffer.aceDocument))
@aceEditor.setTheme(require "ace/theme/twilight")
getAceSession: ->
@aceEditor.getSession()
save: ->
@buffer.save()

View File

@@ -24,9 +24,6 @@ windowAdditions =
onerror: ->
@showConsole true
handleKeyEvent: ->
null
triggerEvent: ->
null