<commit_before>###
  todo:

    - make save dialog a view with pistachio
    - put listeners in methods
    - make this splittable

###

class AceView extends JView

  constructor:(options, file)->

    super

    @listenWindowResize()

    @saveButton = new KDButtonViewWithMenu
      title         : "Save"
      style         : "editor-button save-menu"
      type          : "contextmenu"
      delegate      : @
      menu          : @getSaveMenu.bind @
      callback      : ()=>
        @ace.requestSave()

    @caretPosition = new KDCustomHTMLView
      tagName       : "div"
      cssClass      : "caret-position section"
      partial       : "<span>1</span>:<span>1</span>"

    @ace = new Ace {}, file

    @advancedSettings = new KDButtonViewWithMenu
      style         : 'editor-advanced-settings-menu'
      icon          : yes
      iconOnly      : yes
      iconClass     : "cog"
      type          : "contextmenu"
      delegate      : @
      itemClass     : AceSettingsView
      click         : (pubInst, event)-> @contextMenu event
      menu          : @getAdvancedSettingsMenuItems.bind @

    publicUrlCheck = /.*\/(.*\.koding.com)\/website\/(.*)/
    @previewButton = new KDButtonView
      style     : "editor-button"
      icon      : yes
      iconOnly  : yes
      iconClass : "preview"
      callback  : =>
        publicPath = @getData().path.replace publicUrlCheck, 'http://$1/$2'
        return if publicPath is @getData().path
        appManager.openFileWithApplication publicPath, "Viewer"

    @previewButton.hide() unless publicUrlCheck.test(@getData().path)

    @compileAndRunButton = new KDButtonView
      style     : "editor-button"
      title     : "Compile & Run"
      loader    :
        color   : "#444444"
        diameter: 12
      callback  : =>
        manifest = KodingAppsController.getManifestFromPath @getData().path
        @ace.notify "Compiling...", null, yes
        @getSingleton('kodingAppsController').compileApp manifest.name, =>
          @ace.notify "App compiled!", "success"
          @getSingleton('kodingAppsController').runApp manifest
          @compileAndRunButton.hideLoader()

    @compileAndRunButton.hide() unless /\.kdapp\//.test @getData().path

    @setViewListeners()

  setViewListeners:->
<commit_msg>Handle errors on Ace<commit_after>###
  todo:

    - make save dialog a view with pistachio
    - put listeners in methods
    - make this splittable

###

class AceView extends JView

  constructor:(options, file)->

    super

    @listenWindowResize()

    @saveButton = new KDButtonViewWithMenu
      title         : "Save"
      style         : "editor-button save-menu"
      type          : "contextmenu"
      delegate      : @
      menu          : @getSaveMenu.bind @
      callback      : ()=>
        @ace.requestSave()

    @caretPosition = new KDCustomHTMLView
      tagName       : "div"
      cssClass      : "caret-position section"
      partial       : "<span>1</span>:<span>1</span>"

    @ace = new Ace {}, file

    @advancedSettings = new KDButtonViewWithMenu
      style         : 'editor-advanced-settings-menu'
      icon          : yes
      iconOnly      : yes
      iconClass     : "cog"
      type          : "contextmenu"
      delegate      : @
      itemClass     : AceSettingsView
      click         : (pubInst, event)-> @contextMenu event
      menu          : @getAdvancedSettingsMenuItems.bind @

    publicUrlCheck = /.*\/(.*\.koding.com)\/website\/(.*)/
    @previewButton = new KDButtonView
      style     : "editor-button"
      icon      : yes
      iconOnly  : yes
      iconClass : "preview"
      callback  : =>
        publicPath = @getData().path.replace publicUrlCheck, 'http://$1/$2'
        return if publicPath is @getData().path
        appManager.openFileWithApplication publicPath, "Viewer"

    @previewButton.hide() unless publicUrlCheck.test(@getData().path)

    @compileAndRunButton = new KDButtonView
      style     : "editor-button"
      title     : "Compile & Run"
      loader    :
        color   : "#444444"
        diameter: 12
      callback  : =>
        manifest = KodingAppsController.getManifestFromPath @getData().path
        @ace.notify "Compiling...", null, yes
        @getSingleton('kodingAppsController').compileApp manifest.name, (err)=>
          if not err
            @ace.notify "App compiled!", "success"
          else
            @ace.notify "Trying to run old version..."
          @getSingleton('kodingAppsController').runApp manifest
          @compileAndRunButton.hideLoader()

    @compileAndRunButton.hide() unless /\.kdapp\//.test @getData().path

    @setViewListeners()

  setViewListeners:->

{'fraction_non_alphanumeric': 0.11348578756144476, 'fraction_numerical': 0.005129301132720667, 'mean_word_length': 2.0232558139534884, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5559972', 'n_tokens_mistral': 1376, 'n_tokens_neox': 1328, 'n_words': 296}