pax_global_header00006660000000000000000000000064136344146770014531gustar00rootroot0000000000000052 comment=58a3aff12121a7e876c1b47612571bf2757c916a sisteransi-1.0.5/000077500000000000000000000000001363441467700137205ustar00rootroot00000000000000sisteransi-1.0.5/.gitignore000066400000000000000000000000521363441467700157050ustar00rootroot00000000000000node_modules .DS_Store pacckage-lock.json sisteransi-1.0.5/.travis.yml000066400000000000000000000000411363441467700160240ustar00rootroot00000000000000language: node_js node_js: - 8 sisteransi-1.0.5/example.js000066400000000000000000000011401363441467700157050ustar00rootroot00000000000000'use strict'; const { beep, erase, cursor } = require('./src'); console.log('--- test 1 ---'); process.stdin.write('Line 1\n'); process.stdin.write('Line 2'+erase.line); process.stdin.write(cursor.left); process.stdin.write('Line 3\n'); console.log('--- test 2 ---'); process.stdin.write('Line 1\n'); process.stdin.write('Line 2\n'); process.stdin.write('Line 3\n'); process.stdin.write('Line 4\n'); process.stdin.write(cursor.prevLine(2)); process.stdin.write('third \n'); process.stdin.write(cursor.down(2)); process.stdin.write('last \n'); console.log('--- test 3 ---'); process.stdin.write(beep); sisteransi-1.0.5/license000066400000000000000000000020671363441467700152720ustar00rootroot00000000000000MIT 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. sisteransi-1.0.5/package.json000077500000000000000000000012231363441467700162070ustar00rootroot00000000000000{ "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" } } sisteransi-1.0.5/readme.md000077500000000000000000000050331363441467700155030ustar00rootroot00000000000000# 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) sisteransi-1.0.5/src/000077500000000000000000000000001363441467700145075ustar00rootroot00000000000000sisteransi-1.0.5/src/index.js000066400000000000000000000025211363441467700161540ustar00rootroot00000000000000'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 }; sisteransi-1.0.5/src/sisteransi.d.ts000066400000000000000000000021211363441467700174610ustar00rootroot00000000000000export 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; } sisteransi-1.0.5/test/000077500000000000000000000000001363441467700146775ustar00rootroot00000000000000sisteransi-1.0.5/test/index.js000066400000000000000000000051121363441467700163430ustar00rootroot00000000000000'use strict'; const test = require('tape'); const ansi = require('../src'); test('basic', t => { t.plan(6); t.equal(typeof ansi, 'object'); let expect = ['cursor', 'scroll', 'erase', 'beep']; expect.forEach(x => t.equal(x in ansi, true)); t.equal(typeof ansi.beep, 'string'); }); test('cursor', t => { t.plan(37); let c = ansi.cursor; t.equal(typeof c, 'object'); t.equal(typeof c.to, 'function'); t.equal(typeof c.move, 'function'); t.equal(typeof c.up, 'function'); t.equal(typeof c.down, 'function'); t.equal(typeof c.forward, 'function'); t.equal(typeof c.backward, 'function'); t.equal(typeof c.nextLine, 'function'); t.equal(typeof c.prevLine, 'function'); t.equal(typeof c.left, 'string'); t.equal(typeof c.hide, 'string'); t.equal(typeof c.show, 'string'); t.equal(typeof c.save, 'string'); t.equal(typeof c.restore, 'string'); t.equal(c.to(0), '\x1b[1G'); t.equal(c.to(2, 2), '\u001B[3;3H'); t.equal(c.move(1, 4), '\x1b[1C\x1b[4B'); t.equal(c.up(), '\x1b[1A'); t.equal(c.up(1), '\x1b[1A'); t.equal(c.up(2), '\x1b[2A'); t.equal(c.up(0), '\x1b[0A'); t.equal(c.down(), '\x1b[1B'); t.equal(c.down(1), '\x1b[1B'); t.equal(c.down(2), '\x1b[2B'); t.equal(c.down(0), '\x1b[0B'); t.equal(c.forward(), '\x1b[1C'); t.equal(c.forward(2), '\x1b[2C'); t.equal(c.forward(0), '\x1b[0C'); t.equal(c.backward(), '\x1b[1D'); t.equal(c.backward(2), '\x1b[2D'); t.equal(c.backward(0), '\x1b[0D'); t.equal(c.nextLine(), '\x1b[E'); t.equal(c.nextLine(2), '\x1b[E\x1b[E'); t.equal(c.prevLine(), '\x1b[F'); t.equal(c.prevLine(2), '\x1b[F\x1b[F'); t.equal(c.save, '\x1b7'); t.equal(c.restore, '\x1b8'); }); test('scroll', t => { t.plan(9); let s = ansi.scroll; t.equal(typeof s, 'object'); t.equal(typeof s.up, 'function'); t.equal(typeof s.down, 'function'); t.equal(s.up(), `\x1b[S`); t.equal(s.up(2), `\x1b[S\x1b[S`); t.equal(s.up(0), ``); t.equal(s.down(), `\x1b[T`); t.equal(s.down(2), `\x1b[T\x1b[T`); t.equal(s.down(0), ``); }); test('erase', t => { t.plan(15); let e = ansi.erase; t.equal(typeof e, 'object'); t.equal(typeof e.screen, 'string'); t.equal(typeof e.up, 'function'); t.equal(typeof e.down, 'function'); t.equal(typeof e.line, 'string'); t.equal(typeof e.lineEnd, 'string'); t.equal(typeof e.lineStart, 'string'); t.equal(typeof e.lines, 'function'); t.equal(e.up(), `\x1b[1J`); t.equal(e.up(2), `\x1b[1J\x1b[1J`); t.equal(e.up(0), ``); t.equal(e.down(), `\x1b[J`); t.equal(e.down(2), `\x1b[J\x1b[J`); t.equal(e.down(0), ``); t.equal(e.lines(2), '\x1b[2K\x1b[1A\x1b[2K\x1b[G'); });