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