<commit_before>'use strict';

var createRli = require('./readline')
  , parseKey = require('parse-key')
  ;

module.exports = function createHarness (wraprli) { 
  var hns = {
      rli        : undefined 
      // wrapper returned by calling the wraprli
    , rlw        : undefined
    , normal     : undefined
    , insert     : undefined
    , key        : key
    , code       : code
    , seq        : seq
    , keyed      : undefined
    , coded      : undefined
    , seqed      : undefined
    , written    : []
    , writtenStr : []

    , resetModes : resetModes
    , reset      : reset

    // assign to function to perform extra reset steps with every reset
    , onreset    : undefined
  };

  function key(k) {
    var keyObj;
    keyObj = parseKey(k);
    hns.rli._ttyWrite(null, keyObj);
    hns.keyed = ' [' + k + '] ';
  }

  function code(code_) {
    hns.rli._ttyWrite(code_, { });
    hns.coded = ' [' + code_ + '] ';
  }

  function seq(seq_) {
    var keys = seq_.split(' ');

    // since we are dealing with a sequence here, it makes sense to reset
    hns.reset();

    hns.key(keys.shift());
    hns.key(keys.shift());
    hns.seqed = ' [' + seq_ + '] ';
  }

  function resetModes() {
    hns.normal = 0;
    hns.insert = 0;
  }

  function reset() {
    hns.rli = createRli();
    hns.rlw = wraprli(hns.rli);

    hns.resetModes();

    hns.keyed = hns.coded = hns.seqed = hns.pressed = undefined;
    hns.written = [] ;
    hns.writtenStr = [];
    
    // do more reset steps if the function is set
    if (hns.onreset) hns.onreset();
    return hns;
  }
  reset();

  return hns;
};<commit_msg>fixes and more readline-vim related removals<commit_after>'use strict';

var createRli = require('./readline')
  , parseKey = require('parse-key')
  ;

module.exports = function createHarness (wraprli) { 
  var hns = {
      rli        : undefined 

      // wrapper returned by calling the wraprli
    , rlw        : undefined

    , key        : key
    , code       : code
    , seq        : seq
    , keyed      : undefined
    , coded      : undefined
    , seqed      : undefined

    , reset      : reset

    // assign to function to perform extra reset steps with every reset
    , onreset    : undefined
  };

  function key(k) {
    var keyObj;
    try { 
      keyObj = parseKey(k);
    } catch(e) {
      // XXX: probably should fix parse key to handle these cases (same for stringify key)
      keyObj = { name: k };
    }
    hns.rli._ttyWrite(null, keyObj);
    hns.keyed = ' [' + k + '] ';
  }

  function code(code_) {
    hns.rli._ttyWrite(code_, { });
    hns.coded = ' [' + code_ + '] ';
  }

  function seq(seq_) {
    var keys = seq_.split(' ');

    // since we are dealing with a sequence here, it makes sense to reset
    hns.reset();

    hns.key(keys.shift());
    hns.key(keys.shift());
    hns.seqed = ' [' + seq_ + '] ';
  }

  function reset() {
    hns.rli = createRli();
    hns.rlw = wraprli(hns.rli);

    hns.keyed = hns.coded = hns.seqed = hns.pressed = undefined;
    
    // do more reset steps if the function is set
    if (hns.onreset) hns.onreset();
    return hns;
  }
  reset();

  return hns;
};
{'fraction_non_alphanumeric': 0.13406940063091483, 'fraction_numerical': 0.0006309148264984228, 'mean_word_length': 1.9774647887323944, 'pattern_counts': {'":': 0, '<': 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': '1967739', 'n_tokens_mistral': 1122, 'n_tokens_neox': 1084, 'n_words': 273}