diff options
Diffstat (limited to 'node_modules/sisteransi')
-rw-r--r-- | node_modules/sisteransi/license | 21 | ||||
-rwxr-xr-x | node_modules/sisteransi/package.json | 34 | ||||
-rwxr-xr-x | node_modules/sisteransi/readme.md | 113 | ||||
-rw-r--r-- | node_modules/sisteransi/src/index.js | 58 | ||||
-rw-r--r-- | node_modules/sisteransi/src/sisteransi.d.ts | 35 |
5 files changed, 261 insertions, 0 deletions
diff --git a/node_modules/sisteransi/license b/node_modules/sisteransi/license new file mode 100644 index 0000000..13dc83c --- /dev/null +++ b/node_modules/sisteransi/license @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Terkel Gjervig Nielsen + +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/node_modules/sisteransi/package.json b/node_modules/sisteransi/package.json new file mode 100755 index 0000000..55a6476 --- /dev/null +++ b/node_modules/sisteransi/package.json @@ -0,0 +1,34 @@ +{ + "name": "sisteransi", + "version": "1.0.5", + "description": "ANSI escape codes for some terminal swag", + "main": "src/index.js", + "license": "MIT", + "author": { + "name": "Terkel Gjervig", + "email": "terkel@terkel.com", + "url": "https://terkel.com" + }, + "scripts": { + "test": "tape test/*.js | tap-spec" + }, + "repository": { + "type": "git", + "url": "https://github.com/terkelg/sisteransi" + }, + "files": [ + "src" + ], + "types": "./src/sisteransi.d.ts", + "keywords": [ + "ansi", + "escape codes", + "escape", + "terminal", + "style" + ], + "devDependencies": { + "tap-spec": "^5.0.0", + "tape": "^4.13.2" + } +} diff --git a/node_modules/sisteransi/readme.md b/node_modules/sisteransi/readme.md new file mode 100755 index 0000000..632f0d7 --- /dev/null +++ b/node_modules/sisteransi/readme.md @@ -0,0 +1,113 @@ +# sister ANSI [![Version](https://img.shields.io/npm/v/sisteransi.svg)](https://www.npmjs.com/package/sisteransi) [![Build Status](https://travis-ci.org/terkelg/sisteransi.svg?branch=master)](https://travis-ci.org/terkelg/sisteransi) [![Downloads](https://img.shields.io/npm/dm/sisteransi.svg)](https://www.npmjs.com/package/sisteransi) + +> Ansi escape codes faster than you can say "[Bam bam](https://www.youtube.com/watch?v=OcaPu9JPenU)". + +## Installation + +``` +npm install sisteransi +``` + + +## Usage + +```js +const ansi = require('sisteransi'); +// or const { cursor } = require('sisteransi'); + +const p = str => process.stdout.write(str); + +// move cursor to 2, 1 +p(ansi.cursor.to(2, 1)); + +// to up, one down +p(ansi.cursor.up(2)+ansi.cursor.down(1)); +``` + +## API + +### cursor + +#### to(x, y) +Set the absolute position of the cursor. `x0` `y0` is the top left of the screen. + +#### move(x, y) +Set the position of the cursor relative to its current position. + +#### up(count = 1) +Move cursor up a specific amount of rows. Default is `1`. + +#### down(count = 1) +Move cursor down a specific amount of rows. Default is `1`. + +#### forward(count = 1) +Move cursor forward a specific amount of rows. Default is `1`. + +#### backward(count = 1) +Move cursor backward a specific amount of rows. Default is `1`. + +#### nextLine(count = 1) +Move cursor to the next line a specific amount of lines. Default is `1`. + +#### prevLine(count = 1) +Move cursor to the previous a specific amount of lines. Default is `1`. + +#### left +Move cursor to the left side. + +#### hide +Hide cursor. + +#### show +Show cursor. + +#### save + +Save cursor position. + +#### restore + +Restore cursor position. + + +### scroll + +#### up(count = 1) +Scroll display up a specific amount of lines. Default to `1`. + +#### down(count = 1) +Scroll display down a specific amount of lines. Default to `1`. + + +### erase + +#### screen +Erase the screen and move the cursor the top left position. + +#### up(count = 1) +Erase the screen from the current line up to the top of the screen. Default to `1`. + +#### down(count = 2) +Erase the screen from the current line down to the bottom of the screen. Default to `1`. + +#### line +Erase the entire current line. + +#### lineEnd +Erase from the current cursor position to the end of the current line. + +#### lineStart +Erase from the current cursor position to the start of the current line. + +#### lines(count) +Erase from the current cursor position up the specified amount of rows. + + +## Credit + +This is a fork of [ansi-escapes](https://github.com/sindresorhus/ansi-escapes). + + +## License + +MIT © [Terkel Gjervig](https://terkel.com) diff --git a/node_modules/sisteransi/src/index.js b/node_modules/sisteransi/src/index.js new file mode 100644 index 0000000..7034e2e --- /dev/null +++ b/node_modules/sisteransi/src/index.js @@ -0,0 +1,58 @@ +'use strict'; + +const ESC = '\x1B'; +const CSI = `${ESC}[`; +const beep = '\u0007'; + +const cursor = { + to(x, y) { + if (!y) return `${CSI}${x + 1}G`; + return `${CSI}${y + 1};${x + 1}H`; + }, + move(x, y) { + let ret = ''; + + if (x < 0) ret += `${CSI}${-x}D`; + else if (x > 0) ret += `${CSI}${x}C`; + + if (y < 0) ret += `${CSI}${-y}A`; + else if (y > 0) ret += `${CSI}${y}B`; + + return ret; + }, + up: (count = 1) => `${CSI}${count}A`, + down: (count = 1) => `${CSI}${count}B`, + forward: (count = 1) => `${CSI}${count}C`, + backward: (count = 1) => `${CSI}${count}D`, + nextLine: (count = 1) => `${CSI}E`.repeat(count), + prevLine: (count = 1) => `${CSI}F`.repeat(count), + left: `${CSI}G`, + hide: `${CSI}?25l`, + show: `${CSI}?25h`, + save: `${ESC}7`, + restore: `${ESC}8` +} + +const scroll = { + up: (count = 1) => `${CSI}S`.repeat(count), + down: (count = 1) => `${CSI}T`.repeat(count) +} + +const erase = { + screen: `${CSI}2J`, + up: (count = 1) => `${CSI}1J`.repeat(count), + down: (count = 1) => `${CSI}J`.repeat(count), + line: `${CSI}2K`, + lineEnd: `${CSI}K`, + lineStart: `${CSI}1K`, + lines(count) { + let clear = ''; + for (let i = 0; i < count; i++) + clear += this.line + (i < count - 1 ? cursor.up() : ''); + if (count) + clear += cursor.left; + return clear; + } +} + +module.exports = { cursor, scroll, erase, beep }; diff --git a/node_modules/sisteransi/src/sisteransi.d.ts b/node_modules/sisteransi/src/sisteransi.d.ts new file mode 100644 index 0000000..113da2f --- /dev/null +++ b/node_modules/sisteransi/src/sisteransi.d.ts @@ -0,0 +1,35 @@ +export const beep: string; +export const clear: string; + +export namespace cursor { + export const left: string; + export const hide: string; + export const show: string; + export const save: string; + export const restore: string; + + export function to(x: number, y?: number): string; + export function move(x: number, y: number): string; + export function up(count?: number): string; + export function down(count?: number): string; + export function forward(count?: number): string; + export function backward(count?: number): string; + export function nextLine(count?: number): string; + export function prevLine(count?: number): string; +} + +export namespace scroll { + export function up(count?: number): string; + export function down(count?: number): string; +} + +export namespace erase { + export const screen: string; + export const line: string; + export const lineEnd: string; + export const lineStart: string; + + export function up(count?: number): string; + export function down(count?: number): string; + export function lines(count: number): string; +} |