We use multiple ace editors per window now.

This commit is contained in:
Corey Johnson
2011-11-14 15:37:33 -08:00
parent 82f11c86f2
commit d677aaa562
2 changed files with 10 additions and 6 deletions

View File

@@ -7,16 +7,20 @@ ace = require 'ace/ace'
module.exports =
class EditorPane extends Pane
html: $ "<div id='ace-editor'></div>"
id: null
html: null
position: 'main'
editor: null
constructor: ->
@id = _.uniqueId 'editor-'
@html = $ "<div id='#{@id}'></div>"
@show()
@ace = ace.edit 'ace-editor'
@ace = ace.edit @id
# This stuff should all be grabbed from the .atomicity dir
@ace.setTheme require "ace/theme/twilight"

View File

@@ -56,18 +56,17 @@ class Editor extends Resource
if @url then _.last @url.split '/' else 'untitled'
show: ->
@ace.setSession @session
@pane.show()
@ace.resize()
window.setTitle @title()
open: (url) ->
if url
return false if not fs.isFile url
return false if @url
# HACK! We want only one EditorPane for all the Editors.
@pane = Editor.pane ?= new EditorPane
window.setTitle @title()
@pane ?= new EditorPane
@ace = @pane.ace
@url = url
@@ -77,6 +76,7 @@ class Editor extends Resource
@session.setTabSize if useSoftTabs then @guessTabSize code else 8
@session.setUndoManager new UndoManager
@session.on 'change', => @dirty = true
@ace.setSession @session
@show()
@setModeForURL @url if @url