Update CUI.

This commit is contained in:
unknown 2024-07-11 21:08:00 +08:00
parent fd44057e6e
commit d3f1c00435
123 changed files with 73795 additions and 56 deletions

206
app.js
View File

@ -1,3 +1,146 @@
const blessed = require('blessed');
const { Writable } = require('stream');
const chalk = require('chalk');
// 创建屏幕对象
const screen = blessed.screen({
smartCSR: true
});
screen.title = 'Blessed UI';
// 创建日志框
const logBox = blessed.log({
top: 0,
left: 0,
width: '70%',
height: '100%',
label: 'Logs',
border: { type: 'line' },
style: {
border: { fg: 'cyan' },
scrollbar: { bg: 'blue' },
},
scrollbar: {
ch: ' ',
track: { bg: 'yellow' },
style: { inverse: true },
},
keys: true,
mouse: true,
alwaysScroll: true,
scrollable: true,
vi: true
});
// 创建状态框
const statusBox = blessed.box({
top: 0,
left: '70%',
width: '30%',
height: '100%',
label: 'Status', // 更新标签为 "Status"
border: { type: 'line' },
style: {
border: { fg: 'cyan' }
},
content: 'Uptime: 0m 0s' // 初始显示 "Uptime" 统计信息
});
// 创建菜单
const menu = blessed.list({
top: 'center',
left: 'center',
width: '30%',
height: '30%',
label: 'Menu',
border: { type: 'line' },
style: {
border: { fg: 'cyan' },
selected: { bg: 'blue' }
},
keys: true,
mouse: true,
items: ['Button1', 'Button2', 'Button3'],
hidden: true,
vi: true
});
// 添加到屏幕
screen.append(logBox);
screen.append(statusBox);
screen.append(menu);
// 绑定ESC键以打开菜单
screen.key(['escape'], (ch, key) => {
if (menu.hidden) {
menu.show();
screen.render();
menu.focus();
} else {
menu.hide();
screen.render();
logBox.focus();
}
});
// 创建自定义的可写流
class LogStream extends Writable {
constructor(options) {
super(options);
}
_write(chunk, encoding, callback) {
logBox.log(chunk.toString());
callback();
}
}
// 实例化自定义流
const logStream = new LogStream();
// 重新定向 console 的输出到日志框
console.log = function(...args) {
logStream.write(chalk.gray(args.join(' ')) + '\n');
};
console.info = function(...args) {
logStream.write(chalk.white(args.join(' ')) + '\n');
};
console.warn = function(...args) {
logStream.write(chalk.yellow(args.join(' ')) + '\n');
};
console.error = function(...args) {
logStream.write(chalk.red(args.join(' ')) + '\n');
};
// 更新 Uptime 统计信息
let uptimeInterval = setInterval(updateUptime, 1000); // 每秒更新一次
function updateUptime() {
const uptimeSeconds = Math.floor(process.uptime());
const minutes = Math.floor(uptimeSeconds / 60);
const seconds = uptimeSeconds % 60;
statusBox.setContent(`Uptime: ${minutes}m ${seconds}s`);
screen.render();
}
// 默认使日志框获得焦点
logBox.focus();
// 渲染屏幕
screen.render();
// 示例日志
console.log('Log message');
console.info('Info message');
console.warn('Warning message');
console.error('Error message');
//config.json
const fs = require('fs');
const path = require('path');
@ -5,7 +148,7 @@ require('./meowLog')
console.info("Loading config...")
function getConfig() {
function loadConfig() {
const configPath = path.join(__dirname, 'config.json');
try {
const rawConfig = fs.readFileSync(configPath, 'utf8');
@ -17,52 +160,27 @@ function getConfig() {
}
}
const config = getConfig();
let config = loadConfig();
if (!("serverList" in config)) {
console.error("proxyOptions is needed.");
process.exit(1);
}
if (!("proxyServerOptions" in config)) {
console.error("proxyOptions is needed.");
process.exit(1);
}
if (!("proxyOptions" in config)) {
console.error("proxyOptions is needed.");
process.exit(1);
}
if (!("localServerOptions" in config)) {
console.error("proxyOptions is needed.");
process.exit(1);
}
//启动本地服务器作为default和fallback
let defaultServer = require('./localServer')(config)
//启动代理服务器
let proxy = require('./proxy')(config)
//控制台指令处理
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
function handleCommand(command) {
const args = command.trim().split(' ');
const cmd = args[0].toLowerCase();
switch (cmd) {
case 'greet':
const name = args[1] || 'stranger';
console.log(`Hello, ${name}!`);
break;
case 'exit':
console.log('Goodbye!');
rl.close();
break;
default:
console.log(`Unknown command: ${cmd}`);
}
}
rl.setPrompt('> ');
rl.prompt();
rl.on('line', (input) => {
handleCommand(input);
rl.prompt();
});
rl.on('close', () => {
console.log('Stopping server...')
Object.values(proxy.clients).forEach(client => {
client.write('kick_disconnect', {
reason: '111'
})
})
process.exit(0);
});

View File

@ -19,12 +19,15 @@
"port": 25565
}
},
"proxyOptions": {
"proxyServerOptions": {
"port": 25565,
"version": "1.16.3",
"online-mode": false,
"motd": "Minecraft Proxy in NodeJS"
},
"proxyOptions": {
"enablePlugins": true
},
"localServerOptions": {
"online-mode": false,
"encryption": true,

104
consoleManager.js Normal file
View File

@ -0,0 +1,104 @@
const readline = require('readline');
const EventEmitter = require('events');
class ConsoleManager extends EventEmitter {
constructor() {
super();
this.rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
this.rl.setPrompt('> ');
this.currentInput = '';
this.lastLineOffset = 0; // 记录最后一行的偏移量
// 创建日期格式化器
this.dateFormatter = new Intl.DateTimeFormat('en-US', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hour12: false // 使用24小时制
});
this._overrideConsole();
this._setupReadline();
this.rl.prompt();
}
getFormattedTime() {
return `[${this.dateFormatter.format(new Date())}]`;
}
_overrideConsole() {
const originalLog = console.log;
const originalInfo = console.info;
const originalError = console.error;
const originalWarn = console.warn;
console.log = (message) => {
this._moveCursorToLastLine();
originalLog(`${this.getFormattedTime()} ${message}`);
this.rl.prompt();
};
console.info = (message) => {
this._moveCursorToLastLine();
originalInfo(`${this.getFormattedTime()} ${message}`);
this.rl.prompt();
};
console.error = (message) => {
this._moveCursorToLastLine();
originalError(`${this.getFormattedTime()} ${message}`);
this.rl.prompt();
};
console.warn = (message) => {
this._moveCursorToLastLine();
originalWarn(`${this.getFormattedTime()} ${message}`);
this.rl.prompt();
};
}
_setupReadline() {
this.rl.on('line', (input) => {
this.currentInput = ''; // 清空当前输入
this.emit('line', input); // 触发 line 事件
this.rl.prompt();
});
// 捕捉输入事件,并手动处理字符显示
this.rl.input.on('keypress', (char, key) => {
if (key.name === 'return' || key.name === 'enter') {
// 当按下回车键时,清空 currentInput并发出 'line' 事件
this.currentInput = '';
} else if (key.name === 'backspace') {
// 处理退格键
if (this.currentInput.length > 0) {
this.currentInput = this.currentInput.slice(0, -1); // 删除一个字符
this._moveCursorToLastLine();
}
} else if (!key.ctrl && !key.meta && char) {
// 处理普通字符,不拦截功能键和控制键
this.currentInput += char; // 添加字符到当前输入
this._moveCursorToLastLine();
}
});
}
_moveCursorToLastLine() {
readline.moveCursor(process.stdout, 0, -this.lastLineOffset); // 将光标移动到最后一行的位置
readline.cursorTo(process.stdout, 0); // 将光标移动到行首
readline.clearLine(process.stdout, 1); // 清除当前行,包括提示符
readline.moveCursor(process.stdout, 0, this.lastLineOffset); // 恢复光标位置
readline.cursorTo(process.stdout, 0); // 将光标移动到行首
process.stdout.write(`> ${this.currentInput}`); // 重新显示提示符和当前输入内容
readline.moveCursor(process.stdout, 0, -this.lastLineOffset); // 将光标移动到最后一行的位置
}
}
module.exports = ConsoleManager;

16
node_modules/.bin/blessed generated vendored Normal file
View File

@ -0,0 +1,16 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=`cygpath -w "$basedir"`
fi
;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../blessed/bin/tput.js" "$@"
else
exec node "$basedir/../blessed/bin/tput.js" "$@"
fi

17
node_modules/.bin/blessed.cmd generated vendored Normal file
View File

@ -0,0 +1,17 @@
@ECHO off
GOTO start
:find_dp0
SET dp0=%~dp0
EXIT /b
:start
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\blessed\bin\tput.js" %*

28
node_modules/.bin/blessed.ps1 generated vendored Normal file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/../blessed/bin/tput.js" $args
} else {
& "$basedir/node$exe" "$basedir/../blessed/bin/tput.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../blessed/bin/tput.js" $args
} else {
& "node$exe" "$basedir/../blessed/bin/tput.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

75
node_modules/.package-lock.json generated vendored
View File

@ -87,6 +87,20 @@
"url": "https://github.com/sponsors/epoberezkin"
}
},
"node_modules/ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dependencies": {
"color-convert": "^2.0.1"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/asn1": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz",
@ -135,6 +149,17 @@
"resolved": "https://registry.npmjs.org/minecraft-data/-/minecraft-data-2.221.0.tgz",
"integrity": "sha512-0AhqzbIKb6WqPSF6qBevaPryeWOz545hLxt6q+gfJF8YIQX/YfkyX/nXWhl+pSIS2rTBcQ0RJkRCtTeRzQwHDA=="
},
"node_modules/blessed": {
"version": "0.1.81",
"resolved": "https://registry.npmjs.org/blessed/-/blessed-0.1.81.tgz",
"integrity": "sha512-LoF5gae+hlmfORcG1M5+5XZi4LBmvlXTzwJWzUlPryN/SJdSflZvROM2TwkT0GMpq7oqT48NRd4GS7BiVBc5OQ==",
"bin": {
"blessed": "bin/tput.js"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/buffer": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",
@ -174,6 +199,37 @@
"resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz",
"integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA=="
},
"node_modules/chalk": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"dependencies": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/chalk?sponsor=1"
}
},
"node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dependencies": {
"color-name": "~1.1.4"
},
"engines": {
"node": ">=7.0.0"
}
},
"node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"node_modules/commander": {
"version": "2.20.3",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
@ -258,6 +314,14 @@
}
}
},
"node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"engines": {
"node": ">=8"
}
},
"node_modules/ieee754": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
@ -762,6 +826,17 @@
}
]
},
"node_modules/supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dependencies": {
"has-flag": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",

345
node_modules/ansi-styles/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,345 @@
declare type CSSColor =
| 'aliceblue'
| 'antiquewhite'
| 'aqua'
| 'aquamarine'
| 'azure'
| 'beige'
| 'bisque'
| 'black'
| 'blanchedalmond'
| 'blue'
| 'blueviolet'
| 'brown'
| 'burlywood'
| 'cadetblue'
| 'chartreuse'
| 'chocolate'
| 'coral'
| 'cornflowerblue'
| 'cornsilk'
| 'crimson'
| 'cyan'
| 'darkblue'
| 'darkcyan'
| 'darkgoldenrod'
| 'darkgray'
| 'darkgreen'
| 'darkgrey'
| 'darkkhaki'
| 'darkmagenta'
| 'darkolivegreen'
| 'darkorange'
| 'darkorchid'
| 'darkred'
| 'darksalmon'
| 'darkseagreen'
| 'darkslateblue'
| 'darkslategray'
| 'darkslategrey'
| 'darkturquoise'
| 'darkviolet'
| 'deeppink'
| 'deepskyblue'
| 'dimgray'
| 'dimgrey'
| 'dodgerblue'
| 'firebrick'
| 'floralwhite'
| 'forestgreen'
| 'fuchsia'
| 'gainsboro'
| 'ghostwhite'
| 'gold'
| 'goldenrod'
| 'gray'
| 'green'
| 'greenyellow'
| 'grey'
| 'honeydew'
| 'hotpink'
| 'indianred'
| 'indigo'
| 'ivory'
| 'khaki'
| 'lavender'
| 'lavenderblush'
| 'lawngreen'
| 'lemonchiffon'
| 'lightblue'
| 'lightcoral'
| 'lightcyan'
| 'lightgoldenrodyellow'
| 'lightgray'
| 'lightgreen'
| 'lightgrey'
| 'lightpink'
| 'lightsalmon'
| 'lightseagreen'
| 'lightskyblue'
| 'lightslategray'
| 'lightslategrey'
| 'lightsteelblue'
| 'lightyellow'
| 'lime'
| 'limegreen'
| 'linen'
| 'magenta'
| 'maroon'
| 'mediumaquamarine'
| 'mediumblue'
| 'mediumorchid'
| 'mediumpurple'
| 'mediumseagreen'
| 'mediumslateblue'
| 'mediumspringgreen'
| 'mediumturquoise'
| 'mediumvioletred'
| 'midnightblue'
| 'mintcream'
| 'mistyrose'
| 'moccasin'
| 'navajowhite'
| 'navy'
| 'oldlace'
| 'olive'
| 'olivedrab'
| 'orange'
| 'orangered'
| 'orchid'
| 'palegoldenrod'
| 'palegreen'
| 'paleturquoise'
| 'palevioletred'
| 'papayawhip'
| 'peachpuff'
| 'peru'
| 'pink'
| 'plum'
| 'powderblue'
| 'purple'
| 'rebeccapurple'
| 'red'
| 'rosybrown'
| 'royalblue'
| 'saddlebrown'
| 'salmon'
| 'sandybrown'
| 'seagreen'
| 'seashell'
| 'sienna'
| 'silver'
| 'skyblue'
| 'slateblue'
| 'slategray'
| 'slategrey'
| 'snow'
| 'springgreen'
| 'steelblue'
| 'tan'
| 'teal'
| 'thistle'
| 'tomato'
| 'turquoise'
| 'violet'
| 'wheat'
| 'white'
| 'whitesmoke'
| 'yellow'
| 'yellowgreen';
declare namespace ansiStyles {
interface ColorConvert {
/**
The RGB color space.
@param red - (`0`-`255`)
@param green - (`0`-`255`)
@param blue - (`0`-`255`)
*/
rgb(red: number, green: number, blue: number): string;
/**
The RGB HEX color space.
@param hex - A hexadecimal string containing RGB data.
*/
hex(hex: string): string;
/**
@param keyword - A CSS color name.
*/
keyword(keyword: CSSColor): string;
/**
The HSL color space.
@param hue - (`0`-`360`)
@param saturation - (`0`-`100`)
@param lightness - (`0`-`100`)
*/
hsl(hue: number, saturation: number, lightness: number): string;
/**
The HSV color space.
@param hue - (`0`-`360`)
@param saturation - (`0`-`100`)
@param value - (`0`-`100`)
*/
hsv(hue: number, saturation: number, value: number): string;
/**
The HSV color space.
@param hue - (`0`-`360`)
@param whiteness - (`0`-`100`)
@param blackness - (`0`-`100`)
*/
hwb(hue: number, whiteness: number, blackness: number): string;
/**
Use a [4-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4-bit) to set text color.
*/
ansi(ansi: number): string;
/**
Use an [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color.
*/
ansi256(ansi: number): string;
}
interface CSPair {
/**
The ANSI terminal control sequence for starting this style.
*/
readonly open: string;
/**
The ANSI terminal control sequence for ending this style.
*/
readonly close: string;
}
interface ColorBase {
readonly ansi: ColorConvert;
readonly ansi256: ColorConvert;
readonly ansi16m: ColorConvert;
/**
The ANSI terminal control sequence for ending this color.
*/
readonly close: string;
}
interface Modifier {
/**
Resets the current color chain.
*/
readonly reset: CSPair;
/**
Make text bold.
*/
readonly bold: CSPair;
/**
Emitting only a small amount of light.
*/
readonly dim: CSPair;
/**
Make text italic. (Not widely supported)
*/
readonly italic: CSPair;
/**
Make text underline. (Not widely supported)
*/
readonly underline: CSPair;
/**
Inverse background and foreground colors.
*/
readonly inverse: CSPair;
/**
Prints the text, but makes it invisible.
*/
readonly hidden: CSPair;
/**
Puts a horizontal line through the center of the text. (Not widely supported)
*/
readonly strikethrough: CSPair;
}
interface ForegroundColor {
readonly black: CSPair;
readonly red: CSPair;
readonly green: CSPair;
readonly yellow: CSPair;
readonly blue: CSPair;
readonly cyan: CSPair;
readonly magenta: CSPair;
readonly white: CSPair;
/**
Alias for `blackBright`.
*/
readonly gray: CSPair;
/**
Alias for `blackBright`.
*/
readonly grey: CSPair;
readonly blackBright: CSPair;
readonly redBright: CSPair;
readonly greenBright: CSPair;
readonly yellowBright: CSPair;
readonly blueBright: CSPair;
readonly cyanBright: CSPair;
readonly magentaBright: CSPair;
readonly whiteBright: CSPair;
}
interface BackgroundColor {
readonly bgBlack: CSPair;
readonly bgRed: CSPair;
readonly bgGreen: CSPair;
readonly bgYellow: CSPair;
readonly bgBlue: CSPair;
readonly bgCyan: CSPair;
readonly bgMagenta: CSPair;
readonly bgWhite: CSPair;
/**
Alias for `bgBlackBright`.
*/
readonly bgGray: CSPair;
/**
Alias for `bgBlackBright`.
*/
readonly bgGrey: CSPair;
readonly bgBlackBright: CSPair;
readonly bgRedBright: CSPair;
readonly bgGreenBright: CSPair;
readonly bgYellowBright: CSPair;
readonly bgBlueBright: CSPair;
readonly bgCyanBright: CSPair;
readonly bgMagentaBright: CSPair;
readonly bgWhiteBright: CSPair;
}
}
declare const ansiStyles: {
readonly modifier: ansiStyles.Modifier;
readonly color: ansiStyles.ForegroundColor & ansiStyles.ColorBase;
readonly bgColor: ansiStyles.BackgroundColor & ansiStyles.ColorBase;
readonly codes: ReadonlyMap<number, number>;
} & ansiStyles.BackgroundColor & ansiStyles.ForegroundColor & ansiStyles.Modifier;
export = ansiStyles;

163
node_modules/ansi-styles/index.js generated vendored Normal file
View File

@ -0,0 +1,163 @@
'use strict';
const wrapAnsi16 = (fn, offset) => (...args) => {
const code = fn(...args);
return `\u001B[${code + offset}m`;
};
const wrapAnsi256 = (fn, offset) => (...args) => {
const code = fn(...args);
return `\u001B[${38 + offset};5;${code}m`;
};
const wrapAnsi16m = (fn, offset) => (...args) => {
const rgb = fn(...args);
return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
};
const ansi2ansi = n => n;
const rgb2rgb = (r, g, b) => [r, g, b];
const setLazyProperty = (object, property, get) => {
Object.defineProperty(object, property, {
get: () => {
const value = get();
Object.defineProperty(object, property, {
value,
enumerable: true,
configurable: true
});
return value;
},
enumerable: true,
configurable: true
});
};
/** @type {typeof import('color-convert')} */
let colorConvert;
const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
if (colorConvert === undefined) {
colorConvert = require('color-convert');
}
const offset = isBackground ? 10 : 0;
const styles = {};
for (const [sourceSpace, suite] of Object.entries(colorConvert)) {
const name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace;
if (sourceSpace === targetSpace) {
styles[name] = wrap(identity, offset);
} else if (typeof suite === 'object') {
styles[name] = wrap(suite[targetSpace], offset);
}
}
return styles;
};
function assembleStyles() {
const codes = new Map();
const styles = {
modifier: {
reset: [0, 0],
// 21 isn't widely supported and 22 does the same thing
bold: [1, 22],
dim: [2, 22],
italic: [3, 23],
underline: [4, 24],
inverse: [7, 27],
hidden: [8, 28],
strikethrough: [9, 29]
},
color: {
black: [30, 39],
red: [31, 39],
green: [32, 39],
yellow: [33, 39],
blue: [34, 39],
magenta: [35, 39],
cyan: [36, 39],
white: [37, 39],
// Bright color
blackBright: [90, 39],
redBright: [91, 39],
greenBright: [92, 39],
yellowBright: [93, 39],
blueBright: [94, 39],
magentaBright: [95, 39],
cyanBright: [96, 39],
whiteBright: [97, 39]
},
bgColor: {
bgBlack: [40, 49],
bgRed: [41, 49],
bgGreen: [42, 49],
bgYellow: [43, 49],
bgBlue: [44, 49],
bgMagenta: [45, 49],
bgCyan: [46, 49],
bgWhite: [47, 49],
// Bright color
bgBlackBright: [100, 49],
bgRedBright: [101, 49],
bgGreenBright: [102, 49],
bgYellowBright: [103, 49],
bgBlueBright: [104, 49],
bgMagentaBright: [105, 49],
bgCyanBright: [106, 49],
bgWhiteBright: [107, 49]
}
};
// Alias bright black as gray (and grey)
styles.color.gray = styles.color.blackBright;
styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
styles.color.grey = styles.color.blackBright;
styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
for (const [groupName, group] of Object.entries(styles)) {
for (const [styleName, style] of Object.entries(group)) {
styles[styleName] = {
open: `\u001B[${style[0]}m`,
close: `\u001B[${style[1]}m`
};
group[styleName] = styles[styleName];
codes.set(style[0], style[1]);
}
Object.defineProperty(styles, groupName, {
value: group,
enumerable: false
});
}
Object.defineProperty(styles, 'codes', {
value: codes,
enumerable: false
});
styles.color.close = '\u001B[39m';
styles.bgColor.close = '\u001B[49m';
setLazyProperty(styles.color, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false));
setLazyProperty(styles.color, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false));
setLazyProperty(styles.color, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false));
setLazyProperty(styles.bgColor, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true));
setLazyProperty(styles.bgColor, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true));
setLazyProperty(styles.bgColor, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true));
return styles;
}
// Make the export immutable
Object.defineProperty(module, 'exports', {
enumerable: true,
get: assembleStyles
});

9
node_modules/ansi-styles/license generated vendored Normal file
View File

@ -0,0 +1,9 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

56
node_modules/ansi-styles/package.json generated vendored Normal file
View File

@ -0,0 +1,56 @@
{
"name": "ansi-styles",
"version": "4.3.0",
"description": "ANSI escape codes for styling strings in the terminal",
"license": "MIT",
"repository": "chalk/ansi-styles",
"funding": "https://github.com/chalk/ansi-styles?sponsor=1",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=8"
},
"scripts": {
"test": "xo && ava && tsd",
"screenshot": "svg-term --command='node screenshot' --out=screenshot.svg --padding=3 --width=55 --height=3 --at=1000 --no-cursor"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"ansi",
"styles",
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"string",
"tty",
"escape",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"log",
"logging",
"command-line",
"text"
],
"dependencies": {
"color-convert": "^2.0.1"
},
"devDependencies": {
"@types/color-convert": "^1.9.0",
"ava": "^2.3.0",
"svg-term-cli": "^2.1.1",
"tsd": "^0.11.0",
"xo": "^0.25.3"
}
}

152
node_modules/ansi-styles/readme.md generated vendored Normal file
View File

@ -0,0 +1,152 @@
# ansi-styles [![Build Status](https://travis-ci.org/chalk/ansi-styles.svg?branch=master)](https://travis-ci.org/chalk/ansi-styles)
> [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) for styling strings in the terminal
You probably want the higher-level [chalk](https://github.com/chalk/chalk) module for styling your strings.
<img src="screenshot.svg" width="900">
## Install
```
$ npm install ansi-styles
```
## Usage
```js
const style = require('ansi-styles');
console.log(`${style.green.open}Hello world!${style.green.close}`);
// Color conversion between 16/256/truecolor
// NOTE: If conversion goes to 16 colors or 256 colors, the original color
// may be degraded to fit that color palette. This means terminals
// that do not support 16 million colors will best-match the
// original color.
console.log(style.bgColor.ansi.hsl(120, 80, 72) + 'Hello world!' + style.bgColor.close);
console.log(style.color.ansi256.rgb(199, 20, 250) + 'Hello world!' + style.color.close);
console.log(style.color.ansi16m.hex('#abcdef') + 'Hello world!' + style.color.close);
```
## API
Each style has an `open` and `close` property.
## Styles
### Modifiers
- `reset`
- `bold`
- `dim`
- `italic` *(Not widely supported)*
- `underline`
- `inverse`
- `hidden`
- `strikethrough` *(Not widely supported)*
### Colors
- `black`
- `red`
- `green`
- `yellow`
- `blue`
- `magenta`
- `cyan`
- `white`
- `blackBright` (alias: `gray`, `grey`)
- `redBright`
- `greenBright`
- `yellowBright`
- `blueBright`
- `magentaBright`
- `cyanBright`
- `whiteBright`
### Background colors
- `bgBlack`
- `bgRed`
- `bgGreen`
- `bgYellow`
- `bgBlue`
- `bgMagenta`
- `bgCyan`
- `bgWhite`
- `bgBlackBright` (alias: `bgGray`, `bgGrey`)
- `bgRedBright`
- `bgGreenBright`
- `bgYellowBright`
- `bgBlueBright`
- `bgMagentaBright`
- `bgCyanBright`
- `bgWhiteBright`
## Advanced usage
By default, you get a map of styles, but the styles are also available as groups. They are non-enumerable so they don't show up unless you access them explicitly. This makes it easier to expose only a subset in a higher-level module.
- `style.modifier`
- `style.color`
- `style.bgColor`
###### Example
```js
console.log(style.color.green.open);
```
Raw escape codes (i.e. without the CSI escape prefix `\u001B[` and render mode postfix `m`) are available under `style.codes`, which returns a `Map` with the open codes as keys and close codes as values.
###### Example
```js
console.log(style.codes.get(36));
//=> 39
```
## [256 / 16 million (TrueColor) support](https://gist.github.com/XVilka/8346728)
`ansi-styles` uses the [`color-convert`](https://github.com/Qix-/color-convert) package to allow for converting between various colors and ANSI escapes, with support for 256 and 16 million colors.
The following color spaces from `color-convert` are supported:
- `rgb`
- `hex`
- `keyword`
- `hsl`
- `hsv`
- `hwb`
- `ansi`
- `ansi256`
To use these, call the associated conversion function with the intended output, for example:
```js
style.color.ansi.rgb(100, 200, 15); // RGB to 16 color ansi foreground code
style.bgColor.ansi.rgb(100, 200, 15); // RGB to 16 color ansi background code
style.color.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code
style.bgColor.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code
style.color.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color foreground code
style.bgColor.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color background code
```
## Related
- [ansi-escapes](https://github.com/sindresorhus/ansi-escapes) - ANSI escape codes for manipulating the terminal
## Maintainers
- [Sindre Sorhus](https://github.com/sindresorhus)
- [Josh Junon](https://github.com/qix-)
## For enterprise
Available as part of the Tidelift Subscription.
The maintainers of `ansi-styles` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-ansi-styles?utm_source=npm-ansi-styles&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)

6
node_modules/blessed/.npmignore generated vendored Normal file
View File

@ -0,0 +1,6 @@
.git*
test/
img/
node_modules/
.jshintrc
.jscsrc

83
node_modules/blessed/CHANGELOG.md generated vendored Normal file
View File

@ -0,0 +1,83 @@
# Blessed v0.1.0 - new terminal goodies for node.js
![blessed](https://raw.githubusercontent.com/chjj/blessed/master/img/v0.1.0-3.gif)
The features demonstrated in the above gif __element transparency/shadow__ and
__border docking__.
## New useful options for your typewriter application:
- __`transparent` option__ - Lower element opacity to 50%. This will display
dimmed elements and content behind the foreground element using a naive color
blending function (good enough for a terminal's limited amount of colors).
works best with 256color terminals. (see widget-shadow.js)
- __`shadow` option__ - Give the element a translucent shadow. Automatically
darkens the background behind it. (see widget-shadow.js)
- __`dockBorders` option__ - Element borders will automatically "dock" to each
other. Instead of overlapping the borders end up connecting. (see
widget-dock.js)
- __`autoPadding` default__ - Auto padding is now enabled by default, meaning
blessed will automatically position elements inside their parent's border.
- __`rleft` property__ - Relative offsets are now default element properties
(`left` instead of `rleft`).
- __`draggable` property__ - Make any element draggable with the mouse. (see
widget-shadow.js or widget-dock.js)
- __`Table` and `ListTable` elements__ - Tables with a high quality rendering.
(see widget-table.js and widget-listtable.js)
- __`Log` element__ - A top to bottom logger box with scrollback and other
features. (see widget-log.js)
- __Obscurable borders__ - In addition to docking borders, it's possible to
obscure borders by sliding them off the screen with negative offsets. (see
widget-dock.js)
- __Percentage expressions__ - Like CSS, arithmetic can now be performed on
percentages. e.g. `width: '50%-1'`. This is useful for overlapping borders on
elements with a percentage width. (see widget-dock.js)
## Other features that weren't mentioned before:
- __`setHover` option__ - Set a hover text box to follow cursor on mouseover,
similar to how a web browser handles the "title" attribute. (see widget.js)
- __`Terminal` element__ - Spin up a pseudo terminal as a blessed element.
useful for writing a terminal multiplexer. (requires term.js and pty.js as
optional dependencies). (see example/multiplex.js)
- __`Image` element__ - Uses `w3mimgdisplay` to draw real images your terminal.
this is much easier than calling w3mimgdisplay by hand. Image elements behave
like any other element, although it is wise to use `width: 'shrink', height:
'shrink'`. (see widget-image.js)
---
The major things that justified the 0.1.0 release were fixes and stabilization
of api (`autoPadding`/`rleft`/`left`). Scrolling boxes were almost completely
revamped to work a bit smarter.
---
## Things yet to come:
- __@secrettriangle's [improvements](https://github.com/slap-editor/slap) for
textareas__ - This allows for real text navigation.
- __Gravity and margin layouts__
This is something that's been in the idea bin for a while. Every element could
potentially have properties like:
```
gravity: 'bottomleft',
margin: 5,
``
In other words, just a more complex `float` system than what the CSSOM is used
to.

20
node_modules/blessed/LICENSE generated vendored Normal file
View File

@ -0,0 +1,20 @@
Copyright (c) 2013-2015, Christopher Jeffrey and contributors
https://github.com/chjj/
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

2421
node_modules/blessed/README.md generated vendored Normal file

File diff suppressed because it is too large Load Diff

16
node_modules/blessed/bin/tput.js generated vendored Normal file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env node
var blessed = require('../')
, argv = process.argv.slice(2)
, cmd = argv.shift()
, tput;
tput = blessed.tput({
terminal: process.env.TERM,
termcap: !!process.env.USE_TERMCAP,
extended: true
});
if (tput[cmd]) {
process.stdout.write(tput[cmd].apply(tput, argv));
}

7
node_modules/blessed/browser/Makefile generated vendored Normal file
View File

@ -0,0 +1,7 @@
all:
@cd .. && browserify -e index.js -o browser/blessed.js
clean:
@rm -f blessed.js
.PHONY: clean all

105
node_modules/blessed/browser/transform.js generated vendored Normal file
View File

@ -0,0 +1,105 @@
/**
* transform.js - browserify workaround for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
var Transform = require('stream').Transform
, path = require('path')
, fs = require('fs');
/**
* Transformer
*/
function transformer(code) {
var stream = new Transform;
stream._transform = function(chunk, encoding, callback) {
return callback(null, chunk);
};
stream._flush = function(callback) {
if (code) {
stream.push(code);
}
return callback();
};
return stream;
}
/**
* Explicitly require all widgets in widget.js
*/
var widgets = fs.readdirSync(__dirname + '/../lib/widgets');
var requireWidgets = widgets.reduce(function(out, name) {
name = path.basename(name, '.js');
out += '\nrequire(\'./widgets/' + name + '\');';
return out;
}, '');
/**
* Do not make filesystem calls in tput.js for
* terminfo or termcap, just use xterm terminfo/cap.
*/
var infoPath = path.resolve(__dirname, '..', 'usr', 'xterm-256color')
, capPath = path.resolve(__dirname, '..', 'usr', 'xterm.termcap');
var infoPathFake = path.resolve(
path.sep, 'usr', 'share', 'terminfo',
path.basename(infoPath)[0],
path.basename(infoPath)
);
function readMethods() {
Tput._infoBuffer = new Buffer(TERMINFO, 'base64');
Tput.prototype.readTerminfo = function() {
this.terminal = TERMINFO_NAME;
return this.parseTerminfo(Tput._infoBuffer, TERMINFO_PATH);
};
Tput.cpaths = [];
Tput.termcap = TERMCAP;
Tput.prototype._readTermcap = Tput.prototype.readTermcap;
Tput.prototype.readTermcap = function() {
this.terminal = TERMCAP_NAME;
return this._readTermcap(this.terminal);
};
Tput.prototype.detectUnicode = function() {
return true;
};
}
readMethods = readMethods.toString().slice(24, -2)
.replace(/^ /gm, '')
.replace('TERMINFO', JSON.stringify(fs.readFileSync(infoPath, 'base64')))
.replace('TERMINFO_NAME', JSON.stringify(path.basename(infoPath)))
.replace('TERMINFO_PATH', JSON.stringify(infoPathFake))
.replace('TERMCAP', JSON.stringify(fs.readFileSync(capPath, 'utf8')))
.replace('TERMCAP_NAME', JSON.stringify(path.basename(capPath, '.termcap')));
/**
* Helpers
*/
function end(file, offset) {
return file.split(path.sep).slice(-offset).join('/');
}
/**
* Expose
*/
module.exports = function(file) {
if (end(file, 2) === 'lib/widget.js') {
return transformer(requireWidgets);
}
if (end(file, 2) === 'lib/tput.js') {
return transformer(readMethods);
}
return transformer();
};

20
node_modules/blessed/example/ansi-viewer/LICENSE generated vendored Normal file
View File

@ -0,0 +1,20 @@
Copyright (c) 2015, Christopher Jeffrey
https://github.com/chjj/
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

17
node_modules/blessed/example/ansi-viewer/README.md generated vendored Normal file
View File

@ -0,0 +1,17 @@
# ansi-viewer
A terminal app to view ANSI art from http://artscene.textfiles.com/ansi/.
![ansi-viewer](https://raw.githubusercontent.com/chjj/blessed/master/img/ansi-viewer.png)
## Contribution and License Agreement
If you contribute code to this project, you are implicitly allowing your code
to be distributed under the MIT license. You are also implicitly verifying that
all code is your original work. `</legalese>`
## License
Copyright (c) 2015, Christopher Jeffrey. (MIT License)
See LICENSE for more info.

2717
node_modules/blessed/example/ansi-viewer/ansi-art.list generated vendored Normal file

File diff suppressed because it is too large Load Diff

292
node_modules/blessed/example/ansi-viewer/index.js generated vendored Normal file
View File

@ -0,0 +1,292 @@
/**
* ansi-viewer
* ANSI art viewer for node.
* Copyright (c) 2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
var blessed = require('blessed')
, request = require('request')
, singlebyte = require('./singlebyte')
, fs = require('fs');
// $ wget -r -o log --tries=10 'http://artscene.textfiles.com/ansi/'
// $ grep 'http.*\.ans$' log | awk '{ print $3 }' > ansi-art.list
var urls = fs.readFileSync(__dirname + '/ansi-art.list', 'utf8').trim().split('\n');
var map = urls.reduce(function(map, url) {
map[/([^.\/]+\/[^.\/]+)\.ans$/.exec(url)[1]] = url;
return map;
}, {});
var max = Object.keys(map).reduce(function(out, text) {
return Math.max(out, text.length);
}, 0) + 6;
var screen = blessed.screen({
smartCSR: true,
dockBorders: true
});
var art = blessed.terminal({
parent: screen,
left: 0,
top: 0,
height: 60,
// some are 78/80, some are 80/82
width: 82,
border: 'line',
tags: true,
label: ' {bold}{cyan-fg}ANSI Art{/cyan-fg}{/bold} (Drag Me) ',
handler: function() {},
draggable: true
});
var list = blessed.list({
parent: screen,
label: ' {bold}{cyan-fg}Art List{/cyan-fg}{/bold} (Drag Me) ',
tags: true,
draggable: true,
top: 0,
right: 0,
width: max,
height: '50%',
keys: true,
vi: true,
mouse: true,
border: 'line',
scrollbar: {
ch: ' ',
track: {
bg: 'cyan'
},
style: {
inverse: true
}
},
style: {
item: {
hover: {
bg: 'blue'
}
},
selected: {
bg: 'blue',
bold: true
}
},
search: function(callback) {
prompt.input('Search:', '', function(err, value) {
if (err) return;
return callback(null, value);
});
}
});
var status = blessed.box({
parent: screen,
bottom: 0,
right: 0,
height: 1,
width: 'shrink',
style: {
bg: 'blue'
},
content: 'Select your piece of ANSI art (`/` to search).'
});
var loader = blessed.loading({
parent: screen,
top: 'center',
left: 'center',
height: 5,
align: 'center',
width: '50%',
tags: true,
hidden: true,
border: 'line'
});
var msg = blessed.message({
parent: screen,
top: 'center',
left: 'center',
height: 'shrink',
width: '50%',
align: 'center',
tags: true,
hidden: true,
border: 'line'
});
var prompt = blessed.prompt({
parent: screen,
top: 'center',
left: 'center',
height: 'shrink',
width: 'shrink',
keys: true,
vi: true,
mouse: true,
tags: true,
border: 'line',
hidden: true
});
list.setItems(Object.keys(map));
list.on('select', function(el, selected) {
if (list._.rendering) return;
var name = el.getText();
var url = map[name];
status.setContent(url);
list._.rendering = true;
loader.load('Loading...');
request({
uri: url,
encoding: null
}, function(err, res, body) {
list._.rendering = false;
loader.stop();
if (err) {
return msg.error(err.message);
}
if (!body) {
return msg.error('No body.');
}
return cp437ToUtf8(body, function(err, body) {
if (err) {
return msg.error(err.message);
}
if (process.argv[2] === '--debug') {
var filename = name.replace(/\//g, '.') + '.ans';
fs.writeFileSync(__dirname + '/' + filename, body);
}
// Remove text:
body = body.replace('Downloaded From P-80 International Information Systems 304-744-2253', '');
// Remove MCI codes:
body = body.replace(/%[A-Z0-9]{2}/g, '');
// ^A (SOH) seems to need to produce CRLF in some cases??
// body = body.replace(/\x01/g, '\r\n');
// Reset and write the art:
art.term.reset();
art.term.write(body);
art.term.cursorHidden = true;
screen.render();
if (process.argv[2] === '--debug' || process.argv[2] === '--save') {
takeScreenshot(name);
}
});
});
});
list.items.forEach(function(item, i) {
var text = item.getText();
item.setHover(map[text]);
});
list.focus();
list.enterSelected(0);
screen.key('h', function() {
list.toggle();
if (list.visible) list.focus();
});
screen.key('r', function() {
shuffle();
});
screen.key('S-s', function() {
takeScreenshot(list.ritems[list.selected]);
});
screen.key('s', function() {
slideshow();
});
screen.key('q', function() {
return process.exit(0);
});
screen.render();
/**
* Helpers
*/
// https://github.com/chjj/blessed/issues/127
// https://github.com/Mithgol/node-singlebyte
function cp437ToUtf8(buf, callback) {
try {
return callback(null, singlebyte.bufToStr(buf, 'cp437'));
} catch (e) {
return callback(e);
}
}
// Animating ANSI art doesn't work for screenshots.
var ANIMATING = [
'bbs/void3',
'holiday/xmasfwks',
'unsorted/diver',
'unsorted/mash-chp',
'unsorted/ryans47',
'unsorted/xmasfwks'
];
function takeScreenshot(name) {
var filename = name.replace(/\//g, '.') + '.ans.sgr';
var image;
// Animating art hangs terminal during screenshot as of right now.
if (~ANIMATING.indexOf(name)) {
image = blessed.element.prototype.screenshot.call(art,
0 - art.ileft, art.width - art.iright,
0 - art.itop, art.height - art.ibottom);
} else {
image = art.screenshot();
}
fs.writeFileSync(__dirname + '/' + filename, image);
msg.display('Screenshot taken.');
}
function slideshow() {
if (!screen._.slideshow) {
screen._.slideshow = setInterval(function slide() {
if (screen.lockKeys) return;
var i = (list.items.length - 1) * Math.random() | 0;
list.enterSelected(i);
return slide;
}(), 3000);
msg.display('Slideshow started.');
} else {
clearInterval(screen._.slideshow);
delete screen._.slideshow;
msg.display('Slideshow stopped.');
}
}
function shuffle() {
var items = Object.keys(map).sort(function(key) {
return Math.random() > 0.5 ? 1 : -1;
});
list.setItems(items);
screen.render();
msg.display('Shuffled items.');
}

19
node_modules/blessed/example/ansi-viewer/package.json generated vendored Normal file
View File

@ -0,0 +1,19 @@
{
"name": "ansi-viewer",
"description": "ANSI art viewer for node",
"author": "Christopher Jeffrey",
"version": "0.0.1",
"main": "./index.js",
"bin": "./index.js",
"preferGlobal": false,
"repository": "git://github.com/chjj/blessed.git",
"homepage": "https://github.com/chjj/blessed",
"bugs": { "url": "http://github.com/chjj/blessed/issues" },
"keywords": ["ansi", "art"],
"tags": ["ansi", "art"],
"dependencies": {
"blessed": ">=0.1.5",
"term.js": "0.0.4",
"request": "2.55.0"
}
}

406
node_modules/blessed/example/ansi-viewer/singlebyte.js generated vendored Normal file
View File

@ -0,0 +1,406 @@
/**
* node-singlebyte
*/
// The MIT License (MIT)
//
// Copyright (c) 2013, Sergey Sokoloff (aka Mithgol the Webmaster).
// https://github.com/Mithgol/node-singlebyte
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
var extend = function(target) {
target = target || {};
Array.prototype.slice.call(arguments, 1).forEach(function(obj) {
Object.keys(obj || {}).forEach(function(key) {
target[key] = obj[key];
});
});
return target;
};
var singlebyte = function(){
/* jshint indent: false */
if(!( this instanceof singlebyte )){
return new singlebyte();
}
this.encodings = [];
// CP437
this.learnEncoding('cp437', this.extendASCII([
0xC7, 0xFC, 0xE9, 0xE2, 0xE4, 0xE0, 0xE5, 0xE7,
0xEA, 0xEB, 0xE8, 0xEF, 0xEE, 0xEC, 0xC4, 0xC5,
0xC9, 0xE6, 0xC6, 0xF4, 0xF6, 0xF2, 0xFB, 0xF9,
0xFF, 0xD6, 0xDC, 0xA2, 0xA3, 0xA5, 0x20A7, 0x192,
0xE1, 0xED, 0xF3, 0xFA, 0xF1, 0xD1, 0xAA, 0xBA,
0xBF, 0x2310, 0xAC, 0xBD, 0xBC, 0xA1, 0xAB, 0xBB,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
0x3B1, 0x3B2, 0x393, 0x3C0, 0x3A3, 0x3C3, 0x3BC, 0x3C4,
0x3A6, 0x398, 0x3A9, 0x3B4, 0x221E, 0x3C6, 0x3B5, 0x2229,
0x2261, 0xB1, 0x2265, 0x2264, 0x2320, 0x2321, 0xF7, 0x2248,
0xB0, 0x2219, 0xB7, 0x221A, 0x207F, 0xB2, 0x25A0, 0xA0
]));
// CP850
this.learnEncoding('cp850', this.extendASCII([
0xC7, 0xFC, 0xE9, 0xE2, 0xE4, 0xE0, 0xE5, 0xE7,
0xEA, 0xEB, 0xE8, 0xEF, 0xEE, 0xEC, 0xC4, 0xC5,
0xC9, 0xE6, 0xC6, 0xF4, 0xF6, 0xF2, 0xFB, 0xF9,
0xFF, 0xD6, 0xDC, 0xF8, 0xA3, 0xD8, 0xD7, 0x192,
0xE1, 0xED, 0xF3, 0xFA, 0xF1, 0xD1, 0xAA, 0xBA,
0xBF, 0xAE, 0xAC, 0xBD, 0xBC, 0xA1, 0xAB, 0xBB,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0xC1, 0xC2, 0xC0,
0xA9, 0x2563, 0x2551, 0x2557, 0x255D, 0xA2, 0xA5, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0xE3, 0xC3,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0xA4,
0xF0, 0xD0, 0xCA, 0xCB, 0xC8, 0x131, 0xCD, 0xCE,
0xCF, 0x2518, 0x250C, 0x2588, 0x2584, 0xA6, 0xCC, 0x2580,
0xD3, 0xDF, 0xD4, 0xD2, 0xF5, 0xD5, 0xB5, 0xFE,
0xDE, 0xDA, 0xDB, 0xD9, 0xFD, 0xDD, 0xAF, 0xB4,
0xAD, 0xB1, 0x2017, 0xBE, 0xB6, 0xA7, 0xF7, 0xB8,
0xB0, 0xA8, 0xB7, 0xB9, 0xB3, 0xB2, 0x25A0, 0xA0
]));
// CP858
this.learnEncoding('cp858', this.extendASCII([
0xC7, 0xFC, 0xE9, 0xE2, 0xE4, 0xE0, 0xE5, 0xE7,
0xEA, 0xEB, 0xE8, 0xEF, 0xEE, 0xEC, 0xC4, 0xC5,
0xC9, 0xE6, 0xC6, 0xF4, 0xF6, 0xF2, 0xFB, 0xF9,
0xFF, 0xD6, 0xDC, 0xF8, 0xA3, 0xD8, 0xD7, 0x192,
0xE1, 0xED, 0xF3, 0xFA, 0xF1, 0xD1, 0xAA, 0xBA,
0xBF, 0xAE, 0xAC, 0xBD, 0xBC, 0xA1, 0xAB, 0xBB,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0xC1, 0xC2, 0xC0,
0xA9, 0x2563, 0x2551, 0x2557, 0x255D, 0xA2, 0xA5, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0xE3, 0xC3,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0xA4,
0xF0, 0xD0, 0xCA, 0xCB, 0xC8, 0x20AC, 0xCD, 0xCE,
0xCF, 0x2518, 0x250C, 0x2588, 0x2584, 0xA6, 0xCC, 0x2580,
0xD3, 0xDF, 0xD4, 0xD2, 0xF5, 0xD5, 0xB5, 0xFE,
0xDE, 0xDA, 0xDB, 0xD9, 0xFD, 0xDD, 0xAF, 0xB4,
0xAD, 0xB1, 0x2017, 0xBE, 0xB6, 0xA7, 0xF7, 0xB8,
0xB0, 0xA8, 0xB7, 0xB9, 0xB3, 0xB2, 0x25A0, 0xA0
]));
// CP808
this.learnEncoding('cp808', this.extendASCII([
0x410, 0x411, 0x412, 0x413, 0x414, 0x415, 0x416, 0x417,
0x418, 0x419, 0x41A, 0x41B, 0x41C, 0x41D, 0x41E, 0x41F,
0x420, 0x421, 0x422, 0x423, 0x424, 0x425, 0x426, 0x427,
0x428, 0x429, 0x42A, 0x42B, 0x42C, 0x42D, 0x42E, 0x42F,
0x430, 0x431, 0x432, 0x433, 0x434, 0x435, 0x436, 0x437,
0x438, 0x439, 0x43A, 0x43B, 0x43C, 0x43D, 0x43E, 0x43F,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
0x440, 0x441, 0x442, 0x443, 0x444, 0x445, 0x446, 0x447,
0x448, 0x449, 0x44A, 0x44B, 0x44C, 0x44D, 0x44E, 0x44F,
0x401, 0x451, 0x404, 0x454, 0x407, 0x457, 0x40E, 0x45E,
0xB0, 0x2219, 0xB7, 0x221A, 0x2116, 0x20AC, 0x25A0, 0xA0
]));
// CP866
this.learnEncoding('cp866', this.extendASCII([
0x410, 0x411, 0x412, 0x413, 0x414, 0x415, 0x416, 0x417,
0x418, 0x419, 0x41A, 0x41B, 0x41C, 0x41D, 0x41E, 0x41F,
0x420, 0x421, 0x422, 0x423, 0x424, 0x425, 0x426, 0x427,
0x428, 0x429, 0x42A, 0x42B, 0x42C, 0x42D, 0x42E, 0x42F,
0x430, 0x431, 0x432, 0x433, 0x434, 0x435, 0x436, 0x437,
0x438, 0x439, 0x43A, 0x43B, 0x43C, 0x43D, 0x43E, 0x43F,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
0x440, 0x441, 0x442, 0x443, 0x444, 0x445, 0x446, 0x447,
0x448, 0x449, 0x44A, 0x44B, 0x44C, 0x44D, 0x44E, 0x44F,
0x401, 0x451, 0x404, 0x454, 0x407, 0x457, 0x40E, 0x45E,
0xB0, 0x2219, 0xB7, 0x221A, 0x2116, 0xA4, 0x25A0, 0xA0
]));
// CP1125
this.learnEncoding('cp1125', this.extendASCII([
0x410, 0x411, 0x412, 0x413, 0x414, 0x415, 0x416, 0x417,
0x418, 0x419, 0x41A, 0x41B, 0x41C, 0x41D, 0x41E, 0x41F,
0x420, 0x421, 0x422, 0x423, 0x424, 0x425, 0x426, 0x427,
0x428, 0x429, 0x42A, 0x42B, 0x42C, 0x42D, 0x42E, 0x42F,
0x430, 0x431, 0x432, 0x433, 0x434, 0x435, 0x436, 0x437,
0x438, 0x439, 0x43A, 0x43B, 0x43C, 0x43D, 0x43E, 0x43F,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
0x440, 0x441, 0x442, 0x443, 0x444, 0x445, 0x446, 0x447,
0x448, 0x449, 0x44A, 0x44B, 0x44C, 0x44D, 0x44E, 0x44F,
0x401, 0x451, 0x490, 0x491, 0x404, 0x454, 0x406, 0x456,
0x407, 0x457, 0xB7, 0x221A, 0x2116, 0xA4, 0x25A0, 0xA0
]));
// KOI8-R
this.learnEncoding('koi8-r', this.extendASCII([
0x2500, 0x2502, 0x250C, 0x2510, 0x2514, 0x2518, 0x251C, 0x2524,
0x252C, 0x2534, 0x253C, 0x2580, 0x2584, 0x2588, 0x258C, 0x2590,
0x2591, 0x2592, 0x2593, 0x2320, 0x25A0, 0x2219, 0x221A, 0x2248,
0x2264, 0x2265, 0xA0, 0x2321, 0xB0, 0xB2, 0xB7, 0xF7,
0x2550, 0x2551, 0x2552, 0x451, 0x2553, 0x2554, 0x2555, 0x2556,
0x2557, 0x2558, 0x2559, 0x255A, 0x255B, 0x255C, 0x255D, 0x255E,
0x255F, 0x2560, 0x2561, 0x401, 0x2562, 0x2563, 0x2564, 0x2565,
0x2566, 0x2567, 0x2568, 0x2569, 0x256A, 0x256B, 0x256C, 0xA9,
0x44E, 0x430, 0x431, 0x446, 0x434, 0x435, 0x444, 0x433,
0x445, 0x438, 0x439, 0x43A, 0x43B, 0x43C, 0x43D, 0x043E,
0x43F, 0x44F, 0x440, 0x441, 0x442, 0x443, 0x436, 0x432,
0x44C, 0x44B, 0x437, 0x448, 0x44D, 0x449, 0x447, 0x44A,
0x42E, 0x410, 0x411, 0x426, 0x414, 0x415, 0x424, 0x413,
0x425, 0x418, 0x419, 0x41A, 0x41B, 0x41C, 0x41D, 0x41E,
0x41F, 0x42F, 0x420, 0x421, 0x422, 0x423, 0x416, 0x412,
0x42C, 0x42B, 0x417, 0x428, 0x42D, 0x429, 0x427, 0x42A
]));
// KOI8-U
this.learnEncoding('koi8-u', this.extendASCII([
0x2500, 0x2502, 0x250C, 0x2510, 0x2514, 0x2518, 0x251C, 0x2524,
0x252C, 0x2534, 0x253C, 0x2580, 0x2584, 0x2588, 0x258C, 0x2590,
0x2591, 0x2592, 0x2593, 0x2320, 0x25A0, 0x2219, 0x221A, 0x2248,
0x2264, 0x2265, 0xA0, 0x2321, 0xB0, 0xB2, 0xB7, 0xF7,
0x2550, 0x2551, 0x2552, 0x451, 0x454, 0x2554, 0x456, 0x457,
0x2557, 0x2558, 0x2559, 0x255A, 0x255B, 0x491, 0x255D, 0x255E,
0x255F, 0x2560, 0x2561, 0x401, 0x404, 0x2563, 0x406, 0x407,
0x2566, 0x2567, 0x2568, 0x2569, 0x256A, 0x490, 0x256C, 0xA9,
0x44E, 0x430, 0x431, 0x446, 0x434, 0x435, 0x444, 0x433,
0x445, 0x438, 0x439, 0x43A, 0x43B, 0x43C, 0x43D, 0x043E,
0x43F, 0x44F, 0x440, 0x441, 0x442, 0x443, 0x436, 0x432,
0x44C, 0x44B, 0x437, 0x448, 0x44D, 0x449, 0x447, 0x44A,
0x42E, 0x410, 0x411, 0x426, 0x414, 0x415, 0x424, 0x413,
0x425, 0x418, 0x419, 0x41A, 0x41B, 0x41C, 0x41D, 0x41E,
0x41F, 0x42F, 0x420, 0x421, 0x422, 0x423, 0x416, 0x412,
0x42C, 0x42B, 0x417, 0x428, 0x42D, 0x429, 0x427, 0x42A
]));
// KOI8-RU
this.learnEncoding('koi8-ru', this.extendASCII([
0x2500, 0x2502, 0x250C, 0x2510, 0x2514, 0x2518, 0x251C, 0x2524,
0x252C, 0x2534, 0x253C, 0x2580, 0x2584, 0x2588, 0x258C, 0x2590,
0x2591, 0x2592, 0x2593, 0x2320, 0x25A0, 0x2219, 0x221A, 0x2248,
0x2264, 0x2265, 0xA0, 0x2321, 0xB0, 0xB2, 0xB7, 0xF7,
0x2550, 0x2551, 0x2552, 0x451, 0x454, 0x2554, 0x456, 0x457,
0x2557, 0x2558, 0x2559, 0x255A, 0x255B, 0x491, 0x45E, 0x255E,
0x255F, 0x2560, 0x2561, 0x401, 0x404, 0x2563, 0x406, 0x407,
0x2566, 0x2567, 0x2568, 0x2569, 0x256A, 0x490, 0x40E, 0xA9,
0x44E, 0x430, 0x431, 0x446, 0x434, 0x435, 0x444, 0x433,
0x445, 0x438, 0x439, 0x43A, 0x43B, 0x43C, 0x43D, 0x043E,
0x43F, 0x44F, 0x440, 0x441, 0x442, 0x443, 0x436, 0x432,
0x44C, 0x44B, 0x437, 0x448, 0x44D, 0x449, 0x447, 0x44A,
0x42E, 0x410, 0x411, 0x426, 0x414, 0x415, 0x424, 0x413,
0x425, 0x418, 0x419, 0x41A, 0x41B, 0x41C, 0x41D, 0x41E,
0x41F, 0x42F, 0x420, 0x421, 0x422, 0x423, 0x416, 0x412,
0x42C, 0x42B, 0x417, 0x428, 0x42D, 0x429, 0x427, 0x42A
]));
// LATIN-1 aka ISO 8859-1 (Western European)
this.learnEncoding('latin-1', this.extendASCII([
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F,
0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7,
0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7,
0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7,
0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF
]));
// Windows-1252
this.learnEncoding('cp1252', this.extendASCII([
0x20AC, 0x81, 0x201A, 0x192, 0x201E, 0x2026, 0x2020, 0x2021,
0x2C6, 0x2030, 0x160, 0x2039, 0x152, 0x8D, 0x017D, 0x8F,
0x90, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
0x02DC, 0x2122, 0x161, 0x203A, 0x0153, 0x9D, 0x17E, 0x178,
0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7,
0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7,
0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7,
0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF
]));
};
singlebyte.prototype.isEncoding = function(encodingName){
if( Buffer.isEncoding(encodingName) ) return true;
for( var i = 0; i < this.encodings.length; i++ ){
if( this.encodings[i].name === encodingName ) return true;
}
return false;
};
singlebyte.prototype.learnEncoding = function(encodingName, encodingTable){
/*jshint bitwise: false */
if( Buffer.isEncoding(encodingName) ){
throw new Error(this.errors.BUFFER_ENCODING);
}
if( encodingTable.length !== 256 ){
throw new Error(this.errors.INVALID_TABLE_LENGTH);
}
var _this = this;
encodingTable = encodingTable.map(function(item){
var nextCode = item |0;
if( 0 > nextCode || nextCode > 0x10FFFF ){
throw new Error(_this.errors.OUT_OF_UNICODE);
}
return item;
});
if( this.isEncoding(encodingName) ){
for( var i = 0; i < this.encodings.length; i++ ){
if( this.encodings[i].name === encodingName ){
this.encodings[i].table = encodingTable;
return;
}
}
} else {
this.encodings.push({
name: encodingName,
table: encodingTable
});
}
};
singlebyte.prototype.getEncodingTable = function(encodingName){
for( var i = 0; i < this.encodings.length; i++ ){
if( this.encodings[i].name === encodingName ){
return this.encodings[i].table;
}
}
return null;
};
singlebyte.prototype.extendASCII = function(extensionTable){
if( extensionTable.length !== 128 ){
throw new Error(this.errors.INVALID_EXTENSION);
}
var output = [];
for( var i = 0; i < 128; i++ ) output.push(i);
return output.concat(extensionTable);
};
singlebyte.prototype.bufToStr = function(buf, encoding, start, end){
/* jshint bitwise: false */
if(!( Buffer.isBuffer(buf) )){
throw new Error(this.errors.NOT_A_BUFFER);
}
if( Buffer.isEncoding(encoding) ){
return buf.toString(encoding, start, end);
}
var table = this.getEncodingTable(encoding);
if( table === null ) throw new Error(this.errors.UNKNOWN_ENCODING);
if( typeof end === 'undefined' ) end = buf.length;
if( typeof start === 'undefined' ) start = 0;
var output = '';
var sourceValue;
for( var i = start; i < end; i++ ){
sourceValue = table[ buf[i] ];
if( sourceValue <= 0xFFFF ){
output += String.fromCharCode(sourceValue);
} else if( 0x10000 <= sourceValue && sourceValue <= 0x10FFFF ){
sourceValue -= 0x10000;
output += String.fromCharCode( 0xD800 + (sourceValue >> 10) );
output += String.fromCharCode( 0xDC00 + (sourceValue & 0x3FF) );
} else throw new Error(this.errors.OUT_OF_UNICODE);
}
return output;
};
var strToBufDefaults = {
defaultCode: 0x3F // '?'
};
singlebyte.prototype.strToBuf = function(str, encoding, encodingOptions){
if( Buffer.isEncoding(encoding) ){
return new Buffer(str, encoding);
}
str = '' + str;
var options = extend({}, strToBufDefaults, encodingOptions);
var table = this.getEncodingTable(encoding);
if( table === null ) throw new Error(this.errors.UNKNOWN_ENCODING);
var output = [];
for( var i = 0; i < str.length; i++ ){
var charUnicode;
var thisCharCode = str.charCodeAt(i);
if( 0xD800 <= thisCharCode && thisCharCode <= 0xDBFF &&
i+1 < str.length
){
var nextCharCode = str.charCodeAt(i+1);
if( 0xDC00 <= nextCharCode && nextCharCode <= 0xDFFF ){
charUnicode = 0x10000 + (thisCharCode - 0xD800)*0x400 +
(nextCharCode - 0xDC00);
i++;
} else {
charUnicode = thisCharCode;
}
} else {
charUnicode = thisCharCode;
}
var codeFoundIndex = table.indexOf(charUnicode);
if( codeFoundIndex < 0 ){
output.push(options.defaultCode);
} else {
output.push(codeFoundIndex);
}
}
return new Buffer(output);
};
singlebyte.prototype.errors = {
NOT_A_BUFFER : 'The given source is not a buffer!',
UNKNOWN_ENCODING : 'The given encoding is not defined!',
INVALID_TABLE_LENGTH : 'The encoding table must have 256 elements!',
INVALID_EXTENSION : 'The ASCII extension table must have 128 elements!',
BUFFER_ENCODING : "Cannot redefine a Node's encoding!",
OUT_OF_UNICODE : "An encoding table's element is greater than 0x10FFFF!"
};
module.exports = singlebyte();

139
node_modules/blessed/example/blessed-telnet.js generated vendored Normal file
View File

@ -0,0 +1,139 @@
#!/usr/bin/env node
/**
* blessed-telnet.js
* https://github.com/chjj/blessed
* Copyright (c) 2013-2015, Christopher Jeffrey (MIT License)
* A blessed telnet server.
* See: https://github.com/TooTallNate/node-telnet
*/
process.title = 'blessed-telnet';
var fs = require('fs');
var path = require('path');
var blessed = require('blessed');
var telnet = require('telnet');
var server = telnet.createServer(function(client) {
client.do.transmit_binary();
client.do.terminal_type();
client.do.window_size();
client.do.environment_variables();
client.on('debug', function(msg) {
console.error(msg);
});
client.on('environment variables', function(data) {
if (data.command === 'sb') {
if (data.name === 'TERM') {
screen.terminal = data.value;
} else {
// Clear the screen since they may have used `env send [var]`.
screen.realloc();
}
screen.render();
}
});
client.on('terminal type', function(data) {
if (data.command === 'sb' && data.name) {
screen.terminal = data.name;
screen.render();
}
});
client.on('window size', function(data) {
if (data.command === 'sb') {
client.columns = data.columns;
client.rows = data.rows;
client.emit('resize');
}
});
// Make the client look like a tty:
client.setRawMode = function(mode) {
client.isRaw = mode;
if (!client.writable) return;
if (mode) {
client.do.suppress_go_ahead();
client.will.suppress_go_ahead();
client.will.echo();
} else {
client.dont.suppress_go_ahead();
client.wont.suppress_go_ahead();
client.wont.echo();
}
};
client.isTTY = true;
client.isRaw = false;
client.columns = 80;
client.rows = 24;
var screen = blessed.screen({
smartCSR: true,
input: client,
output: client,
terminal: 'xterm-256color',
fullUnicode: true
});
client.on('close', function() {
if (!screen.destroyed) {
screen.destroy();
}
});
screen.on('destroy', function() {
if (client.writable) {
client.destroy();
}
});
if (test === 'widget-simple') {
return simpleTest(screen);
}
loadTest(screen, test);
});
function simpleTest(screen) {
screen.data.main = blessed.box({
parent: screen,
width: '80%',
height: '90%',
border: 'line',
content: 'Welcome to my server. Here is your own private session.',
style: {
bg: 'red'
}
});
screen.key('i', function() {
screen.data.main.style.bg = 'blue';
screen.render();
});
screen.key(['C-c', 'q'], function(ch, key) {
screen.destroy();
});
screen.render();
}
var test = process.argv[2] || path.resolve(__dirname, '../test/widget-shadow.js');
if (~test.indexOf('widget-png.js')) process.argv.length = 2;
test = path.resolve(process.cwd(), test);
function loadTest(screen, name) {
var Screen = blessed.screen;
blessed.screen = function() { return screen; };
var path = require.resolve(name);
delete require.cache[path];
require(name);
blessed.screen = Screen;
}
server.listen(2300);
console.log('Listening on 2300...');

77
node_modules/blessed/example/index.js generated vendored Normal file
View File

@ -0,0 +1,77 @@
/**
* Example Program for Blessed
* Copyright (c) 2013, Christopher Jeffrey (MIT License).
* https://github.com/chjj/blessed
*/
var blessed = require('../')
, program = blessed.program();
process.title = 'blessed';
program.on('keypress', function(ch, key) {
if (key.name === 'q') {
program.clear();
program.disableMouse();
program.showCursor();
program.normalBuffer();
process.exit(0);
}
});
program.on('mouse', function(data) {
if (data.action === 'mouseup') return;
program.move(1, program.rows);
program.eraseInLine('right');
if (data.action === 'wheelup') {
program.write('Mouse wheel up at: ' + data.x + ', ' + data.y);
} else if (data.action === 'wheeldown') {
program.write('Mouse wheel down at: ' + data.x + ', ' + data.y);
} else if (data.action === 'mousedown' && data.button === 'left') {
program.write('Left button down at: ' + data.x + ', ' + data.y);
} else if (data.action === 'mousedown' && data.button === 'right') {
program.write('Right button down at: ' + data.x + ', ' + data.y);
} else {
program.write('Mouse at: ' + data.x + ', ' + data.y);
}
program.move(data.x, data.y);
program.bg('red');
program.write(' ');
program.bg('!red');
});
program.on('focus', function() {
program.move(1, program.rows);
program.write('Gained focus.');
});
program.on('blur', function() {
program.move(1, program.rows);
program.write('Lost focus.');
});
program.alternateBuffer();
program.enableMouse();
program.hideCursor();
program.clear();
program.move(1, 1);
program.bg('black');
program.write('Hello world', 'blue fg');
program.setx((program.cols / 2 | 0) - 4);
program.down(5);
program.write('Hi again!');
program.bg('!black');
program.feed();
program.getCursor(function(err, data) {
if (!err) {
program.write('Cursor is at: ' + data.x + ', ' + data.y + '.');
program.feed();
}
program.charset('SCLD');
program.write('abcdefghijklmnopqrstuvwxyz0123456789');
program.charset('US');
program.setx(1);
});

142
node_modules/blessed/example/multiplex.js generated vendored Normal file
View File

@ -0,0 +1,142 @@
#!/usr/bin/env node
/**
* multiplex.js
* https://github.com/chjj/blessed
* Copyright (c) 2013-2015, Christopher Jeffrey (MIT License)
* A terminal multiplexer created by blessed.
*/
process.title = 'multiplex.js';
var blessed = require('blessed')
, screen;
screen = blessed.screen({
smartCSR: true,
log: process.env.HOME + '/blessed-terminal.log',
fullUnicode: true,
dockBorders: true,
ignoreDockContrast: true
});
var topleft = blessed.terminal({
parent: screen,
cursor: 'line',
cursorBlink: true,
screenKeys: false,
label: ' multiplex.js ',
left: 0,
top: 0,
width: '50%',
height: '50%',
border: 'line',
style: {
fg: 'default',
bg: 'default',
focus: {
border: {
fg: 'green'
}
}
}
});
topleft.pty.on('data', function(data) {
screen.log(JSON.stringify(data));
});
var topright = blessed.terminal({
parent: screen,
cursor: 'block',
cursorBlink: true,
screenKeys: false,
label: ' multiplex.js ',
left: '50%-1',
top: 0,
width: '50%+1',
height: '50%',
border: 'line',
style: {
fg: 'red',
bg: 'black',
focus: {
border: {
fg: 'green'
}
}
}
});
var bottomleft = blessed.terminal({
parent: screen,
cursor: 'block',
cursorBlink: true,
screenKeys: false,
label: ' multiplex.js ',
left: 0,
top: '50%-1',
width: '50%',
height: '50%+1',
border: 'line',
style: {
fg: 'default',
bg: 'default',
focus: {
border: {
fg: 'green'
}
}
}
});
var bottomright = blessed.terminal({
parent: screen,
cursor: 'block',
cursorBlink: true,
screenKeys: false,
label: ' multiplex.js ',
left: '50%-1',
top: '50%-1',
width: '50%+1',
height: '50%+1',
border: 'line',
style: {
fg: 'default',
bg: 'default',
focus: {
border: {
fg: 'green'
}
}
}
});
[topleft, topright, bottomleft, bottomright].forEach(function(term) {
term.enableDrag(function(mouse) {
return !!mouse.ctrl;
});
term.on('title', function(title) {
screen.title = title;
term.setLabel(' ' + title + ' ');
screen.render();
});
term.on('click', term.focus.bind(term));
});
topleft.focus();
screen.key('C-q', function() {
topleft.kill();
topright.kill();
bottomleft.kill();
bottomright.kill();
return screen.destroy();
});
screen.program.key('S-tab', function() {
screen.focusNext();
screen.render();
});
screen.render();

448
node_modules/blessed/example/ping generated vendored Normal file
View File

@ -0,0 +1,448 @@
#!/usr/bin/env node
/**
* ping
* https://github.com/chjj/blessed
* Copyright (c) 2013, Christopher Jeffrey (MIT License)
* Online (ping)pong in your terminal.
*/
// Example Usage:
// Server: $ ./example/ping 3000
// Client: $ ./example/ping 127.0.0.1 3000
// Demo: $ ./example/ping
process.title = 'ping';
if (/^(-h|--help|-\?)$/.test(process.argv[2])) {
console.log('node-ping');
console.log('Example Usage:');
console.log('Server: $ node-ping 3000');
console.log('Client: $ node-ping 127.0.0.1 3000');
console.log('Demo: $ node-ping');
return process.exit(0);
}
var blessed = require('blessed')
, nssocket;
try {
nssocket = require('nssocket');
} catch (e) {
;
}
var server
, socket;
/**
* Screen Layout
*/
var screen = blessed.screen();
var table = blessed.box({
left: 0,
top: 0,
width: screen.width,
height: screen.height
});
var ball = blessed.box({
width: 1,
height: 1,
bg: 'white',
top: 0,
left: 0
});
var lpaddle = blessed.box({
width: 1,
height: 3,
bg: 'yellow',
top: 0,
left: 0
});
var rpaddle = blessed.box({
width: 1,
height: 3,
bg: 'yellow',
top: 0,
right: 0
});
var score = blessed.box({
top: 0,
left: 4,
height: 3,
width: 'shrink',
border: {
type: 'line'
},
//align: 'center',
style: {
bold: true
},
tags: true
});
score.lwins = 0;
score.rwins = 0;
var net = blessed.box({
width: 1,
height: '100%',
bg: 'yellow',
top: 0,
left: 'center'
});
var message = blessed.box({
width: '50%',
height: 3,
border: {
type: 'line'
},
top: 'center',
left: 'center'
});
var text = blessed.box({
top: 'center',
left: 1,
right: 1,
height: 1,
align: 'center',
content: 'Waiting for players to connect...'
});
message.append(text);
screen.append(table);
table.append(score);
table.append(lpaddle);
table.append(rpaddle);
table.append(net);
table.append(ball);
table.append(message);
screen.on('resize', function() {
table.width = screen.width;
table.height = screen.height;
[ball, lpaddle, rpaddle].forEach(function(el) {
if (el.rbottom < 0) el.rtop = table.height - 1 - el.height;
if (el.rright < 0) el.rleft = table.width - 1;
});
screen.render();
sync();
});
/**
* Options
*/
ball.speed = 2;
ball.unpredictable = true;
lpaddle.speed = 2;
rpaddle.speed = 2;
/**
* Game
*/
function sync() {
if (!socket) return;
socket.send(['update'], {
table: { width: table.width, height: table.height },
lpaddle: { rleft: lpaddle.rleft, rtop: lpaddle.rtop, speed: lpaddle.speed },
rpaddle: { rleft: rpaddle.rleft, rtop: rpaddle.rtop, speed: rpaddle.speed },
score: { lwins: score.lwins, rwins: score.rwins }
});
}
function reset() {
text.setContent('Waiting for players to connect...');
message.hide();
ball.moving = true;
ball.direction = 'right';
ball.angle = 'down';
ball.rtop = 1;
ball.rleft = 1;
if ((score.lwins + score.rwins) % 2 !== 0) {
ball.direction = 'left';
ball.rleft = table.width - 1;
}
lpaddle.rtop = 0;
rpaddle.rtop = 0;
score.setContent('{green-fg}Score:{/} ' + score.lwins + ' | ' + score.rwins);
rpaddle.movable = true;
screen.render();
if (server && socket) {
socket.send(['reset']);
}
}
function rand(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function startGame() {
reset();
if (startGame._bound) return;
startGame._bound = true;
screen.on('keypress', function(ch, key) {
if (!ball.moving) return;
if (key.name === 'up' || key.name === 'k') {
if (socket) socket.send(['up']);
if (lpaddle.rtop > 0) lpaddle.rtop -= lpaddle.speed;
if (!socket) if (rpaddle.rtop > 0) rpaddle.rtop -= rpaddle.speed;
if (lpaddle.rtop < 0) lpaddle.rtop = 0;
if (rpaddle.rtop < 0) rpaddle.rtop = 0;
screen.render();
} else if (key.name === 'down' || key.name === 'j') {
if (socket) socket.send(['down']);
if (lpaddle.rbottom > 0) lpaddle.rtop += lpaddle.speed;
if (!socket) if (rpaddle.rbottom > 0) rpaddle.rtop += rpaddle.speed;
if (lpaddle.rbottom < 0) lpaddle.rtop = table.height - lpaddle.height - 1;
if (rpaddle.rbottom < 0) rpaddle.rtop = table.height - rpaddle.height - 1;
screen.render();
}
});
setInterval(function() {
if (!ball.moving) return;
if (ball.direction === 'right') {
if (ball.rright > 1) {
ball.rleft += ball.speed;
} else {
if (ball.rtop >= rpaddle.rtop && ball.rtop <= rpaddle.rtop + rpaddle.height) {
ball.direction = 'left';
ball.rleft -= ball.speed;
ball.rleft -= rand(0, 3);
if (ball.angle === 'down') ball.rtop += rand(0, 3);
else if (ball.angle === 'up') ball.rtop -= rand(0, 3);
} else {
// Right loses
score.lwins++;
ball.rleft = table.width - 1;
if (socket) socket.send(['lose']);
ball.moving = false;
text.setContent('Right player loses!');
message.show();
setTimeout(reset, 3000);
screen.render();
return;
}
}
if (ball.rright < 1) ball.rleft = table.width - 2;
} else if (ball.direction === 'left') {
if (ball.rleft > 1) {
ball.rleft -= ball.speed;
} else {
if (ball.rtop >= lpaddle.rtop && ball.rtop <= lpaddle.rtop + lpaddle.height) {
ball.direction = 'right';
ball.rleft += ball.speed;
ball.rleft += rand(0, 3);
if (ball.angle === 'down') ball.rtop += rand(0, 3);
else if (ball.angle === 'up') ball.rtop -= rand(0, 3);
} else {
// Left loses
score.rwins++;
ball.rleft = 0;
if (socket) socket.send(['win']);
ball.moving = false;
text.setContent('Left player loses!');
message.show();
setTimeout(reset, 3000);
screen.render();
return;
}
}
if (ball.rleft < 1) ball.rleft = 1;
}
if (ball.angle === 'down') {
if (ball.rbottom > 0) {
ball.rtop++;
if (ball.unpredictable) ball.rtop += rand(0, 3);
} else {
ball.angle = 'up';
ball.rtop--;
}
} else if (ball.angle === 'up') {
if (ball.rtop > 0) {
ball.rtop--;
if (ball.unpredictable) ball.rtop -= rand(0, 3);
} else {
ball.angle = 'down';
ball.rtop++;
}
}
if (ball.rtop < 0) ball.rtop = 0;
if (ball.rbottom < 0) ball.rtop = table.height - 1;
if (socket) socket.send(['ball'], { rleft: ball.rleft, rtop: ball.rtop });
screen.render();
}, 100);
}
function startServer() {
server = nssocket.createServer({}, function(socket_) {
socket = socket_;
sync();
socket.data(['up'], function() {
if (!ball.moving) return;
if (rpaddle.rtop > 0) rpaddle.rtop -= rpaddle.speed;
screen.render();
});
socket.data(['down'], function() {
if (!ball.moving) return;
if (rpaddle.rtop < table.height - 1) rpaddle.rtop += rpaddle.speed;
screen.render();
});
socket.on('error', function() {
socket = null;
reset();
ball.moving = false;
message.show();
screen.render();
});
startGame();
});
server.listen(+process.argv[2]);
}
function startClient() {
var socket = new nssocket.NsSocket({
reconnect: true,
maxRetries: Infinity,
retryInterval: 5000
});
socket.connect(+process.argv[3], process.argv[2]);
screen.on('keypress', function(ch, key) {
if (!rpaddle.movable) return;
if (key.name === 'up' || key.name === 'k') {
socket.send(['up']);
if (rpaddle.rtop > 0) rpaddle.rtop -= rpaddle.speed;
if (rpaddle.rtop < 0) rpaddle.rtop = 0;
screen.render();
} else if (key.name === 'down' || key.name === 'j') {
socket.send(['down']);
if (rpaddle.rbottom > 0) rpaddle.rtop += rpaddle.speed;
if (rpaddle.rbottom < 0) rpaddle.rtop = table.height - rpaddle.height - 1;
screen.render();
}
});
socket.data(['up'], function() {
if (lpaddle.rtop > 0) lpaddle.rtop -= lpaddle.speed;
screen.render();
});
socket.data(['down'], function() {
if (lpaddle.rtop < table.height - 1) lpaddle.rtop += lpaddle.speed;
screen.render();
});
socket.data(['ball'], function(data) {
ball.rleft = data.rleft;
ball.rtop = data.rtop;
screen.render();
});
socket.data(['update'], function(data) {
if (data.lpaddle) {
lpaddle.rleft = data.lpaddle.rleft;
lpaddle.rtop = data.lpaddle.rtop;
lpaddle.speed = data.lpaddle.speed;
}
if (data.rpaddle) {
rpaddle.rleft = data.rpaddle.rleft;
rpaddle.rtop = data.rpaddle.rtop;
rpaddle.speed = data.rpaddle.speed;
}
if (data.ball) {
ball.moving = data.ball.moving;
ball.rleft = data.ball.rleft;
ball.rtop = data.ball.rtop;
}
if (data.table) {
table.height = data.table.height;
table.width = data.table.width;
}
if (data.score) {
score.lwins = data.score.lwins;
score.rwins = data.score.rwins;
}
screen.render();
});
socket.data(['win'], function() {
rpaddle.movable = false;
score.rwins++;
text.setContent('Left player loses!');
message.show();
screen.render();
});
socket.data(['lose'], function() {
rpaddle.movable = false;
score.lwins++;
text.setContent('Right player loses!');
message.show();
screen.render();
});
socket.data(['reset'], reset);
reset();
}
/**
* Main
*/
function main() {
screen.on('keypress', function(ch, key) {
if (key.name === 'q' || key.name === 'escape') {
return process.exit(0);
}
});
screen.render();
// Demo Mode / Single Player
if (!nssocket || !process.argv[2]) return startGame();
// Server Mode
if (!process.argv[3]) return startServer();
// Client Mode
if (process.argv[2] && process.argv[3]) return startClient();
}
/**
* Execute
*/
main();

87
node_modules/blessed/example/simple-form.js generated vendored Normal file
View File

@ -0,0 +1,87 @@
var blessed = require('blessed')
, screen = blessed.screen();
var form = blessed.form({
parent: screen,
keys: true,
left: 0,
top: 0,
width: 30,
height: 4,
bg: 'green',
content: 'Submit or cancel?'
});
var submit = blessed.button({
parent: form,
mouse: true,
keys: true,
shrink: true,
padding: {
left: 1,
right: 1
},
left: 10,
top: 2,
shrink: true,
name: 'submit',
content: 'submit',
style: {
bg: 'blue',
focus: {
bg: 'red'
},
hover: {
bg: 'red'
}
}
});
var cancel = blessed.button({
parent: form,
mouse: true,
keys: true,
shrink: true,
padding: {
left: 1,
right: 1
},
left: 20,
top: 2,
shrink: true,
name: 'cancel',
content: 'cancel',
style: {
bg: 'blue',
focus: {
bg: 'red'
},
hover: {
bg: 'red'
}
}
});
submit.on('press', function() {
form.submit();
});
cancel.on('press', function() {
form.reset();
});
form.on('submit', function(data) {
form.setContent('Submitted.');
screen.render();
});
form.on('reset', function(data) {
form.setContent('Canceled.');
screen.render();
});
screen.key('q', function() {
process.exit(0);
});
screen.render();

1052
node_modules/blessed/example/time.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

55
node_modules/blessed/example/widget.js generated vendored Normal file
View File

@ -0,0 +1,55 @@
var blessed = require('../');
// Create a screen object.
var screen = blessed.screen();
// Create a box perfectly centered horizontally and vertically.
var box = blessed.box({
top: 'center',
left: 'center',
width: '50%',
height: '50%',
content: 'Hello {bold}world{/bold}!',
tags: true,
border: {
type: 'line'
},
style: {
fg: 'white',
bg: 'magenta',
border: {
fg: '#ffffff'
},
hover: {
bg: 'green'
}
}
});
// Append our box to the screen.
screen.append(box);
// If our box is clicked, change the content.
box.on('click', function(data) {
box.setContent('{center}Some different {red-fg}content{/red-fg}.{/center}');
screen.render();
});
// If box is focused, handle `enter` and give us some more content.
box.key('enter', function() {
box.setContent('{right}Even different {black-fg}content{/black-fg}.{/right}\n');
box.setLine(1, 'bar');
box.insertLine(1, 'foo');
screen.render();
});
// Quit on Escape, q, or Control-C.
screen.key(['escape', 'q', 'C-c'], function(ch, key) {
return process.exit(0);
});
// Focus our element.
box.focus();
// Render the screen.
screen.render();

1
node_modules/blessed/index.js generated vendored Normal file
View File

@ -0,0 +1 @@
module.exports = require('./lib/blessed');

526
node_modules/blessed/lib/alias.js generated vendored Normal file
View File

@ -0,0 +1,526 @@
/**
* alias.js - terminfo/cap aliases for blessed.
* https://github.com/chjj/blessed
* Taken from terminfo(5) man page.
*/
/* jshint maxlen: 300 */
// jscs:disable maximumLineLength
// jscs:disable
var alias = exports;
// These are the boolean capabilities:
alias.bools = {
// Variable Cap- TCap Description
// Booleans name Code
'auto_left_margin': ['bw', 'bw'], // cub1 wraps from col umn 0 to last column
'auto_right_margin': ['am', 'am'], // terminal has auto matic margins
'back_color_erase': ['bce', 'ut'], // screen erased with background color
'can_change': ['ccc', 'cc'], // terminal can re- define existing col ors
'ceol_standout_glitch': ['xhp', 'xs'], // standout not erased by overwriting (hp)
'col_addr_glitch': ['xhpa', 'YA'], // only positive motion for hpa/mhpa caps
'cpi_changes_res': ['cpix', 'YF'], // changing character pitch changes reso lution
'cr_cancels_micro_mode': ['crxm', 'YB'], // using cr turns off micro mode
'dest_tabs_magic_smso': ['xt', 'xt'], // tabs destructive, magic so char (t1061)
'eat_newline_glitch': ['xenl', 'xn'], // newline ignored after 80 cols (con cept)
'erase_overstrike': ['eo', 'eo'], // can erase over strikes with a blank
'generic_type': ['gn', 'gn'], // generic line type
'hard_copy': ['hc', 'hc'], // hardcopy terminal
'hard_cursor': ['chts', 'HC'], // cursor is hard to see
'has_meta_key': ['km', 'km'], // Has a meta key (i.e., sets 8th-bit)
'has_print_wheel': ['daisy', 'YC'], // printer needs opera tor to change char acter set
'has_status_line': ['hs', 'hs'], // has extra status line
'hue_lightness_saturation': ['hls', 'hl'], // terminal uses only HLS color notation (Tektronix)
'insert_null_glitch': ['in', 'in'], // insert mode distin guishes nulls
'lpi_changes_res': ['lpix', 'YG'], // changing line pitch changes resolution
'memory_above': ['da', 'da'], // display may be retained above the screen
'memory_below': ['db', 'db'], // display may be retained below the screen
'move_insert_mode': ['mir', 'mi'], // safe to move while in insert mode
'move_standout_mode': ['msgr', 'ms'], // safe to move while in standout mode
'needs_xon_xoff': ['nxon', 'nx'], // padding will not work, xon/xoff required
'no_esc_ctlc': ['xsb', 'xb'], // beehive (f1=escape, f2=ctrl C)
'no_pad_char': ['npc', 'NP'], // pad character does not exist
'non_dest_scroll_region': ['ndscr', 'ND'], // scrolling region is non-destructive
'non_rev_rmcup': ['nrrmc', 'NR'], // smcup does not reverse rmcup
'over_strike': ['os', 'os'], // terminal can over strike
'prtr_silent': ['mc5i', '5i'], // printer will not echo on screen
'row_addr_glitch': ['xvpa', 'YD'], // only positive motion for vpa/mvpa caps
'semi_auto_right_margin': ['sam', 'YE'], // printing in last column causes cr
'status_line_esc_ok': ['eslok', 'es'], // escape can be used on the status line
'tilde_glitch': ['hz', 'hz'], // cannot print ~'s (hazeltine)
'transparent_underline': ['ul', 'ul'], // underline character overstrikes
'xon_xoff': ['xon', 'xo'] // terminal uses xon/xoff handshaking
};
// These are the numeric capabilities:
alias.numbers = {
// Variable Cap- TCap Description
// Numeric name Code
'columns': ['cols', 'co'], // number of columns in a line
'init_tabs': ['it', 'it'], // tabs initially every # spaces
'label_height': ['lh', 'lh'], // rows in each label
'label_width': ['lw', 'lw'], // columns in each label
'lines': ['lines', 'li'], // number of lines on screen or page
'lines_of_memory': ['lm', 'lm'], // lines of memory if > line. 0 means varies
'magic_cookie_glitch': ['xmc', 'sg'], // number of blank characters left by smso or rmso
'max_attributes': ['ma', 'ma'], // maximum combined attributes terminal can handle
'max_colors': ['colors', 'Co'], // maximum number of colors on screen
'max_pairs': ['pairs', 'pa'], // maximum number of color-pairs on the screen
'maximum_windows': ['wnum', 'MW'], // maximum number of defineable windows
'no_color_video': ['ncv', 'NC'], // video attributes that cannot be used with colors
'num_labels': ['nlab', 'Nl'], // number of labels on screen
'padding_baud_rate': ['pb', 'pb'], // lowest baud rate where padding needed
'virtual_terminal': ['vt', 'vt'], // virtual terminal number (CB/unix)
'width_status_line': ['wsl', 'ws'], // number of columns in status line
// The following numeric capabilities are present in the SVr4.0 term structure, but are not yet documented in the man page. They came in with
// SVr4's printer support.
// Variable Cap- TCap Description
// Numeric name Code
'bit_image_entwining': ['bitwin', 'Yo'], // number of passes for each bit-image row
'bit_image_type': ['bitype', 'Yp'], // type of bit-image device
'buffer_capacity': ['bufsz', 'Ya'], // numbers of bytes buffered before printing
'buttons': ['btns', 'BT'], // number of buttons on mouse
'dot_horz_spacing': ['spinh', 'Yc'], // spacing of dots hor izontally in dots per inch
'dot_vert_spacing': ['spinv', 'Yb'], // spacing of pins ver tically in pins per inch
'max_micro_address': ['maddr', 'Yd'], // maximum value in micro_..._address
'max_micro_jump': ['mjump', 'Ye'], // maximum value in parm_..._micro
'micro_col_size': ['mcs', 'Yf'], // character step size when in micro mode
'micro_line_size': ['mls', 'Yg'], // line step size when in micro mode
'number_of_pins': ['npins', 'Yh'], // numbers of pins in print-head
'output_res_char': ['orc', 'Yi'], // horizontal resolu tion in units per line
'output_res_horz_inch': ['orhi', 'Yk'], // horizontal resolu tion in units per inch
'output_res_line': ['orl', 'Yj'], // vertical resolution in units per line
'output_res_vert_inch': ['orvi', 'Yl'], // vertical resolution in units per inch
'print_rate': ['cps', 'Ym'], // print rate in char acters per second
'wide_char_size': ['widcs', 'Yn'] // character step size when in double wide mode
};
// These are the string capabilities:
alias.strings = {
// Variable Cap- TCap Description
// String name Code
'acs_chars': ['acsc', 'ac'], // graphics charset pairs, based on vt100
'back_tab': ['cbt', 'bt'], // back tab (P)
'bell': ['bel', 'bl'], // audible signal (bell) (P)
'carriage_return': ['cr', 'cr'], // carriage return (P*) (P*)
'change_char_pitch': ['cpi', 'ZA'], // Change number of characters per inch to #1
'change_line_pitch': ['lpi', 'ZB'], // Change number of lines per inch to #1
'change_res_horz': ['chr', 'ZC'], // Change horizontal resolution to #1
'change_res_vert': ['cvr', 'ZD'], // Change vertical res olution to #1
'change_scroll_region': ['csr', 'cs'], // change region to line #1 to line #2 (P)
'char_padding': ['rmp', 'rP'], // like ip but when in insert mode
'clear_all_tabs': ['tbc', 'ct'], // clear all tab stops (P)
'clear_margins': ['mgc', 'MC'], // clear right and left soft margins
'clear_screen': ['clear', 'cl'], // clear screen and home cursor (P*)
'clr_bol': ['el1', 'cb'], // Clear to beginning of line
'clr_eol': ['el', 'ce'], // clear to end of line (P)
'clr_eos': ['ed', 'cd'], // clear to end of screen (P*)
'column_address': ['hpa', 'ch'], // horizontal position #1, absolute (P)
'command_character': ['cmdch', 'CC'], // terminal settable cmd character in prototype !?
'create_window': ['cwin', 'CW'], // define a window #1 from #2,#3 to #4,#5
'cursor_address': ['cup', 'cm'], // move to row #1 col umns #2
'cursor_down': ['cud1', 'do'], // down one line
'cursor_home': ['home', 'ho'], // home cursor (if no cup)
'cursor_invisible': ['civis', 'vi'], // make cursor invisi ble
'cursor_left': ['cub1', 'le'], // move left one space
'cursor_mem_address': ['mrcup', 'CM'], // memory relative cur sor addressing, move to row #1 columns #2
'cursor_normal': ['cnorm', 've'], // make cursor appear normal (undo civis/cvvis)
'cursor_right': ['cuf1', 'nd'], // non-destructive space (move right one space)
'cursor_to_ll': ['ll', 'll'], // last line, first column (if no cup)
'cursor_up': ['cuu1', 'up'], // up one line
'cursor_visible': ['cvvis', 'vs'], // make cursor very visible
'define_char': ['defc', 'ZE'], // Define a character #1, #2 dots wide, descender #3
'delete_character': ['dch1', 'dc'], // delete character (P*)
'delete_line': ['dl1', 'dl'], // delete line (P*)
'dial_phone': ['dial', 'DI'], // dial number #1
'dis_status_line': ['dsl', 'ds'], // disable status line
'display_clock': ['dclk', 'DK'], // display clock
'down_half_line': ['hd', 'hd'], // half a line down
'ena_acs': ['enacs', 'eA'], // enable alternate char set
'enter_alt_charset_mode': ['smacs', 'as'], // start alternate character set (P)
'enter_am_mode': ['smam', 'SA'], // turn on automatic margins
'enter_blink_mode': ['blink', 'mb'], // turn on blinking
'enter_bold_mode': ['bold', 'md'], // turn on bold (extra bright) mode
'enter_ca_mode': ['smcup', 'ti'], // string to start pro grams using cup
'enter_delete_mode': ['smdc', 'dm'], // enter delete mode
'enter_dim_mode': ['dim', 'mh'], // turn on half-bright mode
'enter_doublewide_mode': ['swidm', 'ZF'], // Enter double-wide mode
'enter_draft_quality': ['sdrfq', 'ZG'], // Enter draft-quality mode
'enter_insert_mode': ['smir', 'im'], // enter insert mode
'enter_italics_mode': ['sitm', 'ZH'], // Enter italic mode
'enter_leftward_mode': ['slm', 'ZI'], // Start leftward car riage motion
'enter_micro_mode': ['smicm', 'ZJ'], // Start micro-motion mode
'enter_near_letter_quality': ['snlq', 'ZK'], // Enter NLQ mode
'enter_normal_quality': ['snrmq', 'ZL'], // Enter normal-quality mode
'enter_protected_mode': ['prot', 'mp'], // turn on protected mode
'enter_reverse_mode': ['rev', 'mr'], // turn on reverse video mode
'enter_secure_mode': ['invis', 'mk'], // turn on blank mode (characters invisi ble)
'enter_shadow_mode': ['sshm', 'ZM'], // Enter shadow-print mode
'enter_standout_mode': ['smso', 'so'], // begin standout mode
'enter_subscript_mode': ['ssubm', 'ZN'], // Enter subscript mode
'enter_superscript_mode': ['ssupm', 'ZO'], // Enter superscript mode
'enter_underline_mode': ['smul', 'us'], // begin underline mode
'enter_upward_mode': ['sum', 'ZP'], // Start upward car riage motion
'enter_xon_mode': ['smxon', 'SX'], // turn on xon/xoff handshaking
'erase_chars': ['ech', 'ec'], // erase #1 characters (P)
'exit_alt_charset_mode': ['rmacs', 'ae'], // end alternate char acter set (P)
'exit_am_mode': ['rmam', 'RA'], // turn off automatic margins
'exit_attribute_mode': ['sgr0', 'me'], // turn off all attributes
'exit_ca_mode': ['rmcup', 'te'], // strings to end pro grams using cup
'exit_delete_mode': ['rmdc', 'ed'], // end delete mode
'exit_doublewide_mode': ['rwidm', 'ZQ'], // End double-wide mode
'exit_insert_mode': ['rmir', 'ei'], // exit insert mode
'exit_italics_mode': ['ritm', 'ZR'], // End italic mode
'exit_leftward_mode': ['rlm', 'ZS'], // End left-motion mode
'exit_micro_mode': ['rmicm', 'ZT'], // End micro-motion mode
'exit_shadow_mode': ['rshm', 'ZU'], // End shadow-print mode
'exit_standout_mode': ['rmso', 'se'], // exit standout mode
'exit_subscript_mode': ['rsubm', 'ZV'], // End subscript mode
'exit_superscript_mode': ['rsupm', 'ZW'], // End superscript mode
'exit_underline_mode': ['rmul', 'ue'], // exit underline mode
'exit_upward_mode': ['rum', 'ZX'], // End reverse charac ter motion
'exit_xon_mode': ['rmxon', 'RX'], // turn off xon/xoff handshaking
'fixed_pause': ['pause', 'PA'], // pause for 2-3 sec onds
'flash_hook': ['hook', 'fh'], // flash switch hook
'flash_screen': ['flash', 'vb'], // visible bell (may not move cursor)
'form_feed': ['ff', 'ff'], // hardcopy terminal page eject (P*)
'from_status_line': ['fsl', 'fs'], // return from status line
'goto_window': ['wingo', 'WG'], // go to window #1
'hangup': ['hup', 'HU'], // hang-up phone
'init_1string': ['is1', 'i1'], // initialization string
'init_2string': ['is2', 'is'], // initialization string
'init_3string': ['is3', 'i3'], // initialization string
'init_file': ['if', 'if'], // name of initializa tion file
'init_prog': ['iprog', 'iP'], // path name of program for initialization
'initialize_color': ['initc', 'Ic'], // initialize color #1 to (#2,#3,#4)
'initialize_pair': ['initp', 'Ip'], // Initialize color pair #1 to fg=(#2,#3,#4), bg=(#5,#6,#7)
'insert_character': ['ich1', 'ic'], // insert character (P)
'insert_line': ['il1', 'al'], // insert line (P*)
'insert_padding': ['ip', 'ip'], // insert padding after inserted character
'key_a1': ['ka1', 'K1'], // upper left of keypad
'key_a3': ['ka3', 'K3'], // upper right of key pad
'key_b2': ['kb2', 'K2'], // center of keypad
'key_backspace': ['kbs', 'kb'], // backspace key
'key_beg': ['kbeg', '@1'], // begin key
'key_btab': ['kcbt', 'kB'], // back-tab key
'key_c1': ['kc1', 'K4'], // lower left of keypad
'key_c3': ['kc3', 'K5'], // lower right of key pad
'key_cancel': ['kcan', '@2'], // cancel key
'key_catab': ['ktbc', 'ka'], // clear-all-tabs key
'key_clear': ['kclr', 'kC'], // clear-screen or erase key
'key_close': ['kclo', '@3'], // close key
'key_command': ['kcmd', '@4'], // command key
'key_copy': ['kcpy', '@5'], // copy key
'key_create': ['kcrt', '@6'], // create key
'key_ctab': ['kctab', 'kt'], // clear-tab key
'key_dc': ['kdch1', 'kD'], // delete-character key
'key_dl': ['kdl1', 'kL'], // delete-line key
'key_down': ['kcud1', 'kd'], // down-arrow key
'key_eic': ['krmir', 'kM'], // sent by rmir or smir in insert mode
'key_end': ['kend', '@7'], // end key
'key_enter': ['kent', '@8'], // enter/send key
'key_eol': ['kel', 'kE'], // clear-to-end-of-line key
'key_eos': ['ked', 'kS'], // clear-to-end-of- screen key
'key_exit': ['kext', '@9'], // exit key
'key_f0': ['kf0', 'k0'], // F0 function key
'key_f1': ['kf1', 'k1'], // F1 function key
'key_f10': ['kf10', 'k;'], // F10 function key
'key_f11': ['kf11', 'F1'], // F11 function key
'key_f12': ['kf12', 'F2'], // F12 function key
'key_f13': ['kf13', 'F3'], // F13 function key
'key_f14': ['kf14', 'F4'], // F14 function key
'key_f15': ['kf15', 'F5'], // F15 function key
'key_f16': ['kf16', 'F6'], // F16 function key
'key_f17': ['kf17', 'F7'], // F17 function key
'key_f18': ['kf18', 'F8'], // F18 function key
'key_f19': ['kf19', 'F9'], // F19 function key
'key_f2': ['kf2', 'k2'], // F2 function key
'key_f20': ['kf20', 'FA'], // F20 function key
'key_f21': ['kf21', 'FB'], // F21 function key
'key_f22': ['kf22', 'FC'], // F22 function key
'key_f23': ['kf23', 'FD'], // F23 function key
'key_f24': ['kf24', 'FE'], // F24 function key
'key_f25': ['kf25', 'FF'], // F25 function key
'key_f26': ['kf26', 'FG'], // F26 function key
'key_f27': ['kf27', 'FH'], // F27 function key
'key_f28': ['kf28', 'FI'], // F28 function key
'key_f29': ['kf29', 'FJ'], // F29 function key
'key_f3': ['kf3', 'k3'], // F3 function key
'key_f30': ['kf30', 'FK'], // F30 function key
'key_f31': ['kf31', 'FL'], // F31 function key
'key_f32': ['kf32', 'FM'], // F32 function key
'key_f33': ['kf33', 'FN'], // F33 function key
'key_f34': ['kf34', 'FO'], // F34 function key
'key_f35': ['kf35', 'FP'], // F35 function key
'key_f36': ['kf36', 'FQ'], // F36 function key
'key_f37': ['kf37', 'FR'], // F37 function key
'key_f38': ['kf38', 'FS'], // F38 function key
'key_f39': ['kf39', 'FT'], // F39 function key
'key_f4': ['kf4', 'k4'], // F4 function key
'key_f40': ['kf40', 'FU'], // F40 function key
'key_f41': ['kf41', 'FV'], // F41 function key
'key_f42': ['kf42', 'FW'], // F42 function key
'key_f43': ['kf43', 'FX'], // F43 function key
'key_f44': ['kf44', 'FY'], // F44 function key
'key_f45': ['kf45', 'FZ'], // F45 function key
'key_f46': ['kf46', 'Fa'], // F46 function key
'key_f47': ['kf47', 'Fb'], // F47 function key
'key_f48': ['kf48', 'Fc'], // F48 function key
'key_f49': ['kf49', 'Fd'], // F49 function key
'key_f5': ['kf5', 'k5'], // F5 function key
'key_f50': ['kf50', 'Fe'], // F50 function key
'key_f51': ['kf51', 'Ff'], // F51 function key
'key_f52': ['kf52', 'Fg'], // F52 function key
'key_f53': ['kf53', 'Fh'], // F53 function key
'key_f54': ['kf54', 'Fi'], // F54 function key
'key_f55': ['kf55', 'Fj'], // F55 function key
'key_f56': ['kf56', 'Fk'], // F56 function key
'key_f57': ['kf57', 'Fl'], // F57 function key
'key_f58': ['kf58', 'Fm'], // F58 function key
'key_f59': ['kf59', 'Fn'], // F59 function key
'key_f6': ['kf6', 'k6'], // F6 function key
'key_f60': ['kf60', 'Fo'], // F60 function key
'key_f61': ['kf61', 'Fp'], // F61 function key
'key_f62': ['kf62', 'Fq'], // F62 function key
'key_f63': ['kf63', 'Fr'], // F63 function key
'key_f7': ['kf7', 'k7'], // F7 function key
'key_f8': ['kf8', 'k8'], // F8 function key
'key_f9': ['kf9', 'k9'], // F9 function key
'key_find': ['kfnd', '@0'], // find key
'key_help': ['khlp', '%1'], // help key
'key_home': ['khome', 'kh'], // home key
'key_ic': ['kich1', 'kI'], // insert-character key
'key_il': ['kil1', 'kA'], // insert-line key
'key_left': ['kcub1', 'kl'], // left-arrow key
'key_ll': ['kll', 'kH'], // lower-left key (home down)
'key_mark': ['kmrk', '%2'], // mark key
'key_message': ['kmsg', '%3'], // message key
'key_move': ['kmov', '%4'], // move key
'key_next': ['knxt', '%5'], // next key
'key_npage': ['knp', 'kN'], // next-page key
'key_open': ['kopn', '%6'], // open key
'key_options': ['kopt', '%7'], // options key
'key_ppage': ['kpp', 'kP'], // previous-page key
'key_previous': ['kprv', '%8'], // previous key
'key_print': ['kprt', '%9'], // print key
'key_redo': ['krdo', '%0'], // redo key
'key_reference': ['kref', '&1'], // reference key
'key_refresh': ['krfr', '&2'], // refresh key
'key_replace': ['krpl', '&3'], // replace key
'key_restart': ['krst', '&4'], // restart key
'key_resume': ['kres', '&5'], // resume key
'key_right': ['kcuf1', 'kr'], // right-arrow key
'key_save': ['ksav', '&6'], // save key
'key_sbeg': ['kBEG', '&9'], // shifted begin key
'key_scancel': ['kCAN', '&0'], // shifted cancel key
'key_scommand': ['kCMD', '*1'], // shifted command key
'key_scopy': ['kCPY', '*2'], // shifted copy key
'key_screate': ['kCRT', '*3'], // shifted create key
'key_sdc': ['kDC', '*4'], // shifted delete-char acter key
'key_sdl': ['kDL', '*5'], // shifted delete-line key
'key_select': ['kslt', '*6'], // select key
'key_send': ['kEND', '*7'], // shifted end key
'key_seol': ['kEOL', '*8'], // shifted clear-to- end-of-line key
'key_sexit': ['kEXT', '*9'], // shifted exit key
'key_sf': ['kind', 'kF'], // scroll-forward key
'key_sfind': ['kFND', '*0'], // shifted find key
'key_shelp': ['kHLP', '#1'], // shifted help key
'key_shome': ['kHOM', '#2'], // shifted home key
'key_sic': ['kIC', '#3'], // shifted insert-char acter key
'key_sleft': ['kLFT', '#4'], // shifted left-arrow key
'key_smessage': ['kMSG', '%a'], // shifted message key
'key_smove': ['kMOV', '%b'], // shifted move key
'key_snext': ['kNXT', '%c'], // shifted next key
'key_soptions': ['kOPT', '%d'], // shifted options key
'key_sprevious': ['kPRV', '%e'], // shifted previous key
'key_sprint': ['kPRT', '%f'], // shifted print key
'key_sr': ['kri', 'kR'], // scroll-backward key
'key_sredo': ['kRDO', '%g'], // shifted redo key
'key_sreplace': ['kRPL', '%h'], // shifted replace key
'key_sright': ['kRIT', '%i'], // shifted right-arrow key
'key_srsume': ['kRES', '%j'], // shifted resume key
'key_ssave': ['kSAV', '!1'], // shifted save key
'key_ssuspend': ['kSPD', '!2'], // shifted suspend key
'key_stab': ['khts', 'kT'], // set-tab key
'key_sundo': ['kUND', '!3'], // shifted undo key
'key_suspend': ['kspd', '&7'], // suspend key
'key_undo': ['kund', '&8'], // undo key
'key_up': ['kcuu1', 'ku'], // up-arrow key
'keypad_local': ['rmkx', 'ke'], // leave 'key board_transmit' mode
'keypad_xmit': ['smkx', 'ks'], // enter 'key board_transmit' mode
'lab_f0': ['lf0', 'l0'], // label on function key f0 if not f0
'lab_f1': ['lf1', 'l1'], // label on function key f1 if not f1
'lab_f10': ['lf10', 'la'], // label on function key f10 if not f10
'lab_f2': ['lf2', 'l2'], // label on function key f2 if not f2
'lab_f3': ['lf3', 'l3'], // label on function key f3 if not f3
'lab_f4': ['lf4', 'l4'], // label on function key f4 if not f4
'lab_f5': ['lf5', 'l5'], // label on function key f5 if not f5
'lab_f6': ['lf6', 'l6'], // label on function key f6 if not f6
'lab_f7': ['lf7', 'l7'], // label on function key f7 if not f7
'lab_f8': ['lf8', 'l8'], // label on function key f8 if not f8
'lab_f9': ['lf9', 'l9'], // label on function key f9 if not f9
'label_format': ['fln', 'Lf'], // label format
'label_off': ['rmln', 'LF'], // turn off soft labels
'label_on': ['smln', 'LO'], // turn on soft labels
'meta_off': ['rmm', 'mo'], // turn off meta mode
'meta_on': ['smm', 'mm'], // turn on meta mode (8th-bit on)
'micro_column_address': ['mhpa', 'ZY'], // Like column_address in micro mode
'micro_down': ['mcud1', 'ZZ'], // Like cursor_down in micro mode
'micro_left': ['mcub1', 'Za'], // Like cursor_left in micro mode
'micro_right': ['mcuf1', 'Zb'], // Like cursor_right in micro mode
'micro_row_address': ['mvpa', 'Zc'], // Like row_address #1 in micro mode
'micro_up': ['mcuu1', 'Zd'], // Like cursor_up in micro mode
'newline': ['nel', 'nw'], // newline (behave like cr followed by lf)
'order_of_pins': ['porder', 'Ze'], // Match software bits to print-head pins
'orig_colors': ['oc', 'oc'], // Set all color pairs to the original ones
'orig_pair': ['op', 'op'], // Set default pair to its original value
'pad_char': ['pad', 'pc'], // padding char (instead of null)
'parm_dch': ['dch', 'DC'], // delete #1 characters (P*)
'parm_delete_line': ['dl', 'DL'], // delete #1 lines (P*)
'parm_down_cursor': ['cud', 'DO'], // down #1 lines (P*)
'parm_down_micro': ['mcud', 'Zf'], // Like parm_down_cur sor in micro mode
'parm_ich': ['ich', 'IC'], // insert #1 characters (P*)
'parm_index': ['indn', 'SF'], // scroll forward #1 lines (P)
'parm_insert_line': ['il', 'AL'], // insert #1 lines (P*)
'parm_left_cursor': ['cub', 'LE'], // move #1 characters to the left (P)
'parm_left_micro': ['mcub', 'Zg'], // Like parm_left_cur sor in micro mode
'parm_right_cursor': ['cuf', 'RI'], // move #1 characters to the right (P*)
'parm_right_micro': ['mcuf', 'Zh'], // Like parm_right_cur sor in micro mode
'parm_rindex': ['rin', 'SR'], // scroll back #1 lines (P)
'parm_up_cursor': ['cuu', 'UP'], // up #1 lines (P*)
'parm_up_micro': ['mcuu', 'Zi'], // Like parm_up_cursor in micro mode
'pkey_key': ['pfkey', 'pk'], // program function key #1 to type string #2
'pkey_local': ['pfloc', 'pl'], // program function key #1 to execute string #2
'pkey_xmit': ['pfx', 'px'], // program function key #1 to transmit string #2
'plab_norm': ['pln', 'pn'], // program label #1 to show string #2
'print_screen': ['mc0', 'ps'], // print contents of screen
'prtr_non': ['mc5p', 'pO'], // turn on printer for #1 bytes
'prtr_off': ['mc4', 'pf'], // turn off printer
'prtr_on': ['mc5', 'po'], // turn on printer
'pulse': ['pulse', 'PU'], // select pulse dialing
'quick_dial': ['qdial', 'QD'], // dial number #1 with out checking
'remove_clock': ['rmclk', 'RC'], // remove clock
'repeat_char': ['rep', 'rp'], // repeat char #1 #2 times (P*)
'req_for_input': ['rfi', 'RF'], // send next input char (for ptys)
'reset_1string': ['rs1', 'r1'], // reset string
'reset_2string': ['rs2', 'r2'], // reset string
'reset_3string': ['rs3', 'r3'], // reset string
'reset_file': ['rf', 'rf'], // name of reset file
'restore_cursor': ['rc', 'rc'], // restore cursor to position of last save_cursor
'row_address': ['vpa', 'cv'], // vertical position #1 absolute (P)
'save_cursor': ['sc', 'sc'], // save current cursor position (P)
'scroll_forward': ['ind', 'sf'], // scroll text up (P)
'scroll_reverse': ['ri', 'sr'], // scroll text down (P)
'select_char_set': ['scs', 'Zj'], // Select character set, #1
'set_attributes': ['sgr', 'sa'], // define video attributes #1-#9 (PG9)
'set_background': ['setb', 'Sb'], // Set background color #1
'set_bottom_margin': ['smgb', 'Zk'], // Set bottom margin at current line
'set_bottom_margin_parm': ['smgbp', 'Zl'], // Set bottom margin at line #1 or (if smgtp is not given) #2 lines from bottom
'set_clock': ['sclk', 'SC'], // set clock, #1 hrs #2 mins #3 secs
'set_color_pair': ['scp', 'sp'], // Set current color pair to #1
'set_foreground': ['setf', 'Sf'], // Set foreground color #1
'set_left_margin': ['smgl', 'ML'], // set left soft margin at current col umn. See smgl. (ML is not in BSD termcap).
'set_left_margin_parm': ['smglp', 'Zm'], // Set left (right) margin at column #1
'set_right_margin': ['smgr', 'MR'], // set right soft margin at current column
'set_right_margin_parm': ['smgrp', 'Zn'], // Set right margin at column #1
'set_tab': ['hts', 'st'], // set a tab in every row, current columns
'set_top_margin': ['smgt', 'Zo'], // Set top margin at current line
'set_top_margin_parm': ['smgtp', 'Zp'], // Set top (bottom) margin at row #1
'set_window': ['wind', 'wi'], // current window is lines #1-#2 cols #3-#4
'start_bit_image': ['sbim', 'Zq'], // Start printing bit image graphics
'start_char_set_def': ['scsd', 'Zr'], // Start character set defi nition #1, with #2 charac ters in the set
'stop_bit_image': ['rbim', 'Zs'], // Stop printing bit image graphics
'stop_char_set_def': ['rcsd', 'Zt'], // End definition of charac ter set #1
'subscript_characters': ['subcs', 'Zu'], // List of subscriptable characters
'superscript_characters': ['supcs', 'Zv'], // List of superscriptable characters
'tab': ['ht', 'ta'], // tab to next 8-space hard ware tab stop
'these_cause_cr': ['docr', 'Zw'], // Printing any of these characters causes CR
'to_status_line': ['tsl', 'ts'], // move to status line, col umn #1
'tone': ['tone', 'TO'], // select touch tone dialing
'underline_char': ['uc', 'uc'], // underline char and move past it
'up_half_line': ['hu', 'hu'], // half a line up
'user0': ['u0', 'u0'], // User string #0
'user1': ['u1', 'u1'], // User string #1
'user2': ['u2', 'u2'], // User string #2
'user3': ['u3', 'u3'], // User string #3
'user4': ['u4', 'u4'], // User string #4
'user5': ['u5', 'u5'], // User string #5
'user6': ['u6', 'u6'], // User string #6
'user7': ['u7', 'u7'], // User string #7
'user8': ['u8', 'u8'], // User string #8
'user9': ['u9', 'u9'], // User string #9
'wait_tone': ['wait', 'WA'], // wait for dial-tone
'xoff_character': ['xoffc', 'XF'], // XOFF character
'xon_character': ['xonc', 'XN'], // XON character
'zero_motion': ['zerom', 'Zx'], // No motion for subsequent character
// The following string capabilities are present in the SVr4.0 term structure, but were originally not documented in the man page.
// Variable Cap- TCap Description
// String name Code
'alt_scancode_esc': ['scesa', 'S8'], // Alternate escape for scancode emu lation
'bit_image_carriage_return': ['bicr', 'Yv'], // Move to beginning of same row
'bit_image_newline': ['binel', 'Zz'], // Move to next row of the bit image
'bit_image_repeat': ['birep', 'Xy'], // Repeat bit image cell #1 #2 times
'char_set_names': ['csnm', 'Zy'], // Produce #1'th item from list of char acter set names
'code_set_init': ['csin', 'ci'], // Init sequence for multiple codesets
'color_names': ['colornm', 'Yw'], // Give name for color #1
'define_bit_image_region': ['defbi', 'Yx'], // Define rectan gualar bit image region
'device_type': ['devt', 'dv'], // Indicate lan guage/codeset sup port
'display_pc_char': ['dispc', 'S1'], // Display PC charac ter #1
'end_bit_image_region': ['endbi', 'Yy'], // End a bit-image region
'enter_pc_charset_mode': ['smpch', 'S2'], // Enter PC character display mode
'enter_scancode_mode': ['smsc', 'S4'], // Enter PC scancode mode
'exit_pc_charset_mode': ['rmpch', 'S3'], // Exit PC character display mode
'exit_scancode_mode': ['rmsc', 'S5'], // Exit PC scancode mode
'get_mouse': ['getm', 'Gm'], // Curses should get button events, parameter #1 not documented.
'key_mouse': ['kmous', 'Km'], // Mouse event has occurred
'mouse_info': ['minfo', 'Mi'], // Mouse status information
'pc_term_options': ['pctrm', 'S6'], // PC terminal options
'pkey_plab': ['pfxl', 'xl'], // Program function key #1 to type string #2 and show string #3
'req_mouse_pos': ['reqmp', 'RQ'], // Request mouse position
'scancode_escape': ['scesc', 'S7'], // Escape for scan code emulation
'set0_des_seq': ['s0ds', 's0'], // Shift to codeset 0 (EUC set 0, ASCII)
'set1_des_seq': ['s1ds', 's1'], // Shift to codeset 1
'set2_des_seq': ['s2ds', 's2'], // Shift to codeset 2
'set3_des_seq': ['s3ds', 's3'], // Shift to codeset 3
'set_a_background': ['setab', 'AB'], // Set background color to #1, using ANSI escape
'set_a_foreground': ['setaf', 'AF'], // Set foreground color to #1, using ANSI escape
'set_color_band': ['setcolor', 'Yz'], // Change to ribbon color #1
'set_lr_margin': ['smglr', 'ML'], // Set both left and right margins to #1, #2. (ML is not in BSD term cap).
'set_page_length': ['slines', 'YZ'], // Set page length to #1 lines
'set_tb_margin': ['smgtb', 'MT'], // Sets both top and bottom margins to #1, #2
// The XSI Curses standard added these. They are some post-4.1 versions of System V curses, e.g., Solaris 2.5 and IRIX 6.x. The ncurses termcap
// names for them are invented; according to the XSI Curses standard, they have no termcap names. If your compiled terminfo entries use these,
// they may not be binary-compatible with System V terminfo entries after SVr4.1; beware!
// Variable Cap- TCap Description
// String name Code
'enter_horizontal_hl_mode': ['ehhlm', 'Xh'], // Enter horizontal highlight mode
'enter_left_hl_mode': ['elhlm', 'Xl'], // Enter left highlight mode
'enter_low_hl_mode': ['elohlm', 'Xo'], // Enter low highlight mode
'enter_right_hl_mode': ['erhlm', 'Xr'], // Enter right high light mode
'enter_top_hl_mode': ['ethlm', 'Xt'], // Enter top highlight mode
'enter_vertical_hl_mode': ['evhlm', 'Xv'], // Enter vertical high light mode
'set_a_attributes': ['sgr1', 'sA'], // Define second set of video attributes #1-#6
'set_pglen_inch': ['slength', 'sL'] // YI Set page length to #1 hundredth of an inch
};

32
node_modules/blessed/lib/blessed.js generated vendored Normal file
View File

@ -0,0 +1,32 @@
/**
* blessed - a high-level terminal interface library for node.js
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Blessed
*/
function blessed() {
return blessed.program.apply(null, arguments);
}
blessed.program = blessed.Program = require('./program');
blessed.tput = blessed.Tput = require('./tput');
blessed.widget = require('./widget');
blessed.colors = require('./colors');
blessed.unicode = require('./unicode');
blessed.helpers = require('./helpers');
blessed.helpers.sprintf = blessed.tput.sprintf;
blessed.helpers.tryRead = blessed.tput.tryRead;
blessed.helpers.merge(blessed, blessed.helpers);
blessed.helpers.merge(blessed, blessed.widget);
/**
* Expose
*/
module.exports = blessed;

530
node_modules/blessed/lib/colors.js generated vendored Normal file
View File

@ -0,0 +1,530 @@
/**
* colors.js - color-related functions for blessed.
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
exports.match = function(r1, g1, b1) {
if (typeof r1 === 'string') {
var hex = r1;
if (hex[0] !== '#') {
return -1;
}
hex = exports.hexToRGB(hex);
r1 = hex[0], g1 = hex[1], b1 = hex[2];
} else if (Array.isArray(r1)) {
b1 = r1[2], g1 = r1[1], r1 = r1[0];
}
var hash = (r1 << 16) | (g1 << 8) | b1;
if (exports._cache[hash] != null) {
return exports._cache[hash];
}
var ldiff = Infinity
, li = -1
, i = 0
, c
, r2
, g2
, b2
, diff;
for (; i < exports.vcolors.length; i++) {
c = exports.vcolors[i];
r2 = c[0];
g2 = c[1];
b2 = c[2];
diff = colorDistance(r1, g1, b1, r2, g2, b2);
if (diff === 0) {
li = i;
break;
}
if (diff < ldiff) {
ldiff = diff;
li = i;
}
}
return exports._cache[hash] = li;
};
exports.RGBToHex = function(r, g, b) {
if (Array.isArray(r)) {
b = r[2], g = r[1], r = r[0];
}
function hex(n) {
n = n.toString(16);
if (n.length < 2) n = '0' + n;
return n;
}
return '#' + hex(r) + hex(g) + hex(b);
};
exports.hexToRGB = function(hex) {
if (hex.length === 4) {
hex = hex[0]
+ hex[1] + hex[1]
+ hex[2] + hex[2]
+ hex[3] + hex[3];
}
var col = parseInt(hex.substring(1), 16)
, r = (col >> 16) & 0xff
, g = (col >> 8) & 0xff
, b = col & 0xff;
return [r, g, b];
};
// As it happens, comparing how similar two colors are is really hard. Here is
// one of the simplest solutions, which doesn't require conversion to another
// color space, posted on stackoverflow[1]. Maybe someone better at math can
// propose a superior solution.
// [1] http://stackoverflow.com/questions/1633828
function colorDistance(r1, g1, b1, r2, g2, b2) {
return Math.pow(30 * (r1 - r2), 2)
+ Math.pow(59 * (g1 - g2), 2)
+ Math.pow(11 * (b1 - b2), 2);
}
// This might work well enough for a terminal's colors: treat RGB as XYZ in a
// 3-dimensional space and go midway between the two points.
exports.mixColors = function(c1, c2, alpha) {
// if (c1 === 0x1ff) return c1;
// if (c2 === 0x1ff) return c1;
if (c1 === 0x1ff) c1 = 0;
if (c2 === 0x1ff) c2 = 0;
if (alpha == null) alpha = 0.5;
c1 = exports.vcolors[c1];
var r1 = c1[0];
var g1 = c1[1];
var b1 = c1[2];
c2 = exports.vcolors[c2];
var r2 = c2[0];
var g2 = c2[1];
var b2 = c2[2];
r1 += (r2 - r1) * alpha | 0;
g1 += (g2 - g1) * alpha | 0;
b1 += (b2 - b1) * alpha | 0;
return exports.match([r1, g1, b1]);
};
exports.blend = function blend(attr, attr2, alpha) {
var name, i, c, nc;
var bg = attr & 0x1ff;
if (attr2 != null) {
var bg2 = attr2 & 0x1ff;
if (bg === 0x1ff) bg = 0;
if (bg2 === 0x1ff) bg2 = 0;
bg = exports.mixColors(bg, bg2, alpha);
} else {
if (blend._cache[bg] != null) {
bg = blend._cache[bg];
// } else if (bg < 8) {
// bg += 8;
} else if (bg >= 8 && bg <= 15) {
bg -= 8;
} else {
name = exports.ncolors[bg];
if (name) {
for (i = 0; i < exports.ncolors.length; i++) {
if (name === exports.ncolors[i] && i !== bg) {
c = exports.vcolors[bg];
nc = exports.vcolors[i];
if (nc[0] + nc[1] + nc[2] < c[0] + c[1] + c[2]) {
blend._cache[bg] = i;
bg = i;
break;
}
}
}
}
}
}
attr &= ~0x1ff;
attr |= bg;
var fg = (attr >> 9) & 0x1ff;
if (attr2 != null) {
var fg2 = (attr2 >> 9) & 0x1ff;
// 0, 7, 188, 231, 251
if (fg === 0x1ff) {
// XXX workaround
fg = 248;
} else {
if (fg === 0x1ff) fg = 7;
if (fg2 === 0x1ff) fg2 = 7;
fg = exports.mixColors(fg, fg2, alpha);
}
} else {
if (blend._cache[fg] != null) {
fg = blend._cache[fg];
// } else if (fg < 8) {
// fg += 8;
} else if (fg >= 8 && fg <= 15) {
fg -= 8;
} else {
name = exports.ncolors[fg];
if (name) {
for (i = 0; i < exports.ncolors.length; i++) {
if (name === exports.ncolors[i] && i !== fg) {
c = exports.vcolors[fg];
nc = exports.vcolors[i];
if (nc[0] + nc[1] + nc[2] < c[0] + c[1] + c[2]) {
blend._cache[fg] = i;
fg = i;
break;
}
}
}
}
}
}
attr &= ~(0x1ff << 9);
attr |= fg << 9;
return attr;
};
exports.blend._cache = {};
exports._cache = {};
exports.reduce = function(color, total) {
if (color >= 16 && total <= 16) {
color = exports.ccolors[color];
} else if (color >= 8 && total <= 8) {
color -= 8;
} else if (color >= 2 && total <= 2) {
color %= 2;
}
return color;
};
// XTerm Colors
// These were actually tough to track down. The xterm source only uses color
// keywords. The X11 source needed to be examined to find the actual values.
// They then had to be mapped to rgb values and then converted to hex values.
exports.xterm = [
'#000000', // black
'#cd0000', // red3
'#00cd00', // green3
'#cdcd00', // yellow3
'#0000ee', // blue2
'#cd00cd', // magenta3
'#00cdcd', // cyan3
'#e5e5e5', // gray90
'#7f7f7f', // gray50
'#ff0000', // red
'#00ff00', // green
'#ffff00', // yellow
'#5c5cff', // rgb:5c/5c/ff
'#ff00ff', // magenta
'#00ffff', // cyan
'#ffffff' // white
];
// Seed all 256 colors. Assume xterm defaults.
// Ported from the xterm color generation script.
exports.colors = (function() {
var cols = exports.colors = []
, _cols = exports.vcolors = []
, r
, g
, b
, i
, l;
function hex(n) {
n = n.toString(16);
if (n.length < 2) n = '0' + n;
return n;
}
function push(i, r, g, b) {
cols[i] = '#' + hex(r) + hex(g) + hex(b);
_cols[i] = [r, g, b];
}
// 0 - 15
exports.xterm.forEach(function(c, i) {
c = parseInt(c.substring(1), 16);
push(i, (c >> 16) & 0xff, (c >> 8) & 0xff, c & 0xff);
});
// 16 - 231
for (r = 0; r < 6; r++) {
for (g = 0; g < 6; g++) {
for (b = 0; b < 6; b++) {
i = 16 + (r * 36) + (g * 6) + b;
push(i,
r ? (r * 40 + 55) : 0,
g ? (g * 40 + 55) : 0,
b ? (b * 40 + 55) : 0);
}
}
}
// 232 - 255 are grey.
for (g = 0; g < 24; g++) {
l = (g * 10) + 8;
i = 232 + g;
push(i, l, l, l);
}
return cols;
})();
// Map higher colors to the first 8 colors.
// This allows translation of high colors to low colors on 8-color terminals.
exports.ccolors = (function() {
var _cols = exports.vcolors.slice()
, cols = exports.colors.slice()
, out;
exports.vcolors = exports.vcolors.slice(0, 8);
exports.colors = exports.colors.slice(0, 8);
out = cols.map(exports.match);
exports.colors = cols;
exports.vcolors = _cols;
exports.ccolors = out;
return out;
})();
var colorNames = exports.colorNames = {
// special
default: -1,
normal: -1,
bg: -1,
fg: -1,
// normal
black: 0,
red: 1,
green: 2,
yellow: 3,
blue: 4,
magenta: 5,
cyan: 6,
white: 7,
// light
lightblack: 8,
lightred: 9,
lightgreen: 10,
lightyellow: 11,
lightblue: 12,
lightmagenta: 13,
lightcyan: 14,
lightwhite: 15,
// bright
brightblack: 8,
brightred: 9,
brightgreen: 10,
brightyellow: 11,
brightblue: 12,
brightmagenta: 13,
brightcyan: 14,
brightwhite: 15,
// alternate spellings
grey: 8,
gray: 8,
lightgrey: 7,
lightgray: 7,
brightgrey: 7,
brightgray: 7
};
exports.convert = function(color) {
if (typeof color === 'number') {
;
} else if (typeof color === 'string') {
color = color.replace(/[\- ]/g, '');
if (colorNames[color] != null) {
color = colorNames[color];
} else {
color = exports.match(color);
}
} else if (Array.isArray(color)) {
color = exports.match(color);
} else {
color = -1;
}
return color !== -1 ? color : 0x1ff;
};
// Map higher colors to the first 8 colors.
// This allows translation of high colors to low colors on 8-color terminals.
// Why the hell did I do this by hand?
exports.ccolors = {
blue: [
4,
12,
[17, 21],
[24, 27],
[31, 33],
[38, 39],
45,
[54, 57],
[60, 63],
[67, 69],
[74, 75],
81,
[91, 93],
[97, 99],
[103, 105],
[110, 111],
117,
[128, 129],
[134, 135],
[140, 141],
[146, 147],
153,
165,
171,
177,
183,
189
],
green: [
2,
10,
22,
[28, 29],
[34, 36],
[40, 43],
[46, 50],
[64, 65],
[70, 72],
[76, 79],
[82, 86],
[106, 108],
[112, 115],
[118, 122],
[148, 151],
[154, 158],
[190, 194]
],
cyan: [
6,
14,
23,
30,
37,
44,
51,
66,
73,
80,
87,
109,
116,
123,
152,
159,
195
],
red: [
1,
9,
52,
[88, 89],
[94, 95],
[124, 126],
[130, 132],
[136, 138],
[160, 163],
[166, 169],
[172, 175],
[178, 181],
[196, 200],
[202, 206],
[208, 212],
[214, 218],
[220, 224]
],
magenta: [
5,
13,
53,
90,
96,
127,
133,
139,
164,
170,
176,
182,
201,
207,
213,
219,
225
],
yellow: [
3,
11,
58,
[100, 101],
[142, 144],
[184, 187],
[226, 230]
],
black: [
0,
8,
16,
59,
102,
[232, 243]
],
white: [
7,
15,
145,
188,
231,
[244, 255]
]
};
exports.ncolors = [];
Object.keys(exports.ccolors).forEach(function(name) {
exports.ccolors[name].forEach(function(offset) {
if (typeof offset === 'number') {
exports.ncolors[offset] = name;
exports.ccolors[offset] = exports.colorNames[name];
return;
}
for (var i = offset[0], l = offset[1]; i <= l; i++) {
exports.ncolors[i] = name;
exports.ccolors[i] = exports.colorNames[name];
}
});
delete exports.ccolors[name];
});

189
node_modules/blessed/lib/events.js generated vendored Normal file
View File

@ -0,0 +1,189 @@
/**
* events.js - event emitter for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
var slice = Array.prototype.slice;
/**
* EventEmitter
*/
function EventEmitter() {
if (!this._events) this._events = {};
}
EventEmitter.prototype.setMaxListeners = function(n) {
this._maxListeners = n;
};
EventEmitter.prototype.addListener = function(type, listener) {
if (!this._events[type]) {
this._events[type] = listener;
} else if (typeof this._events[type] === 'function') {
this._events[type] = [this._events[type], listener];
} else {
this._events[type].push(listener);
}
this._emit('newListener', [type, listener]);
};
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
EventEmitter.prototype.removeListener = function(type, listener) {
var handler = this._events[type];
if (!handler) return;
if (typeof handler === 'function' || handler.length === 1) {
delete this._events[type];
this._emit('removeListener', [type, listener]);
return;
}
for (var i = 0; i < handler.length; i++) {
if (handler[i] === listener || handler[i].listener === listener) {
handler.splice(i, 1);
this._emit('removeListener', [type, listener]);
return;
}
}
};
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
EventEmitter.prototype.removeAllListeners = function(type) {
if (type) {
delete this._events[type];
} else {
this._events = {};
}
};
EventEmitter.prototype.once = function(type, listener) {
function on() {
this.removeListener(type, on);
return listener.apply(this, arguments);
}
on.listener = listener;
return this.on(type, on);
};
EventEmitter.prototype.listeners = function(type) {
return typeof this._events[type] === 'function'
? [this._events[type]]
: this._events[type] || [];
};
EventEmitter.prototype._emit = function(type, args) {
var handler = this._events[type]
, ret;
// if (type !== 'event') {
// this._emit('event', [type.replace(/^element /, '')].concat(args));
// }
if (!handler) {
if (type === 'error') {
throw new args[0];
}
return;
}
if (typeof handler === 'function') {
return handler.apply(this, args);
}
for (var i = 0; i < handler.length; i++) {
if (handler[i].apply(this, args) === false) {
ret = false;
}
}
return ret !== false;
};
EventEmitter.prototype.emit = function(type) {
var args = slice.call(arguments, 1)
, params = slice.call(arguments)
, el = this;
this._emit('event', params);
if (this.type === 'screen') {
return this._emit(type, args);
}
if (this._emit(type, args) === false) {
return false;
}
type = 'element ' + type;
args.unshift(this);
// `element` prefix
// params = [type].concat(args);
// no `element` prefix
// params.splice(1, 0, this);
do {
// el._emit('event', params);
if (!el._events[type]) continue;
if (el._emit(type, args) === false) {
return false;
}
} while (el = el.parent);
return true;
};
// For hooking into the main EventEmitter if we want to.
// Might be better to do things this way being that it
// will always be compatible with node, not to mention
// it gives us domain support as well.
// Node.prototype._emit = Node.prototype.emit;
// Node.prototype.emit = function(type) {
// var args, el;
//
// if (this.type === 'screen') {
// return this._emit.apply(this, arguments);
// }
//
// this._emit.apply(this, arguments);
// if (this._bubbleStopped) return false;
//
// args = slice.call(arguments, 1);
// el = this;
//
// args.unshift('element ' + type, this);
// this._bubbleStopped = false;
// //args.push(stopBubble);
//
// do {
// if (!el._events || !el._events[type]) continue;
// el._emit.apply(el, args);
// if (this._bubbleStopped) return false;
// } while (el = el.parent);
//
// return true;
// };
//
// Node.prototype._addListener = Node.prototype.addListener;
// Node.prototype.on =
// Node.prototype.addListener = function(type, listener) {
// function on() {
// if (listener.apply(this, arguments) === false) {
// this._bubbleStopped = true;
// }
// }
// on.listener = listener;
// return this._addListener(type, on);
// };
/**
* Expose
*/
exports = EventEmitter;
exports.EventEmitter = EventEmitter;
module.exports = exports;

221
node_modules/blessed/lib/gpmclient.js generated vendored Normal file
View File

@ -0,0 +1,221 @@
/**
* gpmclient.js - support the gpm mouse protocol
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
var net = require('net');
var fs = require('fs');
var EventEmitter = require('events').EventEmitter;
var GPM_USE_MAGIC = false;
var GPM_MOVE = 1
, GPM_DRAG = 2
, GPM_DOWN = 4
, GPM_UP = 8;
var GPM_DOUBLE = 32
, GPM_MFLAG = 128;
var GPM_REQ_NOPASTE = 3
, GPM_HARD = 256;
var GPM_MAGIC = 0x47706D4C;
var GPM_SOCKET = '/dev/gpmctl';
// typedef struct Gpm_Connect {
// unsigned short eventMask, defaultMask;
// unsigned short minMod, maxMod;
// int pid;
// int vc;
// } Gpm_Connect;
function send_config(socket, Gpm_Connect, callback) {
var buffer;
if (GPM_USE_MAGIC) {
buffer = new Buffer(20);
buffer.writeUInt32LE(GPM_MAGIC, 0);
buffer.writeUInt16LE(Gpm_Connect.eventMask, 4);
buffer.writeUInt16LE(Gpm_Connect.defaultMask, 6);
buffer.writeUInt16LE(Gpm_Connect.minMod, 8);
buffer.writeUInt16LE(Gpm_Connect.maxMod, 10);
buffer.writeInt16LE(process.pid, 12);
buffer.writeInt16LE(Gpm_Connect.vc, 16);
} else {
buffer = new Buffer(16);
buffer.writeUInt16LE(Gpm_Connect.eventMask, 0);
buffer.writeUInt16LE(Gpm_Connect.defaultMask, 2);
buffer.writeUInt16LE(Gpm_Connect.minMod, 4);
buffer.writeUInt16LE(Gpm_Connect.maxMod, 6);
buffer.writeInt16LE(Gpm_Connect.pid, 8);
buffer.writeInt16LE(Gpm_Connect.vc, 12);
}
socket.write(buffer, function() {
if (callback) callback();
});
}
// typedef struct Gpm_Event {
// unsigned char buttons, modifiers; // try to be a multiple of 4
// unsigned short vc;
// short dx, dy, x, y; // displacement x,y for this event, and absolute x,y
// enum Gpm_Etype type;
// // clicks e.g. double click are determined by time-based processing
// int clicks;
// enum Gpm_Margin margin;
// // wdx/y: displacement of wheels in this event. Absolute values are not
// // required, because wheel movement is typically used for scrolling
// // or selecting fields, not for cursor positioning. The application
// // can determine when the end of file or form is reached, and not
// // go any further.
// // A single mouse will use wdy, "vertical scroll" wheel.
// short wdx, wdy;
// } Gpm_Event;
function parseEvent(raw) {
var evnt = {};
evnt.buttons = raw[0];
evnt.modifiers = raw[1];
evnt.vc = raw.readUInt16LE(2);
evnt.dx = raw.readInt16LE(4);
evnt.dy = raw.readInt16LE(6);
evnt.x = raw.readInt16LE(8);
evnt.y = raw.readInt16LE(10);
evnt.type = raw.readInt16LE(12);
evnt.clicks = raw.readInt32LE(16);
evnt.margin = raw.readInt32LE(20);
evnt.wdx = raw.readInt16LE(24);
evnt.wdy = raw.readInt16LE(26);
return evnt;
}
function GpmClient(options) {
if (!(this instanceof GpmClient)) {
return new GpmClient(options);
}
EventEmitter.call(this);
var pid = process.pid;
// check tty for /dev/tty[n]
var path;
try {
path = fs.readlinkSync('/proc/' + pid + '/fd/0');
} catch (e) {
;
}
var tty = /tty[0-9]+$/.exec(path);
if (tty === null) {
// TODO: should also check for /dev/input/..
}
var vc;
if (tty) {
tty = tty[0];
vc = +/[0-9]+$/.exec(tty)[0];
}
var self = this;
if (tty) {
fs.stat(GPM_SOCKET, function(err, stat) {
if (err || !stat.isSocket()) {
return;
}
var conf = {
eventMask: 0xffff,
defaultMask: GPM_MOVE | GPM_HARD,
minMod: 0,
maxMod: 0xffff,
pid: pid,
vc: vc
};
var gpm = net.createConnection(GPM_SOCKET);
this.gpm = gpm;
gpm.on('connect', function() {
send_config(gpm, conf, function() {
conf.pid = 0;
conf.vc = GPM_REQ_NOPASTE;
//send_config(gpm, conf);
});
});
gpm.on('data', function(packet) {
var evnt = parseEvent(packet);
switch (evnt.type & 15) {
case GPM_MOVE:
if (evnt.dx || evnt.dy) {
self.emit('move', evnt.buttons, evnt.modifiers, evnt.x, evnt.y);
}
if (evnt.wdx || evnt.wdy) {
self.emit('mousewheel',
evnt.buttons, evnt.modifiers,
evnt.x, evnt.y, evnt.wdx, evnt.wdy);
}
break;
case GPM_DRAG:
if (evnt.dx || evnt.dy) {
self.emit('drag', evnt.buttons, evnt.modifiers, evnt.x, evnt.y);
}
if (evnt.wdx || evnt.wdy) {
self.emit('mousewheel',
evnt.buttons, evnt.modifiers,
evnt.x, evnt.y, evnt.wdx, evnt.wdy);
}
break;
case GPM_DOWN:
self.emit('btndown', evnt.buttons, evnt.modifiers, evnt.x, evnt.y);
if (evnt.type & GPM_DOUBLE) {
self.emit('dblclick', evnt.buttons, evnt.modifiers, evnt.x, evnt.y);
}
break;
case GPM_UP:
self.emit('btnup', evnt.buttons, evnt.modifiers, evnt.x, evnt.y);
if (!(evnt.type & GPM_MFLAG)) {
self.emit('click', evnt.buttons, evnt.modifiers, evnt.x, evnt.y);
}
break;
}
});
gpm.on('error', function() {
self.stop();
});
});
}
}
GpmClient.prototype.__proto__ = EventEmitter.prototype;
GpmClient.prototype.stop = function() {
if (this.gpm) {
this.gpm.end();
}
delete this.gpm;
};
GpmClient.prototype.ButtonName = function(btn) {
if (btn & 4) return 'left';
if (btn & 2) return 'middle';
if (btn & 1) return 'right';
return '';
};
GpmClient.prototype.hasShiftKey = function(mod) {
return (mod & 1) ? true : false;
};
GpmClient.prototype.hasCtrlKey = function(mod) {
return (mod & 4) ? true : false;
};
GpmClient.prototype.hasMetaKey = function(mod) {
return (mod & 8) ? true : false;
};
module.exports = GpmClient;

165
node_modules/blessed/lib/helpers.js generated vendored Normal file
View File

@ -0,0 +1,165 @@
/**
* helpers.js - helpers for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var fs = require('fs');
var unicode = require('./unicode');
/**
* Helpers
*/
var helpers = exports;
helpers.merge = function(a, b) {
Object.keys(b).forEach(function(key) {
a[key] = b[key];
});
return a;
};
helpers.asort = function(obj) {
return obj.sort(function(a, b) {
a = a.name.toLowerCase();
b = b.name.toLowerCase();
if (a[0] === '.' && b[0] === '.') {
a = a[1];
b = b[1];
} else {
a = a[0];
b = b[0];
}
return a > b ? 1 : (a < b ? -1 : 0);
});
};
helpers.hsort = function(obj) {
return obj.sort(function(a, b) {
return b.index - a.index;
});
};
helpers.findFile = function(start, target) {
return (function read(dir) {
var files, file, stat, out;
if (dir === '/dev' || dir === '/sys'
|| dir === '/proc' || dir === '/net') {
return null;
}
try {
files = fs.readdirSync(dir);
} catch (e) {
files = [];
}
for (var i = 0; i < files.length; i++) {
file = files[i];
if (file === target) {
return (dir === '/' ? '' : dir) + '/' + file;
}
try {
stat = fs.lstatSync((dir === '/' ? '' : dir) + '/' + file);
} catch (e) {
stat = null;
}
if (stat && stat.isDirectory() && !stat.isSymbolicLink()) {
out = read((dir === '/' ? '' : dir) + '/' + file);
if (out) return out;
}
}
return null;
})(start);
};
// Escape text for tag-enabled elements.
helpers.escape = function(text) {
return text.replace(/[{}]/g, function(ch) {
return ch === '{' ? '{open}' : '{close}';
});
};
helpers.parseTags = function(text, screen) {
return helpers.Element.prototype._parseTags.call(
{ parseTags: true, screen: screen || helpers.Screen.global }, text);
};
helpers.generateTags = function(style, text) {
var open = ''
, close = '';
Object.keys(style || {}).forEach(function(key) {
var val = style[key];
if (typeof val === 'string') {
val = val.replace(/^light(?!-)/, 'light-');
val = val.replace(/^bright(?!-)/, 'bright-');
open = '{' + val + '-' + key + '}' + open;
close += '{/' + val + '-' + key + '}';
} else {
if (val === true) {
open = '{' + key + '}' + open;
close += '{/' + key + '}';
}
}
});
if (text != null) {
return open + text + close;
}
return {
open: open,
close: close
};
};
helpers.attrToBinary = function(style, element) {
return helpers.Element.prototype.sattr.call(element || {}, style);
};
helpers.stripTags = function(text) {
if (!text) return '';
return text
.replace(/{(\/?)([\w\-,;!#]*)}/g, '')
.replace(/\x1b\[[\d;]*m/g, '');
};
helpers.cleanTags = function(text) {
return helpers.stripTags(text).trim();
};
helpers.dropUnicode = function(text) {
if (!text) return '';
return text
.replace(unicode.chars.all, '??')
.replace(unicode.chars.combining, '')
.replace(unicode.chars.surrogate, '?');
};
helpers.__defineGetter__('Screen', function() {
if (!helpers._screen) {
helpers._screen = require('./widgets/screen');
}
return helpers._screen;
});
helpers.__defineGetter__('Element', function() {
if (!helpers._element) {
helpers._element = require('./widgets/element');
}
return helpers._element;
});

339
node_modules/blessed/lib/keys.js generated vendored Normal file
View File

@ -0,0 +1,339 @@
/**
* keys.js - emit key presses
* Copyright (c) 2010-2015, Joyent, Inc. and other contributors (MIT License)
* https://github.com/chjj/blessed
*/
// Originally taken from the node.js tree:
//
// Copyright Joyent, Inc. and other Node contributors. All rights reserved.
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
var EventEmitter = require('events').EventEmitter;
// NOTE: node <=v0.8.x has no EventEmitter.listenerCount
function listenerCount(stream, event) {
return EventEmitter.listenerCount
? EventEmitter.listenerCount(stream, event)
: stream.listeners(event).length;
}
/**
* accepts a readable Stream instance and makes it emit "keypress" events
*/
function emitKeypressEvents(stream) {
if (stream._keypressDecoder) return;
var StringDecoder = require('string_decoder').StringDecoder; // lazy load
stream._keypressDecoder = new StringDecoder('utf8');
function onData(b) {
if (listenerCount(stream, 'keypress') > 0) {
var r = stream._keypressDecoder.write(b);
if (r) emitKeys(stream, r);
} else {
// Nobody's watching anyway
stream.removeListener('data', onData);
stream.on('newListener', onNewListener);
}
}
function onNewListener(event) {
if (event === 'keypress') {
stream.on('data', onData);
stream.removeListener('newListener', onNewListener);
}
}
if (listenerCount(stream, 'keypress') > 0) {
stream.on('data', onData);
} else {
stream.on('newListener', onNewListener);
}
}
exports.emitKeypressEvents = emitKeypressEvents;
/*
Some patterns seen in terminal key escape codes, derived from combos seen
at http://www.midnight-commander.org/browser/lib/tty/key.c
ESC letter
ESC [ letter
ESC [ modifier letter
ESC [ 1 ; modifier letter
ESC [ num char
ESC [ num ; modifier char
ESC O letter
ESC O modifier letter
ESC O 1 ; modifier letter
ESC N letter
ESC [ [ num ; modifier char
ESC [ [ 1 ; modifier letter
ESC ESC [ num char
ESC ESC O letter
- char is usually ~ but $ and ^ also happen with rxvt
- modifier is 1 +
(shift * 1) +
(left_alt * 2) +
(ctrl * 4) +
(right_alt * 8)
- two leading ESCs apparently mean the same as one leading ESC
*/
// Regexes used for ansi escape code splitting
var metaKeyCodeReAnywhere = /(?:\x1b)([a-zA-Z0-9])/;
var metaKeyCodeRe = new RegExp('^' + metaKeyCodeReAnywhere.source + '$');
var functionKeyCodeReAnywhere = new RegExp('(?:\x1b+)(O|N|\\[|\\[\\[)(?:' + [
'(\\d+)(?:;(\\d+))?([~^$])',
'(?:M([@ #!a`])(.)(.))', // mouse
'(?:1;)?(\\d+)?([a-zA-Z])'
].join('|') + ')');
var functionKeyCodeRe = new RegExp('^' + functionKeyCodeReAnywhere.source);
var escapeCodeReAnywhere = new RegExp([
functionKeyCodeReAnywhere.source, metaKeyCodeReAnywhere.source, /\x1b./.source
].join('|'));
function emitKeys(stream, s) {
if (Buffer.isBuffer(s)) {
if (s[0] > 127 && s[1] === undefined) {
s[0] -= 128;
s = '\x1b' + s.toString(stream.encoding || 'utf-8');
} else {
s = s.toString(stream.encoding || 'utf-8');
}
}
if (isMouse(s)) return;
var buffer = [];
var match;
while (match = escapeCodeReAnywhere.exec(s)) {
buffer = buffer.concat(s.slice(0, match.index).split(''));
buffer.push(match[0]);
s = s.slice(match.index + match[0].length);
}
buffer = buffer.concat(s.split(''));
buffer.forEach(function(s) {
var ch,
key = {
sequence: s,
name: undefined,
ctrl: false,
meta: false,
shift: false
},
parts;
if (s === '\r') {
// carriage return
key.name = 'return';
} else if (s === '\n') {
// enter, should have been called linefeed
key.name = 'enter';
// linefeed
// key.name = 'linefeed';
} else if (s === '\t') {
// tab
key.name = 'tab';
} else if (s === '\b' || s === '\x7f' ||
s === '\x1b\x7f' || s === '\x1b\b') {
// backspace or ctrl+h
key.name = 'backspace';
key.meta = (s.charAt(0) === '\x1b');
} else if (s === '\x1b' || s === '\x1b\x1b') {
// escape key
key.name = 'escape';
key.meta = (s.length === 2);
} else if (s === ' ' || s === '\x1b ') {
key.name = 'space';
key.meta = (s.length === 2);
} else if (s.length === 1 && s <= '\x1a') {
// ctrl+letter
key.name = String.fromCharCode(s.charCodeAt(0) + 'a'.charCodeAt(0) - 1);
key.ctrl = true;
} else if (s.length === 1 && s >= 'a' && s <= 'z') {
// lowercase letter
key.name = s;
} else if (s.length === 1 && s >= 'A' && s <= 'Z') {
// shift+letter
key.name = s.toLowerCase();
key.shift = true;
} else if (parts = metaKeyCodeRe.exec(s)) {
// meta+character key
key.name = parts[1].toLowerCase();
key.meta = true;
key.shift = /^[A-Z]$/.test(parts[1]);
} else if (parts = functionKeyCodeRe.exec(s)) {
// ansi escape sequence
// reassemble the key code leaving out leading \x1b's,
// the modifier key bitflag and any meaningless "1;" sequence
var code = (parts[1] || '') + (parts[2] || '') +
(parts[4] || '') + (parts[9] || ''),
modifier = (parts[3] || parts[8] || 1) - 1;
// Parse the key modifier
key.ctrl = !!(modifier & 4);
key.meta = !!(modifier & 10);
key.shift = !!(modifier & 1);
key.code = code;
// Parse the key itself
switch (code) {
/* xterm/gnome ESC O letter */
case 'OP': key.name = 'f1'; break;
case 'OQ': key.name = 'f2'; break;
case 'OR': key.name = 'f3'; break;
case 'OS': key.name = 'f4'; break;
/* xterm/rxvt ESC [ number ~ */
case '[11~': key.name = 'f1'; break;
case '[12~': key.name = 'f2'; break;
case '[13~': key.name = 'f3'; break;
case '[14~': key.name = 'f4'; break;
/* from Cygwin and used in libuv */
case '[[A': key.name = 'f1'; break;
case '[[B': key.name = 'f2'; break;
case '[[C': key.name = 'f3'; break;
case '[[D': key.name = 'f4'; break;
case '[[E': key.name = 'f5'; break;
/* common */
case '[15~': key.name = 'f5'; break;
case '[17~': key.name = 'f6'; break;
case '[18~': key.name = 'f7'; break;
case '[19~': key.name = 'f8'; break;
case '[20~': key.name = 'f9'; break;
case '[21~': key.name = 'f10'; break;
case '[23~': key.name = 'f11'; break;
case '[24~': key.name = 'f12'; break;
/* xterm ESC [ letter */
case '[A': key.name = 'up'; break;
case '[B': key.name = 'down'; break;
case '[C': key.name = 'right'; break;
case '[D': key.name = 'left'; break;
case '[E': key.name = 'clear'; break;
case '[F': key.name = 'end'; break;
case '[H': key.name = 'home'; break;
/* xterm/gnome ESC O letter */
case 'OA': key.name = 'up'; break;
case 'OB': key.name = 'down'; break;
case 'OC': key.name = 'right'; break;
case 'OD': key.name = 'left'; break;
case 'OE': key.name = 'clear'; break;
case 'OF': key.name = 'end'; break;
case 'OH': key.name = 'home'; break;
/* xterm/rxvt ESC [ number ~ */
case '[1~': key.name = 'home'; break;
case '[2~': key.name = 'insert'; break;
case '[3~': key.name = 'delete'; break;
case '[4~': key.name = 'end'; break;
case '[5~': key.name = 'pageup'; break;
case '[6~': key.name = 'pagedown'; break;
/* putty */
case '[[5~': key.name = 'pageup'; break;
case '[[6~': key.name = 'pagedown'; break;
/* rxvt */
case '[7~': key.name = 'home'; break;
case '[8~': key.name = 'end'; break;
/* rxvt keys with modifiers */
case '[a': key.name = 'up'; key.shift = true; break;
case '[b': key.name = 'down'; key.shift = true; break;
case '[c': key.name = 'right'; key.shift = true; break;
case '[d': key.name = 'left'; key.shift = true; break;
case '[e': key.name = 'clear'; key.shift = true; break;
case '[2$': key.name = 'insert'; key.shift = true; break;
case '[3$': key.name = 'delete'; key.shift = true; break;
case '[5$': key.name = 'pageup'; key.shift = true; break;
case '[6$': key.name = 'pagedown'; key.shift = true; break;
case '[7$': key.name = 'home'; key.shift = true; break;
case '[8$': key.name = 'end'; key.shift = true; break;
case 'Oa': key.name = 'up'; key.ctrl = true; break;
case 'Ob': key.name = 'down'; key.ctrl = true; break;
case 'Oc': key.name = 'right'; key.ctrl = true; break;
case 'Od': key.name = 'left'; key.ctrl = true; break;
case 'Oe': key.name = 'clear'; key.ctrl = true; break;
case '[2^': key.name = 'insert'; key.ctrl = true; break;
case '[3^': key.name = 'delete'; key.ctrl = true; break;
case '[5^': key.name = 'pageup'; key.ctrl = true; break;
case '[6^': key.name = 'pagedown'; key.ctrl = true; break;
case '[7^': key.name = 'home'; key.ctrl = true; break;
case '[8^': key.name = 'end'; key.ctrl = true; break;
/* misc. */
case '[Z': key.name = 'tab'; key.shift = true; break;
default: key.name = 'undefined'; break;
}
}
// Don't emit a key if no name was found
if (key.name === undefined) {
key = undefined;
}
if (s.length === 1) {
ch = s;
}
if (key || ch) {
stream.emit('keypress', ch, key);
// if (key && key.name === 'return') {
// var nkey = {};
// Object.keys(key).forEach(function(k) {
// nkey[k] = key[k];
// });
// nkey.name = 'enter';
// stream.emit('keypress', ch, nkey);
// }
}
});
}
function isMouse(s) {
return /\x1b\[M/.test(s)
|| /\x1b\[M([\x00\u0020-\uffff]{3})/.test(s)
|| /\x1b\[(\d+;\d+;\d+)M/.test(s)
|| /\x1b\[<(\d+;\d+;\d+)([mM])/.test(s)
|| /\x1b\[<(\d+;\d+;\d+;\d+)&w/.test(s)
|| /\x1b\[24([0135])~\[(\d+),(\d+)\]\r/.test(s)
|| /\x1b\[(O|I)/.test(s);
}

4295
node_modules/blessed/lib/program.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

3018
node_modules/blessed/lib/tput.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

790
node_modules/blessed/lib/unicode.js generated vendored Normal file
View File

@ -0,0 +1,790 @@
/**
* unicode.js - east asian width and surrogate pairs
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
* Borrowed from vangie/east-asian-width, komagata/eastasianwidth,
* and mathiasbynens/String.prototype.codePointAt. Licenses below.
*/
// east-asian-width
//
// Copyright (c) 2015 Vangie Du
// https://github.com/vangie/east-asian-width
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
// eastasianwidth
//
// Copyright (c) 2013, Masaki Komagata
// https://github.com/komagata/eastasianwidth
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// String.prototype.codePointAt
//
// Copyright Mathias Bynens <https://mathiasbynens.be/>
// https://github.com/mathiasbynens/String.prototype.codePointAt
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// String.fromCodePoint
//
// Copyright Mathias Bynens <https://mathiasbynens.be/>
// https://github.com/mathiasbynens/String.fromCodePoint
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
var stringFromCharCode = String.fromCharCode;
var floor = Math.floor;
/**
* Wide, Surrogates, and Combining
*/
exports.charWidth = function(str, i) {
var point = typeof str !== 'number'
? exports.codePointAt(str, i || 0)
: str;
// nul
if (point === 0) return 0;
// tab
if (point === 0x09) {
if (!exports.blessed) {
exports.blessed = require('../');
}
return exports.blessed.screen.global
? exports.blessed.screen.global.tabc.length
: 8;
}
// 8-bit control characters (2-width according to unicode??)
if (point < 32 || (point >= 0x7f && point < 0xa0)) {
return 0;
}
// search table of non-spacing characters
// is ucs combining or C0/C1 control character
if (exports.combining[point]) {
return 0;
}
// check for double-wide
// if (point >= 0x1100
// && (point <= 0x115f // Hangul Jamo init. consonants
// || point === 0x2329 || point === 0x232a
// || (point >= 0x2e80 && point <= 0xa4cf
// && point !== 0x303f) // CJK ... Yi
// || (point >= 0xac00 && point <= 0xd7a3) // Hangul Syllables
// || (point >= 0xf900 && point <= 0xfaff) // CJK Compatibility Ideographs
// || (point >= 0xfe10 && point <= 0xfe19) // Vertical forms
// || (point >= 0xfe30 && point <= 0xfe6f) // CJK Compatibility Forms
// || (point >= 0xff00 && point <= 0xff60) // Fullwidth Forms
// || (point >= 0xffe0 && point <= 0xffe6)
// || (point >= 0x20000 && point <= 0x2fffd)
// || (point >= 0x30000 && point <= 0x3fffd))) {
// return 2;
// }
// check for double-wide
if ((0x3000 === point)
|| (0xFF01 <= point && point <= 0xFF60)
|| (0xFFE0 <= point && point <= 0xFFE6)) {
return 2;
}
if ((0x1100 <= point && point <= 0x115F)
|| (0x11A3 <= point && point <= 0x11A7)
|| (0x11FA <= point && point <= 0x11FF)
|| (0x2329 <= point && point <= 0x232A)
|| (0x2E80 <= point && point <= 0x2E99)
|| (0x2E9B <= point && point <= 0x2EF3)
|| (0x2F00 <= point && point <= 0x2FD5)
|| (0x2FF0 <= point && point <= 0x2FFB)
|| (0x3001 <= point && point <= 0x303E)
|| (0x3041 <= point && point <= 0x3096)
|| (0x3099 <= point && point <= 0x30FF)
|| (0x3105 <= point && point <= 0x312D)
|| (0x3131 <= point && point <= 0x318E)
|| (0x3190 <= point && point <= 0x31BA)
|| (0x31C0 <= point && point <= 0x31E3)
|| (0x31F0 <= point && point <= 0x321E)
|| (0x3220 <= point && point <= 0x3247)
|| (0x3250 <= point && point <= 0x32FE)
|| (0x3300 <= point && point <= 0x4DBF)
|| (0x4E00 <= point && point <= 0xA48C)
|| (0xA490 <= point && point <= 0xA4C6)
|| (0xA960 <= point && point <= 0xA97C)
|| (0xAC00 <= point && point <= 0xD7A3)
|| (0xD7B0 <= point && point <= 0xD7C6)
|| (0xD7CB <= point && point <= 0xD7FB)
|| (0xF900 <= point && point <= 0xFAFF)
|| (0xFE10 <= point && point <= 0xFE19)
|| (0xFE30 <= point && point <= 0xFE52)
|| (0xFE54 <= point && point <= 0xFE66)
|| (0xFE68 <= point && point <= 0xFE6B)
|| (0x1B000 <= point && point <= 0x1B001)
|| (0x1F200 <= point && point <= 0x1F202)
|| (0x1F210 <= point && point <= 0x1F23A)
|| (0x1F240 <= point && point <= 0x1F248)
|| (0x1F250 <= point && point <= 0x1F251)
|| (0x20000 <= point && point <= 0x2F73F)
|| (0x2B740 <= point && point <= 0x2FFFD)
|| (0x30000 <= point && point <= 0x3FFFD)) {
return 2;
}
// CJK Ambiguous
// http://www.unicode.org/reports/tr11/
// http://www.unicode.org/reports/tr11/#Ambiguous
if (process.env.NCURSES_CJK_WIDTH) {
if ((0x00A1 === point)
|| (0x00A4 === point)
|| (0x00A7 <= point && point <= 0x00A8)
|| (0x00AA === point)
|| (0x00AD <= point && point <= 0x00AE)
|| (0x00B0 <= point && point <= 0x00B4)
|| (0x00B6 <= point && point <= 0x00BA)
|| (0x00BC <= point && point <= 0x00BF)
|| (0x00C6 === point)
|| (0x00D0 === point)
|| (0x00D7 <= point && point <= 0x00D8)
|| (0x00DE <= point && point <= 0x00E1)
|| (0x00E6 === point)
|| (0x00E8 <= point && point <= 0x00EA)
|| (0x00EC <= point && point <= 0x00ED)
|| (0x00F0 === point)
|| (0x00F2 <= point && point <= 0x00F3)
|| (0x00F7 <= point && point <= 0x00FA)
|| (0x00FC === point)
|| (0x00FE === point)
|| (0x0101 === point)
|| (0x0111 === point)
|| (0x0113 === point)
|| (0x011B === point)
|| (0x0126 <= point && point <= 0x0127)
|| (0x012B === point)
|| (0x0131 <= point && point <= 0x0133)
|| (0x0138 === point)
|| (0x013F <= point && point <= 0x0142)
|| (0x0144 === point)
|| (0x0148 <= point && point <= 0x014B)
|| (0x014D === point)
|| (0x0152 <= point && point <= 0x0153)
|| (0x0166 <= point && point <= 0x0167)
|| (0x016B === point)
|| (0x01CE === point)
|| (0x01D0 === point)
|| (0x01D2 === point)
|| (0x01D4 === point)
|| (0x01D6 === point)
|| (0x01D8 === point)
|| (0x01DA === point)
|| (0x01DC === point)
|| (0x0251 === point)
|| (0x0261 === point)
|| (0x02C4 === point)
|| (0x02C7 === point)
|| (0x02C9 <= point && point <= 0x02CB)
|| (0x02CD === point)
|| (0x02D0 === point)
|| (0x02D8 <= point && point <= 0x02DB)
|| (0x02DD === point)
|| (0x02DF === point)
|| (0x0300 <= point && point <= 0x036F)
|| (0x0391 <= point && point <= 0x03A1)
|| (0x03A3 <= point && point <= 0x03A9)
|| (0x03B1 <= point && point <= 0x03C1)
|| (0x03C3 <= point && point <= 0x03C9)
|| (0x0401 === point)
|| (0x0410 <= point && point <= 0x044F)
|| (0x0451 === point)
|| (0x2010 === point)
|| (0x2013 <= point && point <= 0x2016)
|| (0x2018 <= point && point <= 0x2019)
|| (0x201C <= point && point <= 0x201D)
|| (0x2020 <= point && point <= 0x2022)
|| (0x2024 <= point && point <= 0x2027)
|| (0x2030 === point)
|| (0x2032 <= point && point <= 0x2033)
|| (0x2035 === point)
|| (0x203B === point)
|| (0x203E === point)
|| (0x2074 === point)
|| (0x207F === point)
|| (0x2081 <= point && point <= 0x2084)
|| (0x20AC === point)
|| (0x2103 === point)
|| (0x2105 === point)
|| (0x2109 === point)
|| (0x2113 === point)
|| (0x2116 === point)
|| (0x2121 <= point && point <= 0x2122)
|| (0x2126 === point)
|| (0x212B === point)
|| (0x2153 <= point && point <= 0x2154)
|| (0x215B <= point && point <= 0x215E)
|| (0x2160 <= point && point <= 0x216B)
|| (0x2170 <= point && point <= 0x2179)
|| (0x2189 === point)
|| (0x2190 <= point && point <= 0x2199)
|| (0x21B8 <= point && point <= 0x21B9)
|| (0x21D2 === point)
|| (0x21D4 === point)
|| (0x21E7 === point)
|| (0x2200 === point)
|| (0x2202 <= point && point <= 0x2203)
|| (0x2207 <= point && point <= 0x2208)
|| (0x220B === point)
|| (0x220F === point)
|| (0x2211 === point)
|| (0x2215 === point)
|| (0x221A === point)
|| (0x221D <= point && point <= 0x2220)
|| (0x2223 === point)
|| (0x2225 === point)
|| (0x2227 <= point && point <= 0x222C)
|| (0x222E === point)
|| (0x2234 <= point && point <= 0x2237)
|| (0x223C <= point && point <= 0x223D)
|| (0x2248 === point)
|| (0x224C === point)
|| (0x2252 === point)
|| (0x2260 <= point && point <= 0x2261)
|| (0x2264 <= point && point <= 0x2267)
|| (0x226A <= point && point <= 0x226B)
|| (0x226E <= point && point <= 0x226F)
|| (0x2282 <= point && point <= 0x2283)
|| (0x2286 <= point && point <= 0x2287)
|| (0x2295 === point)
|| (0x2299 === point)
|| (0x22A5 === point)
|| (0x22BF === point)
|| (0x2312 === point)
|| (0x2460 <= point && point <= 0x24E9)
|| (0x24EB <= point && point <= 0x254B)
|| (0x2550 <= point && point <= 0x2573)
|| (0x2580 <= point && point <= 0x258F)
|| (0x2592 <= point && point <= 0x2595)
|| (0x25A0 <= point && point <= 0x25A1)
|| (0x25A3 <= point && point <= 0x25A9)
|| (0x25B2 <= point && point <= 0x25B3)
|| (0x25B6 <= point && point <= 0x25B7)
|| (0x25BC <= point && point <= 0x25BD)
|| (0x25C0 <= point && point <= 0x25C1)
|| (0x25C6 <= point && point <= 0x25C8)
|| (0x25CB === point)
|| (0x25CE <= point && point <= 0x25D1)
|| (0x25E2 <= point && point <= 0x25E5)
|| (0x25EF === point)
|| (0x2605 <= point && point <= 0x2606)
|| (0x2609 === point)
|| (0x260E <= point && point <= 0x260F)
|| (0x2614 <= point && point <= 0x2615)
|| (0x261C === point)
|| (0x261E === point)
|| (0x2640 === point)
|| (0x2642 === point)
|| (0x2660 <= point && point <= 0x2661)
|| (0x2663 <= point && point <= 0x2665)
|| (0x2667 <= point && point <= 0x266A)
|| (0x266C <= point && point <= 0x266D)
|| (0x266F === point)
|| (0x269E <= point && point <= 0x269F)
|| (0x26BE <= point && point <= 0x26BF)
|| (0x26C4 <= point && point <= 0x26CD)
|| (0x26CF <= point && point <= 0x26E1)
|| (0x26E3 === point)
|| (0x26E8 <= point && point <= 0x26FF)
|| (0x273D === point)
|| (0x2757 === point)
|| (0x2776 <= point && point <= 0x277F)
|| (0x2B55 <= point && point <= 0x2B59)
|| (0x3248 <= point && point <= 0x324F)
|| (0xE000 <= point && point <= 0xF8FF)
|| (0xFE00 <= point && point <= 0xFE0F)
|| (0xFFFD === point)
|| (0x1F100 <= point && point <= 0x1F10A)
|| (0x1F110 <= point && point <= 0x1F12D)
|| (0x1F130 <= point && point <= 0x1F169)
|| (0x1F170 <= point && point <= 0x1F19A)
|| (0xE0100 <= point && point <= 0xE01EF)
|| (0xF0000 <= point && point <= 0xFFFFD)
|| (0x100000 <= point && point <= 0x10FFFD)) {
return +process.env.NCURSES_CJK_WIDTH || 1;
}
}
return 1;
};
exports.strWidth = function(str) {
var width = 0;
for (var i = 0; i < str.length; i++) {
width += exports.charWidth(str, i);
if (exports.isSurrogate(str, i)) i++;
}
return width;
};
exports.isSurrogate = function(str, i) {
var point = typeof str !== 'number'
? exports.codePointAt(str, i || 0)
: str;
return point > 0x00ffff;
};
exports.combiningTable = [
[0x0300, 0x036F], [0x0483, 0x0486], [0x0488, 0x0489],
[0x0591, 0x05BD], [0x05BF, 0x05BF], [0x05C1, 0x05C2],
[0x05C4, 0x05C5], [0x05C7, 0x05C7], [0x0600, 0x0603],
[0x0610, 0x0615], [0x064B, 0x065E], [0x0670, 0x0670],
[0x06D6, 0x06E4], [0x06E7, 0x06E8], [0x06EA, 0x06ED],
[0x070F, 0x070F], [0x0711, 0x0711], [0x0730, 0x074A],
[0x07A6, 0x07B0], [0x07EB, 0x07F3], [0x0901, 0x0902],
[0x093C, 0x093C], [0x0941, 0x0948], [0x094D, 0x094D],
[0x0951, 0x0954], [0x0962, 0x0963], [0x0981, 0x0981],
[0x09BC, 0x09BC], [0x09C1, 0x09C4], [0x09CD, 0x09CD],
[0x09E2, 0x09E3], [0x0A01, 0x0A02], [0x0A3C, 0x0A3C],
[0x0A41, 0x0A42], [0x0A47, 0x0A48], [0x0A4B, 0x0A4D],
[0x0A70, 0x0A71], [0x0A81, 0x0A82], [0x0ABC, 0x0ABC],
[0x0AC1, 0x0AC5], [0x0AC7, 0x0AC8], [0x0ACD, 0x0ACD],
[0x0AE2, 0x0AE3], [0x0B01, 0x0B01], [0x0B3C, 0x0B3C],
[0x0B3F, 0x0B3F], [0x0B41, 0x0B43], [0x0B4D, 0x0B4D],
[0x0B56, 0x0B56], [0x0B82, 0x0B82], [0x0BC0, 0x0BC0],
[0x0BCD, 0x0BCD], [0x0C3E, 0x0C40], [0x0C46, 0x0C48],
[0x0C4A, 0x0C4D], [0x0C55, 0x0C56], [0x0CBC, 0x0CBC],
[0x0CBF, 0x0CBF], [0x0CC6, 0x0CC6], [0x0CCC, 0x0CCD],
[0x0CE2, 0x0CE3], [0x0D41, 0x0D43], [0x0D4D, 0x0D4D],
[0x0DCA, 0x0DCA], [0x0DD2, 0x0DD4], [0x0DD6, 0x0DD6],
[0x0E31, 0x0E31], [0x0E34, 0x0E3A], [0x0E47, 0x0E4E],
[0x0EB1, 0x0EB1], [0x0EB4, 0x0EB9], [0x0EBB, 0x0EBC],
[0x0EC8, 0x0ECD], [0x0F18, 0x0F19], [0x0F35, 0x0F35],
[0x0F37, 0x0F37], [0x0F39, 0x0F39], [0x0F71, 0x0F7E],
[0x0F80, 0x0F84], [0x0F86, 0x0F87], [0x0F90, 0x0F97],
[0x0F99, 0x0FBC], [0x0FC6, 0x0FC6], [0x102D, 0x1030],
[0x1032, 0x1032], [0x1036, 0x1037], [0x1039, 0x1039],
[0x1058, 0x1059], [0x1160, 0x11FF], [0x135F, 0x135F],
[0x1712, 0x1714], [0x1732, 0x1734], [0x1752, 0x1753],
[0x1772, 0x1773], [0x17B4, 0x17B5], [0x17B7, 0x17BD],
[0x17C6, 0x17C6], [0x17C9, 0x17D3], [0x17DD, 0x17DD],
[0x180B, 0x180D], [0x18A9, 0x18A9], [0x1920, 0x1922],
[0x1927, 0x1928], [0x1932, 0x1932], [0x1939, 0x193B],
[0x1A17, 0x1A18], [0x1B00, 0x1B03], [0x1B34, 0x1B34],
[0x1B36, 0x1B3A], [0x1B3C, 0x1B3C], [0x1B42, 0x1B42],
[0x1B6B, 0x1B73], [0x1DC0, 0x1DCA], [0x1DFE, 0x1DFF],
[0x200B, 0x200F], [0x202A, 0x202E], [0x2060, 0x2063],
[0x206A, 0x206F], [0x20D0, 0x20EF], [0x302A, 0x302F],
[0x3099, 0x309A], [0xA806, 0xA806], [0xA80B, 0xA80B],
[0xA825, 0xA826], [0xFB1E, 0xFB1E], [0xFE00, 0xFE0F],
[0xFE20, 0xFE23], [0xFEFF, 0xFEFF], [0xFFF9, 0xFFFB],
[0x10A01, 0x10A03], [0x10A05, 0x10A06], [0x10A0C, 0x10A0F],
[0x10A38, 0x10A3A], [0x10A3F, 0x10A3F], [0x1D167, 0x1D169],
[0x1D173, 0x1D182], [0x1D185, 0x1D18B], [0x1D1AA, 0x1D1AD],
[0x1D242, 0x1D244], [0xE0001, 0xE0001], [0xE0020, 0xE007F],
[0xE0100, 0xE01EF]
];
exports.combining = exports.combiningTable.reduce(function(out, row) {
for (var i = row[0]; i <= row[1]; i++) {
out[i] = true;
}
return out;
}, {});
exports.isCombining = function(str, i) {
var point = typeof str !== 'number'
? exports.codePointAt(str, i || 0)
: str;
return exports.combining[point] === true;
};
/**
* Code Point Helpers
*/
exports.codePointAt = function(str, position) {
if (str == null) {
throw TypeError();
}
var string = String(str);
if (string.codePointAt) {
return string.codePointAt(position);
}
var size = string.length;
// `ToInteger`
var index = position ? Number(position) : 0;
if (index !== index) { // better `isNaN`
index = 0;
}
// Account for out-of-bounds indices:
if (index < 0 || index >= size) {
return undefined;
}
// Get the first code unit
var first = string.charCodeAt(index);
var second;
if ( // check if its the start of a surrogate pair
first >= 0xD800 && first <= 0xDBFF && // high surrogate
size > index + 1 // there is a next code unit
) {
second = string.charCodeAt(index + 1);
if (second >= 0xDC00 && second <= 0xDFFF) { // low surrogate
// http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
}
}
return first;
};
// exports.codePointAt = function(str, position) {
// position = +position || 0;
// var x = str.charCodeAt(position);
// var y = str.length > 1 ? str.charCodeAt(position + 1) : 0;
// var point = x;
// if ((0xD800 <= x && x <= 0xDBFF) && (0xDC00 <= y && y <= 0xDFFF)) {
// x &= 0x3FF;
// y &= 0x3FF;
// point = (x << 10) | y;
// point += 0x10000;
// }
// return point;
// };
exports.fromCodePoint = function() {
if (String.fromCodePoint) {
return String.fromCodePoint.apply(String, arguments);
}
var MAX_SIZE = 0x4000;
var codeUnits = [];
var highSurrogate;
var lowSurrogate;
var index = -1;
var length = arguments.length;
if (!length) {
return '';
}
var result = '';
while (++index < length) {
var codePoint = Number(arguments[index]);
if (
!isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity`
codePoint < 0 || // not a valid Unicode code point
codePoint > 0x10FFFF || // not a valid Unicode code point
floor(codePoint) !== codePoint // not an integer
) {
throw RangeError('Invalid code point: ' + codePoint);
}
if (codePoint <= 0xFFFF) { // BMP code point
codeUnits.push(codePoint);
} else { // Astral code point; split in surrogate halves
// http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
codePoint -= 0x10000;
highSurrogate = (codePoint >> 10) + 0xD800;
lowSurrogate = (codePoint % 0x400) + 0xDC00;
codeUnits.push(highSurrogate, lowSurrogate);
}
if (index + 1 === length || codeUnits.length > MAX_SIZE) {
result += stringFromCharCode.apply(null, codeUnits);
codeUnits.length = 0;
}
}
return result;
};
/**
* Regexes
*/
exports.chars = {};
// Double width characters that are _not_ surrogate pairs.
// NOTE: 0x20000 - 0x2fffd and 0x30000 - 0x3fffd are not necessary for this
// regex anyway. This regex is used to put a blank char after wide chars to
// be eaten, however, if this is a surrogate pair, parseContent already adds
// the extra one char because its length equals 2 instead of 1.
exports.chars.wide = new RegExp('(['
+ '\\u1100-\\u115f' // Hangul Jamo init. consonants
+ '\\u2329\\u232a'
+ '\\u2e80-\\u303e\\u3040-\\ua4cf' // CJK ... Yi
+ '\\uac00-\\ud7a3' // Hangul Syllables
+ '\\uf900-\\ufaff' // CJK Compatibility Ideographs
+ '\\ufe10-\\ufe19' // Vertical forms
+ '\\ufe30-\\ufe6f' // CJK Compatibility Forms
+ '\\uff00-\\uff60' // Fullwidth Forms
+ '\\uffe0-\\uffe6'
+ '])', 'g');
// All surrogate pair wide chars.
exports.chars.swide = new RegExp('('
// 0x20000 - 0x2fffd:
+ '[\\ud840-\\ud87f][\\udc00-\\udffd]'
+ '|'
// 0x30000 - 0x3fffd:
+ '[\\ud880-\\ud8bf][\\udc00-\\udffd]'
+ ')', 'g');
// All wide chars including surrogate pairs.
exports.chars.all = new RegExp('('
+ exports.chars.swide.source.slice(1, -1)
+ '|'
+ exports.chars.wide.source.slice(1, -1)
+ ')', 'g');
// Regex to detect a surrogate pair.
exports.chars.surrogate = /[\ud800-\udbff][\udc00-\udfff]/g;
// Regex to find combining characters.
exports.chars.combining = exports.combiningTable.reduce(function(out, row) {
var low, high, range;
if (row[0] > 0x00ffff) {
low = exports.fromCodePoint(row[0]);
low = [
hexify(low.charCodeAt(0)),
hexify(low.charCodeAt(1))
];
high = exports.fromCodePoint(row[1]);
high = [
hexify(high.charCodeAt(0)),
hexify(high.charCodeAt(1))
];
range = '[\\u' + low[0] + '-' + '\\u' + high[0] + ']'
+ '[\\u' + low[1] + '-' + '\\u' + high[1] + ']';
if (!~out.indexOf('|')) out += ']';
out += '|' + range;
} else {
low = hexify(row[0]);
high = hexify(row[1]);
low = '\\u' + low;
high = '\\u' + high;
out += low + '-' + high;
}
return out;
}, '[');
exports.chars.combining = new RegExp(exports.chars.combining, 'g');
function hexify(n) {
n = n.toString(16);
while (n.length < 4) n = '0' + n;
return n;
}
/*
exports.chars.combining = new RegExp(
'['
+ '\\u0300-\\u036f'
+ '\\u0483-\\u0486'
+ '\\u0488-\\u0489'
+ '\\u0591-\\u05bd'
+ '\\u05bf-\\u05bf'
+ '\\u05c1-\\u05c2'
+ '\\u05c4-\\u05c5'
+ '\\u05c7-\\u05c7'
+ '\\u0600-\\u0603'
+ '\\u0610-\\u0615'
+ '\\u064b-\\u065e'
+ '\\u0670-\\u0670'
+ '\\u06d6-\\u06e4'
+ '\\u06e7-\\u06e8'
+ '\\u06ea-\\u06ed'
+ '\\u070f-\\u070f'
+ '\\u0711-\\u0711'
+ '\\u0730-\\u074a'
+ '\\u07a6-\\u07b0'
+ '\\u07eb-\\u07f3'
+ '\\u0901-\\u0902'
+ '\\u093c-\\u093c'
+ '\\u0941-\\u0948'
+ '\\u094d-\\u094d'
+ '\\u0951-\\u0954'
+ '\\u0962-\\u0963'
+ '\\u0981-\\u0981'
+ '\\u09bc-\\u09bc'
+ '\\u09c1-\\u09c4'
+ '\\u09cd-\\u09cd'
+ '\\u09e2-\\u09e3'
+ '\\u0a01-\\u0a02'
+ '\\u0a3c-\\u0a3c'
+ '\\u0a41-\\u0a42'
+ '\\u0a47-\\u0a48'
+ '\\u0a4b-\\u0a4d'
+ '\\u0a70-\\u0a71'
+ '\\u0a81-\\u0a82'
+ '\\u0abc-\\u0abc'
+ '\\u0ac1-\\u0ac5'
+ '\\u0ac7-\\u0ac8'
+ '\\u0acd-\\u0acd'
+ '\\u0ae2-\\u0ae3'
+ '\\u0b01-\\u0b01'
+ '\\u0b3c-\\u0b3c'
+ '\\u0b3f-\\u0b3f'
+ '\\u0b41-\\u0b43'
+ '\\u0b4d-\\u0b4d'
+ '\\u0b56-\\u0b56'
+ '\\u0b82-\\u0b82'
+ '\\u0bc0-\\u0bc0'
+ '\\u0bcd-\\u0bcd'
+ '\\u0c3e-\\u0c40'
+ '\\u0c46-\\u0c48'
+ '\\u0c4a-\\u0c4d'
+ '\\u0c55-\\u0c56'
+ '\\u0cbc-\\u0cbc'
+ '\\u0cbf-\\u0cbf'
+ '\\u0cc6-\\u0cc6'
+ '\\u0ccc-\\u0ccd'
+ '\\u0ce2-\\u0ce3'
+ '\\u0d41-\\u0d43'
+ '\\u0d4d-\\u0d4d'
+ '\\u0dca-\\u0dca'
+ '\\u0dd2-\\u0dd4'
+ '\\u0dd6-\\u0dd6'
+ '\\u0e31-\\u0e31'
+ '\\u0e34-\\u0e3a'
+ '\\u0e47-\\u0e4e'
+ '\\u0eb1-\\u0eb1'
+ '\\u0eb4-\\u0eb9'
+ '\\u0ebb-\\u0ebc'
+ '\\u0ec8-\\u0ecd'
+ '\\u0f18-\\u0f19'
+ '\\u0f35-\\u0f35'
+ '\\u0f37-\\u0f37'
+ '\\u0f39-\\u0f39'
+ '\\u0f71-\\u0f7e'
+ '\\u0f80-\\u0f84'
+ '\\u0f86-\\u0f87'
+ '\\u0f90-\\u0f97'
+ '\\u0f99-\\u0fbc'
+ '\\u0fc6-\\u0fc6'
+ '\\u102d-\\u1030'
+ '\\u1032-\\u1032'
+ '\\u1036-\\u1037'
+ '\\u1039-\\u1039'
+ '\\u1058-\\u1059'
+ '\\u1160-\\u11ff'
+ '\\u135f-\\u135f'
+ '\\u1712-\\u1714'
+ '\\u1732-\\u1734'
+ '\\u1752-\\u1753'
+ '\\u1772-\\u1773'
+ '\\u17b4-\\u17b5'
+ '\\u17b7-\\u17bd'
+ '\\u17c6-\\u17c6'
+ '\\u17c9-\\u17d3'
+ '\\u17dd-\\u17dd'
+ '\\u180b-\\u180d'
+ '\\u18a9-\\u18a9'
+ '\\u1920-\\u1922'
+ '\\u1927-\\u1928'
+ '\\u1932-\\u1932'
+ '\\u1939-\\u193b'
+ '\\u1a17-\\u1a18'
+ '\\u1b00-\\u1b03'
+ '\\u1b34-\\u1b34'
+ '\\u1b36-\\u1b3a'
+ '\\u1b3c-\\u1b3c'
+ '\\u1b42-\\u1b42'
+ '\\u1b6b-\\u1b73'
+ '\\u1dc0-\\u1dca'
+ '\\u1dfe-\\u1dff'
+ '\\u200b-\\u200f'
+ '\\u202a-\\u202e'
+ '\\u2060-\\u2063'
+ '\\u206a-\\u206f'
+ '\\u20d0-\\u20ef'
+ '\\u302a-\\u302f'
+ '\\u3099-\\u309a'
+ '\\ua806-\\ua806'
+ '\\ua80b-\\ua80b'
+ '\\ua825-\\ua826'
+ '\\ufb1e-\\ufb1e'
+ '\\ufe00-\\ufe0f'
+ '\\ufe20-\\ufe23'
+ '\\ufeff-\\ufeff'
+ '\\ufff9-\\ufffb'
+ ']'
+ '|[\\ud802-\\ud802][\\ude01-\\ude03]'
+ '|[\\ud802-\\ud802][\\ude05-\\ude06]'
+ '|[\\ud802-\\ud802][\\ude0c-\\ude0f]'
+ '|[\\ud802-\\ud802][\\ude38-\\ude3a]'
+ '|[\\ud802-\\ud802][\\ude3f-\\ude3f]'
+ '|[\\ud834-\\ud834][\\udd67-\\udd69]'
+ '|[\\ud834-\\ud834][\\udd73-\\udd82]'
+ '|[\\ud834-\\ud834][\\udd85-\\udd8b]'
+ '|[\\ud834-\\ud834][\\uddaa-\\uddad]'
+ '|[\\ud834-\\ud834][\\ude42-\\ude44]'
+ '|[\\udb40-\\udb40][\\udc01-\\udc01]'
+ '|[\\udb40-\\udb40][\\udc20-\\udc7f]'
+ '|[\\udb40-\\udb40][\\udd00-\\uddef]'
, 'g');
*/

60
node_modules/blessed/lib/widget.js generated vendored Normal file
View File

@ -0,0 +1,60 @@
/**
* widget.js - high-level interface for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
var widget = exports;
widget.classes = [
'Node',
'Screen',
'Element',
'Box',
'Text',
'Line',
'ScrollableBox',
'ScrollableText',
'BigText',
'List',
'Form',
'Input',
'Textarea',
'Textbox',
'Button',
'ProgressBar',
'FileManager',
'Checkbox',
'RadioSet',
'RadioButton',
'Prompt',
'Question',
'Message',
'Loading',
'Listbar',
'Log',
'Table',
'ListTable',
'Terminal',
'Image',
'ANSIImage',
'OverlayImage',
'Video',
'Layout'
];
widget.classes.forEach(function(name) {
var file = name.toLowerCase();
widget[name] = widget[file] = require('./widgets/' + file);
});
widget.aliases = {
'ListBar': 'Listbar',
'PNG': 'ANSIImage'
};
Object.keys(widget.aliases).forEach(function(key) {
var name = widget.aliases[key];
widget[key] = widget[name];
widget[key.toLowerCase()] = widget[name];
});

167
node_modules/blessed/lib/widgets/ansiimage.js generated vendored Normal file
View File

@ -0,0 +1,167 @@
/**
* ansiimage.js - render PNGS/GIFS as ANSI
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var cp = require('child_process');
var colors = require('../colors');
var Node = require('./node');
var Box = require('./box');
var tng = require('../../vendor/tng');
/**
* ANSIImage
*/
function ANSIImage(options) {
var self = this;
if (!(this instanceof Node)) {
return new ANSIImage(options);
}
options = options || {};
options.shrink = true;
Box.call(this, options);
this.scale = this.options.scale || 1.0;
this.options.animate = this.options.animate !== false;
this._noFill = true;
if (this.options.file) {
this.setImage(this.options.file);
}
this.screen.on('prerender', function() {
var lpos = self.lpos;
if (!lpos) return;
// prevent image from blending with itself if there are alpha channels
self.screen.clearRegion(lpos.xi, lpos.xl, lpos.yi, lpos.yl);
});
this.on('destroy', function() {
self.stop();
});
}
ANSIImage.prototype.__proto__ = Box.prototype;
ANSIImage.prototype.type = 'ansiimage';
ANSIImage.curl = function(url) {
try {
return cp.execFileSync('curl',
['-s', '-A', '', url],
{ stdio: ['ignore', 'pipe', 'ignore'] });
} catch (e) {
;
}
try {
return cp.execFileSync('wget',
['-U', '', '-O', '-', url],
{ stdio: ['ignore', 'pipe', 'ignore'] });
} catch (e) {
;
}
throw new Error('curl or wget failed.');
};
ANSIImage.prototype.setImage = function(file) {
this.file = typeof file === 'string' ? file : null;
if (/^https?:/.test(file)) {
file = ANSIImage.curl(file);
}
var width = this.position.width;
var height = this.position.height;
if (width != null) {
width = this.width;
}
if (height != null) {
height = this.height;
}
try {
this.setContent('');
this.img = tng(file, {
colors: colors,
width: width,
height: height,
scale: this.scale,
ascii: this.options.ascii,
speed: this.options.speed,
filename: this.file
});
if (width == null || height == null) {
this.width = this.img.cellmap[0].length;
this.height = this.img.cellmap.length;
}
if (this.img.frames && this.options.animate) {
this.play();
} else {
this.cellmap = this.img.cellmap;
}
} catch (e) {
this.setContent('Image Error: ' + e.message);
this.img = null;
this.cellmap = null;
}
};
ANSIImage.prototype.play = function() {
var self = this;
if (!this.img) return;
return this.img.play(function(bmp, cellmap) {
self.cellmap = cellmap;
self.screen.render();
});
};
ANSIImage.prototype.pause = function() {
if (!this.img) return;
return this.img.pause();
};
ANSIImage.prototype.stop = function() {
if (!this.img) return;
return this.img.stop();
};
ANSIImage.prototype.clearImage = function() {
this.stop();
this.setContent('');
this.img = null;
this.cellmap = null;
};
ANSIImage.prototype.render = function() {
var coords = this._render();
if (!coords) return;
if (this.img && this.cellmap) {
this.img.renderElement(this.cellmap, this);
}
return coords;
};
/**
* Expose
*/
module.exports = ANSIImage;

159
node_modules/blessed/lib/widgets/bigtext.js generated vendored Normal file
View File

@ -0,0 +1,159 @@
/**
* bigtext.js - bigtext element for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var fs = require('fs');
var Node = require('./node');
var Box = require('./box');
/**
* BigText
*/
function BigText(options) {
if (!(this instanceof Node)) {
return new BigText(options);
}
options = options || {};
options.font = options.font
|| __dirname + '/../../usr/fonts/ter-u14n.json';
options.fontBold = options.font
|| __dirname + '/../../usr/fonts/ter-u14b.json';
this.fch = options.fch;
this.ratio = {};
this.font = this.loadFont(options.font);
this.fontBold = this.loadFont(options.font);
Box.call(this, options);
if (this.style.bold) {
this.font = this.fontBold;
}
}
BigText.prototype.__proto__ = Box.prototype;
BigText.prototype.type = 'bigtext';
BigText.prototype.loadFont = function(filename) {
var self = this
, data
, font;
data = JSON.parse(fs.readFileSync(filename, 'utf8'));
this.ratio.width = data.width;
this.ratio.height = data.height;
function convertLetter(ch, lines) {
var line, i;
while (lines.length > self.ratio.height) {
lines.shift();
lines.pop();
}
lines = lines.map(function(line) {
var chs = line.split('');
chs = chs.map(function(ch) {
return ch === ' ' ? 0 : 1;
});
while (chs.length < self.ratio.width) {
chs.push(0);
}
return chs;
});
while (lines.length < self.ratio.height) {
line = [];
for (i = 0; i < self.ratio.width; i++) {
line.push(0);
}
lines.push(line);
}
return lines;
}
font = Object.keys(data.glyphs).reduce(function(out, ch) {
var lines = data.glyphs[ch].map;
out[ch] = convertLetter(ch, lines);
return out;
}, {});
delete font[' '];
return font;
};
BigText.prototype.setContent = function(content) {
this.content = '';
this.text = content || '';
};
BigText.prototype.render = function() {
if (this.position.width == null || this._shrinkWidth) {
// if (this.width - this.iwidth < this.ratio.width * this.text.length + 1) {
this.position.width = this.ratio.width * this.text.length + 1;
this._shrinkWidth = true;
// }
}
if (this.position.height == null || this._shrinkHeight) {
// if (this.height - this.iheight < this.ratio.height + 0) {
this.position.height = this.ratio.height + 0;
this._shrinkHeight = true;
// }
}
var coords = this._render();
if (!coords) return;
var lines = this.screen.lines
, left = coords.xi + this.ileft
, top = coords.yi + this.itop
, right = coords.xl - this.iright
, bottom = coords.yl - this.ibottom;
var dattr = this.sattr(this.style)
, bg = dattr & 0x1ff
, fg = (dattr >> 9) & 0x1ff
, flags = (dattr >> 18) & 0x1ff
, attr = (flags << 18) | (bg << 9) | fg;
for (var x = left, i = 0; x < right; x += this.ratio.width, i++) {
var ch = this.text[i];
if (!ch) break;
var map = this.font[ch];
if (!map) continue;
for (var y = top; y < Math.min(bottom, top + this.ratio.height); y++) {
if (!lines[y]) continue;
var mline = map[y - top];
if (!mline) continue;
for (var mx = 0; mx < this.ratio.width; mx++) {
var mcell = mline[mx];
if (mcell == null) break;
if (this.fch && this.fch !== ' ') {
lines[y][x + mx][0] = dattr;
lines[y][x + mx][1] = mcell === 1 ? this.fch : this.ch;
} else {
lines[y][x + mx][0] = mcell === 1 ? attr : dattr;
lines[y][x + mx][1] = mcell === 1 ? ' ' : this.ch;
}
}
lines[y].dirty = true;
}
}
return coords;
};
/**
* Expose
*/
module.exports = BigText;

34
node_modules/blessed/lib/widgets/box.js generated vendored Normal file
View File

@ -0,0 +1,34 @@
/**
* box.js - box element for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var Node = require('./node');
var Element = require('./element');
/**
* Box
*/
function Box(options) {
if (!(this instanceof Node)) {
return new Box(options);
}
options = options || {};
Element.call(this, options);
}
Box.prototype.__proto__ = Element.prototype;
Box.prototype.type = 'box';
/**
* Expose
*/
module.exports = Box;

62
node_modules/blessed/lib/widgets/button.js generated vendored Normal file
View File

@ -0,0 +1,62 @@
/**
* button.js - button element for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var Node = require('./node');
var Input = require('./input');
/**
* Button
*/
function Button(options) {
var self = this;
if (!(this instanceof Node)) {
return new Button(options);
}
options = options || {};
if (options.autoFocus == null) {
options.autoFocus = false;
}
Input.call(this, options);
this.on('keypress', function(ch, key) {
if (key.name === 'enter' || key.name === 'space') {
return self.press();
}
});
if (this.options.mouse) {
this.on('click', function() {
return self.press();
});
}
}
Button.prototype.__proto__ = Input.prototype;
Button.prototype.type = 'button';
Button.prototype.press = function() {
this.focus();
this.value = true;
var result = this.emit('press');
delete this.value;
return result;
};
/**
* Expose
*/
module.exports = Button;

91
node_modules/blessed/lib/widgets/checkbox.js generated vendored Normal file
View File

@ -0,0 +1,91 @@
/**
* checkbox.js - checkbox element for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var Node = require('./node');
var Input = require('./input');
/**
* Checkbox
*/
function Checkbox(options) {
var self = this;
if (!(this instanceof Node)) {
return new Checkbox(options);
}
options = options || {};
Input.call(this, options);
this.text = options.content || options.text || '';
this.checked = this.value = options.checked || false;
this.on('keypress', function(ch, key) {
if (key.name === 'enter' || key.name === 'space') {
self.toggle();
self.screen.render();
}
});
if (options.mouse) {
this.on('click', function() {
self.toggle();
self.screen.render();
});
}
this.on('focus', function() {
var lpos = self.lpos;
if (!lpos) return;
self.screen.program.lsaveCursor('checkbox');
self.screen.program.cup(lpos.yi, lpos.xi + 1);
self.screen.program.showCursor();
});
this.on('blur', function() {
self.screen.program.lrestoreCursor('checkbox', true);
});
}
Checkbox.prototype.__proto__ = Input.prototype;
Checkbox.prototype.type = 'checkbox';
Checkbox.prototype.render = function() {
this.clearPos(true);
this.setContent('[' + (this.checked ? 'x' : ' ') + '] ' + this.text, true);
return this._render();
};
Checkbox.prototype.check = function() {
if (this.checked) return;
this.checked = this.value = true;
this.emit('check');
};
Checkbox.prototype.uncheck = function() {
if (!this.checked) return;
this.checked = this.value = false;
this.emit('uncheck');
};
Checkbox.prototype.toggle = function() {
return this.checked
? this.uncheck()
: this.check();
};
/**
* Expose
*/
module.exports = Checkbox;

2570
node_modules/blessed/lib/widgets/element.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

212
node_modules/blessed/lib/widgets/filemanager.js generated vendored Normal file
View File

@ -0,0 +1,212 @@
/**
* filemanager.js - file manager element for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var path = require('path')
, fs = require('fs');
var helpers = require('../helpers');
var Node = require('./node');
var List = require('./list');
/**
* FileManager
*/
function FileManager(options) {
var self = this;
if (!(this instanceof Node)) {
return new FileManager(options);
}
options = options || {};
options.parseTags = true;
// options.label = ' {blue-fg}%path{/blue-fg} ';
List.call(this, options);
this.cwd = options.cwd || process.cwd();
this.file = this.cwd;
this.value = this.cwd;
if (options.label && ~options.label.indexOf('%path')) {
this._label.setContent(options.label.replace('%path', this.cwd));
}
this.on('select', function(item) {
var value = item.content.replace(/\{[^{}]+\}/g, '').replace(/@$/, '')
, file = path.resolve(self.cwd, value);
return fs.stat(file, function(err, stat) {
if (err) {
return self.emit('error', err, file);
}
self.file = file;
self.value = file;
if (stat.isDirectory()) {
self.emit('cd', file, self.cwd);
self.cwd = file;
if (options.label && ~options.label.indexOf('%path')) {
self._label.setContent(options.label.replace('%path', file));
}
self.refresh();
} else {
self.emit('file', file);
}
});
});
}
FileManager.prototype.__proto__ = List.prototype;
FileManager.prototype.type = 'file-manager';
FileManager.prototype.refresh = function(cwd, callback) {
if (!callback) {
callback = cwd;
cwd = null;
}
var self = this;
if (cwd) this.cwd = cwd;
else cwd = this.cwd;
return fs.readdir(cwd, function(err, list) {
if (err && err.code === 'ENOENT') {
self.cwd = cwd !== process.env.HOME
? process.env.HOME
: '/';
return self.refresh(callback);
}
if (err) {
if (callback) return callback(err);
return self.emit('error', err, cwd);
}
var dirs = []
, files = [];
list.unshift('..');
list.forEach(function(name) {
var f = path.resolve(cwd, name)
, stat;
try {
stat = fs.lstatSync(f);
} catch (e) {
;
}
if ((stat && stat.isDirectory()) || name === '..') {
dirs.push({
name: name,
text: '{light-blue-fg}' + name + '{/light-blue-fg}/',
dir: true
});
} else if (stat && stat.isSymbolicLink()) {
files.push({
name: name,
text: '{light-cyan-fg}' + name + '{/light-cyan-fg}@',
dir: false
});
} else {
files.push({
name: name,
text: name,
dir: false
});
}
});
dirs = helpers.asort(dirs);
files = helpers.asort(files);
list = dirs.concat(files).map(function(data) {
return data.text;
});
self.setItems(list);
self.select(0);
self.screen.render();
self.emit('refresh');
if (callback) callback();
});
};
FileManager.prototype.pick = function(cwd, callback) {
if (!callback) {
callback = cwd;
cwd = null;
}
var self = this
, focused = this.screen.focused === this
, hidden = this.hidden
, onfile
, oncancel;
function resume() {
self.removeListener('file', onfile);
self.removeListener('cancel', oncancel);
if (hidden) {
self.hide();
}
if (!focused) {
self.screen.restoreFocus();
}
self.screen.render();
}
this.on('file', onfile = function(file) {
resume();
return callback(null, file);
});
this.on('cancel', oncancel = function() {
resume();
return callback();
});
this.refresh(cwd, function(err) {
if (err) return callback(err);
if (hidden) {
self.show();
}
if (!focused) {
self.screen.saveFocus();
self.focus();
}
self.screen.render();
});
};
FileManager.prototype.reset = function(cwd, callback) {
if (!callback) {
callback = cwd;
cwd = null;
}
this.cwd = cwd || this.options.cwd;
this.refresh(callback);
};
/**
* Expose
*/
module.exports = FileManager;

267
node_modules/blessed/lib/widgets/form.js generated vendored Normal file
View File

@ -0,0 +1,267 @@
/**
* form.js - form element for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var Node = require('./node');
var Box = require('./box');
/**
* Form
*/
function Form(options) {
var self = this;
if (!(this instanceof Node)) {
return new Form(options);
}
options = options || {};
options.ignoreKeys = true;
Box.call(this, options);
if (options.keys) {
this.screen._listenKeys(this);
this.on('element keypress', function(el, ch, key) {
if ((key.name === 'tab' && !key.shift)
|| (el.type === 'textbox' && options.autoNext && key.name === 'enter')
|| key.name === 'down'
|| (options.vi && key.name === 'j')) {
if (el.type === 'textbox' || el.type === 'textarea') {
if (key.name === 'j') return;
if (key.name === 'tab') {
// Workaround, since we can't stop the tab from being added.
el.emit('keypress', null, { name: 'backspace' });
}
el.emit('keypress', '\x1b', { name: 'escape' });
}
self.focusNext();
return;
}
if ((key.name === 'tab' && key.shift)
|| key.name === 'up'
|| (options.vi && key.name === 'k')) {
if (el.type === 'textbox' || el.type === 'textarea') {
if (key.name === 'k') return;
el.emit('keypress', '\x1b', { name: 'escape' });
}
self.focusPrevious();
return;
}
if (key.name === 'escape') {
self.focus();
return;
}
});
}
}
Form.prototype.__proto__ = Box.prototype;
Form.prototype.type = 'form';
Form.prototype._refresh = function() {
// XXX Possibly remove this if statement and refresh on every focus.
// Also potentially only include *visible* focusable elements.
// This would remove the need to check for _selected.visible in previous()
// and next().
if (!this._children) {
var out = [];
this.children.forEach(function fn(el) {
if (el.keyable) out.push(el);
el.children.forEach(fn);
});
this._children = out;
}
};
Form.prototype._visible = function() {
return !!this._children.filter(function(el) {
return el.visible;
}).length;
};
Form.prototype.next = function() {
this._refresh();
if (!this._visible()) return;
if (!this._selected) {
this._selected = this._children[0];
if (!this._selected.visible) return this.next();
if (this.screen.focused !== this._selected) return this._selected;
}
var i = this._children.indexOf(this._selected);
if (!~i || !this._children[i + 1]) {
this._selected = this._children[0];
if (!this._selected.visible) return this.next();
return this._selected;
}
this._selected = this._children[i + 1];
if (!this._selected.visible) return this.next();
return this._selected;
};
Form.prototype.previous = function() {
this._refresh();
if (!this._visible()) return;
if (!this._selected) {
this._selected = this._children[this._children.length - 1];
if (!this._selected.visible) return this.previous();
if (this.screen.focused !== this._selected) return this._selected;
}
var i = this._children.indexOf(this._selected);
if (!~i || !this._children[i - 1]) {
this._selected = this._children[this._children.length - 1];
if (!this._selected.visible) return this.previous();
return this._selected;
}
this._selected = this._children[i - 1];
if (!this._selected.visible) return this.previous();
return this._selected;
};
Form.prototype.focusNext = function() {
var next = this.next();
if (next) next.focus();
};
Form.prototype.focusPrevious = function() {
var previous = this.previous();
if (previous) previous.focus();
};
Form.prototype.resetSelected = function() {
this._selected = null;
};
Form.prototype.focusFirst = function() {
this.resetSelected();
this.focusNext();
};
Form.prototype.focusLast = function() {
this.resetSelected();
this.focusPrevious();
};
Form.prototype.submit = function() {
var out = {};
this.children.forEach(function fn(el) {
if (el.value != null) {
var name = el.name || el.type;
if (Array.isArray(out[name])) {
out[name].push(el.value);
} else if (out[name]) {
out[name] = [out[name], el.value];
} else {
out[name] = el.value;
}
}
el.children.forEach(fn);
});
this.emit('submit', out);
return this.submission = out;
};
Form.prototype.cancel = function() {
this.emit('cancel');
};
Form.prototype.reset = function() {
this.children.forEach(function fn(el) {
switch (el.type) {
case 'screen':
break;
case 'box':
break;
case 'text':
break;
case 'line':
break;
case 'scrollable-box':
break;
case 'list':
el.select(0);
return;
case 'form':
break;
case 'input':
break;
case 'textbox':
el.clearInput();
return;
case 'textarea':
el.clearInput();
return;
case 'button':
delete el.value;
break;
case 'progress-bar':
el.setProgress(0);
break;
case 'file-manager':
el.refresh(el.options.cwd);
return;
case 'checkbox':
el.uncheck();
return;
case 'radio-set':
break;
case 'radio-button':
el.uncheck();
return;
case 'prompt':
break;
case 'question':
break;
case 'message':
break;
case 'info':
break;
case 'loading':
break;
case 'list-bar':
//el.select(0);
break;
case 'dir-manager':
el.refresh(el.options.cwd);
return;
case 'terminal':
el.write('');
return;
case 'image':
//el.clearImage();
return;
}
el.children.forEach(fn);
});
this.emit('reset');
};
/**
* Expose
*/
module.exports = Form;

61
node_modules/blessed/lib/widgets/image.js generated vendored Normal file
View File

@ -0,0 +1,61 @@
/**
* image.js - image element for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var Node = require('./node');
var Box = require('./box');
/**
* Image
*/
function Image(options) {
if (!(this instanceof Node)) {
return new Image(options);
}
options = options || {};
options.type = options.itype || options.type || 'ansi';
Box.call(this, options);
if (options.type === 'ansi' && this.type !== 'ansiimage') {
var ANSIImage = require('./ansiimage');
Object.getOwnPropertyNames(ANSIImage.prototype).forEach(function(key) {
if (key === 'type') return;
Object.defineProperty(this, key,
Object.getOwnPropertyDescriptor(ANSIImage.prototype, key));
}, this);
ANSIImage.call(this, options);
return this;
}
if (options.type === 'overlay' && this.type !== 'overlayimage') {
var OverlayImage = require('./overlayimage');
Object.getOwnPropertyNames(OverlayImage.prototype).forEach(function(key) {
if (key === 'type') return;
Object.defineProperty(this, key,
Object.getOwnPropertyDescriptor(OverlayImage.prototype, key));
}, this);
OverlayImage.call(this, options);
return this;
}
throw new Error('`type` must either be `ansi` or `overlay`.');
}
Image.prototype.__proto__ = Box.prototype;
Image.prototype.type = 'image';
/**
* Expose
*/
module.exports = Image;

34
node_modules/blessed/lib/widgets/input.js generated vendored Normal file
View File

@ -0,0 +1,34 @@
/**
* input.js - abstract input element for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var Node = require('./node');
var Box = require('./box');
/**
* Input
*/
function Input(options) {
if (!(this instanceof Node)) {
return new Input(options);
}
options = options || {};
Box.call(this, options);
}
Input.prototype.__proto__ = Box.prototype;
Input.prototype.type = 'input';
/**
* Expose
*/
module.exports = Input;

233
node_modules/blessed/lib/widgets/layout.js generated vendored Normal file
View File

@ -0,0 +1,233 @@
/**
* layout.js - layout element for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var Node = require('./node');
var Element = require('./element');
/**
* Layout
*/
function Layout(options) {
if (!(this instanceof Node)) {
return new Layout(options);
}
options = options || {};
if ((options.width == null
&& (options.left == null && options.right == null))
|| (options.height == null
&& (options.top == null && options.bottom == null))) {
throw new Error('`Layout` must have a width and height!');
}
options.layout = options.layout || 'inline';
Element.call(this, options);
if (options.renderer) {
this.renderer = options.renderer;
}
}
Layout.prototype.__proto__ = Element.prototype;
Layout.prototype.type = 'layout';
Layout.prototype.isRendered = function(el) {
if (!el.lpos) return false;
return (el.lpos.xl - el.lpos.xi) > 0
&& (el.lpos.yl - el.lpos.yi) > 0;
};
Layout.prototype.getLast = function(i) {
while (this.children[--i]) {
var el = this.children[i];
if (this.isRendered(el)) return el;
}
};
Layout.prototype.getLastCoords = function(i) {
var last = this.getLast(i);
if (last) return last.lpos;
};
Layout.prototype._renderCoords = function() {
var coords = this._getCoords(true);
var children = this.children;
this.children = [];
this._render();
this.children = children;
return coords;
};
Layout.prototype.renderer = function(coords) {
var self = this;
// The coordinates of the layout element
var width = coords.xl - coords.xi
, height = coords.yl - coords.yi
, xi = coords.xi
, yi = coords.yi;
// The current row offset in cells (which row are we on?)
var rowOffset = 0;
// The index of the first child in the row
var rowIndex = 0;
var lastRowIndex = 0;
// Figure out the highest width child
if (this.options.layout === 'grid') {
var highWidth = this.children.reduce(function(out, el) {
out = Math.max(out, el.width);
return out;
}, 0);
}
return function iterator(el, i) {
// Make our children shrinkable. If they don't have a height, for
// example, calculate it for them.
el.shrink = true;
// Find the previous rendered child's coordinates
var last = self.getLast(i);
// If there is no previously rendered element, we are on the first child.
if (!last) {
el.position.left = 0;
el.position.top = 0;
} else {
// Otherwise, figure out where to place this child. We'll start by
// setting it's `left`/`x` coordinate to right after the previous
// rendered element. This child will end up directly to the right of it.
el.position.left = last.lpos.xl - xi;
// Make sure the position matches the highest width element
if (self.options.layout === 'grid') {
// Compensate with width:
// el.position.width = el.width + (highWidth - el.width);
// Compensate with position:
el.position.left += highWidth - (last.lpos.xl - last.lpos.xi);
}
// If our child does not overlap the right side of the Layout, set it's
// `top`/`y` to the current `rowOffset` (the coordinate for the current
// row).
if (el.position.left + el.width <= width) {
el.position.top = rowOffset;
} else {
// Otherwise we need to start a new row and calculate a new
// `rowOffset` and `rowIndex` (the index of the child on the current
// row).
rowOffset += self.children.slice(rowIndex, i).reduce(function(out, el) {
if (!self.isRendered(el)) return out;
out = Math.max(out, el.lpos.yl - el.lpos.yi);
return out;
}, 0);
lastRowIndex = rowIndex;
rowIndex = i;
el.position.left = 0;
el.position.top = rowOffset;
}
}
// Make sure the elements on lower rows graviatate up as much as possible
if (self.options.layout === 'inline') {
var above = null;
var abovea = Infinity;
for (var j = lastRowIndex; j < rowIndex; j++) {
var l = self.children[j];
if (!self.isRendered(l)) continue;
var abs = Math.abs(el.position.left - (l.lpos.xi - xi));
// if (abs < abovea && (l.lpos.xl - l.lpos.xi) <= el.width) {
if (abs < abovea) {
above = l;
abovea = abs;
}
}
if (above) {
el.position.top = above.lpos.yl - yi;
}
}
// If our child overflows the Layout, do not render it!
// Disable this feature for now.
if (el.position.top + el.height > height) {
// Returning false tells blessed to ignore this child.
// return false;
}
};
};
Layout.prototype.render = function() {
this._emit('prerender');
var coords = this._renderCoords();
if (!coords) {
delete this.lpos;
return;
}
if (coords.xl - coords.xi <= 0) {
coords.xl = Math.max(coords.xl, coords.xi);
return;
}
if (coords.yl - coords.yi <= 0) {
coords.yl = Math.max(coords.yl, coords.yi);
return;
}
this.lpos = coords;
if (this.border) coords.xi++, coords.xl--, coords.yi++, coords.yl--;
if (this.tpadding) {
coords.xi += this.padding.left, coords.xl -= this.padding.right;
coords.yi += this.padding.top, coords.yl -= this.padding.bottom;
}
var iterator = this.renderer(coords);
if (this.border) coords.xi--, coords.xl++, coords.yi--, coords.yl++;
if (this.tpadding) {
coords.xi -= this.padding.left, coords.xl += this.padding.right;
coords.yi -= this.padding.top, coords.yl += this.padding.bottom;
}
this.children.forEach(function(el, i) {
if (el.screen._ci !== -1) {
el.index = el.screen._ci++;
}
var rendered = iterator(el, i);
if (rendered === false) {
delete el.lpos;
return;
}
// if (el.screen._rendering) {
// el._rendering = true;
// }
el.render();
// if (el.screen._rendering) {
// el._rendering = false;
// }
});
this._emit('render', [coords]);
return coords;
};
/**
* Expose
*/
module.exports = Layout;

56
node_modules/blessed/lib/widgets/line.js generated vendored Normal file
View File

@ -0,0 +1,56 @@
/**
* line.js - line element for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var Node = require('./node');
var Box = require('./box');
/**
* Line
*/
function Line(options) {
if (!(this instanceof Node)) {
return new Line(options);
}
options = options || {};
var orientation = options.orientation || 'vertical';
delete options.orientation;
if (orientation === 'vertical') {
options.width = 1;
} else {
options.height = 1;
}
Box.call(this, options);
this.ch = !options.type || options.type === 'line'
? orientation === 'horizontal' ? '─' : '│'
: options.ch || ' ';
this.border = {
type: 'bg',
__proto__: this
};
this.style.border = this.style;
}
Line.prototype.__proto__ = Box.prototype;
Line.prototype.type = 'line';
/**
* Expose
*/
module.exports = Line;

599
node_modules/blessed/lib/widgets/list.js generated vendored Normal file
View File

@ -0,0 +1,599 @@
/**
* list.js - list element for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var helpers = require('../helpers');
var Node = require('./node');
var Box = require('./box');
/**
* List
*/
function List(options) {
var self = this;
if (!(this instanceof Node)) {
return new List(options);
}
options = options || {};
options.ignoreKeys = true;
// Possibly put this here: this.items = [];
options.scrollable = true;
Box.call(this, options);
this.value = '';
this.items = [];
this.ritems = [];
this.selected = 0;
this._isList = true;
if (!this.style.selected) {
this.style.selected = {};
this.style.selected.bg = options.selectedBg;
this.style.selected.fg = options.selectedFg;
this.style.selected.bold = options.selectedBold;
this.style.selected.underline = options.selectedUnderline;
this.style.selected.blink = options.selectedBlink;
this.style.selected.inverse = options.selectedInverse;
this.style.selected.invisible = options.selectedInvisible;
}
if (!this.style.item) {
this.style.item = {};
this.style.item.bg = options.itemBg;
this.style.item.fg = options.itemFg;
this.style.item.bold = options.itemBold;
this.style.item.underline = options.itemUnderline;
this.style.item.blink = options.itemBlink;
this.style.item.inverse = options.itemInverse;
this.style.item.invisible = options.itemInvisible;
}
// Legacy: for apps written before the addition of item attributes.
['bg', 'fg', 'bold', 'underline',
'blink', 'inverse', 'invisible'].forEach(function(name) {
if (self.style[name] != null && self.style.item[name] == null) {
self.style.item[name] = self.style[name];
}
});
if (this.options.itemHoverBg) {
this.options.itemHoverEffects = { bg: this.options.itemHoverBg };
}
if (this.options.itemHoverEffects) {
this.style.item.hover = this.options.itemHoverEffects;
}
if (this.options.itemFocusEffects) {
this.style.item.focus = this.options.itemFocusEffects;
}
this.interactive = options.interactive !== false;
this.mouse = options.mouse || false;
if (options.items) {
this.ritems = options.items;
options.items.forEach(this.add.bind(this));
}
this.select(0);
if (options.mouse) {
this.screen._listenMouse(this);
this.on('element wheeldown', function() {
self.select(self.selected + 2);
self.screen.render();
});
this.on('element wheelup', function() {
self.select(self.selected - 2);
self.screen.render();
});
}
if (options.keys) {
this.on('keypress', function(ch, key) {
if (key.name === 'up' || (options.vi && key.name === 'k')) {
self.up();
self.screen.render();
return;
}
if (key.name === 'down' || (options.vi && key.name === 'j')) {
self.down();
self.screen.render();
return;
}
if (key.name === 'enter'
|| (options.vi && key.name === 'l' && !key.shift)) {
self.enterSelected();
return;
}
if (key.name === 'escape' || (options.vi && key.name === 'q')) {
self.cancelSelected();
return;
}
if (options.vi && key.name === 'u' && key.ctrl) {
self.move(-((self.height - self.iheight) / 2) | 0);
self.screen.render();
return;
}
if (options.vi && key.name === 'd' && key.ctrl) {
self.move((self.height - self.iheight) / 2 | 0);
self.screen.render();
return;
}
if (options.vi && key.name === 'b' && key.ctrl) {
self.move(-(self.height - self.iheight));
self.screen.render();
return;
}
if (options.vi && key.name === 'f' && key.ctrl) {
self.move(self.height - self.iheight);
self.screen.render();
return;
}
if (options.vi && key.name === 'h' && key.shift) {
self.move(self.childBase - self.selected);
self.screen.render();
return;
}
if (options.vi && key.name === 'm' && key.shift) {
// TODO: Maybe use Math.min(this.items.length,
// ... for calculating visible items elsewhere.
var visible = Math.min(
self.height - self.iheight,
self.items.length) / 2 | 0;
self.move(self.childBase + visible - self.selected);
self.screen.render();
return;
}
if (options.vi && key.name === 'l' && key.shift) {
// XXX This goes one too far on lists with an odd number of items.
self.down(self.childBase
+ Math.min(self.height - self.iheight, self.items.length)
- self.selected);
self.screen.render();
return;
}
if (options.vi && key.name === 'g' && !key.shift) {
self.select(0);
self.screen.render();
return;
}
if (options.vi && key.name === 'g' && key.shift) {
self.select(self.items.length - 1);
self.screen.render();
return;
}
if (options.vi && (key.ch === '/' || key.ch === '?')) {
if (typeof self.options.search !== 'function') {
return;
}
return self.options.search(function(err, value) {
if (typeof err === 'string' || typeof err === 'function'
|| typeof err === 'number' || (err && err.test)) {
value = err;
err = null;
}
if (err || !value) return self.screen.render();
self.select(self.fuzzyFind(value, key.ch === '?'));
self.screen.render();
});
}
});
}
this.on('resize', function() {
var visible = self.height - self.iheight;
// if (self.selected < visible - 1) {
if (visible >= self.selected + 1) {
self.childBase = 0;
self.childOffset = self.selected;
} else {
// Is this supposed to be: self.childBase = visible - self.selected + 1; ?
self.childBase = self.selected - visible + 1;
self.childOffset = visible - 1;
}
});
this.on('adopt', function(el) {
if (!~self.items.indexOf(el)) {
el.fixed = true;
}
});
// Ensure children are removed from the
// item list if they are items.
this.on('remove', function(el) {
self.removeItem(el);
});
}
List.prototype.__proto__ = Box.prototype;
List.prototype.type = 'list';
List.prototype.createItem = function(content) {
var self = this;
// Note: Could potentially use Button here.
var options = {
screen: this.screen,
content: content,
align: this.align || 'left',
top: 0,
left: 0,
right: (this.scrollbar ? 1 : 0),
tags: this.parseTags,
height: 1,
hoverEffects: this.mouse ? this.style.item.hover : null,
focusEffects: this.mouse ? this.style.item.focus : null,
autoFocus: false
};
if (!this.screen.autoPadding) {
options.top = 1;
options.left = this.ileft;
options.right = this.iright + (this.scrollbar ? 1 : 0);
}
// if (this.shrink) {
// XXX NOTE: Maybe just do this on all shrinkage once autoPadding is default?
if (this.shrink && this.options.normalShrink) {
delete options.right;
options.width = 'shrink';
}
['bg', 'fg', 'bold', 'underline',
'blink', 'inverse', 'invisible'].forEach(function(name) {
options[name] = function() {
var attr = self.items[self.selected] === item && self.interactive
? self.style.selected[name]
: self.style.item[name];
if (typeof attr === 'function') attr = attr(item);
return attr;
};
});
if (this.style.transparent) {
options.transparent = true;
}
var item = new Box(options);
if (this.mouse) {
item.on('click', function() {
self.focus();
if (self.items[self.selected] === item) {
self.emit('action', item, self.selected);
self.emit('select', item, self.selected);
return;
}
self.select(item);
self.screen.render();
});
}
this.emit('create item');
return item;
};
List.prototype.add =
List.prototype.addItem =
List.prototype.appendItem = function(content) {
content = typeof content === 'string' ? content : content.getContent();
var item = this.createItem(content);
item.position.top = this.items.length;
if (!this.screen.autoPadding) {
item.position.top = this.itop + this.items.length;
}
this.ritems.push(content);
this.items.push(item);
this.append(item);
if (this.items.length === 1) {
this.select(0);
}
this.emit('add item');
return item;
};
List.prototype.removeItem = function(child) {
var i = this.getItemIndex(child);
if (~i && this.items[i]) {
child = this.items.splice(i, 1)[0];
this.ritems.splice(i, 1);
this.remove(child);
for (var j = i; j < this.items.length; j++) {
this.items[j].position.top--;
}
if (i === this.selected) {
this.select(i - 1);
}
}
this.emit('remove item');
return child;
};
List.prototype.insertItem = function(child, content) {
content = typeof content === 'string' ? content : content.getContent();
var i = this.getItemIndex(child);
if (!~i) return;
if (i >= this.items.length) return this.appendItem(content);
var item = this.createItem(content);
for (var j = i; j < this.items.length; j++) {
this.items[j].position.top++;
}
item.position.top = i + (!this.screen.autoPadding ? 1 : 0);
this.ritems.splice(i, 0, content);
this.items.splice(i, 0, item);
this.append(item);
if (i === this.selected) {
this.select(i + 1);
}
this.emit('insert item');
};
List.prototype.getItem = function(child) {
return this.items[this.getItemIndex(child)];
};
List.prototype.setItem = function(child, content) {
content = typeof content === 'string' ? content : content.getContent();
var i = this.getItemIndex(child);
if (!~i) return;
this.items[i].setContent(content);
this.ritems[i] = content;
};
List.prototype.clearItems = function() {
return this.setItems([]);
};
List.prototype.setItems = function(items) {
var original = this.items.slice()
, selected = this.selected
, sel = this.ritems[this.selected]
, i = 0;
items = items.slice();
this.select(0);
for (; i < items.length; i++) {
if (this.items[i]) {
this.items[i].setContent(items[i]);
} else {
this.add(items[i]);
}
}
for (; i < original.length; i++) {
this.remove(original[i]);
}
this.ritems = items;
// Try to find our old item if it still exists.
sel = items.indexOf(sel);
if (~sel) {
this.select(sel);
} else if (items.length === original.length) {
this.select(selected);
} else {
this.select(Math.min(selected, items.length - 1));
}
this.emit('set items');
};
List.prototype.pushItem = function(content) {
this.appendItem(content);
return this.items.length;
};
List.prototype.popItem = function() {
return this.removeItem(this.items.length - 1);
};
List.prototype.unshiftItem = function(content) {
this.insertItem(0, content);
return this.items.length;
};
List.prototype.shiftItem = function() {
return this.removeItem(0);
};
List.prototype.spliceItem = function(child, n) {
var self = this;
var i = this.getItemIndex(child);
if (!~i) return;
var items = Array.prototype.slice.call(arguments, 2);
var removed = [];
while (n--) {
removed.push(this.removeItem(i));
}
items.forEach(function(item) {
self.insertItem(i++, item);
});
return removed;
};
List.prototype.find =
List.prototype.fuzzyFind = function(search, back) {
var start = this.selected + (back ? -1 : 1)
, i;
if (typeof search === 'number') search += '';
if (search && search[0] === '/' && search[search.length - 1] === '/') {
try {
search = new RegExp(search.slice(1, -1));
} catch (e) {
;
}
}
var test = typeof search === 'string'
? function(item) { return !!~item.indexOf(search); }
: (search.test ? search.test.bind(search) : search);
if (typeof test !== 'function') {
if (this.screen.options.debug) {
throw new Error('fuzzyFind(): `test` is not a function.');
}
return this.selected;
}
if (!back) {
for (i = start; i < this.ritems.length; i++) {
if (test(helpers.cleanTags(this.ritems[i]))) return i;
}
for (i = 0; i < start; i++) {
if (test(helpers.cleanTags(this.ritems[i]))) return i;
}
} else {
for (i = start; i >= 0; i--) {
if (test(helpers.cleanTags(this.ritems[i]))) return i;
}
for (i = this.ritems.length - 1; i > start; i--) {
if (test(helpers.cleanTags(this.ritems[i]))) return i;
}
}
return this.selected;
};
List.prototype.getItemIndex = function(child) {
if (typeof child === 'number') {
return child;
} else if (typeof child === 'string') {
var i = this.ritems.indexOf(child);
if (~i) return i;
for (i = 0; i < this.ritems.length; i++) {
if (helpers.cleanTags(this.ritems[i]) === child) {
return i;
}
}
return -1;
} else {
return this.items.indexOf(child);
}
};
List.prototype.select = function(index) {
if (!this.interactive) {
return;
}
if (!this.items.length) {
this.selected = 0;
this.value = '';
this.scrollTo(0);
return;
}
if (typeof index === 'object') {
index = this.items.indexOf(index);
}
if (index < 0) {
index = 0;
} else if (index >= this.items.length) {
index = this.items.length - 1;
}
if (this.selected === index && this._listInitialized) return;
this._listInitialized = true;
this.selected = index;
this.value = helpers.cleanTags(this.ritems[this.selected]);
if (!this.parent) return;
this.scrollTo(this.selected);
// XXX Move `action` and `select` events here.
this.emit('select item', this.items[this.selected], this.selected);
};
List.prototype.move = function(offset) {
this.select(this.selected + offset);
};
List.prototype.up = function(offset) {
this.move(-(offset || 1));
};
List.prototype.down = function(offset) {
this.move(offset || 1);
};
List.prototype.pick = function(label, callback) {
if (!callback) {
callback = label;
label = null;
}
if (!this.interactive) {
return callback();
}
var self = this;
var focused = this.screen.focused;
if (focused && focused._done) focused._done('stop');
this.screen.saveFocus();
// XXX Keep above:
// var parent = this.parent;
// this.detach();
// parent.append(this);
this.focus();
this.show();
this.select(0);
if (label) this.setLabel(label);
this.screen.render();
this.once('action', function(el, selected) {
if (label) self.removeLabel();
self.screen.restoreFocus();
self.hide();
self.screen.render();
if (!el) return callback();
return callback(null, helpers.cleanTags(self.ritems[selected]));
});
};
List.prototype.enterSelected = function(i) {
if (i != null) this.select(i);
this.emit('action', this.items[this.selected], this.selected);
this.emit('select', this.items[this.selected], this.selected);
};
List.prototype.cancelSelected = function(i) {
if (i != null) this.select(i);
this.emit('action');
this.emit('cancel');
};
/**
* Expose
*/
module.exports = List;

411
node_modules/blessed/lib/widgets/listbar.js generated vendored Normal file
View File

@ -0,0 +1,411 @@
/**
* listbar.js - listbar element for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var helpers = require('../helpers');
var Node = require('./node');
var Box = require('./box');
/**
* Listbar / HorizontalList
*/
function Listbar(options) {
var self = this;
if (!(this instanceof Node)) {
return new Listbar(options);
}
options = options || {};
this.items = [];
this.ritems = [];
this.commands = [];
this.leftBase = 0;
this.leftOffset = 0;
this.mouse = options.mouse || false;
Box.call(this, options);
if (!this.style.selected) {
this.style.selected = {};
}
if (!this.style.item) {
this.style.item = {};
}
if (options.commands || options.items) {
this.setItems(options.commands || options.items);
}
if (options.keys) {
this.on('keypress', function(ch, key) {
if (key.name === 'left'
|| (options.vi && key.name === 'h')
|| (key.shift && key.name === 'tab')) {
self.moveLeft();
self.screen.render();
// Stop propagation if we're in a form.
if (key.name === 'tab') return false;
return;
}
if (key.name === 'right'
|| (options.vi && key.name === 'l')
|| key.name === 'tab') {
self.moveRight();
self.screen.render();
// Stop propagation if we're in a form.
if (key.name === 'tab') return false;
return;
}
if (key.name === 'enter'
|| (options.vi && key.name === 'k' && !key.shift)) {
self.emit('action', self.items[self.selected], self.selected);
self.emit('select', self.items[self.selected], self.selected);
var item = self.items[self.selected];
if (item._.cmd.callback) {
item._.cmd.callback();
}
self.screen.render();
return;
}
if (key.name === 'escape' || (options.vi && key.name === 'q')) {
self.emit('action');
self.emit('cancel');
return;
}
});
}
if (options.autoCommandKeys) {
this.onScreenEvent('keypress', function(ch) {
if (/^[0-9]$/.test(ch)) {
var i = +ch - 1;
if (!~i) i = 9;
return self.selectTab(i);
}
});
}
this.on('focus', function() {
self.select(self.selected);
});
}
Listbar.prototype.__proto__ = Box.prototype;
Listbar.prototype.type = 'listbar';
Listbar.prototype.__defineGetter__('selected', function() {
return this.leftBase + this.leftOffset;
});
Listbar.prototype.setItems = function(commands) {
var self = this;
if (!Array.isArray(commands)) {
commands = Object.keys(commands).reduce(function(obj, key, i) {
var cmd = commands[key]
, cb;
if (typeof cmd === 'function') {
cb = cmd;
cmd = { callback: cb };
}
if (cmd.text == null) cmd.text = key;
if (cmd.prefix == null) cmd.prefix = ++i + '';
if (cmd.text == null && cmd.callback) {
cmd.text = cmd.callback.name;
}
obj.push(cmd);
return obj;
}, []);
}
this.items.forEach(function(el) {
el.detach();
});
this.items = [];
this.ritems = [];
this.commands = [];
commands.forEach(function(cmd) {
self.add(cmd);
});
this.emit('set items');
};
Listbar.prototype.add =
Listbar.prototype.addItem =
Listbar.prototype.appendItem = function(item, callback) {
var self = this
, prev = this.items[this.items.length - 1]
, drawn
, cmd
, title
, len;
if (!this.parent) {
drawn = 0;
} else {
drawn = prev ? prev.aleft + prev.width : 0;
if (!this.screen.autoPadding) {
drawn += this.ileft;
}
}
if (typeof item === 'object') {
cmd = item;
if (cmd.prefix == null) cmd.prefix = (this.items.length + 1) + '';
}
if (typeof item === 'string') {
cmd = {
prefix: (this.items.length + 1) + '',
text: item,
callback: callback
};
}
if (typeof item === 'function') {
cmd = {
prefix: (this.items.length + 1) + '',
text: item.name,
callback: item
};
}
if (cmd.keys && cmd.keys[0]) {
cmd.prefix = cmd.keys[0];
}
var t = helpers.generateTags(this.style.prefix || { fg: 'lightblack' });
title = (cmd.prefix != null ? t.open + cmd.prefix + t.close + ':' : '') + cmd.text;
len = ((cmd.prefix != null ? cmd.prefix + ':' : '') + cmd.text).length;
var options = {
screen: this.screen,
top: 0,
left: drawn + 1,
height: 1,
content: title,
width: len + 2,
align: 'center',
autoFocus: false,
tags: true,
mouse: true,
style: helpers.merge({}, this.style.item),
noOverflow: true
};
if (!this.screen.autoPadding) {
options.top += this.itop;
options.left += this.ileft;
}
['bg', 'fg', 'bold', 'underline',
'blink', 'inverse', 'invisible'].forEach(function(name) {
options.style[name] = function() {
var attr = self.items[self.selected] === el
? self.style.selected[name]
: self.style.item[name];
if (typeof attr === 'function') attr = attr(el);
return attr;
};
});
var el = new Box(options);
this._[cmd.text] = el;
cmd.element = el;
el._.cmd = cmd;
this.ritems.push(cmd.text);
this.items.push(el);
this.commands.push(cmd);
this.append(el);
if (cmd.callback) {
if (cmd.keys) {
this.screen.key(cmd.keys, function() {
self.emit('action', el, self.selected);
self.emit('select', el, self.selected);
if (el._.cmd.callback) {
el._.cmd.callback();
}
self.select(el);
self.screen.render();
});
}
}
if (this.items.length === 1) {
this.select(0);
}
// XXX May be affected by new element.options.mouse option.
if (this.mouse) {
el.on('click', function() {
self.emit('action', el, self.selected);
self.emit('select', el, self.selected);
if (el._.cmd.callback) {
el._.cmd.callback();
}
self.select(el);
self.screen.render();
});
}
this.emit('add item');
};
Listbar.prototype.render = function() {
var self = this
, drawn = 0;
if (!this.screen.autoPadding) {
drawn += this.ileft;
}
this.items.forEach(function(el, i) {
if (i < self.leftBase) {
el.hide();
} else {
el.rleft = drawn + 1;
drawn += el.width + 2;
el.show();
}
});
return this._render();
};
Listbar.prototype.select = function(offset) {
if (typeof offset !== 'number') {
offset = this.items.indexOf(offset);
}
if (offset < 0) {
offset = 0;
} else if (offset >= this.items.length) {
offset = this.items.length - 1;
}
if (!this.parent) {
this.emit('select item', this.items[offset], offset);
return;
}
var lpos = this._getCoords();
if (!lpos) return;
var self = this
, width = (lpos.xl - lpos.xi) - this.iwidth
, drawn = 0
, visible = 0
, el;
el = this.items[offset];
if (!el) return;
this.items.forEach(function(el, i) {
if (i < self.leftBase) return;
var lpos = el._getCoords();
if (!lpos) return;
if (lpos.xl - lpos.xi <= 0) return;
drawn += (lpos.xl - lpos.xi) + 2;
if (drawn <= width) visible++;
});
var diff = offset - (this.leftBase + this.leftOffset);
if (offset > this.leftBase + this.leftOffset) {
if (offset > this.leftBase + visible - 1) {
this.leftOffset = 0;
this.leftBase = offset;
} else {
this.leftOffset += diff;
}
} else if (offset < this.leftBase + this.leftOffset) {
diff = -diff;
if (offset < this.leftBase) {
this.leftOffset = 0;
this.leftBase = offset;
} else {
this.leftOffset -= diff;
}
}
// XXX Move `action` and `select` events here.
this.emit('select item', el, offset);
};
Listbar.prototype.removeItem = function(child) {
var i = typeof child !== 'number'
? this.items.indexOf(child)
: child;
if (~i && this.items[i]) {
child = this.items.splice(i, 1)[0];
this.ritems.splice(i, 1);
this.commands.splice(i, 1);
this.remove(child);
if (i === this.selected) {
this.select(i - 1);
}
}
this.emit('remove item');
};
Listbar.prototype.move = function(offset) {
this.select(this.selected + offset);
};
Listbar.prototype.moveLeft = function(offset) {
this.move(-(offset || 1));
};
Listbar.prototype.moveRight = function(offset) {
this.move(offset || 1);
};
Listbar.prototype.selectTab = function(index) {
var item = this.items[index];
if (item) {
if (item._.cmd.callback) {
item._.cmd.callback();
}
this.select(index);
this.screen.render();
}
this.emit('select tab', item, index);
};
/**
* Expose
*/
module.exports = Listbar;

252
node_modules/blessed/lib/widgets/listtable.js generated vendored Normal file
View File

@ -0,0 +1,252 @@
/**
* listtable.js - list table element for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var Node = require('./node');
var Box = require('./box');
var List = require('./list');
var Table = require('./table');
/**
* ListTable
*/
function ListTable(options) {
var self = this;
if (!(this instanceof Node)) {
return new ListTable(options);
}
options = options || {};
options.shrink = true;
options.normalShrink = true;
options.style = options.style || {};
options.style.border = options.style.border || {};
options.style.header = options.style.header || {};
options.style.cell = options.style.cell || {};
this.__align = options.align || 'center';
delete options.align;
options.style.selected = options.style.cell.selected;
options.style.item = options.style.cell;
List.call(this, options);
this._header = new Box({
parent: this,
left: this.screen.autoPadding ? 0 : this.ileft,
top: 0,
width: 'shrink',
height: 1,
style: options.style.header,
tags: options.parseTags || options.tags
});
this.on('scroll', function() {
self._header.setFront();
self._header.rtop = self.childBase;
if (!self.screen.autoPadding) {
self._header.rtop = self.childBase + (self.border ? 1 : 0);
}
});
this.pad = options.pad != null
? options.pad
: 2;
this.setData(options.rows || options.data);
this.on('attach', function() {
self.setData(self.rows);
});
this.on('resize', function() {
var selected = self.selected;
self.setData(self.rows);
self.select(selected);
self.screen.render();
});
}
ListTable.prototype.__proto__ = List.prototype;
ListTable.prototype.type = 'list-table';
ListTable.prototype._calculateMaxes = Table.prototype._calculateMaxes;
ListTable.prototype.setRows =
ListTable.prototype.setData = function(rows) {
var self = this
, align = this.__align;
if (this.visible && this.lpos) {
this.clearPos();
}
this.clearItems();
this.rows = rows || [];
this._calculateMaxes();
if (!this._maxes) return;
this.addItem('');
this.rows.forEach(function(row, i) {
var isHeader = i === 0;
var text = '';
row.forEach(function(cell, i) {
var width = self._maxes[i];
var clen = self.strWidth(cell);
if (i !== 0) {
text += ' ';
}
while (clen < width) {
if (align === 'center') {
cell = ' ' + cell + ' ';
clen += 2;
} else if (align === 'left') {
cell = cell + ' ';
clen += 1;
} else if (align === 'right') {
cell = ' ' + cell;
clen += 1;
}
}
if (clen > width) {
if (align === 'center') {
cell = cell.substring(1);
clen--;
} else if (align === 'left') {
cell = cell.slice(0, -1);
clen--;
} else if (align === 'right') {
cell = cell.substring(1);
clen--;
}
}
text += cell;
});
if (isHeader) {
self._header.setContent(text);
} else {
self.addItem(text);
}
});
this._header.setFront();
this.select(0);
};
ListTable.prototype._select = ListTable.prototype.select;
ListTable.prototype.select = function(i) {
if (i === 0) {
i = 1;
}
if (i <= this.childBase) {
this.setScroll(this.childBase - 1);
}
return this._select(i);
};
ListTable.prototype.render = function() {
var self = this;
var coords = this._render();
if (!coords) return;
this._calculateMaxes();
if (!this._maxes) return coords;
var lines = this.screen.lines
, xi = coords.xi
, yi = coords.yi
, rx
, ry
, i;
var battr = this.sattr(this.style.border);
var height = coords.yl - coords.yi - this.ibottom;
if (!this.border || this.options.noCellBorders) return coords;
// Draw border with correct angles.
ry = 0;
for (i = 0; i < height + 1; i++) {
if (!lines[yi + ry]) break;
rx = 0;
self._maxes.slice(0, -1).forEach(function(max) {
rx += max;
if (!lines[yi + ry][xi + rx + 1]) return;
// center
if (ry === 0) {
// top
rx++;
lines[yi + ry][xi + rx][0] = battr;
lines[yi + ry][xi + rx][1] = '\u252c'; // '┬'
// XXX If we alter iheight and itop for no borders - nothing should be written here
if (!self.border.top) {
lines[yi + ry][xi + rx][1] = '\u2502'; // '│'
}
lines[yi + ry].dirty = true;
} else if (ry === height) {
// bottom
rx++;
lines[yi + ry][xi + rx][0] = battr;
lines[yi + ry][xi + rx][1] = '\u2534'; // '┴'
// XXX If we alter iheight and ibottom for no borders - nothing should be written here
if (!self.border.bottom) {
lines[yi + ry][xi + rx][1] = '\u2502'; // '│'
}
lines[yi + ry].dirty = true;
} else {
// middle
rx++;
}
});
ry += 1;
}
// Draw internal borders.
for (ry = 1; ry < height; ry++) {
if (!lines[yi + ry]) break;
rx = 0;
self._maxes.slice(0, -1).forEach(function(max) {
rx += max;
if (!lines[yi + ry][xi + rx + 1]) return;
if (self.options.fillCellBorders !== false) {
var lbg = lines[yi + ry][xi + rx][0] & 0x1ff;
rx++;
lines[yi + ry][xi + rx][0] = (battr & ~0x1ff) | lbg;
} else {
rx++;
lines[yi + ry][xi + rx][0] = battr;
}
lines[yi + ry][xi + rx][1] = '\u2502'; // '│'
lines[yi + ry].dirty = true;
});
}
return coords;
};
/**
* Expose
*/
module.exports = ListTable;

88
node_modules/blessed/lib/widgets/loading.js generated vendored Normal file
View File

@ -0,0 +1,88 @@
/**
* loading.js - loading element for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var Node = require('./node');
var Box = require('./box');
var Text = require('./text');
/**
* Loading
*/
function Loading(options) {
if (!(this instanceof Node)) {
return new Loading(options);
}
options = options || {};
Box.call(this, options);
this._.icon = new Text({
parent: this,
align: 'center',
top: 2,
left: 1,
right: 1,
height: 1,
content: '|'
});
}
Loading.prototype.__proto__ = Box.prototype;
Loading.prototype.type = 'loading';
Loading.prototype.load = function(text) {
var self = this;
// XXX Keep above:
// var parent = this.parent;
// this.detach();
// parent.append(this);
this.show();
this.setContent(text);
if (this._.timer) {
this.stop();
}
this.screen.lockKeys = true;
this._.timer = setInterval(function() {
if (self._.icon.content === '|') {
self._.icon.setContent('/');
} else if (self._.icon.content === '/') {
self._.icon.setContent('-');
} else if (self._.icon.content === '-') {
self._.icon.setContent('\\');
} else if (self._.icon.content === '\\') {
self._.icon.setContent('|');
}
self.screen.render();
}, 200);
};
Loading.prototype.stop = function() {
this.screen.lockKeys = false;
this.hide();
if (this._.timer) {
clearInterval(this._.timer);
delete this._.timer;
}
this.screen.render();
};
/**
* Expose
*/
module.exports = Loading;

83
node_modules/blessed/lib/widgets/log.js generated vendored Normal file
View File

@ -0,0 +1,83 @@
/**
* log.js - log element for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var util = require('util');
var nextTick = global.setImmediate || process.nextTick.bind(process);
var Node = require('./node');
var ScrollableText = require('./scrollabletext');
/**
* Log
*/
function Log(options) {
var self = this;
if (!(this instanceof Node)) {
return new Log(options);
}
options = options || {};
ScrollableText.call(this, options);
this.scrollback = options.scrollback != null
? options.scrollback
: Infinity;
this.scrollOnInput = options.scrollOnInput;
this.on('set content', function() {
if (!self._userScrolled || self.scrollOnInput) {
nextTick(function() {
self.setScrollPerc(100);
self._userScrolled = false;
self.screen.render();
});
}
});
}
Log.prototype.__proto__ = ScrollableText.prototype;
Log.prototype.type = 'log';
Log.prototype.log =
Log.prototype.add = function() {
var args = Array.prototype.slice.call(arguments);
if (typeof args[0] === 'object') {
args[0] = util.inspect(args[0], true, 20, true);
}
var text = util.format.apply(util, args);
this.emit('log', text);
var ret = this.pushLine(text);
if (this._clines.fake.length > this.scrollback) {
this.shiftLine(0, (this.scrollback / 3) | 0);
}
return ret;
};
Log.prototype._scroll = Log.prototype.scroll;
Log.prototype.scroll = function(offset, always) {
if (offset === 0) return this._scroll(offset, always);
this._userScrolled = true;
var ret = this._scroll(offset, always);
if (this.getScrollPerc() === 100) {
this._userScrolled = false;
}
return ret;
};
/**
* Expose
*/
module.exports = Log;

123
node_modules/blessed/lib/widgets/message.js generated vendored Normal file
View File

@ -0,0 +1,123 @@
/**
* message.js - message element for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var Node = require('./node');
var Box = require('./box');
/**
* Message / Error
*/
function Message(options) {
if (!(this instanceof Node)) {
return new Message(options);
}
options = options || {};
options.tags = true;
Box.call(this, options);
}
Message.prototype.__proto__ = Box.prototype;
Message.prototype.type = 'message';
Message.prototype.log =
Message.prototype.display = function(text, time, callback) {
var self = this;
if (typeof time === 'function') {
callback = time;
time = null;
}
if (time == null) time = 3;
// Keep above:
// var parent = this.parent;
// this.detach();
// parent.append(this);
if (this.scrollable) {
this.screen.saveFocus();
this.focus();
this.scrollTo(0);
}
this.show();
this.setContent(text);
this.screen.render();
if (time === Infinity || time === -1 || time === 0) {
var end = function() {
if (end.done) return;
end.done = true;
if (self.scrollable) {
try {
self.screen.restoreFocus();
} catch (e) {
;
}
}
self.hide();
self.screen.render();
if (callback) callback();
};
setTimeout(function() {
self.onScreenEvent('keypress', function fn(ch, key) {
if (key.name === 'mouse') return;
if (self.scrollable) {
if ((key.name === 'up' || (self.options.vi && key.name === 'k'))
|| (key.name === 'down' || (self.options.vi && key.name === 'j'))
|| (self.options.vi && key.name === 'u' && key.ctrl)
|| (self.options.vi && key.name === 'd' && key.ctrl)
|| (self.options.vi && key.name === 'b' && key.ctrl)
|| (self.options.vi && key.name === 'f' && key.ctrl)
|| (self.options.vi && key.name === 'g' && !key.shift)
|| (self.options.vi && key.name === 'g' && key.shift)) {
return;
}
}
if (self.options.ignoreKeys && ~self.options.ignoreKeys.indexOf(key.name)) {
return;
}
self.removeScreenEvent('keypress', fn);
end();
});
// XXX May be affected by new element.options.mouse option.
if (!self.options.mouse) return;
self.onScreenEvent('mouse', function fn(data) {
if (data.action === 'mousemove') return;
self.removeScreenEvent('mouse', fn);
end();
});
}, 10);
return;
}
setTimeout(function() {
self.hide();
self.screen.render();
if (callback) callback();
}, time * 1000);
};
Message.prototype.error = function(text, time, callback) {
return this.display('{red-fg}Error: ' + text + '{/red-fg}', time, callback);
};
/**
* Expose
*/
module.exports = Message;

282
node_modules/blessed/lib/widgets/node.js generated vendored Normal file
View File

@ -0,0 +1,282 @@
/**
* node.js - base abstract node for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var EventEmitter = require('../events').EventEmitter;
/**
* Node
*/
function Node(options) {
var self = this;
var Screen = require('./screen');
if (!(this instanceof Node)) {
return new Node(options);
}
EventEmitter.call(this);
options = options || {};
this.options = options;
this.screen = this.screen || options.screen;
if (!this.screen) {
if (this.type === 'screen') {
this.screen = this;
} else if (Screen.total === 1) {
this.screen = Screen.global;
} else if (options.parent) {
this.screen = options.parent;
while (this.screen && this.screen.type !== 'screen') {
this.screen = this.screen.parent;
}
} else if (Screen.total) {
// This _should_ work in most cases as long as the element is appended
// synchronously after the screen's creation. Throw error if not.
this.screen = Screen.instances[Screen.instances.length - 1];
process.nextTick(function() {
if (!self.parent) {
throw new Error('Element (' + self.type + ')'
+ ' was not appended synchronously after the'
+ ' screen\'s creation. Please set a `parent`'
+ ' or `screen` option in the element\'s constructor'
+ ' if you are going to use multiple screens and'
+ ' append the element later.');
}
});
} else {
throw new Error('No active screen.');
}
}
this.parent = options.parent || null;
this.children = [];
this.$ = this._ = this.data = {};
this.uid = Node.uid++;
this.index = this.index != null ? this.index : -1;
if (this.type !== 'screen') {
this.detached = true;
}
if (this.parent) {
this.parent.append(this);
}
(options.children || []).forEach(this.append.bind(this));
}
Node.uid = 0;
Node.prototype.__proto__ = EventEmitter.prototype;
Node.prototype.type = 'node';
Node.prototype.insert = function(element, i) {
var self = this;
if (element.screen && element.screen !== this.screen) {
throw new Error('Cannot switch a node\'s screen.');
}
element.detach();
element.parent = this;
element.screen = this.screen;
if (i === 0) {
this.children.unshift(element);
} else if (i === this.children.length) {
this.children.push(element);
} else {
this.children.splice(i, 0, element);
}
element.emit('reparent', this);
this.emit('adopt', element);
(function emit(el) {
var n = el.detached !== self.detached;
el.detached = self.detached;
if (n) el.emit('attach');
el.children.forEach(emit);
})(element);
if (!this.screen.focused) {
this.screen.focused = element;
}
};
Node.prototype.prepend = function(element) {
this.insert(element, 0);
};
Node.prototype.append = function(element) {
this.insert(element, this.children.length);
};
Node.prototype.insertBefore = function(element, other) {
var i = this.children.indexOf(other);
if (~i) this.insert(element, i);
};
Node.prototype.insertAfter = function(element, other) {
var i = this.children.indexOf(other);
if (~i) this.insert(element, i + 1);
};
Node.prototype.remove = function(element) {
if (element.parent !== this) return;
var i = this.children.indexOf(element);
if (!~i) return;
element.clearPos();
element.parent = null;
this.children.splice(i, 1);
i = this.screen.clickable.indexOf(element);
if (~i) this.screen.clickable.splice(i, 1);
i = this.screen.keyable.indexOf(element);
if (~i) this.screen.keyable.splice(i, 1);
element.emit('reparent', null);
this.emit('remove', element);
(function emit(el) {
var n = el.detached !== true;
el.detached = true;
if (n) el.emit('detach');
el.children.forEach(emit);
})(element);
if (this.screen.focused === element) {
this.screen.rewindFocus();
}
};
Node.prototype.detach = function() {
if (this.parent) this.parent.remove(this);
};
Node.prototype.free = function() {
return;
};
Node.prototype.destroy = function() {
this.detach();
this.forDescendants(function(el) {
el.free();
el.destroyed = true;
el.emit('destroy');
}, this);
};
Node.prototype.forDescendants = function(iter, s) {
if (s) iter(this);
this.children.forEach(function emit(el) {
iter(el);
el.children.forEach(emit);
});
};
Node.prototype.forAncestors = function(iter, s) {
var el = this;
if (s) iter(this);
while (el = el.parent) {
iter(el);
}
};
Node.prototype.collectDescendants = function(s) {
var out = [];
this.forDescendants(function(el) {
out.push(el);
}, s);
return out;
};
Node.prototype.collectAncestors = function(s) {
var out = [];
this.forAncestors(function(el) {
out.push(el);
}, s);
return out;
};
Node.prototype.emitDescendants = function() {
var args = Array.prototype.slice(arguments)
, iter;
if (typeof args[args.length - 1] === 'function') {
iter = args.pop();
}
return this.forDescendants(function(el) {
if (iter) iter(el);
el.emit.apply(el, args);
}, true);
};
Node.prototype.emitAncestors = function() {
var args = Array.prototype.slice(arguments)
, iter;
if (typeof args[args.length - 1] === 'function') {
iter = args.pop();
}
return this.forAncestors(function(el) {
if (iter) iter(el);
el.emit.apply(el, args);
}, true);
};
Node.prototype.hasDescendant = function(target) {
return (function find(el) {
for (var i = 0; i < el.children.length; i++) {
if (el.children[i] === target) {
return true;
}
if (find(el.children[i]) === true) {
return true;
}
}
return false;
})(this);
};
Node.prototype.hasAncestor = function(target) {
var el = this;
while (el = el.parent) {
if (el === target) return true;
}
return false;
};
Node.prototype.get = function(name, value) {
if (this.data.hasOwnProperty(name)) {
return this.data[name];
}
return value;
};
Node.prototype.set = function(name, value) {
return this.data[name] = value;
};
/**
* Expose
*/
module.exports = Node;

717
node_modules/blessed/lib/widgets/overlayimage.js generated vendored Normal file
View File

@ -0,0 +1,717 @@
/**
* overlayimage.js - w3m image element for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var fs = require('fs')
, cp = require('child_process');
var helpers = require('../helpers');
var Node = require('./node');
var Box = require('./box');
/**
* OverlayImage
* Good example of w3mimgdisplay commands:
* https://github.com/hut/ranger/blob/master/ranger/ext/img_display.py
*/
function OverlayImage(options) {
var self = this;
if (!(this instanceof Node)) {
return new OverlayImage(options);
}
options = options || {};
Box.call(this, options);
if (options.w3m) {
OverlayImage.w3mdisplay = options.w3m;
}
if (OverlayImage.hasW3MDisplay == null) {
if (fs.existsSync(OverlayImage.w3mdisplay)) {
OverlayImage.hasW3MDisplay = true;
} else if (options.search !== false) {
var file = helpers.findFile('/usr', 'w3mimgdisplay')
|| helpers.findFile('/lib', 'w3mimgdisplay')
|| helpers.findFile('/bin', 'w3mimgdisplay');
if (file) {
OverlayImage.hasW3MDisplay = true;
OverlayImage.w3mdisplay = file;
} else {
OverlayImage.hasW3MDisplay = false;
}
}
}
this.on('hide', function() {
self._lastFile = self.file;
self.clearImage();
});
this.on('show', function() {
if (!self._lastFile) return;
self.setImage(self._lastFile);
});
this.on('detach', function() {
self._lastFile = self.file;
self.clearImage();
});
this.on('attach', function() {
if (!self._lastFile) return;
self.setImage(self._lastFile);
});
this.onScreenEvent('resize', function() {
self._needsRatio = true;
});
// Get images to overlap properly. Maybe not worth it:
// this.onScreenEvent('render', function() {
// self.screen.program.flush();
// if (!self._noImage) return;
// function display(el, next) {
// if (el.type === 'w3mimage' && el.file) {
// el.setImage(el.file, next);
// } else {
// next();
// }
// }
// function done(el) {
// el.children.forEach(recurse);
// }
// function recurse(el) {
// display(el, function() {
// var pending = el.children.length;
// el.children.forEach(function(el) {
// display(el, function() {
// if (!--pending) done(el);
// });
// });
// });
// }
// recurse(self.screen);
// });
this.onScreenEvent('render', function() {
self.screen.program.flush();
if (!self._noImage) {
self.setImage(self.file);
}
});
if (this.options.file || this.options.img) {
this.setImage(this.options.file || this.options.img);
}
}
OverlayImage.prototype.__proto__ = Box.prototype;
OverlayImage.prototype.type = 'overlayimage';
OverlayImage.w3mdisplay = '/usr/lib/w3m/w3mimgdisplay';
OverlayImage.prototype.spawn = function(file, args, opt, callback) {
var spawn = require('child_process').spawn
, ps;
opt = opt || {};
ps = spawn(file, args, opt);
ps.on('error', function(err) {
if (!callback) return;
return callback(err);
});
ps.on('exit', function(code) {
if (!callback) return;
if (code !== 0) return callback(new Error('Exit Code: ' + code));
return callback(null, code === 0);
});
return ps;
};
OverlayImage.prototype.setImage = function(img, callback) {
var self = this;
if (this._settingImage) {
this._queue = this._queue || [];
this._queue.push([img, callback]);
return;
}
this._settingImage = true;
var reset = function() {
self._settingImage = false;
self._queue = self._queue || [];
var item = self._queue.shift();
if (item) {
self.setImage(item[0], item[1]);
}
};
if (OverlayImage.hasW3MDisplay === false) {
reset();
if (!callback) return;
return callback(new Error('W3M Image Display not available.'));
}
if (!img) {
reset();
if (!callback) return;
return callback(new Error('No image.'));
}
this.file = img;
return this.getPixelRatio(function(err, ratio) {
if (err) {
reset();
if (!callback) return;
return callback(err);
}
return self.renderImage(img, ratio, function(err, success) {
if (err) {
reset();
if (!callback) return;
return callback(err);
}
if (self.shrink || self.options.autofit) {
delete self.shrink;
delete self.options.shrink;
self.options.autofit = true;
return self.imageSize(function(err, size) {
if (err) {
reset();
if (!callback) return;
return callback(err);
}
if (self._lastSize
&& ratio.tw === self._lastSize.tw
&& ratio.th === self._lastSize.th
&& size.width === self._lastSize.width
&& size.height === self._lastSize.height
&& self.aleft === self._lastSize.aleft
&& self.atop === self._lastSize.atop) {
reset();
if (!callback) return;
return callback(null, success);
}
self._lastSize = {
tw: ratio.tw,
th: ratio.th,
width: size.width,
height: size.height,
aleft: self.aleft,
atop: self.atop
};
self.position.width = size.width / ratio.tw | 0;
self.position.height = size.height / ratio.th | 0;
self._noImage = true;
self.screen.render();
self._noImage = false;
reset();
return self.renderImage(img, ratio, callback);
});
}
reset();
if (!callback) return;
return callback(null, success);
});
});
};
OverlayImage.prototype.renderImage = function(img, ratio, callback) {
var self = this;
if (cp.execSync) {
callback = callback || function(err, result) { return result; };
try {
return callback(null, this.renderImageSync(img, ratio));
} catch (e) {
return callback(e);
}
}
if (OverlayImage.hasW3MDisplay === false) {
if (!callback) return;
return callback(new Error('W3M Image Display not available.'));
}
if (!ratio) {
if (!callback) return;
return callback(new Error('No ratio.'));
}
// clearImage unsets these:
var _file = self.file;
var _lastSize = self._lastSize;
return self.clearImage(function(err) {
if (err) return callback(err);
self.file = _file;
self._lastSize = _lastSize;
var opt = {
stdio: 'pipe',
env: process.env,
cwd: process.env.HOME
};
var ps = self.spawn(OverlayImage.w3mdisplay, [], opt, function(err, success) {
if (!callback) return;
return err
? callback(err)
: callback(null, success);
});
var width = self.width * ratio.tw | 0
, height = self.height * ratio.th | 0
, aleft = self.aleft * ratio.tw | 0
, atop = self.atop * ratio.th | 0;
var input = '0;1;'
+ aleft + ';'
+ atop + ';'
+ width + ';'
+ height + ';;;;;'
+ img
+ '\n4;\n3;\n';
self._props = {
aleft: aleft,
atop: atop,
width: width,
height: height
};
ps.stdin.write(input);
ps.stdin.end();
});
};
OverlayImage.prototype.clearImage = function(callback) {
if (cp.execSync) {
callback = callback || function(err, result) { return result; };
try {
return callback(null, this.clearImageSync());
} catch (e) {
return callback(e);
}
}
if (OverlayImage.hasW3MDisplay === false) {
if (!callback) return;
return callback(new Error('W3M Image Display not available.'));
}
if (!this._props) {
if (!callback) return;
return callback(null);
}
var opt = {
stdio: 'pipe',
env: process.env,
cwd: process.env.HOME
};
var ps = this.spawn(OverlayImage.w3mdisplay, [], opt, function(err, success) {
if (!callback) return;
return err
? callback(err)
: callback(null, success);
});
var width = this._props.width + 2
, height = this._props.height + 2
, aleft = this._props.aleft
, atop = this._props.atop;
if (this._drag) {
aleft -= 10;
atop -= 10;
width += 10;
height += 10;
}
var input = '6;'
+ aleft + ';'
+ atop + ';'
+ width + ';'
+ height
+ '\n4;\n3;\n';
delete this.file;
delete this._props;
delete this._lastSize;
ps.stdin.write(input);
ps.stdin.end();
};
OverlayImage.prototype.imageSize = function(callback) {
var img = this.file;
if (cp.execSync) {
callback = callback || function(err, result) { return result; };
try {
return callback(null, this.imageSizeSync());
} catch (e) {
return callback(e);
}
}
if (OverlayImage.hasW3MDisplay === false) {
if (!callback) return;
return callback(new Error('W3M Image Display not available.'));
}
if (!img) {
if (!callback) return;
return callback(new Error('No image.'));
}
var opt = {
stdio: 'pipe',
env: process.env,
cwd: process.env.HOME
};
var ps = this.spawn(OverlayImage.w3mdisplay, [], opt);
var buf = '';
ps.stdout.setEncoding('utf8');
ps.stdout.on('data', function(data) {
buf += data;
});
ps.on('error', function(err) {
if (!callback) return;
return callback(err);
});
ps.on('exit', function() {
if (!callback) return;
var size = buf.trim().split(/\s+/);
return callback(null, {
raw: buf.trim(),
width: +size[0],
height: +size[1]
});
});
var input = '5;' + img + '\n';
ps.stdin.write(input);
ps.stdin.end();
};
OverlayImage.prototype.termSize = function(callback) {
var self = this;
if (cp.execSync) {
callback = callback || function(err, result) { return result; };
try {
return callback(null, this.termSizeSync());
} catch (e) {
return callback(e);
}
}
if (OverlayImage.hasW3MDisplay === false) {
if (!callback) return;
return callback(new Error('W3M Image Display not available.'));
}
var opt = {
stdio: 'pipe',
env: process.env,
cwd: process.env.HOME
};
var ps = this.spawn(OverlayImage.w3mdisplay, ['-test'], opt);
var buf = '';
ps.stdout.setEncoding('utf8');
ps.stdout.on('data', function(data) {
buf += data;
});
ps.on('error', function(err) {
if (!callback) return;
return callback(err);
});
ps.on('exit', function() {
if (!callback) return;
if (!buf.trim()) {
// Bug: w3mimgdisplay will sometimes
// output nothing. Try again:
return self.termSize(callback);
}
var size = buf.trim().split(/\s+/);
return callback(null, {
raw: buf.trim(),
width: +size[0],
height: +size[1]
});
});
ps.stdin.end();
};
OverlayImage.prototype.getPixelRatio = function(callback) {
var self = this;
if (cp.execSync) {
callback = callback || function(err, result) { return result; };
try {
return callback(null, this.getPixelRatioSync());
} catch (e) {
return callback(e);
}
}
// XXX We could cache this, but sometimes it's better
// to recalculate to be pixel perfect.
if (this._ratio && !this._needsRatio) {
return callback(null, this._ratio);
}
return this.termSize(function(err, dimensions) {
if (err) return callback(err);
self._ratio = {
tw: dimensions.width / self.screen.width,
th: dimensions.height / self.screen.height
};
self._needsRatio = false;
return callback(null, self._ratio);
});
};
OverlayImage.prototype.renderImageSync = function(img, ratio) {
if (OverlayImage.hasW3MDisplay === false) {
throw new Error('W3M Image Display not available.');
}
if (!ratio) {
throw new Error('No ratio.');
}
// clearImage unsets these:
var _file = this.file;
var _lastSize = this._lastSize;
this.clearImageSync();
this.file = _file;
this._lastSize = _lastSize;
var width = this.width * ratio.tw | 0
, height = this.height * ratio.th | 0
, aleft = this.aleft * ratio.tw | 0
, atop = this.atop * ratio.th | 0;
var input = '0;1;'
+ aleft + ';'
+ atop + ';'
+ width + ';'
+ height + ';;;;;'
+ img
+ '\n4;\n3;\n';
this._props = {
aleft: aleft,
atop: atop,
width: width,
height: height
};
try {
cp.execFileSync(OverlayImage.w3mdisplay, [], {
env: process.env,
encoding: 'utf8',
input: input,
timeout: 1000
});
} catch (e) {
;
}
return true;
};
OverlayImage.prototype.clearImageSync = function() {
if (OverlayImage.hasW3MDisplay === false) {
throw new Error('W3M Image Display not available.');
}
if (!this._props) {
return false;
}
var width = this._props.width + 2
, height = this._props.height + 2
, aleft = this._props.aleft
, atop = this._props.atop;
if (this._drag) {
aleft -= 10;
atop -= 10;
width += 10;
height += 10;
}
var input = '6;'
+ aleft + ';'
+ atop + ';'
+ width + ';'
+ height
+ '\n4;\n3;\n';
delete this.file;
delete this._props;
delete this._lastSize;
try {
cp.execFileSync(OverlayImage.w3mdisplay, [], {
env: process.env,
encoding: 'utf8',
input: input,
timeout: 1000
});
} catch (e) {
;
}
return true;
};
OverlayImage.prototype.imageSizeSync = function() {
var img = this.file;
if (OverlayImage.hasW3MDisplay === false) {
throw new Error('W3M Image Display not available.');
}
if (!img) {
throw new Error('No image.');
}
var buf = '';
var input = '5;' + img + '\n';
try {
buf = cp.execFileSync(OverlayImage.w3mdisplay, [], {
env: process.env,
encoding: 'utf8',
input: input,
timeout: 1000
});
} catch (e) {
;
}
var size = buf.trim().split(/\s+/);
return {
raw: buf.trim(),
width: +size[0],
height: +size[1]
};
};
OverlayImage.prototype.termSizeSync = function(_, recurse) {
if (OverlayImage.hasW3MDisplay === false) {
throw new Error('W3M Image Display not available.');
}
var buf = '';
try {
buf = cp.execFileSync(OverlayImage.w3mdisplay, ['-test'], {
env: process.env,
encoding: 'utf8',
timeout: 1000
});
} catch (e) {
;
}
if (!buf.trim()) {
// Bug: w3mimgdisplay will sometimes
// output nothing. Try again:
recurse = recurse || 0;
if (++recurse === 5) {
throw new Error('Term size not determined.');
}
return this.termSizeSync(_, recurse);
}
var size = buf.trim().split(/\s+/);
return {
raw: buf.trim(),
width: +size[0],
height: +size[1]
};
};
OverlayImage.prototype.getPixelRatioSync = function() {
// XXX We could cache this, but sometimes it's better
// to recalculate to be pixel perfect.
if (this._ratio && !this._needsRatio) {
return this._ratio;
}
this._needsRatio = false;
var dimensions = this.termSizeSync();
this._ratio = {
tw: dimensions.width / this.screen.width,
th: dimensions.height / this.screen.height
};
return this._ratio;
};
OverlayImage.prototype.displayImage = function(callback) {
return this.screen.displayImage(this.file, callback);
};
/**
* Expose
*/
module.exports = OverlayImage;

157
node_modules/blessed/lib/widgets/progressbar.js generated vendored Normal file
View File

@ -0,0 +1,157 @@
/**
* progressbar.js - progress bar element for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var Node = require('./node');
var Input = require('./input');
/**
* ProgressBar
*/
function ProgressBar(options) {
var self = this;
if (!(this instanceof Node)) {
return new ProgressBar(options);
}
options = options || {};
Input.call(this, options);
this.filled = options.filled || 0;
if (typeof this.filled === 'string') {
this.filled = +this.filled.slice(0, -1);
}
this.value = this.filled;
this.pch = options.pch || ' ';
// XXX Workaround that predates the usage of `el.ch`.
if (options.ch) {
this.pch = options.ch;
this.ch = ' ';
}
if (options.bch) {
this.ch = options.bch;
}
if (!this.style.bar) {
this.style.bar = {};
this.style.bar.fg = options.barFg;
this.style.bar.bg = options.barBg;
}
this.orientation = options.orientation || 'horizontal';
if (options.keys) {
this.on('keypress', function(ch, key) {
var back, forward;
if (self.orientation === 'horizontal') {
back = ['left', 'h'];
forward = ['right', 'l'];
} else if (self.orientation === 'vertical') {
back = ['down', 'j'];
forward = ['up', 'k'];
}
if (key.name === back[0] || (options.vi && key.name === back[1])) {
self.progress(-5);
self.screen.render();
return;
}
if (key.name === forward[0] || (options.vi && key.name === forward[1])) {
self.progress(5);
self.screen.render();
return;
}
});
}
if (options.mouse) {
this.on('click', function(data) {
var x, y, m, p;
if (!self.lpos) return;
if (self.orientation === 'horizontal') {
x = data.x - self.lpos.xi;
m = (self.lpos.xl - self.lpos.xi) - self.iwidth;
p = x / m * 100 | 0;
} else if (self.orientation === 'vertical') {
y = data.y - self.lpos.yi;
m = (self.lpos.yl - self.lpos.yi) - self.iheight;
p = y / m * 100 | 0;
}
self.setProgress(p);
});
}
}
ProgressBar.prototype.__proto__ = Input.prototype;
ProgressBar.prototype.type = 'progress-bar';
ProgressBar.prototype.render = function() {
var ret = this._render();
if (!ret) return;
var xi = ret.xi
, xl = ret.xl
, yi = ret.yi
, yl = ret.yl
, dattr;
if (this.border) xi++, yi++, xl--, yl--;
if (this.orientation === 'horizontal') {
xl = xi + ((xl - xi) * (this.filled / 100)) | 0;
} else if (this.orientation === 'vertical') {
yi = yi + ((yl - yi) - (((yl - yi) * (this.filled / 100)) | 0));
}
dattr = this.sattr(this.style.bar);
this.screen.fillRegion(dattr, this.pch, xi, xl, yi, yl);
if (this.content) {
var line = this.screen.lines[yi];
for (var i = 0; i < this.content.length; i++) {
line[xi + i][1] = this.content[i];
}
line.dirty = true;
}
return ret;
};
ProgressBar.prototype.progress = function(filled) {
this.filled += filled;
if (this.filled < 0) this.filled = 0;
else if (this.filled > 100) this.filled = 100;
if (this.filled === 100) {
this.emit('complete');
}
this.value = this.filled;
};
ProgressBar.prototype.setProgress = function(filled) {
this.filled = 0;
this.progress(filled);
};
ProgressBar.prototype.reset = function() {
this.emit('reset');
this.filled = 0;
this.value = this.filled;
};
/**
* Expose
*/
module.exports = ProgressBar;

120
node_modules/blessed/lib/widgets/prompt.js generated vendored Normal file
View File

@ -0,0 +1,120 @@
/**
* prompt.js - prompt element for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var Node = require('./node');
var Box = require('./box');
var Button = require('./button');
var Textbox = require('./textbox');
/**
* Prompt
*/
function Prompt(options) {
if (!(this instanceof Node)) {
return new Prompt(options);
}
options = options || {};
options.hidden = true;
Box.call(this, options);
this._.input = new Textbox({
parent: this,
top: 3,
height: 1,
left: 2,
right: 2,
bg: 'black'
});
this._.okay = new Button({
parent: this,
top: 5,
height: 1,
left: 2,
width: 6,
content: 'Okay',
align: 'center',
bg: 'black',
hoverBg: 'blue',
autoFocus: false,
mouse: true
});
this._.cancel = new Button({
parent: this,
top: 5,
height: 1,
shrink: true,
left: 10,
width: 8,
content: 'Cancel',
align: 'center',
bg: 'black',
hoverBg: 'blue',
autoFocus: false,
mouse: true
});
}
Prompt.prototype.__proto__ = Box.prototype;
Prompt.prototype.type = 'prompt';
Prompt.prototype.input =
Prompt.prototype.setInput =
Prompt.prototype.readInput = function(text, value, callback) {
var self = this;
var okay, cancel;
if (!callback) {
callback = value;
value = '';
}
// Keep above:
// var parent = this.parent;
// this.detach();
// parent.append(this);
this.show();
this.setContent(' ' + text);
this._.input.value = value;
this.screen.saveFocus();
this._.okay.on('press', okay = function() {
self._.input.submit();
});
this._.cancel.on('press', cancel = function() {
self._.input.cancel();
});
this._.input.readInput(function(err, data) {
self.hide();
self.screen.restoreFocus();
self._.okay.removeListener('press', okay);
self._.cancel.removeListener('press', cancel);
return callback(err, data);
});
this.screen.render();
};
/**
* Expose
*/
module.exports = Prompt;

116
node_modules/blessed/lib/widgets/question.js generated vendored Normal file
View File

@ -0,0 +1,116 @@
/**
* question.js - question element for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var Node = require('./node');
var Box = require('./box');
var Button = require('./button');
/**
* Question
*/
function Question(options) {
if (!(this instanceof Node)) {
return new Question(options);
}
options = options || {};
options.hidden = true;
Box.call(this, options);
this._.okay = new Button({
screen: this.screen,
parent: this,
top: 2,
height: 1,
left: 2,
width: 6,
content: 'Okay',
align: 'center',
bg: 'black',
hoverBg: 'blue',
autoFocus: false,
mouse: true
});
this._.cancel = new Button({
screen: this.screen,
parent: this,
top: 2,
height: 1,
shrink: true,
left: 10,
width: 8,
content: 'Cancel',
align: 'center',
bg: 'black',
hoverBg: 'blue',
autoFocus: false,
mouse: true
});
}
Question.prototype.__proto__ = Box.prototype;
Question.prototype.type = 'question';
Question.prototype.ask = function(text, callback) {
var self = this;
var press, okay, cancel;
// Keep above:
// var parent = this.parent;
// this.detach();
// parent.append(this);
this.show();
this.setContent(' ' + text);
this.onScreenEvent('keypress', press = function(ch, key) {
if (key.name === 'mouse') return;
if (key.name !== 'enter'
&& key.name !== 'escape'
&& key.name !== 'q'
&& key.name !== 'y'
&& key.name !== 'n') {
return;
}
done(null, key.name === 'enter' || key.name === 'y');
});
this._.okay.on('press', okay = function() {
done(null, true);
});
this._.cancel.on('press', cancel = function() {
done(null, false);
});
this.screen.saveFocus();
this.focus();
function done(err, data) {
self.hide();
self.screen.restoreFocus();
self.removeScreenEvent('keypress', press);
self._.okay.removeListener('press', okay);
self._.cancel.removeListener('press', cancel);
return callback(err, data);
}
this.screen.render();
};
/**
* Expose
*/
module.exports = Question;

61
node_modules/blessed/lib/widgets/radiobutton.js generated vendored Normal file
View File

@ -0,0 +1,61 @@
/**
* radiobutton.js - radio button element for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var Node = require('./node');
var Checkbox = require('./checkbox');
/**
* RadioButton
*/
function RadioButton(options) {
var self = this;
if (!(this instanceof Node)) {
return new RadioButton(options);
}
options = options || {};
Checkbox.call(this, options);
this.on('check', function() {
var el = self;
while (el = el.parent) {
if (el.type === 'radio-set'
|| el.type === 'form') break;
}
el = el || self.parent;
el.forDescendants(function(el) {
if (el.type !== 'radio-button' || el === self) {
return;
}
el.uncheck();
});
});
}
RadioButton.prototype.__proto__ = Checkbox.prototype;
RadioButton.prototype.type = 'radio-button';
RadioButton.prototype.render = function() {
this.clearPos(true);
this.setContent('(' + (this.checked ? '*' : ' ') + ') ' + this.text, true);
return this._render();
};
RadioButton.prototype.toggle = RadioButton.prototype.check;
/**
* Expose
*/
module.exports = RadioButton;

36
node_modules/blessed/lib/widgets/radioset.js generated vendored Normal file
View File

@ -0,0 +1,36 @@
/**
* radioset.js - radio set element for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var Node = require('./node');
var Box = require('./box');
/**
* RadioSet
*/
function RadioSet(options) {
if (!(this instanceof Node)) {
return new RadioSet(options);
}
options = options || {};
// Possibly inherit parent's style.
// options.style = this.parent.style;
Box.call(this, options);
}
RadioSet.prototype.__proto__ = Box.prototype;
RadioSet.prototype.type = 'radio-set';
/**
* Expose
*/
module.exports = RadioSet;

2298
node_modules/blessed/lib/widgets/screen.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

389
node_modules/blessed/lib/widgets/scrollablebox.js generated vendored Normal file
View File

@ -0,0 +1,389 @@
/**
* scrollablebox.js - scrollable box element for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var Node = require('./node');
var Box = require('./box');
/**
* ScrollableBox
*/
function ScrollableBox(options) {
var self = this;
if (!(this instanceof Node)) {
return new ScrollableBox(options);
}
options = options || {};
Box.call(this, options);
if (options.scrollable === false) {
return this;
}
this.scrollable = true;
this.childOffset = 0;
this.childBase = 0;
this.baseLimit = options.baseLimit || Infinity;
this.alwaysScroll = options.alwaysScroll;
this.scrollbar = options.scrollbar;
if (this.scrollbar) {
this.scrollbar.ch = this.scrollbar.ch || ' ';
this.style.scrollbar = this.style.scrollbar || this.scrollbar.style;
if (!this.style.scrollbar) {
this.style.scrollbar = {};
this.style.scrollbar.fg = this.scrollbar.fg;
this.style.scrollbar.bg = this.scrollbar.bg;
this.style.scrollbar.bold = this.scrollbar.bold;
this.style.scrollbar.underline = this.scrollbar.underline;
this.style.scrollbar.inverse = this.scrollbar.inverse;
this.style.scrollbar.invisible = this.scrollbar.invisible;
}
//this.scrollbar.style = this.style.scrollbar;
if (this.track || this.scrollbar.track) {
this.track = this.scrollbar.track || this.track;
this.style.track = this.style.scrollbar.track || this.style.track;
this.track.ch = this.track.ch || ' ';
this.style.track = this.style.track || this.track.style;
if (!this.style.track) {
this.style.track = {};
this.style.track.fg = this.track.fg;
this.style.track.bg = this.track.bg;
this.style.track.bold = this.track.bold;
this.style.track.underline = this.track.underline;
this.style.track.inverse = this.track.inverse;
this.style.track.invisible = this.track.invisible;
}
this.track.style = this.style.track;
}
// Allow controlling of the scrollbar via the mouse:
if (options.mouse) {
this.on('mousedown', function(data) {
if (self._scrollingBar) {
// Do not allow dragging on the scrollbar:
delete self.screen._dragging;
delete self._drag;
return;
}
var x = data.x - self.aleft;
var y = data.y - self.atop;
if (x === self.width - self.iright - 1) {
// Do not allow dragging on the scrollbar:
delete self.screen._dragging;
delete self._drag;
var perc = (y - self.itop) / (self.height - self.iheight);
self.setScrollPerc(perc * 100 | 0);
self.screen.render();
var smd, smu;
self._scrollingBar = true;
self.onScreenEvent('mousedown', smd = function(data) {
var y = data.y - self.atop;
var perc = y / self.height;
self.setScrollPerc(perc * 100 | 0);
self.screen.render();
});
// If mouseup occurs out of the window, no mouseup event fires, and
// scrollbar will drag again on mousedown until another mouseup
// occurs.
self.onScreenEvent('mouseup', smu = function() {
self._scrollingBar = false;
self.removeScreenEvent('mousedown', smd);
self.removeScreenEvent('mouseup', smu);
});
}
});
}
}
if (options.mouse) {
this.on('wheeldown', function() {
self.scroll(self.height / 2 | 0 || 1);
self.screen.render();
});
this.on('wheelup', function() {
self.scroll(-(self.height / 2 | 0) || -1);
self.screen.render();
});
}
if (options.keys && !options.ignoreKeys) {
this.on('keypress', function(ch, key) {
if (key.name === 'up' || (options.vi && key.name === 'k')) {
self.scroll(-1);
self.screen.render();
return;
}
if (key.name === 'down' || (options.vi && key.name === 'j')) {
self.scroll(1);
self.screen.render();
return;
}
if (options.vi && key.name === 'u' && key.ctrl) {
self.scroll(-(self.height / 2 | 0) || -1);
self.screen.render();
return;
}
if (options.vi && key.name === 'd' && key.ctrl) {
self.scroll(self.height / 2 | 0 || 1);
self.screen.render();
return;
}
if (options.vi && key.name === 'b' && key.ctrl) {
self.scroll(-self.height || -1);
self.screen.render();
return;
}
if (options.vi && key.name === 'f' && key.ctrl) {
self.scroll(self.height || 1);
self.screen.render();
return;
}
if (options.vi && key.name === 'g' && !key.shift) {
self.scrollTo(0);
self.screen.render();
return;
}
if (options.vi && key.name === 'g' && key.shift) {
self.scrollTo(self.getScrollHeight());
self.screen.render();
return;
}
});
}
this.on('parsed content', function() {
self._recalculateIndex();
});
self._recalculateIndex();
}
ScrollableBox.prototype.__proto__ = Box.prototype;
ScrollableBox.prototype.type = 'scrollable-box';
// XXX Potentially use this in place of scrollable checks elsewhere.
ScrollableBox.prototype.__defineGetter__('reallyScrollable', function() {
if (this.shrink) return this.scrollable;
return this.getScrollHeight() > this.height;
});
ScrollableBox.prototype._scrollBottom = function() {
if (!this.scrollable) return 0;
// We could just calculate the children, but we can
// optimize for lists by just returning the items.length.
if (this._isList) {
return this.items ? this.items.length : 0;
}
if (this.lpos && this.lpos._scrollBottom) {
return this.lpos._scrollBottom;
}
var bottom = this.children.reduce(function(current, el) {
// el.height alone does not calculate the shrunken height, we need to use
// getCoords. A shrunken box inside a scrollable element will not grow any
// larger than the scrollable element's context regardless of how much
// content is in the shrunken box, unless we do this (call getCoords
// without the scrollable calculation):
// See: $ node test/widget-shrink-fail-2.js
if (!el.detached) {
var lpos = el._getCoords(false, true);
if (lpos) {
return Math.max(current, el.rtop + (lpos.yl - lpos.yi));
}
}
return Math.max(current, el.rtop + el.height);
}, 0);
// XXX Use this? Makes .getScrollHeight() useless!
// if (bottom < this._clines.length) bottom = this._clines.length;
if (this.lpos) this.lpos._scrollBottom = bottom;
return bottom;
};
ScrollableBox.prototype.setScroll =
ScrollableBox.prototype.scrollTo = function(offset, always) {
// XXX
// At first, this appeared to account for the first new calculation of childBase:
this.scroll(0);
return this.scroll(offset - (this.childBase + this.childOffset), always);
};
ScrollableBox.prototype.getScroll = function() {
return this.childBase + this.childOffset;
};
ScrollableBox.prototype.scroll = function(offset, always) {
if (!this.scrollable) return;
if (this.detached) return;
// Handle scrolling.
var visible = this.height - this.iheight
, base = this.childBase
, d
, p
, t
, b
, max
, emax;
if (this.alwaysScroll || always) {
// Semi-workaround
this.childOffset = offset > 0
? visible - 1 + offset
: offset;
} else {
this.childOffset += offset;
}
if (this.childOffset > visible - 1) {
d = this.childOffset - (visible - 1);
this.childOffset -= d;
this.childBase += d;
} else if (this.childOffset < 0) {
d = this.childOffset;
this.childOffset += -d;
this.childBase += d;
}
if (this.childBase < 0) {
this.childBase = 0;
} else if (this.childBase > this.baseLimit) {
this.childBase = this.baseLimit;
}
// Find max "bottom" value for
// content and descendant elements.
// Scroll the content if necessary.
if (this.childBase === base) {
return this.emit('scroll');
}
// When scrolling text, we want to be able to handle SGR codes as well as line
// feeds. This allows us to take preformatted text output from other programs
// and put it in a scrollable text box.
this.parseContent();
// XXX
// max = this.getScrollHeight() - (this.height - this.iheight);
max = this._clines.length - (this.height - this.iheight);
if (max < 0) max = 0;
emax = this._scrollBottom() - (this.height - this.iheight);
if (emax < 0) emax = 0;
this.childBase = Math.min(this.childBase, Math.max(emax, max));
if (this.childBase < 0) {
this.childBase = 0;
} else if (this.childBase > this.baseLimit) {
this.childBase = this.baseLimit;
}
// Optimize scrolling with CSR + IL/DL.
p = this.lpos;
// Only really need _getCoords() if we want
// to allow nestable scrolling elements...
// or if we **really** want shrinkable
// scrolling elements.
// p = this._getCoords();
if (p && this.childBase !== base && this.screen.cleanSides(this)) {
t = p.yi + this.itop;
b = p.yl - this.ibottom - 1;
d = this.childBase - base;
if (d > 0 && d < visible) {
// scrolled down
this.screen.deleteLine(d, t, t, b);
} else if (d < 0 && -d < visible) {
// scrolled up
d = -d;
this.screen.insertLine(d, t, t, b);
}
}
return this.emit('scroll');
};
ScrollableBox.prototype._recalculateIndex = function() {
var max, emax;
if (this.detached || !this.scrollable) {
return 0;
}
// XXX
// max = this.getScrollHeight() - (this.height - this.iheight);
max = this._clines.length - (this.height - this.iheight);
if (max < 0) max = 0;
emax = this._scrollBottom() - (this.height - this.iheight);
if (emax < 0) emax = 0;
this.childBase = Math.min(this.childBase, Math.max(emax, max));
if (this.childBase < 0) {
this.childBase = 0;
} else if (this.childBase > this.baseLimit) {
this.childBase = this.baseLimit;
}
};
ScrollableBox.prototype.resetScroll = function() {
if (!this.scrollable) return;
this.childOffset = 0;
this.childBase = 0;
return this.emit('scroll');
};
ScrollableBox.prototype.getScrollHeight = function() {
return Math.max(this._clines.length, this._scrollBottom());
};
ScrollableBox.prototype.getScrollPerc = function(s) {
var pos = this.lpos || this._getCoords();
if (!pos) return s ? -1 : 0;
var height = (pos.yl - pos.yi) - this.iheight
, i = this.getScrollHeight()
, p;
if (height < i) {
if (this.alwaysScroll) {
p = this.childBase / (i - height);
} else {
p = (this.childBase + this.childOffset) / (i - 1);
}
return p * 100;
}
return s ? -1 : 0;
};
ScrollableBox.prototype.setScrollPerc = function(i) {
// XXX
// var m = this.getScrollHeight();
var m = Math.max(this._clines.length, this._scrollBottom());
return this.scrollTo((i / 100) * m | 0);
};
/**
* Expose
*/
module.exports = ScrollableBox;

35
node_modules/blessed/lib/widgets/scrollabletext.js generated vendored Normal file
View File

@ -0,0 +1,35 @@
/**
* scrollabletext.js - scrollable text element for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var Node = require('./node');
var ScrollableBox = require('./scrollablebox');
/**
* ScrollableText
*/
function ScrollableText(options) {
if (!(this instanceof Node)) {
return new ScrollableText(options);
}
options = options || {};
options.alwaysScroll = true;
ScrollableBox.call(this, options);
}
ScrollableText.prototype.__proto__ = ScrollableBox.prototype;
ScrollableText.prototype.type = 'scrollable-text';
/**
* Expose
*/
module.exports = ScrollableText;

354
node_modules/blessed/lib/widgets/table.js generated vendored Normal file
View File

@ -0,0 +1,354 @@
/**
* table.js - table element for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var Node = require('./node');
var Box = require('./box');
/**
* Table
*/
function Table(options) {
var self = this;
if (!(this instanceof Node)) {
return new Table(options);
}
options = options || {};
options.shrink = true;
options.style = options.style || {};
options.style.border = options.style.border || {};
options.style.header = options.style.header || {};
options.style.cell = options.style.cell || {};
options.align = options.align || 'center';
// Regular tables do not get custom height (this would
// require extra padding). Maybe add in the future.
delete options.height;
Box.call(this, options);
this.pad = options.pad != null
? options.pad
: 2;
this.setData(options.rows || options.data);
this.on('attach', function() {
self.setContent('');
self.setData(self.rows);
});
this.on('resize', function() {
self.setContent('');
self.setData(self.rows);
self.screen.render();
});
}
Table.prototype.__proto__ = Box.prototype;
Table.prototype.type = 'table';
Table.prototype._calculateMaxes = function() {
var self = this;
var maxes = [];
if (this.detached) return;
this.rows = this.rows || [];
this.rows.forEach(function(row) {
row.forEach(function(cell, i) {
var clen = self.strWidth(cell);
if (!maxes[i] || maxes[i] < clen) {
maxes[i] = clen;
}
});
});
var total = maxes.reduce(function(total, max) {
return total + max;
}, 0);
total += maxes.length + 1;
// XXX There might be an issue with resizing where on the first resize event
// width appears to be less than total if it's a percentage or left/right
// combination.
if (this.width < total) {
delete this.position.width;
}
if (this.position.width != null) {
var missing = this.width - total;
var w = missing / maxes.length | 0;
var wr = missing % maxes.length;
maxes = maxes.map(function(max, i) {
if (i === maxes.length - 1) {
return max + w + wr;
}
return max + w;
});
} else {
maxes = maxes.map(function(max) {
return max + self.pad;
});
}
return this._maxes = maxes;
};
Table.prototype.setRows =
Table.prototype.setData = function(rows) {
var self = this
, text = ''
, align = this.align;
this.rows = rows || [];
this._calculateMaxes();
if (!this._maxes) return;
this.rows.forEach(function(row, i) {
var isFooter = i === self.rows.length - 1;
row.forEach(function(cell, i) {
var width = self._maxes[i];
var clen = self.strWidth(cell);
if (i !== 0) {
text += ' ';
}
while (clen < width) {
if (align === 'center') {
cell = ' ' + cell + ' ';
clen += 2;
} else if (align === 'left') {
cell = cell + ' ';
clen += 1;
} else if (align === 'right') {
cell = ' ' + cell;
clen += 1;
}
}
if (clen > width) {
if (align === 'center') {
cell = cell.substring(1);
clen--;
} else if (align === 'left') {
cell = cell.slice(0, -1);
clen--;
} else if (align === 'right') {
cell = cell.substring(1);
clen--;
}
}
text += cell;
});
if (!isFooter) {
text += '\n\n';
}
});
delete this.align;
this.setContent(text);
this.align = align;
};
Table.prototype.render = function() {
var self = this;
var coords = this._render();
if (!coords) return;
this._calculateMaxes();
if (!this._maxes) return coords;
var lines = this.screen.lines
, xi = coords.xi
, yi = coords.yi
, rx
, ry
, i;
var dattr = this.sattr(this.style)
, hattr = this.sattr(this.style.header)
, cattr = this.sattr(this.style.cell)
, battr = this.sattr(this.style.border);
var width = coords.xl - coords.xi - this.iright
, height = coords.yl - coords.yi - this.ibottom;
// Apply attributes to header cells and cells.
for (var y = this.itop; y < height; y++) {
if (!lines[yi + y]) break;
for (var x = this.ileft; x < width; x++) {
if (!lines[yi + y][xi + x]) break;
// Check to see if it's not the default attr. Allows for tags:
if (lines[yi + y][xi + x][0] !== dattr) continue;
if (y === this.itop) {
lines[yi + y][xi + x][0] = hattr;
} else {
lines[yi + y][xi + x][0] = cattr;
}
lines[yi + y].dirty = true;
}
}
if (!this.border || this.options.noCellBorders) return coords;
// Draw border with correct angles.
ry = 0;
for (i = 0; i < self.rows.length + 1; i++) {
if (!lines[yi + ry]) break;
rx = 0;
self._maxes.forEach(function(max, i) {
rx += max;
if (i === 0) {
if (!lines[yi + ry][xi + 0]) return;
// left side
if (ry === 0) {
// top
lines[yi + ry][xi + 0][0] = battr;
// lines[yi + ry][xi + 0][1] = '\u250c'; // '┌'
} else if (ry / 2 === self.rows.length) {
// bottom
lines[yi + ry][xi + 0][0] = battr;
// lines[yi + ry][xi + 0][1] = '\u2514'; // '└'
} else {
// middle
lines[yi + ry][xi + 0][0] = battr;
lines[yi + ry][xi + 0][1] = '\u251c'; // '├'
// XXX If we alter iwidth and ileft for no borders - nothing should be written here
if (!self.border.left) {
lines[yi + ry][xi + 0][1] = '\u2500'; // '─'
}
}
lines[yi + ry].dirty = true;
} else if (i === self._maxes.length - 1) {
if (!lines[yi + ry][xi + rx + 1]) return;
// right side
if (ry === 0) {
// top
rx++;
lines[yi + ry][xi + rx][0] = battr;
// lines[yi + ry][xi + rx][1] = '\u2510'; // '┐'
} else if (ry / 2 === self.rows.length) {
// bottom
rx++;
lines[yi + ry][xi + rx][0] = battr;
// lines[yi + ry][xi + rx][1] = '\u2518'; // '┘'
} else {
// middle
rx++;
lines[yi + ry][xi + rx][0] = battr;
lines[yi + ry][xi + rx][1] = '\u2524'; // '┤'
// XXX If we alter iwidth and iright for no borders - nothing should be written here
if (!self.border.right) {
lines[yi + ry][xi + rx][1] = '\u2500'; // '─'
}
}
lines[yi + ry].dirty = true;
return;
}
if (!lines[yi + ry][xi + rx + 1]) return;
// center
if (ry === 0) {
// top
rx++;
lines[yi + ry][xi + rx][0] = battr;
lines[yi + ry][xi + rx][1] = '\u252c'; // '┬'
// XXX If we alter iheight and itop for no borders - nothing should be written here
if (!self.border.top) {
lines[yi + ry][xi + rx][1] = '\u2502'; // '│'
}
} else if (ry / 2 === self.rows.length) {
// bottom
rx++;
lines[yi + ry][xi + rx][0] = battr;
lines[yi + ry][xi + rx][1] = '\u2534'; // '┴'
// XXX If we alter iheight and ibottom for no borders - nothing should be written here
if (!self.border.bottom) {
lines[yi + ry][xi + rx][1] = '\u2502'; // '│'
}
} else {
// middle
if (self.options.fillCellBorders) {
var lbg = (ry <= 2 ? hattr : cattr) & 0x1ff;
rx++;
lines[yi + ry][xi + rx][0] = (battr & ~0x1ff) | lbg;
} else {
rx++;
lines[yi + ry][xi + rx][0] = battr;
}
lines[yi + ry][xi + rx][1] = '\u253c'; // '┼'
// rx++;
}
lines[yi + ry].dirty = true;
});
ry += 2;
}
// Draw internal borders.
for (ry = 1; ry < self.rows.length * 2; ry++) {
if (!lines[yi + ry]) break;
rx = 0;
self._maxes.slice(0, -1).forEach(function(max) {
rx += max;
if (!lines[yi + ry][xi + rx + 1]) return;
if (ry % 2 !== 0) {
if (self.options.fillCellBorders) {
var lbg = (ry <= 2 ? hattr : cattr) & 0x1ff;
rx++;
lines[yi + ry][xi + rx][0] = (battr & ~0x1ff) | lbg;
} else {
rx++;
lines[yi + ry][xi + rx][0] = battr;
}
lines[yi + ry][xi + rx][1] = '\u2502'; // '│'
lines[yi + ry].dirty = true;
} else {
rx++;
}
});
rx = 1;
self._maxes.forEach(function(max) {
while (max--) {
if (ry % 2 === 0) {
if (!lines[yi + ry]) break;
if (!lines[yi + ry][xi + rx + 1]) break;
if (self.options.fillCellBorders) {
var lbg = (ry <= 2 ? hattr : cattr) & 0x1ff;
lines[yi + ry][xi + rx][0] = (battr & ~0x1ff) | lbg;
} else {
lines[yi + ry][xi + rx][0] = battr;
}
lines[yi + ry][xi + rx][1] = '\u2500'; // '─'
lines[yi + ry].dirty = true;
}
rx++;
}
rx++;
});
}
return coords;
};
/**
* Expose
*/
module.exports = Table;

412
node_modules/blessed/lib/widgets/terminal.js generated vendored Normal file
View File

@ -0,0 +1,412 @@
/**
* terminal.js - term.js terminal element for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var nextTick = global.setImmediate || process.nextTick.bind(process);
var Node = require('./node');
var Box = require('./box');
/**
* Terminal
*/
function Terminal(options) {
if (!(this instanceof Node)) {
return new Terminal(options);
}
options = options || {};
options.scrollable = false;
Box.call(this, options);
// XXX Workaround for all motion
if (this.screen.program.tmux && this.screen.program.tmuxVersion >= 2) {
this.screen.program.enableMouse();
}
this.handler = options.handler;
this.shell = options.shell || process.env.SHELL || 'sh';
this.args = options.args || [];
this.cursor = this.options.cursor;
this.cursorBlink = this.options.cursorBlink;
this.screenKeys = this.options.screenKeys;
this.style = this.style || {};
this.style.bg = this.style.bg || 'default';
this.style.fg = this.style.fg || 'default';
this.termName = options.terminal
|| options.term
|| process.env.TERM
|| 'xterm';
this.bootstrap();
}
Terminal.prototype.__proto__ = Box.prototype;
Terminal.prototype.type = 'terminal';
Terminal.prototype.bootstrap = function() {
var self = this;
var element = {
// window
get document() { return element; },
navigator: { userAgent: 'node.js' },
// document
get defaultView() { return element; },
get documentElement() { return element; },
createElement: function() { return element; },
// element
get ownerDocument() { return element; },
addEventListener: function() {},
removeEventListener: function() {},
getElementsByTagName: function() { return [element]; },
getElementById: function() { return element; },
parentNode: null,
offsetParent: null,
appendChild: function() {},
removeChild: function() {},
setAttribute: function() {},
getAttribute: function() {},
style: {},
focus: function() {},
blur: function() {},
console: console
};
element.parentNode = element;
element.offsetParent = element;
this.term = require('term.js')({
termName: this.termName,
cols: this.width - this.iwidth,
rows: this.height - this.iheight,
context: element,
document: element,
body: element,
parent: element,
cursorBlink: this.cursorBlink,
screenKeys: this.screenKeys
});
this.term.refresh = function() {
self.screen.render();
};
this.term.keyDown = function() {};
this.term.keyPress = function() {};
this.term.open(element);
// Emits key sequences in html-land.
// Technically not necessary here.
// In reality if we wanted to be neat, we would overwrite the keyDown and
// keyPress methods with our own node.js-keys->terminal-keys methods, but
// since all the keys are already coming in as escape sequences, we can just
// send the input directly to the handler/socket (see below).
// this.term.on('data', function(data) {
// self.handler(data);
// });
// Incoming keys and mouse inputs.
// NOTE: Cannot pass mouse events - coordinates will be off!
this.screen.program.input.on('data', this._onData = function(data) {
if (self.screen.focused === self && !self._isMouse(data)) {
self.handler(data);
}
});
this.onScreenEvent('mouse', function(data) {
if (self.screen.focused !== self) return;
if (data.x < self.aleft + self.ileft) return;
if (data.y < self.atop + self.itop) return;
if (data.x > self.aleft - self.ileft + self.width) return;
if (data.y > self.atop - self.itop + self.height) return;
if (self.term.x10Mouse
|| self.term.vt200Mouse
|| self.term.normalMouse
|| self.term.mouseEvents
|| self.term.utfMouse
|| self.term.sgrMouse
|| self.term.urxvtMouse) {
;
} else {
return;
}
var b = data.raw[0]
, x = data.x - self.aleft
, y = data.y - self.atop
, s;
if (self.term.urxvtMouse) {
if (self.screen.program.sgrMouse) {
b += 32;
}
s = '\x1b[' + b + ';' + (x + 32) + ';' + (y + 32) + 'M';
} else if (self.term.sgrMouse) {
if (!self.screen.program.sgrMouse) {
b -= 32;
}
s = '\x1b[<' + b + ';' + x + ';' + y
+ (data.action === 'mousedown' ? 'M' : 'm');
} else {
if (self.screen.program.sgrMouse) {
b += 32;
}
s = '\x1b[M'
+ String.fromCharCode(b)
+ String.fromCharCode(x + 32)
+ String.fromCharCode(y + 32);
}
self.handler(s);
});
this.on('focus', function() {
self.term.focus();
});
this.on('blur', function() {
self.term.blur();
});
this.term.on('title', function(title) {
self.title = title;
self.emit('title', title);
});
this.term.on('passthrough', function(data) {
self.screen.program.flush();
self.screen.program._owrite(data);
});
this.on('resize', function() {
nextTick(function() {
self.term.resize(self.width - self.iwidth, self.height - self.iheight);
});
});
this.once('render', function() {
self.term.resize(self.width - self.iwidth, self.height - self.iheight);
});
this.on('destroy', function() {
self.kill();
self.screen.program.input.removeListener('data', self._onData);
});
if (this.handler) {
return;
}
this.pty = require('pty.js').fork(this.shell, this.args, {
name: this.termName,
cols: this.width - this.iwidth,
rows: this.height - this.iheight,
cwd: process.env.HOME,
env: this.options.env || process.env
});
this.on('resize', function() {
nextTick(function() {
try {
self.pty.resize(self.width - self.iwidth, self.height - self.iheight);
} catch (e) {
;
}
});
});
this.handler = function(data) {
self.pty.write(data);
self.screen.render();
};
this.pty.on('data', function(data) {
self.write(data);
self.screen.render();
});
this.pty.on('exit', function(code) {
self.emit('exit', code || null);
});
this.onScreenEvent('keypress', function() {
self.screen.render();
});
this.screen._listenKeys(this);
};
Terminal.prototype.write = function(data) {
return this.term.write(data);
};
Terminal.prototype.render = function() {
var ret = this._render();
if (!ret) return;
this.dattr = this.sattr(this.style);
var xi = ret.xi + this.ileft
, xl = ret.xl - this.iright
, yi = ret.yi + this.itop
, yl = ret.yl - this.ibottom
, cursor;
var scrollback = this.term.lines.length - (yl - yi);
for (var y = Math.max(yi, 0); y < yl; y++) {
var line = this.screen.lines[y];
if (!line || !this.term.lines[scrollback + y - yi]) break;
if (y === yi + this.term.y
&& this.term.cursorState
&& this.screen.focused === this
&& (this.term.ydisp === this.term.ybase || this.term.selectMode)
&& !this.term.cursorHidden) {
cursor = xi + this.term.x;
} else {
cursor = -1;
}
for (var x = Math.max(xi, 0); x < xl; x++) {
if (!line[x] || !this.term.lines[scrollback + y - yi][x - xi]) break;
line[x][0] = this.term.lines[scrollback + y - yi][x - xi][0];
if (x === cursor) {
if (this.cursor === 'line') {
line[x][0] = this.dattr;
line[x][1] = '\u2502';
continue;
} else if (this.cursor === 'underline') {
line[x][0] = this.dattr | (2 << 18);
} else if (this.cursor === 'block' || !this.cursor) {
line[x][0] = this.dattr | (8 << 18);
}
}
line[x][1] = this.term.lines[scrollback + y - yi][x - xi][1];
// default foreground = 257
if (((line[x][0] >> 9) & 0x1ff) === 257) {
line[x][0] &= ~(0x1ff << 9);
line[x][0] |= ((this.dattr >> 9) & 0x1ff) << 9;
}
// default background = 256
if ((line[x][0] & 0x1ff) === 256) {
line[x][0] &= ~0x1ff;
line[x][0] |= this.dattr & 0x1ff;
}
}
line.dirty = true;
}
return ret;
};
Terminal.prototype._isMouse = function(buf) {
var s = buf;
if (Buffer.isBuffer(s)) {
if (s[0] > 127 && s[1] === undefined) {
s[0] -= 128;
s = '\x1b' + s.toString('utf-8');
} else {
s = s.toString('utf-8');
}
}
return (buf[0] === 0x1b && buf[1] === 0x5b && buf[2] === 0x4d)
|| /^\x1b\[M([\x00\u0020-\uffff]{3})/.test(s)
|| /^\x1b\[(\d+;\d+;\d+)M/.test(s)
|| /^\x1b\[<(\d+;\d+;\d+)([mM])/.test(s)
|| /^\x1b\[<(\d+;\d+;\d+;\d+)&w/.test(s)
|| /^\x1b\[24([0135])~\[(\d+),(\d+)\]\r/.test(s)
|| /^\x1b\[(O|I)/.test(s);
};
Terminal.prototype.setScroll =
Terminal.prototype.scrollTo = function(offset) {
this.term.ydisp = offset;
return this.emit('scroll');
};
Terminal.prototype.getScroll = function() {
return this.term.ydisp;
};
Terminal.prototype.scroll = function(offset) {
this.term.scrollDisp(offset);
return this.emit('scroll');
};
Terminal.prototype.resetScroll = function() {
this.term.ydisp = 0;
this.term.ybase = 0;
return this.emit('scroll');
};
Terminal.prototype.getScrollHeight = function() {
return this.term.rows - 1;
};
Terminal.prototype.getScrollPerc = function() {
return (this.term.ydisp / this.term.ybase) * 100;
};
Terminal.prototype.setScrollPerc = function(i) {
return this.setScroll((i / 100) * this.term.ybase | 0);
};
Terminal.prototype.screenshot = function(xi, xl, yi, yl) {
xi = 0 + (xi || 0);
if (xl != null) {
xl = 0 + (xl || 0);
} else {
xl = this.term.lines[0].length;
}
yi = 0 + (yi || 0);
if (yl != null) {
yl = 0 + (yl || 0);
} else {
yl = this.term.lines.length;
}
return this.screen.screenshot(xi, xl, yi, yl, this.term);
};
Terminal.prototype.kill = function() {
if (this.pty) {
this.pty.destroy();
this.pty.kill();
}
this.term.refresh = function() {};
this.term.write('\x1b[H\x1b[J');
if (this.term._blink) {
clearInterval(this.term._blink);
}
this.term.destroy();
};
/**
* Expose
*/
module.exports = Terminal;

35
node_modules/blessed/lib/widgets/text.js generated vendored Normal file
View File

@ -0,0 +1,35 @@
/**
* text.js - text element for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var Node = require('./node');
var Element = require('./element');
/**
* Text
*/
function Text(options) {
if (!(this instanceof Node)) {
return new Text(options);
}
options = options || {};
options.shrink = true;
Element.call(this, options);
}
Text.prototype.__proto__ = Element.prototype;
Text.prototype.type = 'text';
/**
* Expose
*/
module.exports = Text;

342
node_modules/blessed/lib/widgets/textarea.js generated vendored Normal file
View File

@ -0,0 +1,342 @@
/**
* textarea.js - textarea element for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var unicode = require('../unicode');
var nextTick = global.setImmediate || process.nextTick.bind(process);
var Node = require('./node');
var Input = require('./input');
/**
* Textarea
*/
function Textarea(options) {
var self = this;
if (!(this instanceof Node)) {
return new Textarea(options);
}
options = options || {};
options.scrollable = options.scrollable !== false;
Input.call(this, options);
this.screen._listenKeys(this);
this.value = options.value || '';
this.__updateCursor = this._updateCursor.bind(this);
this.on('resize', this.__updateCursor);
this.on('move', this.__updateCursor);
if (options.inputOnFocus) {
this.on('focus', this.readInput.bind(this, null));
}
if (!options.inputOnFocus && options.keys) {
this.on('keypress', function(ch, key) {
if (self._reading) return;
if (key.name === 'enter' || (options.vi && key.name === 'i')) {
return self.readInput();
}
if (key.name === 'e') {
return self.readEditor();
}
});
}
if (options.mouse) {
this.on('click', function(data) {
if (self._reading) return;
if (data.button !== 'right') return;
self.readEditor();
});
}
}
Textarea.prototype.__proto__ = Input.prototype;
Textarea.prototype.type = 'textarea';
Textarea.prototype._updateCursor = function(get) {
if (this.screen.focused !== this) {
return;
}
var lpos = get ? this.lpos : this._getCoords();
if (!lpos) return;
var last = this._clines[this._clines.length - 1]
, program = this.screen.program
, line
, cx
, cy;
// Stop a situation where the textarea begins scrolling
// and the last cline appears to always be empty from the
// _typeScroll `+ '\n'` thing.
// Maybe not necessary anymore?
if (last === '' && this.value[this.value.length - 1] !== '\n') {
last = this._clines[this._clines.length - 2] || '';
}
line = Math.min(
this._clines.length - 1 - (this.childBase || 0),
(lpos.yl - lpos.yi) - this.iheight - 1);
// When calling clearValue() on a full textarea with a border, the first
// argument in the above Math.min call ends up being -2. Make sure we stay
// positive.
line = Math.max(0, line);
cy = lpos.yi + this.itop + line;
cx = lpos.xi + this.ileft + this.strWidth(last);
// XXX Not sure, but this may still sometimes
// cause problems when leaving editor.
if (cy === program.y && cx === program.x) {
return;
}
if (cy === program.y) {
if (cx > program.x) {
program.cuf(cx - program.x);
} else if (cx < program.x) {
program.cub(program.x - cx);
}
} else if (cx === program.x) {
if (cy > program.y) {
program.cud(cy - program.y);
} else if (cy < program.y) {
program.cuu(program.y - cy);
}
} else {
program.cup(cy, cx);
}
};
Textarea.prototype.input =
Textarea.prototype.setInput =
Textarea.prototype.readInput = function(callback) {
var self = this
, focused = this.screen.focused === this;
if (this._reading) return;
this._reading = true;
this._callback = callback;
if (!focused) {
this.screen.saveFocus();
this.focus();
}
this.screen.grabKeys = true;
this._updateCursor();
this.screen.program.showCursor();
//this.screen.program.sgr('normal');
this._done = function fn(err, value) {
if (!self._reading) return;
if (fn.done) return;
fn.done = true;
self._reading = false;
delete self._callback;
delete self._done;
self.removeListener('keypress', self.__listener);
delete self.__listener;
self.removeListener('blur', self.__done);
delete self.__done;
self.screen.program.hideCursor();
self.screen.grabKeys = false;
if (!focused) {
self.screen.restoreFocus();
}
if (self.options.inputOnFocus) {
self.screen.rewindFocus();
}
// Ugly
if (err === 'stop') return;
if (err) {
self.emit('error', err);
} else if (value != null) {
self.emit('submit', value);
} else {
self.emit('cancel', value);
}
self.emit('action', value);
if (!callback) return;
return err
? callback(err)
: callback(null, value);
};
// Put this in a nextTick so the current
// key event doesn't trigger any keys input.
nextTick(function() {
self.__listener = self._listener.bind(self);
self.on('keypress', self.__listener);
});
this.__done = this._done.bind(this, null, null);
this.on('blur', this.__done);
};
Textarea.prototype._listener = function(ch, key) {
var done = this._done
, value = this.value;
if (key.name === 'return') return;
if (key.name === 'enter') {
ch = '\n';
}
// TODO: Handle directional keys.
if (key.name === 'left' || key.name === 'right'
|| key.name === 'up' || key.name === 'down') {
;
}
if (this.options.keys && key.ctrl && key.name === 'e') {
return this.readEditor();
}
// TODO: Optimize typing by writing directly
// to the screen and screen buffer here.
if (key.name === 'escape') {
done(null, null);
} else if (key.name === 'backspace') {
if (this.value.length) {
if (this.screen.fullUnicode) {
if (unicode.isSurrogate(this.value, this.value.length - 2)) {
// || unicode.isCombining(this.value, this.value.length - 1)) {
this.value = this.value.slice(0, -2);
} else {
this.value = this.value.slice(0, -1);
}
} else {
this.value = this.value.slice(0, -1);
}
}
} else if (ch) {
if (!/^[\x00-\x08\x0b-\x0c\x0e-\x1f\x7f]$/.test(ch)) {
this.value += ch;
}
}
if (this.value !== value) {
this.screen.render();
}
};
Textarea.prototype._typeScroll = function() {
// XXX Workaround
var height = this.height - this.iheight;
if (this._clines.length - this.childBase > height) {
this.scroll(this._clines.length);
}
};
Textarea.prototype.getValue = function() {
return this.value;
};
Textarea.prototype.setValue = function(value) {
if (value == null) {
value = this.value;
}
if (this._value !== value) {
this.value = value;
this._value = value;
this.setContent(this.value);
this._typeScroll();
this._updateCursor();
}
};
Textarea.prototype.clearInput =
Textarea.prototype.clearValue = function() {
return this.setValue('');
};
Textarea.prototype.submit = function() {
if (!this.__listener) return;
return this.__listener('\x1b', { name: 'escape' });
};
Textarea.prototype.cancel = function() {
if (!this.__listener) return;
return this.__listener('\x1b', { name: 'escape' });
};
Textarea.prototype.render = function() {
this.setValue();
return this._render();
};
Textarea.prototype.editor =
Textarea.prototype.setEditor =
Textarea.prototype.readEditor = function(callback) {
var self = this;
if (this._reading) {
var _cb = this._callback
, cb = callback;
this._done('stop');
callback = function(err, value) {
if (_cb) _cb(err, value);
if (cb) cb(err, value);
};
}
if (!callback) {
callback = function() {};
}
return this.screen.readEditor({ value: this.value }, function(err, value) {
if (err) {
if (err.message === 'Unsuccessful.') {
self.screen.render();
return self.readInput(callback);
}
self.screen.render();
self.readInput(callback);
return callback(err);
}
self.setValue(value);
self.screen.render();
return self.readInput(callback);
});
};
/**
* Expose
*/
module.exports = Textarea;

77
node_modules/blessed/lib/widgets/textbox.js generated vendored Normal file
View File

@ -0,0 +1,77 @@
/**
* textbox.js - textbox element for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var Node = require('./node');
var Textarea = require('./textarea');
/**
* Textbox
*/
function Textbox(options) {
if (!(this instanceof Node)) {
return new Textbox(options);
}
options = options || {};
options.scrollable = false;
Textarea.call(this, options);
this.secret = options.secret;
this.censor = options.censor;
}
Textbox.prototype.__proto__ = Textarea.prototype;
Textbox.prototype.type = 'textbox';
Textbox.prototype.__olistener = Textbox.prototype._listener;
Textbox.prototype._listener = function(ch, key) {
if (key.name === 'enter') {
this._done(null, this.value);
return;
}
return this.__olistener(ch, key);
};
Textbox.prototype.setValue = function(value) {
var visible, val;
if (value == null) {
value = this.value;
}
if (this._value !== value) {
value = value.replace(/\n/g, '');
this.value = value;
this._value = value;
if (this.secret) {
this.setContent('');
} else if (this.censor) {
this.setContent(Array(this.value.length + 1).join('*'));
} else {
visible = -(this.width - this.iwidth - 1);
val = this.value.replace(/\t/g, this.screen.tabc);
this.setContent(val.slice(visible));
}
this._updateCursor();
}
};
Textbox.prototype.submit = function() {
if (!this.__listener) return;
return this.__listener('\r', { name: 'enter' });
};
/**
* Expose
*/
module.exports = Textbox;

126
node_modules/blessed/lib/widgets/video.js generated vendored Normal file
View File

@ -0,0 +1,126 @@
/**
* video.js - video element for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var cp = require('child_process');
var Node = require('./node');
var Box = require('./box');
var Terminal = require('./terminal');
/**
* Video
*/
function Video(options) {
var self = this
, shell
, args;
if (!(this instanceof Node)) {
return new Video(options);
}
options = options || {};
Box.call(this, options);
if (this.exists('mplayer')) {
shell = 'mplayer';
args = ['-vo', 'caca', '-quiet', options.file];
} else if (this.exists('mpv')) {
shell = 'mpv';
args = ['--vo', 'caca', '--really-quiet', options.file];
} else {
this.parseTags = true;
this.setContent('{red-fg}{bold}Error:{/bold}'
+ ' mplayer or mpv not installed.{/red-fg}');
return this;
}
var opts = {
parent: this,
left: 0,
top: 0,
width: this.width - this.iwidth,
height: this.height - this.iheight,
shell: shell,
args: args.slice()
};
this.now = Date.now() / 1000 | 0;
this.start = opts.start || 0;
if (this.start) {
if (shell === 'mplayer') {
opts.args.unshift('-ss', this.start + '');
} else if (shell === 'mpv') {
opts.args.unshift('--start', this.start + '');
}
}
var DISPLAY = process.env.DISPLAY;
delete process.env.DISPLAY;
this.tty = new Terminal(opts);
process.env.DISPLAY = DISPLAY;
this.on('click', function() {
self.tty.pty.write('p');
});
// mplayer/mpv cannot resize itself in the terminal, so we have
// to restart it at the correct start time.
this.on('resize', function() {
self.tty.destroy();
var opts = {
parent: self,
left: 0,
top: 0,
width: self.width - self.iwidth,
height: self.height - self.iheight,
shell: shell,
args: args.slice()
};
var watched = (Date.now() / 1000 | 0) - self.now;
self.now = Date.now() / 1000 | 0;
self.start += watched;
if (shell === 'mplayer') {
opts.args.unshift('-ss', self.start + '');
} else if (shell === 'mpv') {
opts.args.unshift('--start', self.start + '');
}
var DISPLAY = process.env.DISPLAY;
delete process.env.DISPLAY;
self.tty = new Terminal(opts);
process.env.DISPLAY = DISPLAY;
self.screen.render();
});
}
Video.prototype.__proto__ = Box.prototype;
Video.prototype.type = 'video';
Video.prototype.exists = function(program) {
try {
return !!+cp.execSync('type '
+ program + ' > /dev/null 2> /dev/null'
+ ' && echo 1', { encoding: 'utf8' }).trim();
} catch (e) {
return false;
}
};
/**
* Expose
*/
module.exports = Video;

21
node_modules/blessed/package.json generated vendored Normal file
View File

@ -0,0 +1,21 @@
{
"name": "blessed",
"description": "A high-level terminal interface library for node.js.",
"author": "Christopher Jeffrey",
"version": "0.1.81",
"license": "MIT",
"main": "./lib/blessed.js",
"bin": "./bin/tput.js",
"preferGlobal": false,
"repository": "git://github.com/chjj/blessed.git",
"homepage": "https://github.com/chjj/blessed",
"bugs": { "url": "http://github.com/chjj/blessed/issues" },
"keywords": ["curses", "tui", "tput", "terminfo", "termcap"],
"tags": ["curses", "tui", "tput", "terminfo", "termcap"],
"engines": {
"node": ">= 0.8.0"
},
"browserify": {
"transform": ["./browser/transform.js"]
}
}

1
node_modules/blessed/usr/fonts/AUTHORS generated vendored Normal file
View File

@ -0,0 +1 @@
Dimitar Zhekov <dimitar.zhekov@gmail.com>

94
node_modules/blessed/usr/fonts/LICENSE generated vendored Normal file
View File

@ -0,0 +1,94 @@
Copyright (c) 2014 Dimitar Toshkov Zhekov,
with Reserved Font Name "Terminus Font".
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

340
node_modules/blessed/usr/fonts/README generated vendored Normal file
View File

@ -0,0 +1,340 @@
NOTE: This directory contains the terminus font compiled to a JSON format.
Contents:
1. About.
1.1. Quick installation.
1.2. Legend.
1.3. Variants.
1.4. Notes.
2. Linux console.
2.1. consoletools.
2.2. kbd.
2.3. Quick reference.
2.4. Legend.
2.5. Notes.
3. UNIX console.
3.1. bsd-pcvt.
3.2. Legend.
3.3. Notes.
4. X11 Window System.
4.1. Installation.
4.2. Notes.
5. Frequently Asked Questions.
6. Legal information.
6.1. Licenses.
6.2. Copyright.
1. About.
This archive contains source code for generating and installing Terminus
Font for Linux console, BSD console and X11 Window System.
- version 4.39
- sizes 6x12, 8x14, 8x16, 10x18, 10x20, 11x22, 12x24, 14x28, 16x32
- styles normal, bold, EGA/VGA bold
- characters 891
- format Bitmap Distribution Format (BDF) version 2.1
The character set covers about 120 language sets and supports ISO8859-1/2/5/
7/9/13/15/16, Paratype-PT154/PT254, KOI8-R/U/E/F, Esperanto and many IBM,
Windows and Macintosh code pages, as well as the IBM VGA, vt100 and xterm
pseudographic characters.
1.1. Quick installation.
The commands:
$ ./configure [--prefix=PREFIX]
$ make
# make install fontdir
compile and install the Linux console and X11 Window System fonts.
The default PREFIX is /usr/local.
1.2. Legend.
The file names are structured as follows:
ter-u<SIZE><STYLE>.bdf
where <SIZE> is the font height, and <STYLE> is n for normal (all sizes), b
for bold (all sizes except 6x12) and v for EGA/VGA bold (8x14 and 8x16 only,
makes use of the eight character matrix column).
1.3. Variants.
Some characters are implemented in two variants. To use the alternate
variant, execute:
$ patch -p1 -i alt/<NAME>.diff
before installation. See the font page for examples about the differences.
If you want to combine hi2 with dv1 and/or ka2, apply hi2 and then hi2-dv1
and/or hi2-ka2.
1.4. Notes.
The commands marked with $ can be executed by a regular user.
The configure commands are optional.
The make commands require GNU make.
A lot of characters are available only under X11/ISO10646-1 (UTF+8/Unicode).
Sizes 6x12, 11x22, 14x28-bold and 16x32-normal are worse than the others.
Avoid them.
210E and 210F are not italic.
2. Linux console.
- sizes all available, see "About"
- styles normal, bold, framebuffer-bold
- code pages ISO8859-1/ISO8859-15/Windows-1252, ISO8859-2/Windows-1250,
Windows-1251/ISO8859-5, ISO8859-9/Windows-1254, ISO8859-16,
ISO8859-7/Windows-1253, ISO8859-13/Windows-1257, IBM-437,
Bulgarian-MIK, KOI8-R, KOI8-U, Paratype-PT154, combined
- format PC Screen Font (PSF) with unicode data
2.1. consoletools.
$ ./configure [--prefix=PREFIX | --psfdir=DIRECTORY]
$ make psf
# make install-psf
The files are compressed with gzip and installed in DIRECTORY. The default
DIRECTORY is PREFIX/share/consolefonts. Requires Perl.
If you lack mappings for Windows-1252/1250/1251/1254/1253/1257, ISO8859-16,
IBM-437, KOI8-R, Bulgarian-MIK or Paratype-PT154/PT254, also run:
$ ./configure [--prefix=PREFIX | --acmdir=DIRECTORY]
$ make txt
# make install-acm
The default DIRECTORY is PREFIX/share/consoletrans. Requires awk.
Uninstallation of the mappings is not supported. To load a font:
$ consolechars [-m MAPPING] -f ter-<X><SIZE><STYLE>
where <X> is a character identifying the code page as listed in p.2.4.
2.2. kbd.
$ ./configure [--psfdir=DIRECTORY]
$ make psf
# make install-psf
where DIRECTORY should be either PREFIX/lib/kbd/consolefonts or
PREFIX/share/kbd/consolefonts, depending on kbd version. Missing mappings
are installed with:
$ ./configure [--prefix=PREFIX | --unidir=DIRECTORY]
$ make txt
# make install-uni
The default DIRECTORY is PREFIX/share/kbd/consoletrans. Requires awk. To
load a font:
$ setfont [-m MAPPING] ter-<X><SIZE><STYLE>
where <X> is a character identifying the code page as listed in p.2.4.
2.3. Quick reference.
The commands:
$ ./configure [--prefix=PREFIX | --psfdir=DIRECTORY | --ref=FILENAME]
# make install-ref
install the text from p.2.4 as FILENAME (the default is README.terminus)
in DIRECTORY.
2.4. Legend.
names mappings covered codepage(s)
ter-1* iso01, iso15, cp1252 ISO8859-1, ISO8859-15, Windows-1252
ter-2* iso02, cp1250 ISO8859-2, Windows-1250
ter-7* iso07, cp1253 ISO8859-7, Windows-1253
ter-9* iso09, cp1254 ISO8859-9, Windows-1254
ter-c* cp1251, iso05 Windows-1251, ISO8859-5
ter-d* iso13, cp1257 ISO8859-13, Windows-1257
ter-g* iso16 ISO8859-16
ter-i* cp437 IBM-437
ter-k* koi8r KOI8-R
ter-m* mik Bulgarian-MIK
ter-p* pt154 Paratype-PT154
ter-u* koi8u KOI8-U
ter-v* all listed above all listed above and many others (about 110
and many others language sets), 8 foreground colors
names style
ter-*n normal
ter-*b bold
ter-*f framebuffer-bold
2.5. Notes.
The combined code page is based on IBM-437 (character 0xFF is ogonek).
The ISO8859-16 font also includes all letters and accents from Windows-1250.
3. UNIX console.
- sizes 8x14 and 8x16 only
- styles normal, bold, framebuffer-bold
- code pages ISO8859-1/Windows-1252, ISO8859-2, ISO8859-5, ISO8859-7,
ISO8859-9/Windows-1254, ISO8859-13, ISO8859-15, ISO8859-16,
Windows-1251, IBM-437, KOI8-R, KOI8-U, Paratype-PT154
- format raw data
3.1. bsd-pcvt.
$ ./configure [--prefix=PREFIX | --rawdir=DIRECTORY]
$ make raw
# make install.raw
or, for file names with minus instead of period:
# make install-raw
The default DIRECTORY is PREFIX/share/misc/pcvtfonts. The fonts are
installed uncompressed. Requires Perl. To load a font:
$ loadfont -f /usr/share/misc/pcvtfonts/ter-<X><STYLE>.8<SIZE>
or, for file names with minus instead of period:
$ loadfont -f /usr/share/misc/pcvtfonts/ter-<X><STYLE>-8x<SIZE>
where <X> is a character identifying the code page as listed in p.3.2.
3.2. Legend.
names covered codepage(s)
ter-1* ISO8859-1, Windows-1252
ter-2* ISO8859-2
ter-5* ISO8859-5
ter-7* ISO8859-7
ter-9* ISO8859-9, Windows-1254
ter-c* Windows-1251
ter-d* ISO8859-13
ter-f* ISO8859-15
ter-g* ISO8859-16
ter-i* IBM-437
ter-k* KOI8-R
ter-p* Paratype-PT154
ter-u* KOI8-U
names style
ter-*n normal
ter-*b bold
ter-*f framebuffer-bold
3.3. Notes.
The RAW font contains data only and should be compatible with all UNIX
systems. If any of the bold fonts doesn't look good try framebuffer-bold,
or, if you are using an EGA/VGA adapter, program it to to clear column 8 of
the character matrix (attribute controller register 0x10 bit 0x02).
4. X11 Window System.
- sizes all available, see "About"
- styles normal, bold
- code pages ISO8859-1/Windows-1252, ISO8859-2, ISO8859-5, ISO8859-7,
ISO8859-9/Windows-1254, ISO8859-13, ISO8859-15, ISO8859-16,
Windows-1251, KOI8-R, KOI8-U, Paratype-PT154, ISO10646-1
- format Portable Compiled Font (PCF)
4.1. Installation.
$ ./configure [--prefix=PREFIX | --x11dir=DIRECTORY]
$ make pcf
# make install-pcf
The files are compressed with gzip and installed in DIRECTORY. The default
DIRECTORY is PREFIX/share/fonts/terminus. Requires Perl and bdftopcf.
A copy of the normal 6x12 font is installed as "bold", because some X11
libraries and applications substitute the missing bold fonts by shifting the
normal fonts, and others do not recognize the bold style at all if the
lowest font size lacks it. To install only the normal font, use "n12"
instead of "pcf" in the above commands.
To update the font cache in DIRECTORY after (un)installation, run:
# make fontdir
The configuration file which lists the font directories must contain
DIRECTORY. If xfs or the X-server were active during the installation, they
should be restarted so the font list can be updated.
4.2. Notes.
The ISO8859-1 and ISO8859-9 fonts contain the Windows Western characters and
can be used as Windows-1252 and Windows-1254 respectively.
5. Frequently Asked Questions.
Q. Italic version?
A. No. The quality is significantly lower, and preserving the font width
requires overlapping characters, which are not handled very well by X11/Xft.
If you need it than much, try mkitalic from FreeBSD or bdfslant from Debian.
Q. Scalable version?
A. Long story short, when the average display resolution becomes at least
150 DPI. Prefferably 200.
Q. How about some new characters?
A. Contact me and be ready to help.
Q. The bold 6x12 font...
A. ...does not exist, there is no space for a bold font in a 6x12 matrix.
However, the "normal" font is somewhere between.
Q. The font works in X11/Motif, but not in GNOME/KDE/Xfce.
A. Try adding 75-yes-terminus.conf to the Fontconfig configuration files.
See also mkfontscale(1), mkfontdir(1), fc-cache(1), xorg.conf(5), xfs(1),
xlsfonts(1), fonts-conf(5) etc.
6. Legal information.
6.1. Licenses.
Terminus Font is licensed under the SIL Open Font License, Version 1.1.
The license is included as OFL.TXT, and is also available with a FAQ at:
http://scripts.sil.org/OFL
The files configure, configure.help, bdftopsf.pl and ucstoany.pl are
distributed under the GNU General Public License version 2.0 or (at your
choice) any later version.
6.2. Copyright.
Terminus Font 4.39, Copyright (C) 2014 Dimitar Toshkov Zhekov.
Report bugs to <dimitar.zhekov@gmail.com>
Thanks to Anton Zinoviev, Tim Allen, Kir Koliushkin, Antonios Galanopoulos
and all the others who helped.

17826
node_modules/blessed/usr/fonts/ter-u14b.json generated vendored Normal file

File diff suppressed because it is too large Load Diff

17826
node_modules/blessed/usr/fonts/ter-u14n.json generated vendored Normal file

File diff suppressed because it is too large Load Diff

BIN
node_modules/blessed/usr/linux generated vendored Normal file

Binary file not shown.

BIN
node_modules/blessed/usr/windows-ansi generated vendored Normal file

Binary file not shown.

BIN
node_modules/blessed/usr/xterm generated vendored Normal file

Binary file not shown.

BIN
node_modules/blessed/usr/xterm-256color generated vendored Normal file

Binary file not shown.

243
node_modules/blessed/usr/xterm.termcap generated vendored Normal file
View File

@ -0,0 +1,243 @@
# $XTermId: termcap,v 1.80 2012/06/10 14:30:37 tom Exp $
#
# These are termcap entries that correspond to xterm's terminfo file.
# The file is formatted using ncurses' "tic -CNx", but is not mechanically
# derived from the terminfo.
#
#------------------------------------------------------------------------------
# Copyright 1996-2011,2012 by Thomas E. Dickey
#
# All Rights Reserved
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name(s) of the above copyright
# holders shall not be used in advertising or otherwise to promote the
# sale, use or other dealings in this Software without prior written
# authorization.
#------------------------------------------------------------------------------
#
# Note:
# termcap format is limited to 1023 characters. This set of descriptions
# is a subset of the terminfo, since not all features can be fit into
# that limit. The 'xterm' description supports color. The monochrome
# 'xterm-mono' drops color in favor of additional function keys. If you
# need both, use terminfo.
#
# The 1023-character limit applies to each entry after resolving the
# "tc=" strings. Some implementations may discount all or part of the
# formatting characters in the entry (i.e., the backslash newline tab
# colon). GNU termcap does not have this limit.
#
# I checked the limits using ncurses "captoinfo -CrTUvx", which prints
# the resolved length of each entry in a comment at the end - T.Dickey
#
xf|xterm-new|modern xterm:\
:*6=\EOF:@7=\EOF:F1=\E[23~:F2=\E[24~:K2=\EOE:Km=\E[M:\
:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:k5=\E[15~:k6=\E[17~:\
:k7=\E[18~:k8=\E[19~:k9=\E[20~:k;=\E[21~:kB=\E[Z:kH=\EOF:\
:kI=\E[2~:kN=\E[6~:kP=\E[5~:kd=\EOB:kh=\EOH:kl=\EOD:\
:kr=\EOC:ku=\EOA:tc=xterm-basic:
#
# This chunk is used for building the VT220/Sun/PC keyboard variants.
xb|xterm-basic|modern xterm common:\
:am:bs:km:mi:ms:ut:xn:AX:\
:Co#8:co#80:kn#12:li#24:pa#64:\
:AB=\E[4%dm:AF=\E[3%dm:AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:\
:DO=\E[%dB:LE=\E[%dD:RI=\E[%dC:UP=\E[%dA:ae=\E(B:al=\E[L:\
:as=\E(0:bl=^G:cd=\E[J:ce=\E[K:cl=\E[H\E[2J:\
:cm=\E[%i%d;%dH:cs=\E[%i%d;%dr:ct=\E[3g:dc=\E[P:dl=\E[M:\
:ei=\E[4l:ho=\E[H:im=\E[4h:is=\E[!p\E[?3;4l\E[4l\E>:\
:kD=\E[3~:ke=\E[?1l\E>:ks=\E[?1h\E=:le=^H:md=\E[1m:\
:me=\E[m:ml=\El:mr=\E[7m:mu=\Em:nd=\E[C:op=\E[39;49m:\
:rc=\E8:rs=\E[!p\E[?3;4l\E[4l\E>:sc=\E7:se=\E[27m:sf=^J:\
:so=\E[7m:sr=\EM:st=\EH:te=\E[?1049l:ti=\E[?1049h:\
:ue=\E[24m:up=\E[A:us=\E[4m:ve=\E[?12l\E[?25h:vi=\E[?25l:\
:vs=\E[?12;25h:tc=xterm+kbs:
# The xterm-new description has all of the features, but is not completely
# compatible with vt220. If you are using a Sun or PC keyboard, set the
# sunKeyboard resource to true:
# + maps the editing keypad
# + interprets control-function-key as a second array of keys, so a
# 12-fkey keyboard can support vt220's 20-fkeys.
# + maps numeric keypad "+" to ",".
# + uses DEC-style control sequences for the application keypad.
#
vt|xterm-vt220|xterm emulating vt220:\
:*6=\E[4~:@7=\E[4~:K2=\EOu:Km=\E[M:kB=\E[Z:kH=\E[4~:\
:kh=\E[1~:tc=xterm-basic:
v1|xterm-24|xterms|vs100|24x80 xterm:\
:li#24:tc=xterm-old:
v2|xterm-65|65x80 xterm:\
:li#65:tc=xterm-old:
vb|xterm-bold|xterm with bold for underline:\
:so=\E[7m:us=\E[1m:tc=xterm-old:
vB|xterm-boldso|xterm with bold for standout:\
:se=\E[m:so=\E[1m:tc=xterm-old:
vm|xterm-mono|monochrome xterm:\
:ut@:\
:Co@:NC@:kn#20:pa@:\
:AB@:AF@:Sb@:Sf@:op@:st@:tc=xterm-old:
#
# Alternate terminal description that "works" for interactive shells such as
# tcsh and bash.
xn|xterm-noapp|xterm with cursor keys in normal mode:\
:kd=\E[B:ke=\E>:kl=\E[D:kr=\E[C:ks=\E=:ku=\E[A:te@:ti@:\
:tc=xterm:
#
# This should work for the commonly used "color xterm" variations (XFree86
# xterm, color_xterm, nxterm, rxvt). Note that it does not set 'bce', so for
# XFree86 and rxvt, some applications that use colors will be less efficient,
# and in a few special cases (with "smart" optimization) the wrong color will
# be painted in spots.
vc|xterm-color|generic "ANSI" color xterm:\
:Co#8:NC@:pa#64:\
:AB=\E[4%dm:AF=\E[3%dm:ac=:op=\E[m:tc=xterm-r6:
#
# These aliases are for compatibility with the terminfo; termcap cannot provide
# the extra features such as color initialization, but termcap applications
# still want the names.
x1|xterm-16color|xterm alias:\
:tc=xterm-new:
x2|xterm-88color|xterm alias:\
:Co#88:pa#7744:tc=xterm-256color:
x3|xterm-256color|xterm alias:\
:Co#256:pa#32767:\
:AB=\E[48;5;%dm:AF=\E[38;5;%dm:tc=xterm-new:
xi|xterm-nrc|xterm alias:\
:tc=xterm:
xr|xterm-rep|xterm alias:\
:tc=xterm:
xx|xterm-xmc|xterm alias:\
:sg#1:tc=xterm:
#
# An 8-bit description is doable with termcap, but there are probably no
# termcap (or BSD curses) applications that are able to use it.
x8|xterm-8bit|xterm terminal emulator 8-bit controls (X Window System):\
:am:km:mi:ms:xn:\
:co#80:it#8:li#24:\
:AL=\233%dL:DC=\233%dP:DL=\233%dM:DO=\233%dB:IC=\233%d@:\
:K2=\217y:Km=\233M:LE=\233%dD:RI=\233%dC:UP=\233%dA:\
:ae=\E(B:al=\233L:as=\E(0:bl=^G:bt=\233Z:cd=\233J:ce=\233K:\
:cl=\233H\2332J:cm=\233%i%d;%dH:cr=^M:cs=\233%i%d;%dr:\
:ct=\2333g:dc=\233P:dl=\233M:do=^J:ei=\2334l:ho=\233H:\
:im=\2334h:\
:is=\E[62"p\E G\233m\233?7h\E>\E7\233?1;3;4;6l\2334l\233r\E8:\
:k1=\23311~:k2=\23312~:k3=\23313~:k4=\23314~:k5=\23315~:\
:k6=\23317~:k7=\23318~:k8=\23319~:k9=\23320~:kD=\2333~:\
:kI=\2332~:kN=\2336~:kP=\2335~:kd=\217B:ke=\233?1l\E>:\
:kh=\2331~:kl=\217D:kr=\217C:ks=\233?1h\E=:ku=\217A:le=^H:\
:mb=\2335m:md=\2331m:me=\233m:mr=\2337m:nd=\233C:rc=\E8:\
:sc=\E7:se=\23327m:sf=^J:so=\2337m:sr=\215:st=\210:ta=^I:\
:te=\233?1049l:ti=\233?1049h:ue=\23324m:up=\233A:\
:us=\2334m:vb=\233?5h\233?5l:ve=\233?25l\233?25h:\
:vi=\233?25l:vs=\233?12;25h:tc=xterm+kbs:
#
hp|xterm-hp|xterm with hpterm function keys:\
:@7=\EF:k1=\Ep:k2=\Eq:k3=\Er:k4=\Es:k5=\Et:k6=\Eu:k7=\Ev:\
:k8=\Ew:kC=\EJ:kD=\EP:kI=\EQ:kN=\ES:kP=\ET:kd=\EB:kh=\Eh:\
:kl=\ED:kr=\EC:ku=\EA:tc=xterm-basic:
#
xS|xterm-sco|xterm with SCO function keys:\
:@7=\E[F:F1=\E[W:F2=\E[X:F3=\E[Y:F5=\E[a:F6=\E[b:F7=\E[c:\
:F8=\E[d:F9=\E[e:FA=\E[f:FB=\E[g:FC=\E[h:FD=\E[i:FE=\E[j:\
:FF=\E[k:ac=:k1=\E[M:k2=\E[N:k3=\E[O:k4=\E[P:k5=\E[Q:\
:k6=\E[R:k7=\E[S:k8=\E[T:k9=\E[U:k;=\E[V:kD=\177:kI=\E[L:\
:kN=\E[G:kP=\E[I:kd=\E[B:kh=\E[H:kl=\E[D:kr=\E[C:ku=\E[A:\
:tc=xterm-basic:
#
v5|xterm-vt52|xterm emulating vt52:\
:bs:\
:co#80:it#8:li#24:\
:ae=\EG:as=\EF:bl=^G:cd=\EJ:ce=\EK:cl=\EH\EJ:cm=\EY%+ %+ :\
:cr=^M:do=\EB:ho=\EH:kd=\EB:kl=\ED:kr=\EC:ku=\EA:le=\ED:\
:nd=\EC:nw=^M^J:sf=^J:sr=\EI:ta=^I:up=\EA:tc=xterm+kbs:
#
xs|xterm-sun|xterm with Sun functionkeys:\
:%1=\E[196z:&8=\E[195z:@0=\E[200z:@5=\E[197z:@7=\E[220z:\
:F1=\E[192z:F2=\E[193z:K2=\E[218z:Km=\E[M:k1=\E[224z:\
:k2=\E[225z:k3=\E[226z:k4=\E[227z:k5=\E[228z:k6=\E[229z:\
:k7=\E[230z:k8=\E[231z:k9=\E[232z:k;=\E[233z:kD=\E[3z:\
:kI=\E[2z:kN=\E[222z:kP=\E[216z:kh=\E[214z:\
:tc=xterm-basic:
#
# vi may work better with this entry, because vi doesn't use insert mode much.
# |xterm-ic|xterm-vi|xterm with insert character instead of insert mode:\
vi|xterm-ic|xterm-vi|xterm with insert char:\
:mi@:\
:IC=\E[%d@:ei@:ic=\E[@:im@:tc=xterm:
#
# Compatible with the X11R6.3 xterm
r6|xterm-r6|xterm-old|X11R6 xterm:\
:am:bs:km:mi:ms:pt:xn:\
:co#80:kn#20:li#24:\
:*6=\E[4~:@0=\E[1~:@7=\E[4~:AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:\
:DO=\E[%dB:F1=\E[23~:F2=\E[24~:F3=\E[25~:F4=\E[26~:\
:F5=\E[28~:F6=\E[29~:F7=\E[31~:F8=\E[32~:F9=\E[33~:\
:FA=\E[34~:LE=\E[%dD:RI=\E[%dC:UP=\E[%dA:ae=^O:al=\E[L:\
:as=^N:bl=^G:cd=\E[J:ce=\E[K:cl=\E[H\E[2J:cm=\E[%i%d;%dH:\
:cs=\E[%i%d;%dr:ct=\E[3g:dc=\E[P:dl=\E[M:eA=\E)0:ei=\E[4l:\
:ho=\E[H:im=\E[4h:\
:is=\E[m\E[?7h\E[4l\E>\E7\E[r\E[?1;3;4;6l\E8:\
:k1=\E[11~:k2=\E[12~:k3=\E[13~:k4=\E[14~:k5=\E[15~:\
:k6=\E[17~:k7=\E[18~:k8=\E[19~:k9=\E[20~:k;=\E[21~:\
:kD=\E[3~:kI=\E[2~:kN=\E[6~:kP=\E[5~:kd=\EOB:ke=\E[?1l\E>:\
:kh=\E[1~:kl=\EOD:kr=\EOC:ks=\E[?1h\E=:ku=\EOA:md=\E[1m:\
:me=\E[m:ml=\El:mr=\E[7m:mu=\Em:nd=\E[C:rc=\E8:\
:rs=\E[m\E[?7h\E[4l\E>\E7\E[r\E[?1;3;4;6l\E8:sc=\E7:\
:se=\E[m:sf=^J:so=\E[7m:sr=\EM:te=\E[2J\E[?47l\E8:\
:ti=\E7\E[?47h:ue=\E[m:up=\E[A:us=\E[4m:tc=xterm+kbs:
#
# Compatible with the R5 xterm
r5|xterm-r5|X11R5 xterm X11R5:\
:am:bs:km:mi:ms:pt:xn:\
:co#80:kn#4:li#24:\
:@7=\E[4~:AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:DO=\E[%dB:\
:IC=\E[%d@:UP=\E[%dA:al=\E[L:cd=\E[J:ce=\E[K:cl=\E[H\E[2J:\
:cm=\E[%i%d;%dH:cs=\E[%i%d;%dr:ct=\E[3g:dc=\E[P:dl=\E[M:\
:ei=\E[4l:ho=\E[H:im=\E[4h:\
:is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l:\
:k1=\E[11~:k2=\E[12~:k3=\E[13~:k4=\E[14~:kd=\EOB:\
:ke=\E[?1l\E>:kh=\E[1~:kl=\EOD:kr=\EOC:ks=\E[?1h\E=:\
:ku=\EOA:md=\E[1m:me=\E[m:mr=\E[7m:nd=\E[C:rc=\E8:\
:rs=\E>\E[?1;3;4;5;6l\E[4l\E[?7h\E[m\E[r\E[2J\E[H:\
:sc=\E7:se=\E[m:sf=^J:so=\E[7m:sr=\EM:te=\E[2J\E[?47l\E8:\
:ti=\E7\E[?47h:ue=\E[m:up=\E[A:us=\E[4m:tc=xterm+kbs:
#
# Customization begins here.
x0|xterm-xfree86|xterm terminal emulator (XFree86):\
:tc=xterm-new:
#
# This is the only entry which you should have to customize, since "xterm"
# is widely used for a variety of incompatible terminal emulations including
# color_xterm and rxvt.
v0|xterm|X11 terminal emulator:\
:tc=xterm-new:
# :tc=xterm-r6:
# This fragment is for people who cannot agree on what the backspace key
# should send.
xterm+kbs|fragment for backspace key:\
:kb=^H:

1977
node_modules/blessed/usr/xterm.terminfo generated vendored Normal file

File diff suppressed because it is too large Load Diff

1755
node_modules/blessed/vendor/tng.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

415
node_modules/chalk/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,415 @@
/**
Basic foreground colors.
[More colors here.](https://github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
*/
declare type ForegroundColor =
| 'black'
| 'red'
| 'green'
| 'yellow'
| 'blue'
| 'magenta'
| 'cyan'
| 'white'
| 'gray'
| 'grey'
| 'blackBright'
| 'redBright'
| 'greenBright'
| 'yellowBright'
| 'blueBright'
| 'magentaBright'
| 'cyanBright'
| 'whiteBright';
/**
Basic background colors.
[More colors here.](https://github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
*/
declare type BackgroundColor =
| 'bgBlack'
| 'bgRed'
| 'bgGreen'
| 'bgYellow'
| 'bgBlue'
| 'bgMagenta'
| 'bgCyan'
| 'bgWhite'
| 'bgGray'
| 'bgGrey'
| 'bgBlackBright'
| 'bgRedBright'
| 'bgGreenBright'
| 'bgYellowBright'
| 'bgBlueBright'
| 'bgMagentaBright'
| 'bgCyanBright'
| 'bgWhiteBright';
/**
Basic colors.
[More colors here.](https://github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
*/
declare type Color = ForegroundColor | BackgroundColor;
declare type Modifiers =
| 'reset'
| 'bold'
| 'dim'
| 'italic'
| 'underline'
| 'inverse'
| 'hidden'
| 'strikethrough'
| 'visible';
declare namespace chalk {
/**
Levels:
- `0` - All colors disabled.
- `1` - Basic 16 colors support.
- `2` - ANSI 256 colors support.
- `3` - Truecolor 16 million colors support.
*/
type Level = 0 | 1 | 2 | 3;
interface Options {
/**
Specify the color support for Chalk.
By default, color support is automatically detected based on the environment.
Levels:
- `0` - All colors disabled.
- `1` - Basic 16 colors support.
- `2` - ANSI 256 colors support.
- `3` - Truecolor 16 million colors support.
*/
level?: Level;
}
/**
Return a new Chalk instance.
*/
type Instance = new (options?: Options) => Chalk;
/**
Detect whether the terminal supports color.
*/
interface ColorSupport {
/**
The color level used by Chalk.
*/
level: Level;
/**
Return whether Chalk supports basic 16 colors.
*/
hasBasic: boolean;
/**
Return whether Chalk supports ANSI 256 colors.
*/
has256: boolean;
/**
Return whether Chalk supports Truecolor 16 million colors.
*/
has16m: boolean;
}
interface ChalkFunction {
/**
Use a template string.
@remarks Template literals are unsupported for nested calls (see [issue #341](https://github.com/chalk/chalk/issues/341))
@example
```
import chalk = require('chalk');
log(chalk`
CPU: {red ${cpu.totalPercent}%}
RAM: {green ${ram.used / ram.total * 100}%}
DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
`);
```
@example
```
import chalk = require('chalk');
log(chalk.red.bgBlack`2 + 3 = {bold ${2 + 3}}`)
```
*/
(text: TemplateStringsArray, ...placeholders: unknown[]): string;
(...text: unknown[]): string;
}
interface Chalk extends ChalkFunction {
/**
Return a new Chalk instance.
*/
Instance: Instance;
/**
The color support for Chalk.
By default, color support is automatically detected based on the environment.
Levels:
- `0` - All colors disabled.
- `1` - Basic 16 colors support.
- `2` - ANSI 256 colors support.
- `3` - Truecolor 16 million colors support.
*/
level: Level;
/**
Use HEX value to set text color.
@param color - Hexadecimal value representing the desired color.
@example
```
import chalk = require('chalk');
chalk.hex('#DEADED');
```
*/
hex(color: string): Chalk;
/**
Use keyword color value to set text color.
@param color - Keyword value representing the desired color.
@example
```
import chalk = require('chalk');
chalk.keyword('orange');
```
*/
keyword(color: string): Chalk;
/**
Use RGB values to set text color.
*/
rgb(red: number, green: number, blue: number): Chalk;
/**
Use HSL values to set text color.
*/
hsl(hue: number, saturation: number, lightness: number): Chalk;
/**
Use HSV values to set text color.
*/
hsv(hue: number, saturation: number, value: number): Chalk;
/**
Use HWB values to set text color.
*/
hwb(hue: number, whiteness: number, blackness: number): Chalk;
/**
Use a [Select/Set Graphic Rendition](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters) (SGR) [color code number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) to set text color.
30 <= code && code < 38 || 90 <= code && code < 98
For example, 31 for red, 91 for redBright.
*/
ansi(code: number): Chalk;
/**
Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color.
*/
ansi256(index: number): Chalk;
/**
Use HEX value to set background color.
@param color - Hexadecimal value representing the desired color.
@example
```
import chalk = require('chalk');
chalk.bgHex('#DEADED');
```
*/
bgHex(color: string): Chalk;
/**
Use keyword color value to set background color.
@param color - Keyword value representing the desired color.
@example
```
import chalk = require('chalk');
chalk.bgKeyword('orange');
```
*/
bgKeyword(color: string): Chalk;
/**
Use RGB values to set background color.
*/
bgRgb(red: number, green: number, blue: number): Chalk;
/**
Use HSL values to set background color.
*/
bgHsl(hue: number, saturation: number, lightness: number): Chalk;
/**
Use HSV values to set background color.
*/
bgHsv(hue: number, saturation: number, value: number): Chalk;
/**
Use HWB values to set background color.
*/
bgHwb(hue: number, whiteness: number, blackness: number): Chalk;
/**
Use a [Select/Set Graphic Rendition](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters) (SGR) [color code number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) to set background color.
30 <= code && code < 38 || 90 <= code && code < 98
For example, 31 for red, 91 for redBright.
Use the foreground code, not the background code (for example, not 41, nor 101).
*/
bgAnsi(code: number): Chalk;
/**
Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set background color.
*/
bgAnsi256(index: number): Chalk;
/**
Modifier: Resets the current color chain.
*/
readonly reset: Chalk;
/**
Modifier: Make text bold.
*/
readonly bold: Chalk;
/**
Modifier: Emitting only a small amount of light.
*/
readonly dim: Chalk;
/**
Modifier: Make text italic. (Not widely supported)
*/
readonly italic: Chalk;
/**
Modifier: Make text underline. (Not widely supported)
*/
readonly underline: Chalk;
/**
Modifier: Inverse background and foreground colors.
*/
readonly inverse: Chalk;
/**
Modifier: Prints the text, but makes it invisible.
*/
readonly hidden: Chalk;
/**
Modifier: Puts a horizontal line through the center of the text. (Not widely supported)
*/
readonly strikethrough: Chalk;
/**
Modifier: Prints the text only when Chalk has a color support level > 0.
Can be useful for things that are purely cosmetic.
*/
readonly visible: Chalk;
readonly black: Chalk;
readonly red: Chalk;
readonly green: Chalk;
readonly yellow: Chalk;
readonly blue: Chalk;
readonly magenta: Chalk;
readonly cyan: Chalk;
readonly white: Chalk;
/*
Alias for `blackBright`.
*/
readonly gray: Chalk;
/*
Alias for `blackBright`.
*/
readonly grey: Chalk;
readonly blackBright: Chalk;
readonly redBright: Chalk;
readonly greenBright: Chalk;
readonly yellowBright: Chalk;
readonly blueBright: Chalk;
readonly magentaBright: Chalk;
readonly cyanBright: Chalk;
readonly whiteBright: Chalk;
readonly bgBlack: Chalk;
readonly bgRed: Chalk;
readonly bgGreen: Chalk;
readonly bgYellow: Chalk;
readonly bgBlue: Chalk;
readonly bgMagenta: Chalk;
readonly bgCyan: Chalk;
readonly bgWhite: Chalk;
/*
Alias for `bgBlackBright`.
*/
readonly bgGray: Chalk;
/*
Alias for `bgBlackBright`.
*/
readonly bgGrey: Chalk;
readonly bgBlackBright: Chalk;
readonly bgRedBright: Chalk;
readonly bgGreenBright: Chalk;
readonly bgYellowBright: Chalk;
readonly bgBlueBright: Chalk;
readonly bgMagentaBright: Chalk;
readonly bgCyanBright: Chalk;
readonly bgWhiteBright: Chalk;
}
}
/**
Main Chalk object that allows to chain styles together.
Call the last one as a method with a string argument.
Order doesn't matter, and later styles take precedent in case of a conflict.
This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
*/
declare const chalk: chalk.Chalk & chalk.ChalkFunction & {
supportsColor: chalk.ColorSupport | false;
Level: chalk.Level;
Color: Color;
ForegroundColor: ForegroundColor;
BackgroundColor: BackgroundColor;
Modifiers: Modifiers;
stderr: chalk.Chalk & {supportsColor: chalk.ColorSupport | false};
};
export = chalk;

9
node_modules/chalk/license generated vendored Normal file
View File

@ -0,0 +1,9 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

68
node_modules/chalk/package.json generated vendored Normal file
View File

@ -0,0 +1,68 @@
{
"name": "chalk",
"version": "4.1.2",
"description": "Terminal string styling done right",
"license": "MIT",
"repository": "chalk/chalk",
"funding": "https://github.com/chalk/chalk?sponsor=1",
"main": "source",
"engines": {
"node": ">=10"
},
"scripts": {
"test": "xo && nyc ava && tsd",
"bench": "matcha benchmark.js"
},
"files": [
"source",
"index.d.ts"
],
"keywords": [
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"string",
"str",
"ansi",
"style",
"styles",
"tty",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"log",
"logging",
"command-line",
"text"
],
"dependencies": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
},
"devDependencies": {
"ava": "^2.4.0",
"coveralls": "^3.0.7",
"execa": "^4.0.0",
"import-fresh": "^3.1.0",
"matcha": "^0.7.0",
"nyc": "^15.0.0",
"resolve-from": "^5.0.0",
"tsd": "^0.7.4",
"xo": "^0.28.2"
},
"xo": {
"rules": {
"unicorn/prefer-string-slice": "off",
"unicorn/prefer-includes": "off",
"@typescript-eslint/member-ordering": "off",
"no-redeclare": "off",
"unicorn/string-content": "off",
"unicorn/better-regex": "off"
}
}
}

341
node_modules/chalk/readme.md generated vendored Normal file
View File

@ -0,0 +1,341 @@
<h1 align="center">
<br>
<br>
<img width="320" src="media/logo.svg" alt="Chalk">
<br>
<br>
<br>
</h1>
> Terminal string styling done right
[![Build Status](https://travis-ci.org/chalk/chalk.svg?branch=master)](https://travis-ci.org/chalk/chalk) [![Coverage Status](https://coveralls.io/repos/github/chalk/chalk/badge.svg?branch=master)](https://coveralls.io/github/chalk/chalk?branch=master) [![npm dependents](https://badgen.net/npm/dependents/chalk)](https://www.npmjs.com/package/chalk?activeTab=dependents) [![Downloads](https://badgen.net/npm/dt/chalk)](https://www.npmjs.com/package/chalk) [![](https://img.shields.io/badge/unicorn-approved-ff69b4.svg)](https://www.youtube.com/watch?v=9auOCbH5Ns4) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo) ![TypeScript-ready](https://img.shields.io/npm/types/chalk.svg) [![run on repl.it](https://repl.it/badge/github/chalk/chalk)](https://repl.it/github/chalk/chalk)
<img src="https://cdn.jsdelivr.net/gh/chalk/ansi-styles@8261697c95bf34b6c7767e2cbe9941a851d59385/screenshot.svg" width="900">
<br>
---
<div align="center">
<p>
<p>
<sup>
Sindre Sorhus' open source work is supported by the community on <a href="https://github.com/sponsors/sindresorhus">GitHub Sponsors</a> and <a href="https://stakes.social/0x44d871aebF0126Bf646753E2C976Aa7e68A66c15">Dev</a>
</sup>
</p>
<sup>Special thanks to:</sup>
<br>
<br>
<a href="https://standardresume.co/tech">
<img src="https://sindresorhus.com/assets/thanks/standard-resume-logo.svg" width="160"/>
</a>
<br>
<br>
<a href="https://retool.com/?utm_campaign=sindresorhus">
<img src="https://sindresorhus.com/assets/thanks/retool-logo.svg" width="230"/>
</a>
<br>
<br>
<a href="https://doppler.com/?utm_campaign=github_repo&utm_medium=referral&utm_content=chalk&utm_source=github">
<div>
<img src="https://dashboard.doppler.com/imgs/logo-long.svg" width="240" alt="Doppler">
</div>
<b>All your environment variables, in one place</b>
<div>
<span>Stop struggling with scattered API keys, hacking together home-brewed tools,</span>
<br>
<span>and avoiding access controls. Keep your team and servers in sync with Doppler.</span>
</div>
</a>
<br>
<a href="https://uibakery.io/?utm_source=chalk&utm_medium=sponsor&utm_campaign=github">
<div>
<img src="https://sindresorhus.com/assets/thanks/uibakery-logo.jpg" width="270" alt="UI Bakery">
</div>
</a>
</p>
</div>
---
<br>
## Highlights
- Expressive API
- Highly performant
- Ability to nest styles
- [256/Truecolor color support](#256-and-truecolor-color-support)
- Auto-detects color support
- Doesn't extend `String.prototype`
- Clean and focused
- Actively maintained
- [Used by ~50,000 packages](https://www.npmjs.com/browse/depended/chalk) as of January 1, 2020
## Install
```console
$ npm install chalk
```
## Usage
```js
const chalk = require('chalk');
console.log(chalk.blue('Hello world!'));
```
Chalk comes with an easy to use composable API where you just chain and nest the styles you want.
```js
const chalk = require('chalk');
const log = console.log;
// Combine styled and normal strings
log(chalk.blue('Hello') + ' World' + chalk.red('!'));
// Compose multiple styles using the chainable API
log(chalk.blue.bgRed.bold('Hello world!'));
// Pass in multiple arguments
log(chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz'));
// Nest styles
log(chalk.red('Hello', chalk.underline.bgBlue('world') + '!'));
// Nest styles of the same type even (color, underline, background)
log(chalk.green(
'I am a green line ' +
chalk.blue.underline.bold('with a blue substring') +
' that becomes green again!'
));
// ES2015 template literal
log(`
CPU: ${chalk.red('90%')}
RAM: ${chalk.green('40%')}
DISK: ${chalk.yellow('70%')}
`);
// ES2015 tagged template literal
log(chalk`
CPU: {red ${cpu.totalPercent}%}
RAM: {green ${ram.used / ram.total * 100}%}
DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
`);
// Use RGB colors in terminal emulators that support it.
log(chalk.keyword('orange')('Yay for orange colored text!'));
log(chalk.rgb(123, 45, 67).underline('Underlined reddish color'));
log(chalk.hex('#DEADED').bold('Bold gray!'));
```
Easily define your own themes:
```js
const chalk = require('chalk');
const error = chalk.bold.red;
const warning = chalk.keyword('orange');
console.log(error('Error!'));
console.log(warning('Warning!'));
```
Take advantage of console.log [string substitution](https://nodejs.org/docs/latest/api/console.html#console_console_log_data_args):
```js
const name = 'Sindre';
console.log(chalk.green('Hello %s'), name);
//=> 'Hello Sindre'
```
## API
### chalk.`<style>[.<style>...](string, [string...])`
Example: `chalk.red.bold.underline('Hello', 'world');`
Chain [styles](#styles) and call the last one as a method with a string argument. Order doesn't matter, and later styles take precedent in case of a conflict. This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
Multiple arguments will be separated by space.
### chalk.level
Specifies the level of color support.
Color support is automatically detected, but you can override it by setting the `level` property. You should however only do this in your own code as it applies globally to all Chalk consumers.
If you need to change this in a reusable module, create a new instance:
```js
const ctx = new chalk.Instance({level: 0});
```
| Level | Description |
| :---: | :--- |
| `0` | All colors disabled |
| `1` | Basic color support (16 colors) |
| `2` | 256 color support |
| `3` | Truecolor support (16 million colors) |
### chalk.supportsColor
Detect whether the terminal [supports color](https://github.com/chalk/supports-color). Used internally and handled for you, but exposed for convenience.
Can be overridden by the user with the flags `--color` and `--no-color`. For situations where using `--color` is not possible, use the environment variable `FORCE_COLOR=1` (level 1), `FORCE_COLOR=2` (level 2), or `FORCE_COLOR=3` (level 3) to forcefully enable color, or `FORCE_COLOR=0` to forcefully disable. The use of `FORCE_COLOR` overrides all other color support checks.
Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.
### chalk.stderr and chalk.stderr.supportsColor
`chalk.stderr` contains a separate instance configured with color support detected for `stderr` stream instead of `stdout`. Override rules from `chalk.supportsColor` apply to this too. `chalk.stderr.supportsColor` is exposed for convenience.
## Styles
### Modifiers
- `reset` - Resets the current color chain.
- `bold` - Make text bold.
- `dim` - Emitting only a small amount of light.
- `italic` - Make text italic. *(Not widely supported)*
- `underline` - Make text underline. *(Not widely supported)*
- `inverse`- Inverse background and foreground colors.
- `hidden` - Prints the text, but makes it invisible.
- `strikethrough` - Puts a horizontal line through the center of the text. *(Not widely supported)*
- `visible`- Prints the text only when Chalk has a color level > 0. Can be useful for things that are purely cosmetic.
### Colors
- `black`
- `red`
- `green`
- `yellow`
- `blue`
- `magenta`
- `cyan`
- `white`
- `blackBright` (alias: `gray`, `grey`)
- `redBright`
- `greenBright`
- `yellowBright`
- `blueBright`
- `magentaBright`
- `cyanBright`
- `whiteBright`
### Background colors
- `bgBlack`
- `bgRed`
- `bgGreen`
- `bgYellow`
- `bgBlue`
- `bgMagenta`
- `bgCyan`
- `bgWhite`
- `bgBlackBright` (alias: `bgGray`, `bgGrey`)
- `bgRedBright`
- `bgGreenBright`
- `bgYellowBright`
- `bgBlueBright`
- `bgMagentaBright`
- `bgCyanBright`
- `bgWhiteBright`
## Tagged template literal
Chalk can be used as a [tagged template literal](https://exploringjs.com/es6/ch_template-literals.html#_tagged-template-literals).
```js
const chalk = require('chalk');
const miles = 18;
const calculateFeet = miles => miles * 5280;
console.log(chalk`
There are {bold 5280 feet} in a mile.
In {bold ${miles} miles}, there are {green.bold ${calculateFeet(miles)} feet}.
`);
```
Blocks are delimited by an opening curly brace (`{`), a style, some content, and a closing curly brace (`}`).
Template styles are chained exactly like normal Chalk styles. The following three statements are equivalent:
```js
console.log(chalk.bold.rgb(10, 100, 200)('Hello!'));
console.log(chalk.bold.rgb(10, 100, 200)`Hello!`);
console.log(chalk`{bold.rgb(10,100,200) Hello!}`);
```
Note that function styles (`rgb()`, `hsl()`, `keyword()`, etc.) may not contain spaces between parameters.
All interpolated values (`` chalk`${foo}` ``) are converted to strings via the `.toString()` method. All curly braces (`{` and `}`) in interpolated value strings are escaped.
## 256 and Truecolor color support
Chalk supports 256 colors and [Truecolor](https://gist.github.com/XVilka/8346728) (16 million colors) on supported terminal apps.
Colors are downsampled from 16 million RGB values to an ANSI color format that is supported by the terminal emulator (or by specifying `{level: n}` as a Chalk option). For example, Chalk configured to run at level 1 (basic color support) will downsample an RGB value of #FF0000 (red) to 31 (ANSI escape for red).
Examples:
- `chalk.hex('#DEADED').underline('Hello, world!')`
- `chalk.keyword('orange')('Some orange text')`
- `chalk.rgb(15, 100, 204).inverse('Hello!')`
Background versions of these models are prefixed with `bg` and the first level of the module capitalized (e.g. `keyword` for foreground colors and `bgKeyword` for background colors).
- `chalk.bgHex('#DEADED').underline('Hello, world!')`
- `chalk.bgKeyword('orange')('Some orange text')`
- `chalk.bgRgb(15, 100, 204).inverse('Hello!')`
The following color models can be used:
- [`rgb`](https://en.wikipedia.org/wiki/RGB_color_model) - Example: `chalk.rgb(255, 136, 0).bold('Orange!')`
- [`hex`](https://en.wikipedia.org/wiki/Web_colors#Hex_triplet) - Example: `chalk.hex('#FF8800').bold('Orange!')`
- [`keyword`](https://www.w3.org/wiki/CSS/Properties/color/keywords) (CSS keywords) - Example: `chalk.keyword('orange').bold('Orange!')`
- [`hsl`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsl(32, 100, 50).bold('Orange!')`
- [`hsv`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsv(32, 100, 100).bold('Orange!')`
- [`hwb`](https://en.wikipedia.org/wiki/HWB_color_model) - Example: `chalk.hwb(32, 0, 50).bold('Orange!')`
- [`ansi`](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) - Example: `chalk.ansi(31).bgAnsi(93)('red on yellowBright')`
- [`ansi256`](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) - Example: `chalk.bgAnsi256(194)('Honeydew, more or less')`
## Windows
If you're on Windows, do yourself a favor and use [Windows Terminal](https://github.com/microsoft/terminal) instead of `cmd.exe`.
## Origin story
[colors.js](https://github.com/Marak/colors.js) used to be the most popular string styling module, but it has serious deficiencies like extending `String.prototype` which causes all kinds of [problems](https://github.com/yeoman/yo/issues/68) and the package is unmaintained. Although there are other packages, they either do too much or not enough. Chalk is a clean and focused alternative.
## chalk for enterprise
Available as part of the Tidelift Subscription.
The maintainers of chalk and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-chalk?utm_source=npm-chalk&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
## Related
- [chalk-cli](https://github.com/chalk/chalk-cli) - CLI for this module
- [ansi-styles](https://github.com/chalk/ansi-styles) - ANSI escape codes for styling strings in the terminal
- [supports-color](https://github.com/chalk/supports-color) - Detect whether a terminal supports color
- [strip-ansi](https://github.com/chalk/strip-ansi) - Strip ANSI escape codes
- [strip-ansi-stream](https://github.com/chalk/strip-ansi-stream) - Strip ANSI escape codes from a stream
- [has-ansi](https://github.com/chalk/has-ansi) - Check if a string has ANSI escape codes
- [ansi-regex](https://github.com/chalk/ansi-regex) - Regular expression for matching ANSI escape codes
- [wrap-ansi](https://github.com/chalk/wrap-ansi) - Wordwrap a string with ANSI escape codes
- [slice-ansi](https://github.com/chalk/slice-ansi) - Slice a string with ANSI escape codes
- [color-convert](https://github.com/qix-/color-convert) - Converts colors between different models
- [chalk-animation](https://github.com/bokub/chalk-animation) - Animate strings in the terminal
- [gradient-string](https://github.com/bokub/gradient-string) - Apply color gradients to strings
- [chalk-pipe](https://github.com/LitoMore/chalk-pipe) - Create chalk style schemes with simpler style strings
- [terminal-link](https://github.com/sindresorhus/terminal-link) - Create clickable links in the terminal
## Maintainers
- [Sindre Sorhus](https://github.com/sindresorhus)
- [Josh Junon](https://github.com/qix-)

229
node_modules/chalk/source/index.js generated vendored Normal file
View File

@ -0,0 +1,229 @@
'use strict';
const ansiStyles = require('ansi-styles');
const {stdout: stdoutColor, stderr: stderrColor} = require('supports-color');
const {
stringReplaceAll,
stringEncaseCRLFWithFirstIndex
} = require('./util');
const {isArray} = Array;
// `supportsColor.level` → `ansiStyles.color[name]` mapping
const levelMapping = [
'ansi',
'ansi',
'ansi256',
'ansi16m'
];
const styles = Object.create(null);
const applyOptions = (object, options = {}) => {
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
throw new Error('The `level` option should be an integer from 0 to 3');
}
// Detect level if not set manually
const colorLevel = stdoutColor ? stdoutColor.level : 0;
object.level = options.level === undefined ? colorLevel : options.level;
};
class ChalkClass {
constructor(options) {
// eslint-disable-next-line no-constructor-return
return chalkFactory(options);
}
}
const chalkFactory = options => {
const chalk = {};
applyOptions(chalk, options);
chalk.template = (...arguments_) => chalkTag(chalk.template, ...arguments_);
Object.setPrototypeOf(chalk, Chalk.prototype);
Object.setPrototypeOf(chalk.template, chalk);
chalk.template.constructor = () => {
throw new Error('`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.');
};
chalk.template.Instance = ChalkClass;
return chalk.template;
};
function Chalk(options) {
return chalkFactory(options);
}
for (const [styleName, style] of Object.entries(ansiStyles)) {
styles[styleName] = {
get() {
const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
Object.defineProperty(this, styleName, {value: builder});
return builder;
}
};
}
styles.visible = {
get() {
const builder = createBuilder(this, this._styler, true);
Object.defineProperty(this, 'visible', {value: builder});
return builder;
}
};
const usedModels = ['rgb', 'hex', 'keyword', 'hsl', 'hsv', 'hwb', 'ansi', 'ansi256'];
for (const model of usedModels) {
styles[model] = {
get() {
const {level} = this;
return function (...arguments_) {
const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
return createBuilder(this, styler, this._isEmpty);
};
}
};
}
for (const model of usedModels) {
const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
styles[bgModel] = {
get() {
const {level} = this;
return function (...arguments_) {
const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
return createBuilder(this, styler, this._isEmpty);
};
}
};
}
const proto = Object.defineProperties(() => {}, {
...styles,
level: {
enumerable: true,
get() {
return this._generator.level;
},
set(level) {
this._generator.level = level;
}
}
});
const createStyler = (open, close, parent) => {
let openAll;
let closeAll;
if (parent === undefined) {
openAll = open;
closeAll = close;
} else {
openAll = parent.openAll + open;
closeAll = close + parent.closeAll;
}
return {
open,
close,
openAll,
closeAll,
parent
};
};
const createBuilder = (self, _styler, _isEmpty) => {
const builder = (...arguments_) => {
if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
// Called as a template literal, for example: chalk.red`2 + 3 = {bold ${2+3}}`
return applyStyle(builder, chalkTag(builder, ...arguments_));
}
// Single argument is hot path, implicit coercion is faster than anything
// eslint-disable-next-line no-implicit-coercion
return applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));
};
// We alter the prototype because we must return a function, but there is
// no way to create a function with a different prototype
Object.setPrototypeOf(builder, proto);
builder._generator = self;
builder._styler = _styler;
builder._isEmpty = _isEmpty;
return builder;
};
const applyStyle = (self, string) => {
if (self.level <= 0 || !string) {
return self._isEmpty ? '' : string;
}
let styler = self._styler;
if (styler === undefined) {
return string;
}
const {openAll, closeAll} = styler;
if (string.indexOf('\u001B') !== -1) {
while (styler !== undefined) {
// Replace any instances already present with a re-opening code
// otherwise only the part of the string until said closing code
// will be colored, and the rest will simply be 'plain'.
string = stringReplaceAll(string, styler.close, styler.open);
styler = styler.parent;
}
}
// We can move both next actions out of loop, because remaining actions in loop won't have
// any/visible effect on parts we add here. Close the styling before a linebreak and reopen
// after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
const lfIndex = string.indexOf('\n');
if (lfIndex !== -1) {
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
}
return openAll + string + closeAll;
};
let template;
const chalkTag = (chalk, ...strings) => {
const [firstString] = strings;
if (!isArray(firstString) || !isArray(firstString.raw)) {
// If chalk() was called by itself or with a string,
// return the string itself as a string.
return strings.join(' ');
}
const arguments_ = strings.slice(1);
const parts = [firstString.raw[0]];
for (let i = 1; i < firstString.length; i++) {
parts.push(
String(arguments_[i - 1]).replace(/[{}\\]/g, '\\$&'),
String(firstString.raw[i])
);
}
if (template === undefined) {
template = require('./templates');
}
return template(chalk, parts.join(''));
};
Object.defineProperties(Chalk.prototype, styles);
const chalk = Chalk(); // eslint-disable-line new-cap
chalk.supportsColor = stdoutColor;
chalk.stderr = Chalk({level: stderrColor ? stderrColor.level : 0}); // eslint-disable-line new-cap
chalk.stderr.supportsColor = stderrColor;
module.exports = chalk;

134
node_modules/chalk/source/templates.js generated vendored Normal file
View File

@ -0,0 +1,134 @@
'use strict';
const TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
const ESCAPES = new Map([
['n', '\n'],
['r', '\r'],
['t', '\t'],
['b', '\b'],
['f', '\f'],
['v', '\v'],
['0', '\0'],
['\\', '\\'],
['e', '\u001B'],
['a', '\u0007']
]);
function unescape(c) {
const u = c[0] === 'u';
const bracket = c[1] === '{';
if ((u && !bracket && c.length === 5) || (c[0] === 'x' && c.length === 3)) {
return String.fromCharCode(parseInt(c.slice(1), 16));
}
if (u && bracket) {
return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
}
return ESCAPES.get(c) || c;
}
function parseArguments(name, arguments_) {
const results = [];
const chunks = arguments_.trim().split(/\s*,\s*/g);
let matches;
for (const chunk of chunks) {
const number = Number(chunk);
if (!Number.isNaN(number)) {
results.push(number);
} else if ((matches = chunk.match(STRING_REGEX))) {
results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
} else {
throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
}
}
return results;
}
function parseStyle(style) {
STYLE_REGEX.lastIndex = 0;
const results = [];
let matches;
while ((matches = STYLE_REGEX.exec(style)) !== null) {
const name = matches[1];
if (matches[2]) {
const args = parseArguments(name, matches[2]);
results.push([name].concat(args));
} else {
results.push([name]);
}
}
return results;
}
function buildStyle(chalk, styles) {
const enabled = {};
for (const layer of styles) {
for (const style of layer.styles) {
enabled[style[0]] = layer.inverse ? null : style.slice(1);
}
}
let current = chalk;
for (const [styleName, styles] of Object.entries(enabled)) {
if (!Array.isArray(styles)) {
continue;
}
if (!(styleName in current)) {
throw new Error(`Unknown Chalk style: ${styleName}`);
}
current = styles.length > 0 ? current[styleName](...styles) : current[styleName];
}
return current;
}
module.exports = (chalk, temporary) => {
const styles = [];
const chunks = [];
let chunk = [];
// eslint-disable-next-line max-params
temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
if (escapeCharacter) {
chunk.push(unescape(escapeCharacter));
} else if (style) {
const string = chunk.join('');
chunk = [];
chunks.push(styles.length === 0 ? string : buildStyle(chalk, styles)(string));
styles.push({inverse, styles: parseStyle(style)});
} else if (close) {
if (styles.length === 0) {
throw new Error('Found extraneous } in Chalk template literal');
}
chunks.push(buildStyle(chalk, styles)(chunk.join('')));
chunk = [];
styles.pop();
} else {
chunk.push(character);
}
});
chunks.push(chunk.join(''));
if (styles.length > 0) {
const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
throw new Error(errMessage);
}
return chunks.join('');
};

39
node_modules/chalk/source/util.js generated vendored Normal file
View File

@ -0,0 +1,39 @@
'use strict';
const stringReplaceAll = (string, substring, replacer) => {
let index = string.indexOf(substring);
if (index === -1) {
return string;
}
const substringLength = substring.length;
let endIndex = 0;
let returnValue = '';
do {
returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
endIndex = index + substringLength;
index = string.indexOf(substring, endIndex);
} while (index !== -1);
returnValue += string.substr(endIndex);
return returnValue;
};
const stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index) => {
let endIndex = 0;
let returnValue = '';
do {
const gotCR = string[index - 1] === '\r';
returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
endIndex = index + 1;
index = string.indexOf('\n', endIndex);
} while (index !== -1);
returnValue += string.substr(endIndex);
return returnValue;
};
module.exports = {
stringReplaceAll,
stringEncaseCRLFWithFirstIndex
};

54
node_modules/color-convert/CHANGELOG.md generated vendored Normal file
View File

@ -0,0 +1,54 @@
# 1.0.0 - 2016-01-07
- Removed: unused speed test
- Added: Automatic routing between previously unsupported conversions
([#27](https://github.com/Qix-/color-convert/pull/27))
- Removed: `xxx2xxx()` and `xxx2xxxRaw()` functions
([#27](https://github.com/Qix-/color-convert/pull/27))
- Removed: `convert()` class
([#27](https://github.com/Qix-/color-convert/pull/27))
- Changed: all functions to lookup dictionary
([#27](https://github.com/Qix-/color-convert/pull/27))
- Changed: `ansi` to `ansi256`
([#27](https://github.com/Qix-/color-convert/pull/27))
- Fixed: argument grouping for functions requiring only one argument
([#27](https://github.com/Qix-/color-convert/pull/27))
# 0.6.0 - 2015-07-23
- Added: methods to handle
[ANSI](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors) 16/256 colors:
- rgb2ansi16
- rgb2ansi
- hsl2ansi16
- hsl2ansi
- hsv2ansi16
- hsv2ansi
- hwb2ansi16
- hwb2ansi
- cmyk2ansi16
- cmyk2ansi
- keyword2ansi16
- keyword2ansi
- ansi162rgb
- ansi162hsl
- ansi162hsv
- ansi162hwb
- ansi162cmyk
- ansi162keyword
- ansi2rgb
- ansi2hsl
- ansi2hsv
- ansi2hwb
- ansi2cmyk
- ansi2keyword
([#18](https://github.com/harthur/color-convert/pull/18))
# 0.5.3 - 2015-06-02
- Fixed: hsl2hsv does not return `NaN` anymore when using `[0,0,0]`
([#15](https://github.com/harthur/color-convert/issues/15))
---
Check out commit logs for older releases

21
node_modules/color-convert/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
Copyright (c) 2011-2016 Heather Arthur <fayearthur@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Some files were not shown because too many files have changed in this diff Show More