mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
add @code() and @switchToSession() to Editor
This commit is contained in:
@@ -57,7 +57,7 @@ class Editor extends Pane
|
||||
save: ->
|
||||
return @saveAs() if not @filename
|
||||
|
||||
File.write @filename, @ace.getSession().getValue()
|
||||
File.write @filename, @code()
|
||||
@sessions[@filename] = @ace.getSession()
|
||||
activeWindow.setDirty false
|
||||
@ace._emit 'save', { @filename }
|
||||
@@ -88,12 +88,20 @@ class Editor extends Pane
|
||||
activeWindow.setTitle _.last @filename.split '/'
|
||||
@save()
|
||||
|
||||
code: ->
|
||||
@ace.getSession().getValue()
|
||||
|
||||
resize: (timeout=1) ->
|
||||
setTimeout =>
|
||||
@ace.focus()
|
||||
@ace.resize()
|
||||
, timeout
|
||||
|
||||
switchToSession: (path) ->
|
||||
if @sessions[path]
|
||||
@filename = path
|
||||
@ace.setSession @sessions[path]
|
||||
|
||||
newSession: (code) ->
|
||||
doc = new EditSession code or ''
|
||||
doc.setUndoManager new UndoManager
|
||||
@@ -111,7 +119,7 @@ class Editor extends Pane
|
||||
editor.session.remove editor.getSelectionRange()
|
||||
|
||||
eval: ->
|
||||
eval @ace.getSession().getValue()
|
||||
eval @code()
|
||||
|
||||
toggleComment: -> @ace.toggleCommentLines()
|
||||
outdent: -> @ace.blockOutdent()
|
||||
|
||||
Reference in New Issue
Block a user