|
27 | 27 |
|
28 | 28 | 'use strict'; |
29 | 29 |
|
| 30 | +const { debug, inherits } = require('util'); |
| 31 | +const Buffer = require('buffer').Buffer; |
| 32 | +const EventEmitter = require('events'); |
| 33 | +const { |
| 34 | + emitKeys, |
| 35 | + getStringWidth, |
| 36 | + isFullWidthCodePoint, |
| 37 | + stripVTControlCharacters |
| 38 | +} = require('internal/readline'); |
| 39 | + |
30 | 40 | const kHistorySize = 30; |
31 | 41 | const kMincrlfDelay = 100; |
32 | 42 | const kMaxcrlfDelay = 2000; |
| 43 | +// \r\n, \n, or \r followed by something other than \n |
| 44 | +const lineEnding = /\r?\n|\r(?!\n)/; |
33 | 45 |
|
34 | | -const util = require('util'); |
35 | | -const debug = util.debuglog('readline'); |
36 | | -const inherits = util.inherits; |
37 | | -const Buffer = require('buffer').Buffer; |
38 | | -const EventEmitter = require('events'); |
39 | | -const internalReadline = require('internal/readline'); |
40 | | -const emitKeys = internalReadline.emitKeys; |
41 | | -const getStringWidth = internalReadline.getStringWidth; |
42 | | -const isFullWidthCodePoint = internalReadline.isFullWidthCodePoint; |
43 | | -const stripVTControlCharacters = internalReadline.stripVTControlCharacters; |
| 46 | +const KEYPRESS_DECODER = Symbol('keypress-decoder'); |
| 47 | +const ESCAPE_DECODER = Symbol('escape-decoder'); |
| 48 | + |
| 49 | +// GNU readline library - keyseq-timeout is 500ms (default) |
| 50 | +const ESCAPE_CODE_TIMEOUT = 500; |
44 | 51 |
|
45 | 52 |
|
46 | 53 | function createInterface(input, output, completer, terminal) { |
47 | 54 | return new Interface(input, output, completer, terminal); |
48 | | -}; |
| 55 | +} |
49 | 56 |
|
50 | 57 |
|
51 | 58 | function Interface(input, output, completer, terminal) { |
@@ -373,8 +380,6 @@ Interface.prototype.write = function(d, key) { |
373 | 380 | this.terminal ? this._ttyWrite(d, key) : this._normalWrite(d); |
374 | 381 | }; |
375 | 382 |
|
376 | | -// \r\n, \n, or \r followed by something other than \n |
377 | | -const lineEnding = /\r?\n|\r(?!\n)/; |
378 | 383 | Interface.prototype._normalWrite = function(b) { |
379 | 384 | if (b === undefined) { |
380 | 385 | return; |
@@ -961,12 +966,6 @@ Interface.prototype._ttyWrite = function(s, key) { |
961 | 966 | * accepts a readable Stream instance and makes it emit "keypress" events |
962 | 967 | */ |
963 | 968 |
|
964 | | -const KEYPRESS_DECODER = Symbol('keypress-decoder'); |
965 | | -const ESCAPE_DECODER = Symbol('escape-decoder'); |
966 | | - |
967 | | -// GNU readline library - keyseq-timeout is 500ms (default) |
968 | | -const ESCAPE_CODE_TIMEOUT = 500; |
969 | | - |
970 | 969 | function emitKeypressEvents(stream, iface) { |
971 | 970 | if (stream[KEYPRESS_DECODER]) return; |
972 | 971 | var StringDecoder = require('string_decoder').StringDecoder; // lazy load |
|
0 commit comments