     return if not files?
     return if files.length <= 0
     file = files[0]
-    console.log "#{FS.readFileSync file}"
+    @file =
+     name: PATH.basename file, '.ds'
+     path: file
+    @editor.setText "#{FS.readFileSync file}"
+    @_editorChanged = false
+    @_changed = false
+    @elems.save.style.display = 'inline-block'
+    @elems.saveName.textContent = "#{@file.name}"
 
    @listen 'save', ->
+    text = @removeTrailingSpace @editor.getText()
+    @editor.setText text
+    @content = text
+    @send 'saveFileContent', content: text
    @listen 'saveAs', ->
    @listen 'print', ->
     @editor.on.print()

    @content = ''
    @editor = new Editor
     openUrl: @on.openUrl
     onChanged: @on.changed

   @listen 'addResources', (data) ->
    console.log 'resources', data.length

    text = @removeTrailingSpace @editor.getText()
    @editor.setText text


   @listen 'error', (e) ->
    console.error e

   @listen 'editorChanged', ->
    @_editorChanged = true

   @listen 'openUrl', (url) ->
