All Projects β†’ 75lb β†’ Ansi Escape Sequences

75lb / Ansi Escape Sequences

Licence: mit
A simple, isomorphic library containing all known terminal ansi escape codes and sequences.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Ansi Escape Sequences

ansicolor
A JavaScript ANSI color/style management. ANSI parsing. ANSI to CSS. Small, clean, no dependencies.
Stars: ✭ 91 (+106.82%)
Mutual labels:  javascript-library, ansi-colors
Paint
Ruby gem for ANSI terminal colors 🎨︎ VERY FAST
Stars: ✭ 317 (+620.45%)
Mutual labels:  terminal, ansi-colors
Ls Go
A more colorful, user-friendly implementation of `ls` written in Go
Stars: ✭ 162 (+268.18%)
Mutual labels:  terminal, ansi-colors
Ansi
Small, fast library to create ANSI colored strings and codes. [go, golang]
Stars: ✭ 323 (+634.09%)
Mutual labels:  terminal, ansi-colors
Rich
Rich is a Python library for rich text and beautiful formatting in the terminal.
Stars: ✭ 31,664 (+71863.64%)
Mutual labels:  terminal, ansi-colors
Video To Ascii
It is a simple python package to play videos in the terminal using characters as pixels
Stars: ✭ 960 (+2081.82%)
Mutual labels:  terminal, ansi-colors
typical
Isomorphic, functional type-checking for Javascript
Stars: ✭ 17 (-61.36%)
Mutual labels:  isomorphic, javascript-library
Mordant
Full-featured text styling for Kotlin command-line applications
Stars: ✭ 382 (+768.18%)
Mutual labels:  terminal, ansi-colors
Python Coloredlogs
Colored terminal output for Python's logging module
Stars: ✭ 408 (+827.27%)
Mutual labels:  terminal, ansi-colors
Termynal
⬛️ Lightweight and modern terminal animations using async/await
Stars: ✭ 858 (+1850%)
Mutual labels:  terminal, javascript-library
Byte Size
Isomorphic function to convert a bytes value (e.g. 3456) to a human-readable string ('3.5 kB')
Stars: ✭ 33 (-25%)
Mutual labels:  isomorphic, javascript-library
Vue Prism
Simple Vue.js Syntax highlighting with Prism.js
Stars: ✭ 43 (-2.27%)
Mutual labels:  javascript-library
Hokaido
HND✈CTS
Stars: ✭ 41 (-6.82%)
Mutual labels:  terminal
Iterm2 Snazzy
Elegant iTerm2 theme with bright colors
Stars: ✭ 1,005 (+2184.09%)
Mutual labels:  terminal
Dotfiles
Colourful & robust configuration files and utilities for Mac, Linux and BSD
Stars: ✭ 1,006 (+2186.36%)
Mutual labels:  terminal
Typescript Hapi React Hot Loader Example
Simple TypeScript React Hot Loading example with Hapi Server-side rendering
Stars: ✭ 44 (+0%)
Mutual labels:  isomorphic
React Native Heic Converter
Convert your HEIC files with React Native
Stars: ✭ 43 (-2.27%)
Mutual labels:  javascript-library
Far2l
Linux port of FAR v2
Stars: ✭ 1,001 (+2175%)
Mutual labels:  terminal
Redash
Tiny functional programming suite for JavaScript.
Stars: ✭ 40 (-9.09%)
Mutual labels:  javascript-library
Minisauras
An open-source CI/CD automation tool based on GitHub Actions that pulls all the JavaScript and CSS files from your base branch, minify them and creates a pull-request with a new branch.
Stars: ✭ 40 (-9.09%)
Mutual labels:  javascript-library

view on npm npm module downloads Gihub repo dependents Gihub package dependents Build Status js-standard-style

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.

API Reference

Example

const ansi = require('ansi-escape-sequences')

ansi.cursor

cursor-related sequences

Kind: static property of ansi-escape-sequences

cursor.hide

Hides the cursor

Kind: static property of cursor

cursor.show

Shows the cursor

Kind: static property of cursor

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

Kind: static method of cursor

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

Kind: static method of cursor

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

Kind: static method of cursor

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

Kind: static method of cursor

Param Type Default
[lines] number 1

cursor.nextLine([lines]) β‡’ string

Moves cursor to beginning of the line n lines down.

Kind: static method of cursor

Param Type Default
[lines] number 1

cursor.previousLine([lines]) β‡’ string

Moves cursor to beginning of the line n lines up.

Kind: static method of cursor

Param Type Default
[lines] number 1

cursor.horizontalAbsolute(n) β‡’ string

Moves the cursor to column n.

Kind: static method of cursor

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.

Kind: static method of cursor

Param Type Description
n number row number
m number column number

ansi.erase

erase sequences

Kind: static property of ansi-escape-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.

Kind: static method of erase

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.

Kind: static method of erase

Param Type
n number

ansi.style : enum

Various formatting styles (aka Select Graphic Rendition codes).

Kind: static enum of ansi-escape-sequences
Properties

Name Type Default
reset string "\u001b[0m"
bold string "\u001b[1m"
italic string "\u001b[3m"
underline string "\u001b[4m"
fontDefault string "\u001b[10m"
font2 string "\u001b[11m"
font3 string "\u001b[12m"
font4 string "\u001b[13m"
font5 string "\u001b[14m"
font6 string "\u001b[15m"
imageNegative string "\u001b[7m"
imagePositive string "\u001b[27m"
black string "\u001b[30m"
red string "\u001b[31m"
green string "\u001b[32m"
yellow string "\u001b[33m"
blue string "\u001b[34m"
magenta string "\u001b[35m"
cyan string "\u001b[36m"
white string "\u001b[37m"
grey string "\u001b[90m"
gray string "\u001b[90m"
brightRed string "\u001b[91m"
brightGreen string "\u001b[92m"
brightYellow string "\u001b[93m"
brightBlue string "\u001b[94m"
brightMagenta string "\u001b[95m"
brightCyan string "\u001b[96m"
brightWhite string "\u001b[97m"
"bg-black" string "\u001b[40m"
"bg-red" string "\u001b[41m"
"bg-green" string "\u001b[42m"
"bg-yellow" string "\u001b[43m"
"bg-blue" string "\u001b[44m"
"bg-magenta" string "\u001b[45m"
"bg-cyan" string "\u001b[46m"
"bg-white" string "\u001b[47m"
"bg-grey" string "\u001b[100m"
"bg-gray" string "\u001b[100m"
"bg-brightRed" string "\u001b[101m"
"bg-brightGreen" string "\u001b[102m"
"bg-brightYellow" string "\u001b[103m"
"bg-brightBlue" string "\u001b[104m"
"bg-brightMagenta" string "\u001b[105m"
"bg-brightCyan" string "\u001b[106m"
"bg-brightWhite" string "\u001b[107m"

Example

console.log(ansi.style.red + 'this is red' + ansi.style.reset)

ansi.rgb(r, g, b) β‡’ string

Returns a 24-bit "true colour" foreground colour escape sequence.

Kind: static method of ansi-escape-sequences

Param Type Description
r number Red value.
g number Green value.
b number Blue value.

Example

> ansi.rgb(120, 0, 120)
'\u001b[38;2;120;0;120m'

ansi.bgRgb(r, g, b) β‡’ string

Returns a 24-bit "true colour" background colour escape sequence.

Kind: static method of ansi-escape-sequences

Param Type Description
r number Red value.
g number Green value.
b number Blue value.

Example

> ansi.bgRgb(120, 0, 120)
'\u001b[48;2;120;0;120m'

ansi.styles(styles) β‡’ string

Returns an ansi sequence setting one or more styles.

Kind: static method of ansi-escape-sequences

Param Type Description
styles string | Array.<string> One or more style strings.

Example

> ansi.styles('green')
'\u001b[32m'

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

> ansi.styles([ 'bg-red', 'rgb(200,200,200)' ])
'\u001b[41m\u001b[38;2;200;200;200m'

ansi.format(str, [styleArray]) β‡’ string

A convenience function, applying the styles provided in styleArray to the input string.

Partial, inline styling can also be applied using the syntax [style-list]{text to format} anywhere within the input string, where style-list is a space-separated list of styles from ansi.style. For example [bold white bg-red]{bold white text on a red background}.

24-bit "true colour" values can be set using rgb(n,n,n) syntax (no spaces), for example [rgb(255,128,0) underline]{orange underlined}. Background 24-bit colours can be set using bg-rgb(n,n,n) syntax.

Kind: static method of ansi-escape-sequences

Param Type Description
str string The string to format. Can also include inline-formatting using the syntax [style-list]{text to format} anywhere within the string.
[styleArray] string | Array.<string> One or more style strings to apply to the input string. Valid strings are any property from the ansi.style object (e.g. red or bg-red), rgb(n,n,n) or bg-rgb(n,n,n).

Example

> ansi.format('what?', 'green')
'\u001b[32mwhat?\u001b[0m'

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

> ansi.format('something', ['rgb(255,128,0)', 'bold'])
'\u001b[38;2;255;128;0m\u001b[1msomething\u001b[0m'

> ansi.format('Inline styling: [rgb(255,128,0) bold]{something}')
'Inline styling: \u001b[38;2;255;128;0m\u001b[1msomething\u001b[0m'

> ansi.format('Inline styling: [bg-rgb(255,128,0) bold]{something}')
'Inline styling: \u001b[48;2;255;128;0m\u001b[1msomething\u001b[0m'

Load anywhere

This library is compatible with Node.js, the Web and any style of module loader. It can be loaded anywhere, natively without transpilation.

Node.js:

const ansi = require('ansi-escape-sequences')

Within Node.js with ECMAScript Module support enabled:

import ansi from 'ansi-escape-sequences'

Within a modern browser ECMAScript Module:

import ansi from './node_modules/ansi-escape-sequences/dist/index.mjs'

Old browser (adds window.ansi):

<script nomodule src="./node_modules/ansi-escape-sequences/dist/index.js"></script>

Β© 2014-21 Lloyd Brookes <[email protected]>.

Tested by test-runner. Documented by jsdoc-to-markdown.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].