src/core/CliConsole.js
// alt code, or control code.
alt code, or control code.
alt code or control code .
function pullKeyEvent(charCodes) {
      if (!charCodes || charCodes.length === 0) {
        return null;
      }
      var c1 = charCodes.shift();
      if (c1 === ASCII_DEL) {
        c1 = ASCII_BS;
      }
      var cch = String.fromCharCode(c1);
      if (c1 <= codeESC) {
        var k = CtrlCodes[c1];
        if (charCodes.length === 0 || c1 !== codeESC) {
          return { keyCode: k };
        }
      }
      if (c1 >= 32 && c1 < 128) {
         return { visibleChar: cch }
      }
      if (c1 !== codeESC) {
        return { ctrlCode: cch }
      }
      for (var key in EscapeCodes) {
        var escSeq = EscapeCodes[key];
        var i = 0;
        while (i < escSeq.length && i < charCodes.length) {
          if (escSeq[i] === charCodes[i]) {
            i++;
            if (i === escSeq.length) {
              while (i > 0) {
                charCodes.shift(); 
                i--;
              }
              return { keyCode: key };
            }
          }
          else {
            break;
          }
        }
      }
      var c2 = charCodes.shift();
      cch += String.fromCharCode(c2);
      return { ctrlCode: cch }
    }
function pullKeyEvent ( charCodes ) { if ( ! charCodes || charCodes . length === 0 ) { return null ; } var c1 = charCodes . shift ( ) ; if ( c1 === ASCII_DEL ) { c1 = ASCII_BS ; } var cch = String . fromCharCode ( c1 ) ; if ( c1 <= codeESC ) { var k = CtrlCodes [ c1 ] ; if ( charCodes . length === 0 || c1 !== codeESC ) { return { keyCode : k } ; } } if ( c1 >= 32 && c1 < 128 ) { return { visibleChar : cch } } if ( c1 !== codeESC ) { return { ctrlCode : cch } } for ( var key in EscapeCodes ) { var escSeq = EscapeCodes [ key ] ; var i = 0 ; while ( i < escSeq . length && i < charCodes . length ) { if ( escSeq [ i ] === charCodes [ i ] ) { i ++ ; if ( i === escSeq . length ) { while ( i > 0 ) { charCodes . shift ( ) ; i -- ; } return { keyCode : key } ; } } else { break ; } } } var c2 = charCodes . shift ( ) ; cch += String . fromCharCode ( c2 ) ; return { ctrlCode : cch } }
alt code, or control code.
alt code or control code .
// Handle Linux Terminal backspace. // Handle simple key codes. // Now the most common letters. // These are not really control codes since most unicode // chars are visible, but fix this later. TODO: fixme // This a multicharacter escape sequence. // Shift off the matching key codes. // Toss it. // Return a two character ESC code.