JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 629997
  • Score
    100M100P100Q217389F
  • License MIT

A simple library containing all known terminal ansi escape codes and sequences. Useful for adding colour to your command-line output or building a dynamic text user interface.

Package Exports

  • ansi-escape-sequences

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ansi-escape-sequences) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

view on npm npm module downloads per month Build Status Dependency Status

ansi-escape-sequences

A simple library containing all known terminal ansi escape codes and sequences. Useful for adding colour to your command-line output, or building a dynamic text user interface.

Example

var ansi = require("ansi-escape-sequences");

ansi.sgr

Select Graphic Rendition codes

Properties

Name Type
reset string
bold string
italic string
underline string
fontDefault string
font2 string
font3 string
font4 string
font5 string
font6 string
imageNegative string
imagePositive string
black string
red string
green string
yellow string
blue string
magenta string
cyan string
white string

Example

console.log(ansi.sgr.red + "this is red" + ansi.sgr.reset);

sgr.sequence() ⇒ string

Returns an a sequence setting one or more effects

Type Description
string | Array.<string> a sgr effect, or list of effects

Example

> ansi.sgrSequence("green")
    '\u001b[32m'
    > ansi.sgrSequence([ "green", "underline" ])
    '\u001b[32;4m'

sgr.format() ⇒ string

A convenience function, formatting the input string with the specified sgr effects.

Type Description
string the string to format
Array.<string> a list of sgr effects to add

Example

> ansi.sgr.format("what?", "green")
    '\u001b[32mwhat?\u001b[0m'
    > ansi.sgr.format("what?", ["green", "bold"])
    '\u001b[32;1mwhat?\u001b[0m'

ansi.cursor

cursor-related sequences

cursor.up([lines]) ⇒ string

Moves the cursor lines cells up. If the cursor is already at the edge of the screen, this has no effect

Param Type Default
[lines] number 1

cursor.down([lines]) ⇒ string

Moves the cursor lines cells down. If the cursor is already at the edge of the screen, this has no effect

Param Type Default
[lines] number 1

cursor.forward([lines]) ⇒ string

Moves the cursor lines cells forward. If the cursor is already at the edge of the screen, this has no effect

Param Type Default
[lines] number 1

cursor.back([lines]) ⇒ string

Moves the cursor lines cells back. If the cursor is already at the edge of the screen, this has no effect

Param Type Default
[lines] number 1

cursor.nextLine([lines]) ⇒ string

Moves cursor to beginning of the line n lines down.

Param Type Default
[lines] number 1

cursor.previousLine([lines]) ⇒ string

Moves cursor to beginning of the line n lines up.

Param Type Default
[lines] number 1

cursor.horizontalAbsolute(n) ⇒ string

Moves the cursor to column n.

Param Type Description
n number column number

cursor.position(n, m) ⇒ string

Moves the cursor to row n, column m. The values are 1-based, and default to 1 (top left corner) if omitted.

Param Type Description
n number row number
m number column number

ansi.erase

erase sequences

erase.display(n) ⇒ string

Clears part of the screen. If n is 0 (or missing), clear from cursor to end of screen. If n is 1, clear from cursor to beginning of the screen. If n is 2, clear entire screen.

Param Type
n number

erase.inLine(n) ⇒ string

Erases part of the line. If n is zero (or missing), clear from cursor to the end of the line. If n is one, clear from cursor to beginning of the line. If n is two, clear entire line. Cursor position does not change.

Param Type
n number

documented by jsdoc-to-markdown

© 2015 Lloyd Brookes 75pound@gmail.com