UNPKG

7.29 kBMarkdownView Raw
1
2[![★](https://img.shields.io/github/stars/cronvel/terminal-kit.svg?label=❤)](https://github.com/cronvel/terminal-kit/stargazers)
3[![License](https://img.shields.io/github/license/cronvel/terminal-kit.svg)](https://github.com/cronvel/terminal-kit)
4[![Downloads](https://img.shields.io/npm/dm/terminal-kit.svg)](https://www.npmjs.com/package/terminal-kit)
5[![Version](https://img.shields.io/npm/v/terminal-kit.svg)](https://www.npmjs.com/package/terminal-kit)
6[![Run on repl.it](http://repl.it/badge/github/cronvel/terminal-kit)](https://repl.it/github/cronvel/terminal-kit)
7
8[![Stats](https://nodei.co/npm/terminal-kit.png?downloads=true&downloadRank=true&stars=true)](https://www.npmjs.com/package/terminal-kit)
9
10
11
12# Terminal Kit
13
14A full-blown terminal lib featuring: 256 colors, styles, keys & mouse handling, input field, progress bars,
15screen buffer (including **32-bit composition** and **image loading**), text buffer, and many more...
16
17Whether you just need colors & styles, build a simple interactive command line tool or a complexe terminal application:
18this is the absolute terminal lib for Node.js!
19
20It does **NOT** depend on ncurses.
21
22Some tutorials are available at [blog.soulserv.net/tag/terminal](http://blog.soulserv.net/tag/terminal/).
23
24
25
26## Screenshot, PleaZe!
27
28This is a fraction of what Terminal-Kit can do, with only few lines of code.
29Click any image to see the documentation related to the feature!
30
31[![Styles output](https://raw.githubusercontent.com/cronvel/terminal-kit/master/sample/style-doc1.png)](doc/low-level.md)
32
33[![Word-wrapping](https://raw.githubusercontent.com/cronvel/terminal-kit/master/sample/wordwrap-doc1.png)](doc/high-level.md#ref.wrapColumn)
34← Word-wrapping
35
36[![Input field output](https://raw.githubusercontent.com/cronvel/terminal-kit/master/sample/input-field-doc1.gif)](doc/high-level.md#ref.inputField)
37
38[![File input output](https://raw.githubusercontent.com/cronvel/terminal-kit/master/sample/file-input-doc1.gif)](doc/high-level.md#ref.fileInput)
39
40[![Input field output](https://raw.githubusercontent.com/cronvel/terminal-kit/master/sample/input-field-doc4.gif)](doc/high-level.md#ref.inputField)
41
42[![Single line menu output](https://raw.githubusercontent.com/cronvel/terminal-kit/master/sample/single-line-menu-doc1.gif)](doc/high-level.md#ref.singleLineMenu)
43
44[![Single column menu output](https://raw.githubusercontent.com/cronvel/terminal-kit/master/sample/single-column-menu-doc1.gif)](doc/high-level.md#ref.singleColumnMenu)
45
46[![Grid menu output](https://raw.githubusercontent.com/cronvel/terminal-kit/master/sample/grid-menu-doc1.gif)](doc/high-level.md#ref.gridMenu)
47
48[![Progress bar output](https://raw.githubusercontent.com/cronvel/terminal-kit/master/sample/progress-bar-doc1.gif)](doc/high-level.md#ref.progressBar)
49
50[![Progress bar output](https://raw.githubusercontent.com/cronvel/terminal-kit/master/sample/progress-bar-doc2.gif)](doc/high-level.md#ref.progressBar)
51
52[![Slow typing output](https://raw.githubusercontent.com/cronvel/terminal-kit/master/sample/slow-typing-doc1.gif)](doc/high-level.md#ref.slowTyping)
53
54[![Yes or no output](https://raw.githubusercontent.com/cronvel/terminal-kit/master/sample/yes-no-doc1.gif)](doc/high-level.md#ref.yesOrNo)
55
56[![Spaceship](https://raw.githubusercontent.com/cronvel/terminal-kit/master/demo/record.gif)](doc/screenbuffer.md)
57← Surfaces and Sprites
58
59[![Draw an image inside the terminal](https://raw.githubusercontent.com/cronvel/terminal-kit/master/sample/image-loading.png)](doc/high-level.md#ref.drawImage)
60← Load and draw an image inside the terminal
61
62
63
64## Key features
65
66*New:* [Document model](doc/document-model.md#top) for building rich app GUI.
67
68*New:* Promises can be used instead of callback everywhere.
69
70*New:* [Word-wrapping](doc/high-level.md#ref.wrapColumn) along full terminal width or a pre-defined column
71
72*New:* [ScreenBuffer HD](doc/screenbuffer-hd.md#top) (*beta*), 32-bit (RGBA) surfaces with composition and image loading
73
74* [colors, 256 colors or even 24-bit colors](doc/low-level.md#ref.colors), if the terminal supports it
75* [styles (bold, underline, italic, and many more)](doc/low-level.md#ref.styles)
76* [style mixing](doc/low-level.md#ref.chainable)
77* [chainable](doc/low-level.md#ref.chainable)
78* [string formatting](doc/low-level.md#ref.string-formatting)
79* [short style markup](doc/low-level.md#ref.style-markup)
80* [terminal window title](doc/low-level.md#ref.misc)
81* [cursor positioning](doc/low-level.md#ref.movingCursor)
82* [keyboard input](doc/high-level.md#ref.grabInput)
83* [mouse support (GPM is supported for the Linux Console)](doc/high-level.md#ref.grabInput)
84* [input field](doc/high-level.md#ref.inputField)
85* [single line menu](doc/high-level.md#ref.singleLineMenu)
86* [single column menu](doc/high-level.md#ref.singleColumnMenu)
87* [grid/table menu](doc/high-level.md#ref.gridMenu)
88* [progress bar](doc/high-level.md#ref.progressBar)
89* [interactive 'yes or no'](doc/high-level.md#ref.yesOrNo)
90* [screen & off-screen buffers (a concept similar to SDL's *Surface*)](doc/screenbuffer.md#top)
91* [text buffers](doc/textbuffer.md#top)
92* [change the terminal color palette](doc/high-level.md#ref.setPalette)
93* [draw an image file (PNG, JPEG, GIF) directly inside the terminal](doc/high-level.md#ref.drawImage)
94* [event-driven](doc/events.md#top)
95* Platform: any xterm-compatible terminal.
96 These terminals have been successfully tested:
97 * xterm
98 * gnome-terminal
99 * Konsole
100 * iTerm
101 * Terminator
102 * xfce4-terminal
103 * Linux Console
104 * rxvt/urxvt
105 * Eterm
106 * Terminology
107 * **Your terminal?** Help tracking terminal compatibilities [on github!](https://github.com/cronvel/terminal-kit/issues)
108
109
110
111## Quick examples
112
113```js
114// Require the lib, get a working terminal
115var term = require( 'terminal-kit' ).terminal ;
116
117// The term() function simply output a string to stdout, using current style
118// output "Hello world!" in default terminal's colors
119term( 'Hello world!\n' ) ;
120
121// This output 'red' in red
122term.red( 'red' ) ;
123
124// This output 'bold' in bold
125term.bold( 'bold' ) ;
126
127// output 'mixed' using bold, underlined & red, exposing the style-mixing syntax
128term.bold.underline.red( 'mixed' ) ;
129
130// printf() style formatting everywhere:
131// this will output 'My name is Jack, I'm 32.' in green
132term.green( "My name is %s, I'm %d.\n" , 'Jack' , 32 ) ;
133
134// Since v0.16.x, style markup are supported as a shorthand.
135// Those two lines produce the same result.
136term( "My name is " ).red( "Jack" )( " and I'm " ).green( "32\n" ) ;
137term( "My name is ^rJack^ and I'm ^g32\n" ) ;
138
139// Width and height of the terminal
140term( 'The terminal size is %dx%d' , term.width , term.height ) ;
141
142// Move the cursor at the upper-left corner
143term.moveTo( 1 , 1 ) ;
144
145// We can always pass additional arguments that will be displayed...
146term.moveTo( 1 , 1 , 'Upper-left corner' ) ;
147
148// ... and formated
149term.moveTo( 1 , 1 , "My name is %s, I'm %d.\n" , 'Jack' , 32 ) ;
150
151// ... or even combined with other styles
152term.moveTo.cyan( 1 , 1 , "My name is %s, I'm %d.\n" , 'Jack' , 32 ) ;
153
154// Get some user input
155term.magenta( "Enter your name: " ) ;
156term.inputField(
157 function( error , input ) {
158 term.green( "\nYour name is '%s'\n" , input ) ;
159 }
160) ;
161```
162
163
164### ♥♥ [I want to READ THE DOC NOW!](doc/documentation.md#ref.TOC) ♥♥
165
166
167#### License: MIT
168