summaryrefslogtreecommitdiff
path: root/lib/readline.js
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2017-04-29 13:33:35 -0700
committerAnna Henningsen <anna@addaleax.net>2017-05-07 22:53:58 +0200
commit9318f82937d08462c87750946b919b8991c827e2 (patch)
tree6094c1392ba476ff53e0910f82e45ae3b133ffbf /lib/readline.js
parenta398516b4fdba21332d8ffb44ac8d4a8c687fde6 (diff)
downloadandroid-node-v8-9318f82937d08462c87750946b919b8991c827e2.tar.gz
android-node-v8-9318f82937d08462c87750946b919b8991c827e2.tar.bz2
android-node-v8-9318f82937d08462c87750946b919b8991c827e2.zip
readline: use module.exports = {}
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.js41
1 files changed, 19 insertions, 22 deletions
diff --git a/lib/readline.js b/lib/readline.js
index 947daddadd..a01b7a5e90 100644
--- a/lib/readline.js
+++ b/lib/readline.js
@@ -43,7 +43,7 @@ const isFullWidthCodePoint = internalReadline.isFullWidthCodePoint;
const stripVTControlCharacters = internalReadline.stripVTControlCharacters;
-exports.createInterface = function(input, output, completer, terminal) {
+function createInterface(input, output, completer, terminal) {
return new Interface(input, output, completer, terminal);
};
@@ -311,13 +311,13 @@ Interface.prototype._refreshLine = function() {
// first move to the bottom of the current line, based on cursor pos
var prevRows = this.prevRows || 0;
if (prevRows > 0) {
- exports.moveCursor(this.output, 0, -prevRows);
+ moveCursor(this.output, 0, -prevRows);
}
// Cursor to left edge.
- exports.cursorTo(this.output, 0);
+ cursorTo(this.output, 0);
// erase data
- exports.clearScreenDown(this.output);
+ clearScreenDown(this.output);
// Write the prompt and the current buffer content.
this._writeToOutput(line);
@@ -328,11 +328,11 @@ Interface.prototype._refreshLine = function() {
}
// Move cursor to original position.
- exports.cursorTo(this.output, cursorPos.cols);
+ cursorTo(this.output, cursorPos.cols);
var diff = lineRows - cursorPos.rows;
if (diff > 0) {
- exports.moveCursor(this.output, 0, -diff);
+ moveCursor(this.output, 0, -diff);
}
this.prevRows = cursorPos.rows;
@@ -716,7 +716,7 @@ Interface.prototype._moveCursor = function(dx) {
this.line.substring(this.cursor, oldcursor)
);
}
- exports.moveCursor(this.output, diffWidth, 0);
+ moveCursor(this.output, diffWidth, 0);
this.prevRows = newPos.rows;
} else {
this._refreshLine();
@@ -798,8 +798,8 @@ Interface.prototype._ttyWrite = function(s, key) {
break;
case 'l': // clear the whole screen
- exports.cursorTo(this.output, 0, 0);
- exports.clearScreenDown(this.output);
+ cursorTo(this.output, 0, 0);
+ clearScreenDown(this.output);
this._refreshLine();
break;
@@ -957,10 +957,6 @@ Interface.prototype._ttyWrite = function(s, key) {
}
};
-
-exports.Interface = Interface;
-
-
/**
* accepts a readable Stream instance and makes it emit "keypress" events
*/
@@ -1036,8 +1032,6 @@ function emitKeypressEvents(stream, iface) {
stream.on('newListener', onNewListener);
}
}
-exports.emitKeypressEvents = emitKeypressEvents;
-
/**
* moves the cursor to the x and y coordinate on the given stream
@@ -1059,8 +1053,6 @@ function cursorTo(stream, x, y) {
stream.write('\x1b[' + (y + 1) + ';' + (x + 1) + 'H');
}
}
-exports.cursorTo = cursorTo;
-
/**
* moves the cursor relative to its current location
@@ -1082,8 +1074,6 @@ function moveCursor(stream, dx, dy) {
stream.write('\x1b[' + dy + 'B');
}
}
-exports.moveCursor = moveCursor;
-
/**
* clears the current line the cursor is on:
@@ -1107,8 +1097,6 @@ function clearLine(stream, dir) {
stream.write('\x1b[2K');
}
}
-exports.clearLine = clearLine;
-
/**
* clears the screen from the current position of the cursor down
@@ -1120,4 +1108,13 @@ function clearScreenDown(stream) {
stream.write('\x1b[0J');
}
-exports.clearScreenDown = clearScreenDown;
+
+module.exports = {
+ Interface,
+ clearLine,
+ clearScreenDown,
+ createInterface,
+ cursorTo,
+ emitKeypressEvents,
+ moveCursor
+};