<commit_before>﻿cls = window.cls || (window.cls = {});

/**
  * @constructor 
  * @extends ViewBase
  */

cls.CommandLineView = function(id, name, container_class, html, default_handler)
{

  var self = this;

  var __frame_index = -1;

  var __container = null;
  var __console_output = null;
  var __console_input = null;
  var __prefix = null;
  var __textarea = null;
  var __textarea_value = '';

  var submit_buffer = [];
  var line_buffer = [];
  var line_buffer_cursor = 0;

  var __selection_start = -1;
  var __selection_end = 0;

  var __is_tab = false;

  var console_output_data = [];

  var is_debug = false;
  var toolbar_visibility = true;

  var cons_out_render_return_val = function(entry)
  {
    if( __console_output )
    {
      if( is_debug && entry.obj_id )
      {
        __console_output.render
        (
          [
            'pre', 
            entry.value, 
            ['d', ' [' + entry.obj_id + ']'],
            'handler', 'inspect-object-link', 
            'rt-id', entry.runtime_id.toString(), 
            'obj-id', entry.obj_id.toString()
          ]
        );
      }
      else
      {
        __console_output.render
        (
          ['pre', entry.value ].concat
          ( 
            entry.obj_id 
            ? [
                'handler', 'inspect-object-link', 
                'rt-id', entry.runtime_id.toString(), 
                'obj-id', entry.obj_id.toString()
              ]
            : [] 
          )
        );
      }
    }
  }

  var cons_out_render_input = function(entry)
  {
    if( __console_output )
    {
      __console_output.render(['div', entry.value, 'class', 'log-entry']);
    }
  }

  var type_map =
  {
    "return-value": cons_out_render_return_val,
    "input-value": cons_out_render_input
  }

  var cons_out_update = function()
  {
    if( __console_output )
    {
      __console_output.innerHTML = '';
      var entry = null, i = 0;
      for( ; entry = console_output_data[i]; i++ )
      {
        type_map[entry.type](entry);
      }
      __container.scrollTop = __container.scrollHeight;
    };
    if( __textarea )
    {
      __textarea.value = __textarea_value;
      __textarea.selectionEnd = __textarea.selectionStart = __textarea_value.length;
      __textarea.focus();
    };
  }

  var handleEval = function(status, message, runtime_id, obj_id, callback)
  {

    const
    STATUS = 0,
    TYPE = 1,
    VALUE = 2,
    OBJECT_VALUE = 3,
    OBJECT_ID = 0,
    IS_CALLABLE = 1,
    IS_FUNCTION = 2,
    OBJECTVALUE_TYPE = 3,
    PROTOTYPE_ID = 4,
    NAME = 5;

    var value_type = message[TYPE];

    if( message[STATUS] == 'completed' )
    {
      var return_value = message[VALUE];
      if(return_value || /null|undefined/.test(value_type) )
      {
        var value = return_value || ''; 
        if( !obj_id )
        {
          switch (value_type)
          {
            case 'string':
            {
              value = '"' + value + '"';
              break;
            }
            case 'null':
            case 'undefined':
            {
              value = value_type;
              break;
            }
          }
        }
        if(callback)
        {
          callback(runtime_id, obj_id);
        }
        cons_out_render_return_val
        (
          console_output_data[console_output_data.length] =
          {
            type: "return-value",
            obj_id: obj_id,
            runtime_id: runtime_id,
            value: value
          }
        );
        __container.scrollTop = __container.scrollHeight;<commit_msg>Fixed DFL-1043: Escape quotation marks in the command line<commit_after>﻿cls = window.cls || (window.cls = {});

/**
  * @constructor 
  * @extends ViewBase
  */

cls.CommandLineView = function(id, name, container_class, html, default_handler)
{

  var self = this;

  var __frame_index = -1;

  var __container = null;
  var __console_output = null;
  var __console_input = null;
  var __prefix = null;
  var __textarea = null;
  var __textarea_value = '';

  var submit_buffer = [];
  var line_buffer = [];
  var line_buffer_cursor = 0;

  var __selection_start = -1;
  var __selection_end = 0;

  var __is_tab = false;

  var console_output_data = [];

  var is_debug = false;
  var toolbar_visibility = true;

  var cons_out_render_return_val = function(entry)
  {
    if( __console_output )
    {
      if( is_debug && entry.obj_id )
      {
        __console_output.render
        (
          [
            'pre', 
            entry.value, 
            ['d', ' [' + entry.obj_id + ']'],
            'handler', 'inspect-object-link', 
            'rt-id', entry.runtime_id.toString(), 
            'obj-id', entry.obj_id.toString()
          ]
        );
      }
      else
      {
        __console_output.render
        (
          ['pre', entry.value ].concat
          ( 
            entry.obj_id 
            ? [
                'handler', 'inspect-object-link', 
                'rt-id', entry.runtime_id.toString(), 
                'obj-id', entry.obj_id.toString()
              ]
            : [] 
          )
        );
      }
    }
  }

  var cons_out_render_input = function(entry)
  {
    if( __console_output )
    {
      __console_output.render(['div', entry.value, 'class', 'log-entry']);
    }
  }

  var type_map =
  {
    "return-value": cons_out_render_return_val,
    "input-value": cons_out_render_input
  }

  var cons_out_update = function()
  {
    if( __console_output )
    {
      __console_output.innerHTML = '';
      var entry = null, i = 0;
      for( ; entry = console_output_data[i]; i++ )
      {
        type_map[entry.type](entry);
      }
      __container.scrollTop = __container.scrollHeight;
    };
    if( __textarea )
    {
      __textarea.value = __textarea_value;
      __textarea.selectionEnd = __textarea.selectionStart = __textarea_value.length;
      __textarea.focus();
    };
  }

  var handleEval = function(status, message, runtime_id, obj_id, callback)
  {

    const
    STATUS = 0,
    TYPE = 1,
    VALUE = 2,
    OBJECT_VALUE = 3,
    OBJECT_ID = 0,
    IS_CALLABLE = 1,
    IS_FUNCTION = 2,
    OBJECTVALUE_TYPE = 3,
    PROTOTYPE_ID = 4,
    NAME = 5;

    var value_type = message[TYPE];

    if( message[STATUS] == 'completed' )
    {
      var return_value = message[VALUE];
      if(return_value || /null|undefined/.test(value_type) )
      {
        var value = return_value || ''; 
        if( !obj_id )
        {
          switch (value_type)
          {
            case 'string':
            {
              var delimiter = "\"";
              // Escape ' and " Python command line interpreter style
              if (value.indexOf("\"") != -1) {
                delimiter = "'";
                if (value.indexOf("'") != -1) {
                  value = value.replace(/'/g, "\\'");
                }
              }
              value = delimiter + value + delimiter;
              break;
            }
            case 'null':
            case 'undefined':
            {
              value = value_type;
              break;
            }
          }
        }
        if(callback)
        {
          callback(runtime_id, obj_id);
        }
        cons_out_render_return_val
        (
          console_output_data[console_output_data.length] =
          {
            type: "return-value",
            obj_id: obj_id,
            runtime_id: runtime_id,
            value: value
          }
        );
        __container.scrollTop = __container.scrollHeight;
{'fraction_non_alphanumeric': 0.11775676035700014, 'fraction_numerical': 0.004795524177434394, 'mean_word_length': 1.6306937631394534, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, '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': '5270598', 'n_tokens_mistral': 2441, 'n_tokens_neox': 2305, 'n_words': 435}