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

..03-May-2022-

_demos/H28-Jun-2019-722573

encoding/H28-Jun-2019-11677

logos/H03-May-2022-

termbox/H28-Jun-2019-360269

terminfo/H03-May-2022-8,3876,710

views/H28-Jun-2019-2,7931,860

.appveyor.ymlH A D28-Jun-2019275 1413

.gitignoreH A D28-Jun-201913 21

.travis.ymlH A D28-Jun-2019223 1611

AUTHORSH A D28-Jun-2019155 54

LICENSEH A D28-Jun-201911.1 KiB203169

README.adocH A D28-Jun-201912.4 KiB273204

attr.goH A D28-Jun-20191 KiB3311

cell.goH A D28-Jun-20194.6 KiB178120

charset_stub.goH A D28-Jun-2019666 224

charset_unix.goH A D28-Jun-20191.4 KiB5025

charset_windows.goH A D28-Jun-2019669 224

color.goH A D28-Jun-201928.1 KiB1,020959

color_test.goH A D28-Jun-20192.4 KiB9871

colorfit.goH A D28-Jun-20191.4 KiB5332

console_stub.goH A D28-Jun-2019833 244

console_win.goH A D28-Jun-201920.8 KiB1,034858

database.jsonH A D28-Jun-20191.1 MiB1,3521,351

doc.goH A D28-Jun-20192.4 KiB491

encoding.goH A D28-Jun-20195.1 KiB14050

errors.goH A D28-Jun-20192.5 KiB7425

event.goH A D28-Jun-20191.5 KiB5422

event_test.goH A D28-Jun-20191.5 KiB7149

go.modH A D28-Jun-2019250 129

go.sumH A D28-Jun-20191.1 KiB1312

interrupt.goH A D28-Jun-20191.2 KiB4217

key.goH A D28-Jun-201911 KiB465363

mouse.goH A D28-Jun-20193.6 KiB9842

resize.goH A D28-Jun-20191.2 KiB4318

runes.goH A D28-Jun-20193.3 KiB11269

runes_test.goH A D28-Jun-20192.6 KiB9670

screen.goH A D28-Jun-20198.6 KiB21038

sim_test.goH A D28-Jun-20192.9 KiB11287

simulation.goH A D28-Jun-201910.4 KiB509374

style.goH A D28-Jun-20193.9 KiB12759

style_test.goH A D28-Jun-20191.1 KiB4221

tscreen.goH A D28-Jun-201931.5 KiB1,4341,146

tscreen_bsd.goH A D28-Jun-20192.8 KiB12083

tscreen_darwin.goH A D28-Jun-20193.8 KiB14185

tscreen_linux.goH A D28-Jun-20194.5 KiB203146

tscreen_solaris.goH A D28-Jun-20193.9 KiB189138

tscreen_stub.goH A D28-Jun-2019889 3310

tscreen_windows.goH A D28-Jun-20191.1 KiB4114

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