 
   setContents:(contents)-> @editor.getSession().setValue contents
 
-  setTheme:(themeName)->
-    themeName or= @appStorage.getValue('theme') or 'merbivore_soft'
-    require ["ace/theme/#{themeName}"], (callback) =>
-      @editor.setTheme "ace/theme/#{themeName}"
-      @appStorage.setValue 'theme', themeName, =>
-        callback
-
   setSyntax:(mode)->
 
     file = @getData()

      @editor.getSession().setMode new Mode
      @syntaxMode = mode

  setUseSoftTabs:(value)->

    @editor.getSession().setUseSoftTabs value
    @appStorage.setValue 'useSoftTabs', value

  setShowGutter:(value)->

    @editor.renderer.setShowGutter value
    @appStorage.setValue 'showGutter', value

  setShowPrintMargin:(value)->

    @editor.setShowPrintMargin value
    @appStorage.setValue 'showPrintMargin', value

  setHighlightActiveLine:(value)->

    @editor.setHighlightActiveLine value
    @appStorage.setValue 'highlightActiveLine', value

  # setHighlightSelectedWord:(value)-> @editor.setHighlightActiveLine value

  setShowInvisibles:(value)->

    @editor.setShowInvisibles value
    @appStorage.setValue 'showInvisibles', value

  setFontSize:(value, store = yes)->

    @$("#editor#{@getId()}").css 'font-size', "#{value}px"
    if store
      @appStorage.setValue 'fontSize', value

  setTabSize:(value)->
    @editor.getSession().setTabSize +value
    @appStorage.setValue 'tabSize', value

  setUseWordWrap:(value)->

    @editor.getSession().setUseWrapMode value
    @appStorage.setValue 'useWordWrap', value

  setSoftWrap:(value)->
    softWrapValueMap =
      'off'  : [ null, 80 ]
      '40'   : [ 40,   40 ]

    @editor.renderer.setPrintMarginColumn margin
    @setUseWordWrap no if value is "off"

    return  unless save
    @appStorage.setValue 'softWrap', value

  focus: -> @editor?.focus()
