Tab tells editor to close file. Tab is then

notified about closer.

This is in prep for reopening files on app 
relaunch.
This commit is contained in:
Corey Johnson
2011-09-13 16:44:30 -07:00
parent f599058a56
commit ef3fc1d278
2 changed files with 17 additions and 6 deletions

View File

@@ -34,6 +34,9 @@ class Tabs extends Pane
# Only care about files, not directories
return if File.isDirectory(filename)
@addTab filename
@editor.ace.on 'close', ({filename}) =>
@removeTab filename
tab = this
# click tab
@@ -53,14 +56,18 @@ class Tabs extends Pane
"""
$('#tabs ul li:last').addClass 'active'
removeTab: (path) ->
tab = $("#tabs li[data-path='#{path}']")
if tab.hasClass("active")
nextTab = tab.next()
nextTab = tab.prev() if nextTab.length == 0
@switchToTab nextTab if nextTab.length != 0
tab.remove()
closeActiveTab: ->
activeTab = $('#tabs ul .active')
nextTab = activeTab.next()
nextTab = activeTab.prev() if nextTab.length == 0
@editor.deleteSession activeTab.data 'path'
activeTab.remove()
@switchToTab nextTab if nextTab.length != 0
@editor.close(activeTab.data 'path')
hideTabs: ->
$('#tabs').parents('.pane').remove()

View File

@@ -82,6 +82,10 @@ class Editor extends Pane
activeWindow.setDirty false
@ace._emit 'open', { @filename }
close: (path) ->
@deleteSession path
@ace._emit 'close', { filename : path }
saveAs: ->
if file = App.savePanel()
@filename = file