I noticed this problem while running a gowid test program (palette.go)
with TERM=xterm-16color. This terminal type is not present in tcell's
built-in database, and so tcell falls back to the dynamic terminal type
by parsing the output of infocmp. The symptom was that foreground colors
were not correctly set, leaving a monochrome screen. This seems to be
caused by a problem interpreting the *background* color terminfo
rule. The attribute to set background color is defined like this (Ubuntu
20.04):
$ infocmp xterm-16color | grep setab
setab=\E[%?%p1%{8}%<%t%p1%'('%+%e%p1%{92}%+%;%dm,
The middle sections says "if p1<8 then push(p1+'(') ". '(' is ascii
40. If I run
$ tput setab 5
the terminal sees 'ESC[45m'. This correctly sets the background color to
magenta. But if I tell tcell to emit a cell with background color set to
tcell.Color(5), the terminal sees 'ESC[0m'. This means in practice, my
app emits a code to set the foreground color, then an SGR code that
resets all attributes, then the ASCII character.
When tcell "runs" a terminfo rule in terminfo::TParm(), a push to the
stack preserves the type of the argument pushed - int or string. When a
single quote is encountered, the argument within is pushed to the stack
as a string. For the `setab` rule above, tcell will then pop as an int,
discarding the error and returning 0. The fix here is to have tcell push
the argument inside the single quotes as an integer, using the ascii
value of the argument e.g. "(" -> 40 - and assume the string is length
1, I suppose. Cross-referencing against
ncurses/tinfo/lib_tinfo.c::tparam_internal(), it looks like this code
assumes a single-quoted string is assumed to be length=1 and is also
interpreted as an integer with the ascii value of the character:
case S_QUOTE:
cp++;
npush(UChar(*cp));
cp++;
break;
This replaces high numbered function keys on xterm style
emulators with modifiers. So pressing SHIFT-ALT-F1 is
reported as exactly that, for example. This also extends
that to the insert, delete, home, end, etc.
There is a chance that this will break some emulators --
of particular concern are older VTE based emulators and
rxvt (and derivatives). However, we think that most VTE
derivatives are now much more closely aligned to xterm.
The Wyse50 alternate character set was changed (likely
due to a bug fix in ncurses).
This causes colors that are set that are low numbered to
be treated as themed colors -- basically honoring the palette
of the terminal.
The Style and Color implementations have changed quite a bit
to permit growth -- the colors are now 64-bits wide to permit
using the upper bits as flags, and to leave room for a future
alpha channel.
There is a new TrueColor() method on colors that obtains the
value as strict RGB value, and this will be used in lieu of
whatever terminal colors are provided -- giving the application
full control over the color space if they want, without
forcibly clobbering user preferences for terminals for the
vast majority of cases.
Indexed colors are created with the new PaletteColor API.
This works well on the new Windows 10 Terminal, as well as recent
Windows 10 ConHost. Support for this is automatically enabled if
we detect that the terminal supports ANSI escapes, except for
ConEmu, which has a fairly severe scrolling bug with truecolor.
To opt-in anyway, set TCELL_TRUECOLOR to "enable" in your environment.
To opt-out, set TCELL_TRUECOLOR to "disable" in your environment.
This reverts commit 1b5e88726b.
Reuse of the buffer causes a subtle bug if the consumer
does not read from the slice fast enough. This was a regression.
Removing SetCursor makes it possible to add lines to the model on the fly,
while keeping the cursor in position.
Go also initializes them with 0, no need to set it manually.
The build for the "solaris" and "illumos" tags appears to have been
broken by commit 8ec73b6fa6, which
introduced the Beep() API. Restore functionality by using the same
implementation as every other UNIX family platform.
This way GetCell() will get full runes, not just bytes. Now accent characters will show properly
Adjust SetLines() and Init() to work on [][]rune instead of []string
Add a Beep() method to the Screen interface. On *nix systems, this
writes the bell character (0x07) to the tty. On Windows, we call the
MessageBeep syscall.
Fixes: #2
Do not store cursor info (cursorX, CursorY) in CellView, as it belongs to the model (CellModel)
Use GetCursor() to identify current cursor position from CellModel
Implemented key kombination of Shift + PgUp/PgDn for Gnome terminal.
Same combination copied to all other terminal implementations which use same
codes for Shift + Up/Down but since this is tested on Ubuntu 16.04 with Gnome
Terminal 3.18.3 it could be that it is not correctly implemented for some of the
other terminals.
Sometimes, the TIOCGWINSZ ioctl returns all zeroes (including columns,
rows) without an error. I found this when experimenting with the jexer
TUI toolkit for java e.g.
mvn dependency:get -Dartifact=com.gitlab.klamonte:jexer:0.3.2
jexer -jar ~/.m2/repository/com/gitlab/klamonte/jexer/0.3.2/jexer-0.3.2.jar
Once the demo starts, click the "Terminal" button, then type
stty size
it returns
0 0
My understanding is that this is normal, and happens until SIGWINCH is
received, or the size is set explicitly with TIOCSWINSZ.
My tcell application crashed under the jexer terminal because I didn't
anticipate a window size of (0,0).
If you run vim under the jexer terminal, it correctly sizes itself to
80x24. The shell's TERM variable is xterm, and infocmp xterm | grep cols
shows a default of 80 and a default of 24 for lines. The documentation
for vim explains how it computes the terminal size:
https://github.com/vim/vim/blob/master/runtime/doc/term.txt#L629
- an ioctl call (TIOCGSIZE or TIOCGWINSZ, depends on your system)
- the environment variables "LINES" and "COLUMNS"
- from the termcap entries "li" and "co"
This PR replicates that logic in the getWinSize() function. I think it
makes sense here because tScreen holds the TermInfo struct but the
tcell.Screen interface does not expose TermInfo to clients - of course
because the screen is abstracted to work on Windows too.
I have rerun gen.sh having pulled the latest tcell to include this PR:
https://github.com/gdamore/tcell/pull/325.
I am using Ubuntu 19.04 - running gen.sh changed more fields than just
those impacted by the above fix. I've removed those from this commit. (I
verified that gen.sh changed those fields I've removed without the fix
above, so it's not related). Based on TERMINALS.md, I suspect you
regenerate these typically on a Debian machine(?)
@klamonte opened this issue against gowid, a package that relies on tcell for
all its terminal handling: https://github.com/gcla/gowid/issues/24. It
describes how a shell inside a terminal widget that the TUI launches freezes
when the user hits backspace. The TUI loads a tcell TermInfo struct for the
screen-256color terminal and that struct codes KeyBackspace as the single byte
0xff - and so the byte 0xff was sent to the tty. On my Ubuntu 19.04 machine,
`infocmp screen-256color` shows `kbs` is `^?` According to
https://en.wikipedia.org/wiki/Caret_notation, `^?` should map to 0x7f (127) -
"The digraph stands for the control character whose ASCII code is the same as
the character's ASCII code with the uppermost bit, in a 7-bit encoding,
reversed". This affects both mkinfo.go, the generator of the JSON terminfo
database files, and the dynamic terminfo generator.