<commit_before>define (require) ->
  require("jquery.layout")
  ace = require("ace")

  template = """
  <div class="ide">
    <div class="ui-layout-center">
      <div class="ide-editor">
      </div>
      <div class="ide-start-dialog">
        <div class="ide-start-dialog-content">
          <a class="btn btn-primary btn-lg">Start Exercises</a>
          <p> or <a class="ide-skip-btn">skip </a> </p>
        </div>
      </div>
    </div>
    <div class="ui-layout-west">
      <div class="ide-tutorial-container">
      </div>
    </div>
  </div>
  """

  class IDE
    constructor: (el) ->
      @$ = $(el)
      @$.html(template)
      @$container = @$.find(".ide")
      @$editor = @$.find(".ide-editor")
      @$start_dialog = @$.find(".ide-start-dialog")
      @$start_button = @$.find(".ide-start-dialog .btn")
      @$tutorial_container = @$.find(".ide-tutorial-container")

      @$container.layout
        west:
          minSize: 300

      @ace = ace.edit(@$editor.get(0))

    # displays element as tutorial instruction text
    setTutorialInstruction: (el) ->
      @$tutorial_container.html(el)

    # set the tutorial content
    setTutorial: (@tutorial) ->
      @tutorial.setIDE(this)
      @tutorial.goto_first()

    # dynamically dispatches an IDE action
    dispatch: (action) ->
      method = this[action.type]
      method.call(@,action.data)

    edit: (opts) ->
      file = opts.file
      @ace.getSession().setValue file.content


    start: ->
      @$start_dialog.hide()

    stop: ->
      @$start_dialog.show()
<commit_msg>ide: sets mode when editing a file<commit_after>define (require) ->
  require("jquery.layout")
  ace = require("ace")
  modelist = require 'ace/ext/modelist'

  template = """
  <div class="ide">
    <div class="ui-layout-center">
      <div class="ide-editor">
      </div>
      <div class="ide-start-dialog">
        <div class="ide-start-dialog-content">
          <a class="btn btn-primary btn-lg">Start Exercises</a>
          <p> or <a class="ide-skip-btn">skip </a> </p>
        </div>
      </div>
    </div>
    <div class="ui-layout-west">
      <div class="ide-tutorial-container">
      </div>
    </div>
  </div>
  """

  class IDE
    constructor: (el) ->
      @$ = $(el)
      @$.html(template)
      @$container = @$.find(".ide")
      @$editor = @$.find(".ide-editor")
      @$start_dialog = @$.find(".ide-start-dialog")
      @$start_button = @$.find(".ide-start-dialog .btn")
      @$tutorial_container = @$.find(".ide-tutorial-container")

      @$container.layout
        west:
          minSize: 300

      @ace = ace.edit(@$editor.get(0))

    # displays element as tutorial instruction text
    setTutorialInstruction: (el) ->
      @$tutorial_container.html(el)

    # set the tutorial content
    setTutorial: (@tutorial) ->
      @tutorial.setIDE(this)
      @tutorial.goto_first()

    # dynamically dispatches an IDE action
    dispatch: (action) ->
      method = this[action.type]
      method.call(@,action.data)

    edit: (opts) ->
      file = opts.file
      match = modelist.getModeForPath(file.path)
      mode = match.mode
      @ace.getSession().setValue file.content
      @ace.getSession().setMode mode


    start: ->
      @$start_dialog.hide()

    stop: ->
      @$start_dialog.show()

{'fraction_non_alphanumeric': 0.17663125948406677, 'fraction_numerical': 0.0024279210925644916, 'mean_word_length': 2.3360323886639676, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 59, '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': '3657349', 'n_tokens_mistral': 1130, 'n_tokens_neox': 1079, 'n_words': 211}