[Pkg-javascript-commits] [node-ansi-escapes] 01/05: Import Upstream version 1.4.0

Paolo Greppi paolog-guest at moszumanska.debian.org
Mon Dec 19 11:42:25 UTC 2016


This is an automated email from the git hooks/post-receive script.

paolog-guest pushed a commit to branch master
in repository node-ansi-escapes.

commit b7a03f0cf09631795b696152d112c38eaa9a5f46
Author: Paolo Greppi <paolo.greppi at libpf.com>
Date:   Fri Dec 16 18:08:05 2016 +0000

    Import Upstream version 1.4.0
---
 .editorconfig  |  12 ++++
 .gitattributes |   1 +
 .gitignore     |   1 +
 .travis.yml    |   6 ++
 example.js     |   4 ++
 fixture.jpg    | Bin 0 -> 59411 bytes
 index.js       | 106 ++++++++++++++++++++++++++++++++++
 license        |  21 +++++++
 package.json   |  50 ++++++++++++++++
 readme.md      | 176 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 test.js        |   8 +++
 11 files changed, 385 insertions(+)

diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..98a761d
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,12 @@
+root = true
+
+[*]
+indent_style = tab
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[{package.json,*.yml}]
+indent_style = space
+indent_size = 2
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..176a458
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+* text=auto
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3c3629e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+node_modules
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..ab2fee2
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,6 @@
+language: node_js
+node_js:
+  - '5'
+  - '4'
+  - '0.12'
+  - '0.10'
diff --git a/example.js b/example.js
new file mode 100644
index 0000000..b282959
--- /dev/null
+++ b/example.js
@@ -0,0 +1,4 @@
+var fs = require('fs');
+var ansiEscapes = require('./');
+
+console.log(ansiEscapes.image(fs.readFileSync('fixture.jpg'), {width: 15}));
diff --git a/fixture.jpg b/fixture.jpg
new file mode 100644
index 0000000..9625248
Binary files /dev/null and b/fixture.jpg differ
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..7f61fc3
--- /dev/null
+++ b/index.js
@@ -0,0 +1,106 @@
+'use strict';
+var ESC = '\u001b[';
+var x = module.exports;
+
+x.cursorTo = function (x, y) {
+	if (arguments.length === 0) {
+		return ESC + 'H';
+	}
+
+	if (arguments.length === 1) {
+		return ESC + (x + 1) + 'G';
+	}
+
+	return ESC + (y + 1) + ';' + (x + 1) + 'H';
+};
+
+x.cursorMove = function (x, y) {
+	var ret = '';
+
+	if (x < 0) {
+		ret += ESC + (-x) + 'D';
+	} else if (x > 0) {
+		ret += ESC + x + 'C';
+	}
+
+	if (y < 0) {
+		ret += ESC + (-y) + 'A';
+	} else if (y > 0) {
+		ret += ESC + y + 'B';
+	}
+
+	return ret;
+};
+
+x.cursorUp = function (count) {
+	return ESC + (typeof count === 'number' ? count : 1) + 'A';
+};
+
+x.cursorDown = function (count) {
+	return ESC + (typeof count === 'number' ? count : 1) + 'B';
+};
+
+x.cursorForward = function (count) {
+	return ESC + (typeof count === 'number' ? count : 1) + 'C';
+};
+
+x.cursorBackward = function (count) {
+	return ESC + (typeof count === 'number' ? count : 1) + 'D';
+};
+
+x.cursorLeft = ESC + '1000D';
+x.cursorSavePosition = ESC + 's';
+x.cursorRestorePosition = ESC + 'u';
+x.cursorGetPosition = ESC + '6n';
+x.cursorNextLine = ESC + 'E';
+x.cursorPrevLine = ESC + 'F';
+x.cursorHide = ESC + '?25l';
+x.cursorShow = ESC + '?25h';
+
+x.eraseLines = function (count) {
+	var clear = '';
+
+	for (var i = 0; i < count; i++) {
+		clear += x.cursorLeft + x.eraseEndLine + (i < count - 1 ? x.cursorUp() : '');
+	}
+
+	return clear;
+};
+
+x.eraseEndLine = ESC + 'K';
+x.eraseStartLine = ESC + '1K';
+x.eraseLine = ESC + '2K';
+x.eraseDown = ESC + 'J';
+x.eraseUp = ESC + '1J';
+x.eraseScreen = ESC + '2J';
+x.scrollUp = ESC + 'S';
+x.scrollDown = ESC + 'T';
+
+x.clearScreen = '\u001bc';
+x.beep = '\u0007';
+
+x.image = function (buf, opts) {
+	opts = opts || {};
+
+	var ret = '\u001b]1337;File=inline=1';
+
+	if (opts.width) {
+		ret += ';width=' + opts.width;
+	}
+
+	if (opts.height) {
+		ret += ';height=' + opts.height;
+	}
+
+	if (opts.preserveAspectRatio === false) {
+		ret += ';preserveAspectRatio=0';
+	}
+
+	return ret + ':' + buf.toString('base64') + '\u0007';
+};
+
+x.iTerm = {};
+
+x.iTerm.setCwd = function (cwd) {
+	return '\u001b]50;CurrentDir=' + (cwd || process.cwd()) + '\u0007';
+};
diff --git a/license b/license
new file mode 100644
index 0000000..654d0bf
--- /dev/null
+++ b/license
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) Sindre Sorhus <sindresorhus at 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.
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..ed1a4ea
--- /dev/null
+++ b/package.json
@@ -0,0 +1,50 @@
+{
+  "name": "ansi-escapes",
+  "version": "1.4.0",
+  "description": "ANSI escape codes for manipulating the terminal",
+  "license": "MIT",
+  "repository": "sindresorhus/ansi-escapes",
+  "author": {
+    "name": "Sindre Sorhus",
+    "email": "sindresorhus at gmail.com",
+    "url": "sindresorhus.com"
+  },
+  "engines": {
+    "node": ">=0.10.0"
+  },
+  "scripts": {
+    "test": "xo && ava"
+  },
+  "files": [
+    "index.js"
+  ],
+  "keywords": [
+    "ansi",
+    "terminal",
+    "console",
+    "cli",
+    "string",
+    "tty",
+    "escape",
+    "escapes",
+    "formatting",
+    "shell",
+    "xterm",
+    "log",
+    "logging",
+    "command-line",
+    "text",
+    "vt100",
+    "sequence",
+    "control",
+    "code",
+    "codes",
+    "cursor",
+    "iterm",
+    "iterm2"
+  ],
+  "devDependencies": {
+    "ava": "*",
+    "xo": "*"
+  }
+}
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..c1254e9
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,176 @@
+# ansi-escapes [![Build Status](https://travis-ci.org/sindresorhus/ansi-escapes.svg?branch=master)](https://travis-ci.org/sindresorhus/ansi-escapes)
+
+> [ANSI escape codes](http://www.termsys.demon.co.uk/vtansi.htm) for manipulating the terminal
+
+
+## Install
+
+```
+$ npm install --save ansi-escapes
+```
+
+
+## Usage
+
+```js
+const ansiEscapes = require('ansi-escapes');
+
+// moves the cursor two rows up and to the left
+process.stdout.write(ansiEscapes.cursorUp(2) + ansiEscapes.cursorLeft);
+//=> '\u001b[2A\u001b[1000D'
+```
+
+
+## API
+
+### cursorTo([x, [y]])
+
+Set the absolute position of the cursor. `x0` `y0` is the top left of the screen.
+
+Specify either both `x` & `y`, only `x`, or nothing.
+
+### cursorMove(x, [y])
+
+Set the position of the cursor relative to its current position.
+
+### cursorUp(count)
+
+Move cursor up a specific amount of rows. Default is `1`.
+
+### cursorDown(count)
+
+Move cursor down a specific amount of rows. Default is `1`.
+
+### cursorForward(count)
+
+Move cursor forward a specific amount of rows. Default is `1`.
+
+### cursorBackward(count)
+
+Move cursor backward a specific amount of rows. Default is `1`.
+
+### cursorLeft
+
+Move cursor to the left side.
+
+### cursorSavePosition
+
+Save cursor position.
+
+### cursorRestorePosition
+
+Restore saved cursor position.
+
+### cursorGetPosition
+
+Get cursor position.
+
+### cursorNextLine
+
+Move cursor to the next line.
+
+### cursorPrevLine
+
+Move cursor to the previous line.
+
+### cursorHide
+
+Hide cursor.
+
+### cursorShow
+
+Show cursor.
+
+### eraseLines(count)
+
+Erase from the current cursor position up the specified amount of rows.
+
+### eraseEndLine
+
+Erase from the current cursor position to the end of the current line.
+
+### eraseStartLine
+
+Erase from the current cursor position to the start of the current line.
+
+### eraseLine
+
+Erase the entire current line.
+
+### eraseDown
+
+Erase the screen from the current line down to the bottom of the screen.
+
+### eraseUp
+
+Erase the screen from the current line up to the top of the screen.
+
+### eraseScreen
+
+Erase the screen and move the cursor the top left position.
+
+### scrollUp
+
+Scroll display up one line.
+
+### scrollDown
+
+Scroll display down one line.
+
+### clearScreen
+
+Clear the terminal screen.
+
+### beep
+
+Output a beeping sound.
+
+### image(input, [options])
+
+Display an image.
+
+*Currently only supported on iTerm >=2.9.*
+
+See [term-img](https://github.com/sindresorhus/term-img) for a higher-level module.
+
+#### input
+
+Type: `buffer`
+
+Buffer of an image. Usually read in with `fs.readFile()`.
+
+#### options
+
+##### width
+##### height
+
+Type: `string` `number`
+
+The width and height are given as a number followed by a unit, or the word "auto".
+
+- `N`: N character cells.
+- `Npx`: N pixels.
+- `N%`: N percent of the session's width or height.
+- `auto`: The image's inherent size will be used to determine an appropriate dimension.
+
+##### preserveAspectRatio
+
+Type: `boolean`<br>
+Default: `true`
+
+### iTerm.setCwd([path])
+
+Type: `string`<br>
+Default: `process.cwd()`
+
+[Inform iTerm](https://www.iterm2.com/documentation-escape-codes.html) of the current directory to help semantic history and enable [Cmd-clicking relative paths](https://coderwall.com/p/b7e82q/quickly-open-files-in-iterm-with-cmd-click).
+
+
+## Related
+
+- [ansi-styles](https://github.com/chalk/ansi-styles) - ANSI escape codes for styling strings in the terminal
+
+
+## License
+
+MIT © [Sindre Sorhus](https://sindresorhus.com)
diff --git a/test.js b/test.js
new file mode 100644
index 0000000..3b17965
--- /dev/null
+++ b/test.js
@@ -0,0 +1,8 @@
+import test from 'ava';
+import m from './';
+
+test(t => {
+	t.true(Object.keys(m).length > 0);
+	t.is(typeof m.cursorTo, 'function');
+	t.is(m.cursorTo(2, 2), '\u001b[3;3H');
+});

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-ansi-escapes.git



More information about the Pkg-javascript-commits mailing list