diff options
author | James M Snell <jasnell@gmail.com> | 2017-04-29 13:46:26 -0700 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2017-05-07 22:54:22 +0200 |
commit | 4ac7a68ccd6fb0104f171ef49e964fb6d4a170c6 (patch) | |
tree | 0547c1ef505b34c2664c267e079ed9f022444057 /lib/readline.js | |
parent | 392a8987c62f0c54de9036659853467b48f113cd (diff) | |
download | android-node-v8-4ac7a68ccd6fb0104f171ef49e964fb6d4a170c6.tar.gz android-node-v8-4ac7a68ccd6fb0104f171ef49e964fb6d4a170c6.tar.bz2 android-node-v8-4ac7a68ccd6fb0104f171ef49e964fb6d4a170c6.zip |
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>
Diffstat (limited to 'lib/readline.js')
-rw-r--r-- | lib/readline.js | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/lib/readline.js b/lib/readline.js index a01b7a5e90..f46fc0d59c 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -27,25 +27,32 @@ '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 kMincrlfDelay = 100; 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 debug = util.debuglog('readline'); -const inherits = util.inherits; -const Buffer = require('buffer').Buffer; -const EventEmitter = require('events'); -const internalReadline = require('internal/readline'); -const emitKeys = internalReadline.emitKeys; -const getStringWidth = internalReadline.getStringWidth; -const isFullWidthCodePoint = internalReadline.isFullWidthCodePoint; -const stripVTControlCharacters = internalReadline.stripVTControlCharacters; +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 createInterface(input, output, completer, terminal) { return new 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); }; -// \r\n, \n, or \r followed by something other than \n -const lineEnding = /\r?\n|\r(?!\n)/; Interface.prototype._normalWrite = function(b) { if (b === undefined) { return; @@ -961,12 +966,6 @@ Interface.prototype._ttyWrite = function(s, key) { * 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) { if (stream[KEYPRESS_DECODER]) return; var StringDecoder = require('string_decoder').StringDecoder; // lazy load |