first commit
This commit is contained in:
33
build/node_modules/readline2/README.md
generated
vendored
Normal file
33
build/node_modules/readline2/README.md
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
readline2 [](https://travis-ci.org/SBoudrias/readline2)
|
||||
=========
|
||||
|
||||
Node.js (v0.8 and v0.10) had some bugs and issues with the default [Readline](http://nodejs.org/api/readline.html) module.
|
||||
|
||||
This module include fixes seen in later version (0.11-0.12 and iojs) and ease some undesirable behavior one could see using the readline to create interatives prompts. This means `readline2` change some behaviors and as so is **not** meant to be an exact drop-in replacement.
|
||||
|
||||
This project is extracted from the core of [Inquirer.js interactive prompt interface](https://github.com/SBoudrias/Inquirer.js) to be available as a standalone module.
|
||||
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
**Installation**: `npm install --save readline2`
|
||||
|
||||
### readline2.createInterface(options); -> {Interface}
|
||||
|
||||
Present the same API as [Node.js `readline.createInterface()`](http://nodejs.org/api/readline.html)
|
||||
|
||||
#### Improvements
|
||||
- Default `options.input` as `process.stdin`
|
||||
- Default `options.output` as `process.stdout`
|
||||
- `interface.stdout` is wrapped in a [MuteStream](https://github.com/isaacs/mute-stream)
|
||||
- Prevent `up` and `down` keys from moving through history inside the readline
|
||||
- Fix cursor position after a line refresh when the `Interface` prompt contains ANSI colors
|
||||
- Correctly return the cursor position when faced with implicit line returns
|
||||
|
||||
|
||||
License
|
||||
-------------
|
||||
|
||||
Copyright (c) 2012 Simon Boudrias (twitter: [@vaxilart](https://twitter.com/Vaxilart))
|
||||
Licensed under the MIT license.
|
||||
126
build/node_modules/readline2/index.js
generated
vendored
Normal file
126
build/node_modules/readline2/index.js
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
/**
|
||||
* Readline API façade to fix some issues
|
||||
* @Note: May look a bit like Monkey patching... if you know a better way let me know.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
var readline = require("readline");
|
||||
var MuteStream = require("mute-stream");
|
||||
var codePointAt = require("code-point-at");
|
||||
var isFullwidthCodePoint = require("is-fullwidth-code-point");
|
||||
|
||||
var Interface = module.exports = {};
|
||||
|
||||
|
||||
/**
|
||||
* Create a readline interface
|
||||
* @param {Object} opt Readline option hash
|
||||
* @return {readline} the new readline interface
|
||||
*/
|
||||
|
||||
Interface.createInterface = function( opt ) {
|
||||
opt || (opt = {});
|
||||
var filteredOpt = opt;
|
||||
|
||||
// Default `input` to stdin
|
||||
filteredOpt.input = opt.input || process.stdin;
|
||||
|
||||
// Add mute capabilities to the output
|
||||
var ms = new MuteStream();
|
||||
ms.pipe( opt.output || process.stdout );
|
||||
filteredOpt.output = ms;
|
||||
|
||||
// Create the readline
|
||||
var rl = readline.createInterface( filteredOpt );
|
||||
|
||||
// Fix bug with refreshLine
|
||||
var _refreshLine = rl._refreshLine;
|
||||
rl._refreshLine = function() {
|
||||
_refreshLine.call(rl);
|
||||
|
||||
var line = this._prompt + this.line;
|
||||
var cursorPos = this._getCursorPos();
|
||||
|
||||
readline.moveCursor(this.output, -line.length, 0);
|
||||
readline.moveCursor(this.output, cursorPos.cols, 0);
|
||||
};
|
||||
|
||||
// Returns current cursor's position and line
|
||||
rl._getCursorPos = function() {
|
||||
var columns = this.columns;
|
||||
var strBeforeCursor = this._prompt + this.line.substring(0, this.cursor);
|
||||
var dispPos = this._getDisplayPos(strBeforeCursor);
|
||||
var cols = dispPos.cols;
|
||||
var rows = dispPos.rows;
|
||||
// If the cursor is on a full-width character which steps over the line,
|
||||
// move the cursor to the beginning of the next line.
|
||||
if (cols + 1 === columns &&
|
||||
this.cursor < this.line.length &&
|
||||
isFullwidthCodePoint(codePointAt(this.line, this.cursor))) {
|
||||
rows++;
|
||||
cols = 0;
|
||||
}
|
||||
return {cols: cols, rows: rows};
|
||||
};
|
||||
|
||||
// Returns the last character's display position of the given string
|
||||
rl._getDisplayPos = function(str) {
|
||||
var offset = 0;
|
||||
var col = this.columns;
|
||||
var row = 0;
|
||||
var code;
|
||||
str = stripVTControlCharacters(str);
|
||||
for (var i = 0, len = str.length; i < len; i++) {
|
||||
code = codePointAt(str, i);
|
||||
if (code >= 0x10000) { // surrogates
|
||||
i++;
|
||||
}
|
||||
if (code === 0x0a) { // new line \n
|
||||
offset = 0;
|
||||
row += 1;
|
||||
continue;
|
||||
}
|
||||
if (isFullwidthCodePoint(code)) {
|
||||
if ((offset + 1) % col === 0) {
|
||||
offset++;
|
||||
}
|
||||
offset += 2;
|
||||
} else {
|
||||
offset++;
|
||||
}
|
||||
}
|
||||
var cols = offset % col;
|
||||
var rows = row + (offset - cols) / col;
|
||||
return {cols: cols, rows: rows};
|
||||
};
|
||||
|
||||
// Prevent arrows from breaking the question line
|
||||
var origWrite = rl._ttyWrite;
|
||||
rl._ttyWrite = function( s, key ) {
|
||||
key || (key = {});
|
||||
|
||||
if ( key.name === "up" ) return;
|
||||
if ( key.name === "down" ) return;
|
||||
|
||||
origWrite.apply( this, arguments );
|
||||
};
|
||||
|
||||
return rl;
|
||||
};
|
||||
|
||||
// Regexes used for ansi escape code splitting
|
||||
var metaKeyCodeReAnywhere = /(?:\x1b)([a-zA-Z0-9])/;
|
||||
var functionKeyCodeReAnywhere = new RegExp('(?:\x1b+)(O|N|\\[|\\[\\[)(?:' + [
|
||||
'(\\d+)(?:;(\\d+))?([~^$])',
|
||||
'(?:M([@ #!a`])(.)(.))', // mouse
|
||||
'(?:1;)?(\\d+)?([a-zA-Z])'
|
||||
].join('|') + ')');
|
||||
|
||||
/**
|
||||
* Tries to remove all VT control characters. Use to estimate displayed
|
||||
* string width. May be buggy due to not running a real state machine
|
||||
*/
|
||||
function stripVTControlCharacters (str) {
|
||||
str = str.replace(new RegExp(functionKeyCodeReAnywhere.source, 'g'), '');
|
||||
return str.replace(new RegExp(metaKeyCodeReAnywhere.source, 'g'), '');
|
||||
}
|
||||
66
build/node_modules/readline2/package.json
generated
vendored
Normal file
66
build/node_modules/readline2/package.json
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
{
|
||||
"_from": "readline2@^1.0.1",
|
||||
"_id": "readline2@1.0.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-QQWWCP/BVHV7cV2ZidGZ/783LjU=",
|
||||
"_location": "/readline2",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "readline2@^1.0.1",
|
||||
"name": "readline2",
|
||||
"escapedName": "readline2",
|
||||
"rawSpec": "^1.0.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.0.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/inquirer"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/readline2/-/readline2-1.0.1.tgz",
|
||||
"_shasum": "41059608ffc154757b715d9989d199ffbf372e35",
|
||||
"_spec": "readline2@^1.0.1",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/inquirer",
|
||||
"author": {
|
||||
"name": "Simon Boudrias",
|
||||
"email": "admin@simonboudrias.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/SBoudrias/readline2/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"code-point-at": "^1.0.0",
|
||||
"is-fullwidth-code-point": "^1.0.0",
|
||||
"mute-stream": "0.0.5"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Readline Façade fixing bugs and issues found in releases 0.8 and 0.10",
|
||||
"devDependencies": {
|
||||
"chalk": "^1.1.0",
|
||||
"mocha": "^2.1.0",
|
||||
"sinon": "^1.7.3"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/SBoudrias/readline2#readme",
|
||||
"keywords": [
|
||||
"cli",
|
||||
"terminal",
|
||||
"readline",
|
||||
"tty",
|
||||
"ansi"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "readline2",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/SBoudrias/readline2.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha -R spec"
|
||||
},
|
||||
"version": "1.0.1"
|
||||
}
|
||||
Reference in New Issue
Block a user