• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.github/H16-May-2021-

_demos/H16-May-2021-

encoding/H16-May-2021-

logos/H03-May-2022-

termbox/H16-May-2021-

terminfo/H03-May-2022-

views/H16-May-2021-

.appveyor.ymlH A D16-May-2021275

.gitignoreH A D16-May-202113

.travis.ymlH A D16-May-2021243

AUTHORSH A D16-May-2021155

CHANGESv2.adocH A D16-May-20213.4 KiB

LICENSEH A D16-May-202111.1 KiB

README.adocH A D16-May-202113.5 KiB

TUTORIAL.adocH A D16-May-20217 KiB

attr.goH A D16-May-20211.1 KiB

cell.goH A D16-May-20214.6 KiB

charset_stub.goH A D16-May-2021666

charset_unix.goH A D16-May-20211.4 KiB

charset_windows.goH A D16-May-2021669

color.goH A D16-May-202129.9 KiB

color_test.goH A D16-May-20213.2 KiB

colorfit.goH A D16-May-20211.4 KiB

console_stub.goH A D16-May-2021833

console_win.goH A D16-May-202125.2 KiB

doc.goH A D16-May-20212.4 KiB

encoding.goH A D16-May-20215.1 KiB

errors.goH A D16-May-20212.5 KiB

event.goH A D16-May-20211.5 KiB

event_test.goH A D16-May-20211.5 KiB

go.modH A D16-May-2021308

go.sumH A D16-May-20211.4 KiB

interrupt.goH A D16-May-20211.2 KiB

key.goH A D16-May-202111.1 KiB

mouse.goH A D16-May-20213.9 KiB

nonblock_bsd.goH A D16-May-20211.2 KiB

nonblock_unix.goH A D16-May-20211.1 KiB

paste.goH A D16-May-20211.4 KiB

resize.goH A D16-May-20211.2 KiB

runes.goH A D16-May-20213.3 KiB

runes_test.goH A D16-May-20212.6 KiB

screen.goH A D16-May-202110 KiB

sim_test.goH A D16-May-20213.8 KiB

simulation.goH A D16-May-202110.7 KiB

style.goH A D16-May-20213.7 KiB

style_test.goH A D16-May-20211.1 KiB

terms_default.goH A D16-May-2021789

terms_dynamic.goH A D16-May-20211.3 KiB

terms_static.goH A D16-May-2021846

tscreen.goH A D16-May-202138.5 KiB

tscreen_stub.goH A D16-May-2021901

tscreen_unix.goH A D16-May-20211 KiB

tty.goH A D16-May-20212.8 KiB

tty_unix.goH A D16-May-20213.8 KiB

README.adoc

1= tcell
2
3
4image:https://img.shields.io/travis/gdamore/tcell.svg?label=linux[Linux Status,link="https://travis-ci.org/gdamore/tcell"]
5image:https://img.shields.io/appveyor/ci/gdamore/tcell.svg?label=windows[Windows Status,link="https://ci.appveyor.com/project/gdamore/tcell"]
6image:https://img.shields.io/badge/license-APACHE2-blue.svg[Apache License,link="https://github.com/gdamore/tcell/blob/master/LICENSE"]
7image:https://img.shields.io/badge/godoc-reference-blue.svg[GoDoc,link="https://godoc.org/github.com/gdamore/tcell"]
8image:https://goreportcard.com/badge/gdamore/tcell[Go Report Card,link="http://goreportcard.com/report/gdamore/tcell"]
9image:https://img.shields.io/discord/639503822733180969?label=discord[Discord,link="https://discord.gg/urTTxDN"]
10image:https://codecov.io/gh/gdamore/tcell/branch/master/graph/badge.svg[codecov,link="https://codecov.io/gh/gdamore/tcell"]
11
12[cols="2",grid="none"]
13|===
14|_Tcell_ is a _Go_ package that provides a cell based view for text terminals, like _XTerm_.
15It was inspired by _termbox_, but includes many additional improvements.
16a|[.right]
17image::logos/tcell.png[float="right"]
18|===
19
20NOTE: This is version 2 of _Tcell_.  There are breaking changes relative to version 1.
21Version 1.x remains available using the import `github.com/gdamore/tcell`.
22
23== Examples
24
25* https://github.com/gdamore/proxima5[proxima5] - space shooter (https://youtu.be/jNxKTCmY_bQ[video])
26* https://github.com/gdamore/govisor[govisor] - service management UI (http://2.bp.blogspot.com/--OsvnfzSNow/Vf7aqMw3zXI/AAAAAAAAARo/uOMtOvw4Sbg/s1600/Screen%2BShot%2B2015-09-20%2Bat%2B9.08.41%2BAM.png[screenshot])
27* mouse demo - included mouse test (http://2.bp.blogspot.com/-fWvW5opT0es/VhIdItdKqJI/AAAAAAAAATE/7Ojc0L1SpB0/s1600/Screen%2BShot%2B2015-10-04%2Bat%2B11.47.13%2BPM.png[screenshot])
28* https://github.com/gdamore/gomatrix[gomatrix] - converted from Termbox
29* https://github.com/zyedidia/micro/[micro] - lightweight text editor with syntax-highlighting and themes
30* https://github.com/viktomas/godu[godu] - simple golang utility helping to discover large files/folders.
31* https://github.com/rivo/tview/[tview] - rich interactive widgets for terminal UIs
32* https://github.com/awesome-gocui/gocui[awesome gocui] - Go Console User Interface
33* https://github.com/rgm3/gomandelbrot[gomandelbrot] - Mandelbrot!
34* https://github.com/senorprogrammer/wtf[WTF]- Personal information dashboard for your terminal
35* https://github.com/browsh-org/browsh[browsh] - A fully-modern text-based browser, rendering to TTY and browsers (https://www.youtube.com/watch?v=HZq86XfBoRo[video])
36* https://github.com/sachaos/go-life[go-life] - Conway's Game of Life.
37* https://github.com/gcla/gowid[gowid] - compositional widgets for terminal UIs, inspired by urwid
38* https://termshark.io[termshark] - a terminal UI for tshark, inspired by Wireshark, built on gowid
39* https://github.com/MichaelS11/go-tetris[go-tetris] - Go Tetris with AI option
40* https://github.com/junegunn/fzf[fzf] - A command-line fuzzy finder
41* https://github.com/esimov/ascii-fluid[ascii-fluid] - A terminal based ASCII fluid simulation controlled by webcam
42* https://gitlab.com/tslocum/cbind[cbind] - Provides key event encoding, decoding and handling
43* https://github.com/spinzed/tpong[tpong] - The old-school Pong remade in terminal
44* https://git.sr.ht/~sircmpwn/aerc[aerc] - An email client for your terminal.
45* https://github.com/ezeoleaf/tblogs[tblogs] - A terminal based development blogs reader
46* https://github.com/lallassu/spinc[spinc] - An irssi inspired terminal chat application for Cisco Spark/WebEx
47* https://github.com/lallassu/gorss[gorss] - A RSS/Atom feed reader for your terminal
48* https://github.com/Bios-Marcel/memoryalike[memoryalike] - A game where you have to memorize runes and hit their respective keys
49* https://github.com/gokcehan/lf[lf] - Terminal file manager
50* https://github.com/bunyk/gokeybr[gokeybr] - program that helps to deliberately practice your typing.
51* https://github.com/jbaramidze/gonano[gonano] - CLI test editor
52* https://github.com/tmountain/uchess[uchess] - A UCI chess client for your terminal
53* https://github.com/a-h/min[min] - A Gemini browser
54* https://github.com/noborus/ov[ov] - Terminal pager
55* https://github.com/gcla/tmux-wormhole[tmux-wormhole] - A tmux plugin to transfer files with magic wormhole
56* https://github.com/anaseto/gruid-tcell[gruid-tcell] - A tcell driver for the grid based UI and game framework gruid.
57
58== Pure Go Terminfo Database
59
60_Tcell_ includes a full parser and expander for terminfo capability strings,
61so that it can avoid hard coding escape strings for formatting.  It also favors
62portability, and includes support for all POSIX systems.
63
64The database is also flexible & extensible, and can modified by either running
65a program to build the entire database, or an entry for just a single terminal.
66
67== More Portable
68
69_Tcell_ is portable to a wide variety of systems, and is pure Go, without
70any need for CGO.
71_Tcell_ is believed to work with mainstream systems officially supported by golang.
72
73== No Async IO
74
75_Tcell_ is able to operate without requiring `SIGIO` signals (unlike _termbox_),
76or asynchronous I/O, and can instead use standard Go file
77objects and Go routines.
78This means it should be safe, especially for
79use with programs that use exec, or otherwise need to manipulate the
80tty streams.
81This model is also much closer to idiomatic Go, leading
82to fewer surprises.
83
84== Rich Unicode & non-Unicode support
85
86_Tcell_ includes enhanced support for Unicode, including wide characters and
87combining characters, provided your terminal can support them.
88Note that
89Windows terminals generally don't support the full Unicode repertoire.
90
91It will also convert to and from Unicode locales, so that the program
92can work with UTF-8 internally, and get reasonable output in other locales.
93_Tcell_ tries hard to convert to native characters on both input and output, and
94on output _Tcell_ even makes use of the alternate character set to facilitate
95drawing certain characters.
96
97== More Function Keys
98
99_Tcell_ also has richer support for a larger number of special keys that some terminals can send.
100
101== Better Color Handling
102
103_Tcell_ will respect your terminal's color space as specified within your terminfo
104entries, so that for example attempts to emit color sequences on VT100 terminals
105won't result in unintended consequences.
106
107In legacy Windows mode, _Tcell_ supports 16 colors, bold, dim, and reverse,
108instead of just termbox's 8 colors with reverse.  (Note that there is some
109conflation with bold/dim and colors.)
110Modern Windows 10 can benefit from much richer colors however.
111
112_Tcell_ maps 16 colors down to 8, for terminals that need it.
113(The upper 8 colors are just brighter versions of the lower 8.)
114
115== Better Mouse Support
116
117_Tcell_ supports enhanced mouse tracking mode, so your application can receive
118regular mouse motion events, and wheel events, if your terminal supports it.
119
120(Note: The Windows 10 Terminal application suffers from a flaw in this regard,
121and does not support mouse interaction.  The stock Windows 10 console host
122fired up with cmd.exe or PowerShell works fine however.)
123
124== _Termbox_ Compatibility
125
126A compatibility layer for _termbox_ is provided in the `compat` directory.
127To use it, try importing `github.com/gdamore/tcell/termbox` instead.
128Most _termbox-go_ programs will probably work without further modification.
129
130== Working With Unicode
131
132Internally Tcell uses UTF-8, just like Go.
133However, Tcell understands how to
134convert to and from other character sets, using the capabilities of
135the `golang.org/x/text/encoding packages`.
136Your application must supply
137them, as the full set of the most common ones bloats the program by about 2MB.
138If you're lazy, and want them all anyway, see the `encoding` sub-directory.
139
140== Wide & Combining Characters
141
142The `SetContent()` API takes a primary rune, and an optional list of combining runes.
143If any of the runes is a wide (East Asian) rune occupying two cells,
144then the library will skip output from the following cell, but care must be
145taken in the application to avoid explicitly attempting to set content in the
146next cell, otherwise the results are undefined.  (Normally wide character
147is displayed, and the other character is not; do not depend on that behavior.)
148
149Older terminal applications (especially on systems like Windows 8) lack support
150for advanced Unicode, and thus may not fare well.
151
152== Colors
153
154_Tcell_ assumes the ANSI/XTerm color model, including the 256 color map that
155XTerm uses when it supports 256 colors.  The terminfo guidance will be
156honored, with respect to the number of colors supported.  Also, only
157terminals which expose ANSI style `setaf` and `setab` will support color;
158if you have a color terminal that only has `setf` and `setb`, please submit
159a ticket; it wouldn't be hard to add that if there is need.
160
161== 24-bit Color
162
163_Tcell_ _supports true color_!  (That is, if your terminal can support it,
164_Tcell_ can accurately display 24-bit color.)
165
166NOTE: Technically the approach of using 24-bit RGB values for color is more
167accurately described as "direct color", but most people use the term "true color",
168and so we follow the (inaccurate) common convention.
169
170There are a few ways you can enable (or disable) true color.
171
172* For many terminals, we can detect it automatically if your terminal
173includes the `RGB` or `Tc` capabilities (or rather it did when the database
174was updated.)
175
176* You can force this one by setting the `COLORTERM` environment variable to
177"24-bit", "truecolor" or "24bit".  This is the same method used
178by most other terminal applications that support 24-bit color.
179
180* If you set your `TERM` environment variable to a value with the suffix `-truecolor`
181then 24-bit color compatible with XTerm will be assumed (and the terminal will
182otherwise use the same escape sequences as the base terminal definition.)
183
184NOTE: This feature is for compatibility with older _Tcell_ versions.
185It is recommended to use one of other methods instead.
186
187* You can disable 24-bit color by setting `TCELL_TRUECOLOR=disable` in your
188environment.
189
190When using TrueColor, programs will display the colors that the programmer
191intended, overriding any "`themes`" you may have set in your terminal
192emulator.  (For some cases, accurate color fidelity is more important
193than respecting themes.  For other cases, such as typical text apps that
194only use a few colors, its more desirable to respect the themes that
195the user has established.)
196
197== Performance
198
199Reasonable attempts have been made to minimize sending data to terminals,
200avoiding repeated sequences or drawing the same cell on refresh updates.
201
202== Terminfo
203
204(Not relevant for Windows users.)
205
206The Terminfo implementation operates with a built-in database.
207This should satisfy most users.  However, it can also (on systems
208with ncurses installed), dynamically parse the output from `infocmp`
209for terminals it does not already know about.
210
211See the `terminfo/` directory for more information about generating
212new entries for the built-in database.
213
214_Tcell_ requires that the terminal support the `cup` mode of cursor addressing.
215Ancient terminals without the ability to position the cursor directly
216are not supported.
217This is unlikely to be a problem; such terminals have not been mass-produced
218since the early 1970s.
219
220== Mouse Support
221
222Mouse support is detected via the `kmous` terminfo variable, however,
223enablement/disablement and decoding mouse events is done using hard coded
224sequences based on the XTerm X11 model.  As of this writing all popular
225terminals with mouse tracking support this model.  (Full terminfo support
226is not possible as terminfo sequences are not defined.)
227
228On Windows, the mouse works normally.
229
230Mouse wheel buttons on various terminals are known to work, but the support
231in terminal emulators, as well as support for various buttons and
232live mouse tracking, varies widely.  Modern _xterm_, macOS _Terminal_, and _iTerm_ all work well.
233
234== Bracketed Paste
235
236Terminals that appear to support the XTerm mouse model also can support
237bracketed paste, for applications that opt-in.  See `EnablePaste()` for details.
238
239== Testability
240
241There is a `SimulationScreen`, that can be used to simulate a real screen
242for automated testing.  The supplied tests do this.  The simulation contains
243event delivery, screen resizing support, and capabilities to inject events
244and examine "`physical`" screen contents.
245
246== Platforms
247
248=== POSIX (Linux, FreeBSD, macOS, Solaris, etc.)
249
250Everything works using pure Go on mainstream platforms.  Some more esoteric
251platforms (e.g. AIX) may need to be added.  Pull requests are welcome!
252
253=== Windows
254
255Windows console mode applications are supported.
256
257Modern console applications like ConEmu and the Windows 10 terminal,
258support all the good features (resize, mouse tracking, etc.)
259
260=== Plan9, WASM, and others
261
262These platforms won't work, but compilation stubs are supplied
263for folks that want to include parts of this in software for those
264platforms.  The Simulation screen works, but as _Tcell_ doesn't know how to
265allocate a real screen object on those platforms, `NewScreen()` will fail.
266
267If anyone has wisdom about how to improve support for these,
268please let me know.  PRs are especially welcome.
269
270=== Commercial Support
271
272_Tcell_ is absolutely free, but if you want to obtain commercial, professional support, there are options.
273
274[cols="2",align="center",frame="none", grid="none"]
275|===
276^.^|
277image:logos/tidelift.png[100,100]
278a|
279https://tidelift.com/[Tidelift] subscriptions include support for _Tcell_, as well as many other open source packages.
280
281^.^|
282image:logos/staysail.png[100,100]
283a|
284mailto:info@staysail.tech[Staysail Systems, Inc.] offers direct support, and custom development around _Tcell_ on an hourly basis.
285