readline: multiple code cleanups
Variety of code maintenance updates, cleanups PR-URL: https://github.com/nodejs/node/pull/12755 Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
parent
392a8987c6
commit
4ac7a68ccd
@ -27,25 +27,32 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { debug, inherits } = require('util');
|
||||||
|
const Buffer = require('buffer').Buffer;
|
||||||
|
const EventEmitter = require('events');
|
||||||
|
const {
|
||||||
|
emitKeys,
|
||||||
|
getStringWidth,
|
||||||
|
isFullWidthCodePoint,
|
||||||
|
stripVTControlCharacters
|
||||||
|
} = require('internal/readline');
|
||||||
|
|
||||||
const kHistorySize = 30;
|
const kHistorySize = 30;
|
||||||
const kMincrlfDelay = 100;
|
const kMincrlfDelay = 100;
|
||||||
const kMaxcrlfDelay = 2000;
|
const kMaxcrlfDelay = 2000;
|
||||||
|
// \r\n, \n, or \r followed by something other than \n
|
||||||
|
const lineEnding = /\r?\n|\r(?!\n)/;
|
||||||
|
|
||||||
const util = require('util');
|
const KEYPRESS_DECODER = Symbol('keypress-decoder');
|
||||||
const debug = util.debuglog('readline');
|
const ESCAPE_DECODER = Symbol('escape-decoder');
|
||||||
const inherits = util.inherits;
|
|
||||||
const Buffer = require('buffer').Buffer;
|
// GNU readline library - keyseq-timeout is 500ms (default)
|
||||||
const EventEmitter = require('events');
|
const ESCAPE_CODE_TIMEOUT = 500;
|
||||||
const internalReadline = require('internal/readline');
|
|
||||||
const emitKeys = internalReadline.emitKeys;
|
|
||||||
const getStringWidth = internalReadline.getStringWidth;
|
|
||||||
const isFullWidthCodePoint = internalReadline.isFullWidthCodePoint;
|
|
||||||
const stripVTControlCharacters = internalReadline.stripVTControlCharacters;
|
|
||||||
|
|
||||||
|
|
||||||
function createInterface(input, output, completer, terminal) {
|
function createInterface(input, output, completer, terminal) {
|
||||||
return new Interface(input, output, completer, terminal);
|
return new Interface(input, output, completer, terminal);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
function Interface(input, output, completer, terminal) {
|
function Interface(input, output, completer, terminal) {
|
||||||
@ -373,8 +380,6 @@ Interface.prototype.write = function(d, key) {
|
|||||||
this.terminal ? this._ttyWrite(d, key) : this._normalWrite(d);
|
this.terminal ? this._ttyWrite(d, key) : this._normalWrite(d);
|
||||||
};
|
};
|
||||||
|
|
||||||
// \r\n, \n, or \r followed by something other than \n
|
|
||||||
const lineEnding = /\r?\n|\r(?!\n)/;
|
|
||||||
Interface.prototype._normalWrite = function(b) {
|
Interface.prototype._normalWrite = function(b) {
|
||||||
if (b === undefined) {
|
if (b === undefined) {
|
||||||
return;
|
return;
|
||||||
@ -961,12 +966,6 @@ Interface.prototype._ttyWrite = function(s, key) {
|
|||||||
* accepts a readable Stream instance and makes it emit "keypress" events
|
* accepts a readable Stream instance and makes it emit "keypress" events
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const KEYPRESS_DECODER = Symbol('keypress-decoder');
|
|
||||||
const ESCAPE_DECODER = Symbol('escape-decoder');
|
|
||||||
|
|
||||||
// GNU readline library - keyseq-timeout is 500ms (default)
|
|
||||||
const ESCAPE_CODE_TIMEOUT = 500;
|
|
||||||
|
|
||||||
function emitKeypressEvents(stream, iface) {
|
function emitKeypressEvents(stream, iface) {
|
||||||
if (stream[KEYPRESS_DECODER]) return;
|
if (stream[KEYPRESS_DECODER]) return;
|
||||||
var StringDecoder = require('string_decoder').StringDecoder; // lazy load
|
var StringDecoder = require('string_decoder').StringDecoder; // lazy load
|
||||||
|
Loading…
x
Reference in New Issue
Block a user