<commit_before><template id="lively-console">
    <style>
    .container {
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
    }
    #console {
        width: 100%;
        height: 100%;
        overflow: auto;
        flex: 1;
        margin: 0px;
        padding: 0px;
    }
    #commandlineholder {
        margin: 2px;
        height: 20px;
        width: 100%;
        display: flex;
        flex-direction: row;
    }
    #commandline {
        margin-left: 2px;
        margin-right: 2px;
        font-family: monospace;
        flex: 1;
    }
    #evalbutton {
    }
    </style>
    <div class="container">
      <!-- <pre id="console"></pre> -->
      <juicy-ace-editor id="console"></juicy-ace-editor>
      <div id="commandlineholder">
        <button id="evalbutton">eval</button>
        <!-- <input type="text" id="commandline" value=""> -->
        <juicy-ace-editor id="commandline"></juicy-ace-editor>
      </div>
    </div>



    <script type="lively4script" data-name="initialize">
    () => {
      var container = $(this.shadowRoot).find(".container")[0];

      // from: http://stackoverflow.com/questions/32315244/single-line-ace-editor
      this.getSubmorph('#commandline').editor.setOptions({
          maxLines: 1, // make it 1 line
          autoScrollEditorIntoView: true,
          highlightActiveLine: false,
          printMargin: false,
          showGutter: false,
          /* mode: "ace/mode/javascript", */
          /* theme: "ace/theme/tomorrow_night_eighties" */
      });
      // remove newlines in pasted text
      editor.on("paste", function(e) {
          e.text = e.text.replace(/[\r\n]+/g, " ");
      });
      // make mouse position clipping nicer
      editor.renderer.screenToTextCoordinates = function(x, y) {
          var pos = this.pixelToScreenCoordinates(x, y);
          return this.session.screenToDocumentPosition(
              Math.min(this.session.getScreenLength() - 1, Math.max(pos.row, 0)),
              Math.max(pos.column, 0)
          );
      };
      // disable Enter Shift-Enter keys
      editor.commands.bindKey("Enter|Shift-Enter", "null")


      this.getSubmorph('#console').editor.setOptions({
          readOnly: true,
          highlightActiveLine: false,
          highlightGutterLine: false
      });
      this.getSubmorph('#console').editor.renderer.$cursorLayer.element.style.opacity=0

      $(this.getSubmorph('#commandline')).keyup((evt) => {
        if(evt.keyCode == 13) { this.evalInput() }})
      $(this.getSubmorph('#evalbutton')).click( (evt) => {this.evalInput()})
    }
    </script>


    <script type="lively4script" data-name="evalInput">
      function() {
          var src = this.getSubmorph('#commandline').editor.getValue()
          try { var result = eval(src) } catch(e) { result = "ERROR:" + e }
          this.log("" + src)
          this.log("// " + result)
      }
    </script>

    <script type="lively4script" data-name="log">
      function(/* varargs */) {
        var c = this.getSubmorph('#console')
        var editor  = c.editor
        if (!editor || !editor.session ) return
        Array.prototype.forEach.call(arguments, function(s) {
          // c.editor.setValue(c.editor.getValue() + "\n" + s, 1)
          var session = editor.session
          session.insert({
             row: session.getLength(),
             column: 0
          }, "\n" + s)
        })
      }
    </script>


</template>

<script class="registrationScript">
// This ugly piece of code will be auto generated, when exporting a template. Puh.
(function() {
  var template = document.currentScript.ownerDocument.querySelector('#lively-console');
  var clone = document.importNode(template.content, true);

  System.import('../src/client/morphic/component-loader.js').then(loader => { loader.register('lively-console', clone); });
})();
</script>
<commit_msg>wrap code in console<commit_after><template id="lively-console">
    <style>
    .container {
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
    }
    #console {
        width: 100%;
        height: 100%;
        overflow: auto;
        flex: 1;
        margin: 0px;
        padding: 0px;
    }
    #commandlineholder {
        margin: 2px;
        height: 20px;
        width: 100%;
        display: flex;
        flex-direction: row;
    }
    #commandline {
        margin-left: 2px;
        margin-right: 2px;
        font-family: monospace;
        flex: 1;
    }
    #evalbutton {
    }
    </style>
    <div class="container">
      <!-- <pre id="console"></pre> -->
      <juicy-ace-editor id="console" wrapmode="true"></juicy-ace-editor>
      <div id="commandlineholder">
        <button id="evalbutton">eval</button>
        <!-- <input type="text" id="commandline" value=""> -->
        <juicy-ace-editor id="commandline" ></juicy-ace-editor>
      </div>
    </div>



    <script type="lively4script" data-name="initialize">
    () => {
      var container = $(this.shadowRoot).find(".container")[0];

      // from: http://stackoverflow.com/questions/32315244/single-line-ace-editor
      this.getSubmorph('#commandline').editor.setOptions({
          maxLines: 1, // make it 1 line
          autoScrollEditorIntoView: true,
          highlightActiveLine: false,
          printMargin: false,
          showGutter: false,
          /* mode: "ace/mode/javascript", */
          /* theme: "ace/theme/tomorrow_night_eighties" */
      });
      // remove newlines in pasted text
      editor.on("paste", function(e) {
          e.text = e.text.replace(/[\r\n]+/g, " ");
      });
      // make mouse position clipping nicer
      editor.renderer.screenToTextCoordinates = function(x, y) {
          var pos = this.pixelToScreenCoordinates(x, y);
          return this.session.screenToDocumentPosition(
              Math.min(this.session.getScreenLength() - 1, Math.max(pos.row, 0)),
              Math.max(pos.column, 0)
          );
      };
      // disable Enter Shift-Enter keys
      editor.commands.bindKey("Enter|Shift-Enter", "null")


      this.getSubmorph('#console').editor.setOptions({
          readOnly: true,
          highlightActiveLine: false,
          highlightGutterLine: false
      });
      this.getSubmorph('#console').editor.renderer.$cursorLayer.element.style.opacity=0

      $(this.getSubmorph('#commandline')).keyup((evt) => {
        if(evt.keyCode == 13) { this.evalInput() }})
      $(this.getSubmorph('#evalbutton')).click( (evt) => {this.evalInput()})
    }
    </script>


    <script type="lively4script" data-name="evalInput">
      function() {
          var src = this.getSubmorph('#commandline').editor.getValue()
          try { var result = eval(src) } catch(e) { result = "ERROR:" + e }
          this.log("" + src)
          this.log("// " + result)
      }
    </script>

    <script type="lively4script" data-name="log">
      function(/* varargs */) {
        var c = this.getSubmorph('#console')
        var editor  = c.editor
        if (!editor || !editor.session ) return
        Array.prototype.forEach.call(arguments, function(s) {
          // c.editor.setValue(c.editor.getValue() + "\n" + s, 1)
          var session = editor.session
          session.insert({
             row: session.getLength(),
             column: 0
          }, "\n" + s)
        })
      }
    </script>


</template>

<script class="registrationScript">
// This ugly piece of code will be auto generated, when exporting a template. Puh.
(function() {
  var template = document.currentScript.ownerDocument.querySelector('#lively-console');
  var clone = document.importNode(template.content, true);

  System.import('../src/client/morphic/component-loader.js').then(loader => { loader.register('lively-console', clone); });
})();
</script>

{'fraction_non_alphanumeric': 0.15859872611464967, 'fraction_numerical': 0.011719745222929937, 'mean_word_length': 2.1966612377850163, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 65, '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': '494655', 'n_tokens_mistral': 2445, 'n_tokens_neox': 2348, 'n_words': 453}