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

..03-May-2022-

.github/H25-Aug-2020-3326

_demos/H25-Aug-2020-881682

encoding/H25-Aug-2020-11677

logos/H03-May-2022-

termbox/H25-Aug-2020-380284

terminfo/H03-May-2022-7,1276,315

views/H25-Aug-2020-2,8401,892

.appveyor.ymlH A D25-Aug-2020275 1413

.gitignoreH A D25-Aug-202013 21

.travis.ymlH A D25-Aug-2020223 1611

AUTHORSH A D25-Aug-2020155 54

LICENSEH A D25-Aug-202011.1 KiB203169

README.adocH A D25-Aug-202013 KiB280210

attr.goH A D25-Aug-20201.1 KiB3412

cell.goH A D25-Aug-20204.6 KiB178120

charset_stub.goH A D25-Aug-2020666 224

charset_unix.goH A D25-Aug-20201.4 KiB5025

charset_windows.goH A D25-Aug-2020669 224

color.goH A D25-Aug-202028.1 KiB1,020959

color_test.goH A D25-Aug-20202.4 KiB9871

colorfit.goH A D25-Aug-20201.4 KiB5332

console_stub.goH A D25-Aug-2020833 244

console_win.goH A D25-Aug-202023.9 KiB1,171965

doc.goH A D25-Aug-20202.4 KiB491

encoding.goH A D25-Aug-20205.1 KiB14050

errors.goH A D25-Aug-20202.5 KiB7425

event.goH A D25-Aug-20201.5 KiB5422

event_test.goH A D25-Aug-20201.5 KiB7149

go.modH A D25-Aug-2020250 129

go.sumH A D25-Aug-2020897 1110

interrupt.goH A D25-Aug-20201.2 KiB4217

key.goH A D25-Aug-202011 KiB465363

mouse.goH A D25-Aug-20203.6 KiB9842

resize.goH A D25-Aug-20201.2 KiB4318

runes.goH A D25-Aug-20203.3 KiB11269

runes_test.goH A D25-Aug-20202.6 KiB9670

screen.goH A D25-Aug-20208.7 KiB21439

sim_test.goH A D25-Aug-20203.8 KiB153124

simulation.goH A D25-Aug-202010.4 KiB513377

style.goH A D25-Aug-20204.1 KiB13362

style_test.goH A D25-Aug-20201.1 KiB4221

terms_default.goH A D25-Aug-2020786 244

terms_dynamic.goH A D25-Aug-20201.3 KiB3812

terms_static.goH A D25-Aug-2020846 288

tscreen.goH A D25-Aug-202031.6 KiB1,4401,150

tscreen_bsd.goH A D25-Aug-20202.8 KiB12286

tscreen_darwin.goH A D25-Aug-20203.7 KiB14388

tscreen_linux.goH A D25-Aug-20203.1 KiB148104

tscreen_solaris.goH A D25-Aug-20202.7 KiB12380

tscreen_stub.goH A D25-Aug-2020945 3713

tscreen_windows.goH A D25-Aug-20201.2 KiB4517

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:http://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
20## Examples
21
22* https://github.com/gdamore/proxima5[proxima5] - space shooter (https://youtu.be/jNxKTCmY_bQ[video])
23* 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])
24* 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])
25* https://github.com/gdamore/gomatrix[gomatrix] - converted from Termbox
26* https://github.com/zyedidia/micro/[micro] - lightweight text editor with syntax-highlighting and themes
27* https://github.com/viktomas/godu[godu] - simple golang utility helping to discover large files/folders.
28* https://github.com/rivo/tview[tview] - rich interactive widgets for terminal UIs
29* https://github.com/marcusolsson/tui-go[tui-go] - UI library for terminal apps (_deprecated_)
30* https://github.com/rgm3/gomandelbrot[gomandelbrot] - Mandelbrot!
31* https://github.com/senorprogrammer/wtf[WTF]- Personal information dashboard for your terminal
32* 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])
33* https://github.com/sachaos/go-life[go-life] - Conway's Game of Life.
34* https://github.com/gcla/gowid[gowid] - compositional widgets for terminal UIs, inspired by urwid
35* https://termshark.io[termshark] - a terminal UI for tshark, inspired by Wireshark, built on gowid
36* https://github.com/MichaelS11/go-tetris[go-tetris] - Go Tetris with AI option
37* https://github.com/junegunn/fzf[fzf] - A command-line fuzzy finder
38* https://github.com/esimov/ascii-fluid[ascii-fluid] - A terminal based ASCII fluid simulation controlled by webcam
39* https://gitlab.com/tslocum/cbind[cbind] - Provides key event encoding, decoding and handling
40* https://github.com/spinzed/tpong[tpong] - The old-school Pong remade in terminal
41
42## Pure Go Terminfo Database
43
44_Tcell_ includes a full parser and expander for terminfo capability strings,
45so that it can avoid hard coding escape strings for formatting.  It also favors
46portability, and includes support for all POSIX systems.
47
48The database is also flexible & extensible, and can modified by either running
49a program to build the entire database, or an entry for just a single terminal.
50
51## More Portable
52
53_Tcell_ is portable to a wide variety of systems.
54_Tcell_ is believed
55to work with all of the systems officially supported by golang with
56the exception of nacl (which lacks any kind of a terminal interface).
57(Plan9 is not supported by _Tcell_, but it is experimental status only
58in golang.)  _Tcell_ is pure Go, without any need for CGO.
59
60## No Async IO
61
62_Tcell_ is able to operate without requiring `SIGIO` signals (unlike _termbox_),
63or asynchronous I/O, and can instead use standard Go file
64objects and Go routines.
65This means it should be safe, especially for
66use with programs that use exec, or otherwise need to manipulate the
67tty streams.
68This model is also much closer to idiomatic Go, leading
69to fewer surprises.
70
71## Rich Unicode & non-Unicode support
72
73_Tcell_ includes enhanced support for Unicode, including wide characters and
74combining characters, provided your terminal can support them.
75Note that
76Windows terminals generally don't support the full Unicode repertoire.
77
78It will also convert to and from Unicode locales, so that the program
79can work with UTF-8 internally, and get reasonable output in other locales.
80_Tcell_ tries hard to convert to native characters on both input and output, and
81on output _Tcell_ even makes use of the alternate character set to facilitate
82drawing certain characters.
83
84## More Function Keys
85
86_Tcell_ also has richer support for a larger number of special keys that some terminals can send.
87
88## Better Color Handling
89
90_Tcell_ will respect your terminal's color space as specified within your terminfo
91entries, so that for example attempts to emit color sequences on VT100 terminals
92won't result in unintended consequences.
93
94In legacy Windows mode, _Tcell_ supports 16 colors, bold, dim, and reverse,
95instead of just termbox's 8 colors with reverse.  (Note that there is some
96conflation with bold/dim and colors.)
97Modern Windows 10 can benefit from much richer colors however.
98
99_Tcell_ maps 16 colors down to 8, for terminals that need it.
100(The upper 8 colors are just brighter versions of the lower 8.)
101
102## Better Mouse Support
103
104_Tcell_ supports enhanced mouse tracking mode, so your application can receive
105regular mouse motion events, and wheel events, if your terminal supports it.
106
107(Note: The Windows 10 Terminal application suffers from a flaw in this regard,
108and does not support mouse interaction.  The stock Windows 10 console host
109fired up with cmd.exe or PowerShell works fine however.)
110
111## _Termbox_ Compatibility
112
113A compatibility layer for _termbox_ is provided in the `compat` directory.
114To use it, try importing `github.com/gdamore/tcell/termbox` instead.
115Most _termbox-go_ programs will probably work without further modification.
116
117## Working With Unicode
118
119Internally Tcell uses UTF-8, just like Go.
120However, Tcell understands how to
121convert to and from other character sets, using the capabilities of
122the `golang.org/x/text/encoding packages`.
123Your application must supply
124them, as the full set of the most common ones bloats the program by about 2MB.
125If you're lazy, and want them all anyway, see the `encoding` sub-directory.
126
127## Wide & Combining Characters
128
129The `SetContent()` API takes a primary rune, and an optional list of combining runes.
130If any of the runes is a wide (East Asian) rune occupying two cells,
131then the library will skip output from the following cell, but care must be
132taken in the application to avoid explicitly attempting to set content in the
133next cell, otherwise the results are undefined.  (Normally wide character
134is displayed, and the other character is not; do not depend on that behavior.)
135
136Experience has shown that the vanilla Windows 8 console application does not
137support any of these characters properly, but at least some options like
138_ConEmu_ do support Wide characters.
139
140## Colors
141
142_Tcell_ assumes the ANSI/XTerm color model, including the 256 color map that
143XTerm uses when it supports 256 colors.  The terminfo guidance will be
144honored, with respect to the number of colors supported.  Also, only
145terminals which expose ANSI style `setaf` and `setab` will support color;
146if you have a color terminal that only has `setf` and `setb`, please let me
147know; it wouldn't be hard to add that if there is need.
148
149## 24-bit Color
150
151_Tcell_ _supports true color_!  (That is, if your terminal can support it,
152_Tcell_ can accurately display 24-bit color.)
153
154To use 24-bit color, you need to use a terminal that supports it.  Modern
155xterm and similar teminal emulators can support this.  As terminfo lacks any
156way to describe this capability, we fabricate the capability for
157terminals with names ending in `*-truecolor`.  The stock distribution ships
158with a database that defines `xterm-truecolor`.
159To try it out, set your
160`TERM` variable to `xterm-truecolor`.
161
162When using TrueColor, programs will display the colors that the programmer
163intended, overriding any "`themes`" you may have set in your terminal
164emulator.  (For some cases, accurate color fidelity is more important
165than respecting themes.  For other cases, such as typical text apps that
166only use a few colors, its more desirable to respect the themes that
167the user has established.)
168
169If you find this undesirable, you can either use a `TERM` variable
170that lacks the `TRUECOLOR` setting, or set `TCELL_TRUECOLOR=disable` in your
171environment.
172
173## Performance
174
175Reasonable attempts have been made to minimize sending data to terminals,
176avoiding repeated sequences or drawing the same cell on refresh updates.
177
178## Terminfo
179
180(Not relevent for Windows users.)
181
182The Terminfo implementation operates with two forms of database.  The first
183is the built-in go database, which contains a number of real database entries
184that are compiled into the program directly.  This should minimize calling
185out to database file searches.
186
187The second is in the form of JSON files, that contain the same information,
188which can be located either by the `$TCELLDB` environment file, `$HOME/.tcelldb`,
189or is located in the Go source directory as `database.json`.
190
191These files (both the Go and the JSON files) can be generated using the
192mkinfo.go program.  If you need to regnerate the entire set for some reason,
193run the mkdatabase.sh file.  The generation uses the infocmp(1) program on
194the system to collect the necessary information.
195
196The `mkinfo.go` program can also be used to generate specific database entries
197for named terminals, in case your favorite terminal is missing.  (If you
198find that this is the case, please let me know and I'll try to add it!)
199
200_Tcell_ requires that the terminal support the `cup` mode of cursor addressing.
201Terminals without absolute cursor addressability are not supported.
202This is unlikely to be a problem; such terminals have not been mass produced
203since the early 1970s.
204
205## Mouse Support
206
207Mouse support is detected via the `kmous` terminfo variable, however,
208enablement/disablement and decoding mouse events is done using hard coded
209sequences based on the XTerm X11 model.  As of this writing all popular
210terminals with mouse tracking support this model.  (Full terminfo support
211is not possible as terminfo sequences are not defined.)
212
213On Windows, the mouse works normally.
214
215Mouse wheel buttons on various terminals are known to work, but the support
216in terminal emulators, as well as support for various buttons and
217live mouse tracking, varies widely.  Modern _xterm_, macOS _Terminal_, and _iTerm_ all work well.
218
219## Testablity
220
221There is a `SimulationScreen`, that can be used to simulate a real screen
222for automated testing.  The supplied tests do this.  The simulation contains
223event delivery, screen resizing support, and capabilities to inject events
224and examine "`physical`" screen contents.
225
226## Platforms
227
228### POSIX (Linux, FreeBSD, macOS, Solaris, etc.)
229
230For mainstream systems with a suitably well defined system call interface
231to tty settings, everything works using pure Go.
232
233For the remainder (right now means only Solaris/illumos) we use POSIX function
234calls to manage termios, which implies that CGO is required on those platforms.
235
236### Windows
237
238Windows console mode applications are supported.  Unfortunately _mintty_
239and other _cygwin_ style applications are not supported.
240
241Modern console applications like ConEmu, as well as the Windows 10
242console itself, support all the good features (resize, mouse tracking, etc.)
243
244I haven't figured out how to cleanly resolve the dichotomy between cygwin
245style termios and the Windows Console API; it seems that perhaps nobody else
246has either.  If anyone has suggestions, let me know!  Really, if you're
247using a Windows application, you should use the native Windows console or a
248fully compatible console implementation.
249
250### Plan9 and Native Client (Nacl)
251
252The nacl and plan9 platforms won't work, but compilation stubs are supplied
253for folks that want to include parts of this in software targetting those
254platforms.  The Simulation screen works, but as Tcell doesn't know how to
255allocate a real screen object on those platforms, `NewScreen()` will fail.
256
257If anyone has wisdom about how to improve support for either of these,
258please let me know.  PRs are especially welcome.
259
260### Commercial Support
261
262_Tcell_ is absolutely free, but if you want to obtain commercial, professional support, there are options.
263
264[cols="2",align="center",frame="none", grid="none"]
265|===
266^.^|
267image:logos/tidelift.png[100,100]
268a|
269https://tidelift.com/[Tidelift] subscriptions include support for _Tcell_, as well as many other open source packages.
270
271^.^|
272image:logos/staysail.png[100,100]
273a|
274mailto:info@staysail.tech[Staysail Systems, Inc.] offers direct support, and custom development around _Tcell_ on an hourly basis.
275
276^.^|
277image:logos/patreon.png[100,100]
278a|I also welcome donations at https://www.patreon.com/gedamore/[Patreon], if you just want to make a contribution.
279|===
280