Commit Graph

58 Commits

Author SHA1 Message Date
stk 622b6c2aa7 Enable focus reporting only for terminals that support it
We assume that any terminal that supports mouse reporting will also support
focus reporting; but we also add an entry to Terminfo to let specific terminals
override it if needed.
2023-08-14 17:07:05 -07:00
delthas 709868d93d Support Xterm modifier keys for dynamic terminfos
Previously, modified function keys in dyanmic terminals were not
supported (like shift/control/alt + arrow keys).

Even though xterm-compatible terminals were dynamically discovered
and their keys added to the terminfo struct, the Modifiers field
was not supported and therefore the modified Xterm keys were not
added to the keycodes map (prepareXtermModifiers was skipped).

This fixes the issue by setting the Modifiers field when we
discover that the terminal is xterm-compatible.
2023-08-14 17:04:00 -07:00
moson-mo 5e9dd83b52 Add alacritty-direct terminfo
Signed-off-by: moson-mo <mo-son@mailbox.org>
2023-01-08 16:20:58 -08:00
Tim Culverhouse ede1dd5ee6 hyperlinks: fix id escape format
Commit 43efca775e added support for url IDs within OSC8 escape
sequences, however the formatting of the param is incorrect.

Use `id=` instead of `id:`

Fixes: 43efca775e ("hyperlinks: add support for optional id parameter")
2022-10-17 15:40:06 -07:00
Tim Culverhouse 43efca775e hyperlinks: add support for optional id parameter
OSC8 escape sequences allow for marking up hyperlinks in the terminal.
An optional `id` parameter is defined to allow applications to signal to
the terminal that (potentially) broken character sequences belong to the
same URL and should be treated as if they were connected.

Add support for optional id parameters, set by the application. Update
test case for ti.EnterUrl.

Fixes: https://github.com/gdamore/tcell/issues/568
Reference: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda#hover-underlining-and-the-id-parameter
2022-10-16 22:31:33 -07:00
Garrett D'Amore d25117a2e5 Go fmt for the project. 2022-08-31 11:37:42 -07:00
Garrett D'Amore 9b8e158cef fixes #546 terminfo tput escape sequence errors
These fix errors discovered while implementing the same logic
in dcell.  While here, the conditional support was simplified
using a similar approach as used in dcell, and test cases were
added.
2022-08-31 10:50:34 -07:00
Garrett D'Amore 80a58b9089 fixes #462 Console resizing
This supports both terminfo (Linux, macOS) terminals, and
the legacy Windows console.  Perversely, the "modern" Windows
terminal doesn't support application initiated resizing yet.
2022-04-23 09:50:07 -07:00
Garrett D'Amore e7b14a71dc fixes #300 Implement terminal hyperlinks
fixes #526 tcell emits redundant attributes

This work is inspired by, and partly derived from, work submitted by
Simon Ser (@emersion).  However, we've modified the bottom half of
the terminfo parser to better support strings properly, and are using
proper terminfo syntax.

Instead of an attribute called Hyperlink, we have called it Url
for the sake of brevity.

While here we noticed and fixed bug #526, which could badly impact slow
terminals, or slow links. This likely makes things better for folks
coming over long distance SSH connections for example.

We've also provided OSC 8 handling for all terminals which appear to
support the mouse sequences; hopefully ones that don't handle this
sensibly will just ignore it.  (Limited testing seems to show this.)
2022-04-16 10:57:21 -07:00
Garrett D'Amore d699c7e510 fixes #521 tmux-256color missing from bundled terminfo 2022-04-02 14:50:25 -07:00
Daniel Eklöf 23382126c9
Add “foot-extra” as a terminfo alias for “foot” (#506)
There are two “regular”[^1] terminfos for foot. One stripped down
version included with ncurses, and another one shipped with foot
itself, that contains a number on non-standard capabilities (mainly
used by tmux).

Foot’s “own” terminfo is _usually_ packaged as “foot-extra”.

[^1]: there’s actually four; foot also has a “direct” variant (similar
to xterm-direct): foot-direct, and foot-extra-direct.
2021-12-14 06:41:17 -08:00
Garrett D'Amore 761abf6821 fixes #356 Vim cursors shapes?
This adds a new method, SetCursorStyle() to the screen API.
It also automatically restores the cursor when disengaging to
the default cursor.  Modern terminals (and Windows console) support
this.
2021-09-28 20:05:18 -07:00
Hubert Hirtz 0fb69aed47 Add support for the foot terminal
https://codeberg.org/dnkl/foot
2021-06-05 05:29:41 -07:00
Garrett D'Amore 4f213fd72d Make sun-color 256 color by default, and just drop the sun-256color. 2021-06-01 20:43:32 -07:00
Garrett D'Amore d8ae9d764a Add xterm-direct, which gives 24-bit color. 2021-06-01 14:36:48 -07:00
Garrett D'Amore cad1b2a3f3 Add sun-256color as a builtin. 2021-05-31 18:08:06 -07:00
Garrett D'Amore 3687c97d3d Sun terminal color fixes.
This addresses problems in the color handling found on Sun and illumos
consoles.  The infocmp for these terminals is buggy as well.
2021-05-31 17:59:55 -07:00
Garrett D'Amore c43eafe245 Fix for writing in last column of last line for automargin terminals. 2021-05-18 23:17:00 -07:00
Garrett D'Amore a3de596932 Fabricate entries for -256color if they don't exist (xterm colors) 2021-05-18 20:20:43 -07:00
Garrett D'Amore 13bc6c2778 fixes #420 RFE: Mouse wheel only reporting
This adds optional MouseFlags that can be used to adjust what is
tracked for mouse reporting (leaving the other modes to be handled
by the terminal.)  This should work on all XTerm style terminals,
but on Windows we have no way to be selective here.
2021-01-24 15:18:06 -08:00
Garrett D'Amore 197faf3eae fixes #120 Support for bracketed paste mode
This adds Bracketed Paste support for terminals that have mouse
support and support it.  The bracketing events are EventPaste,
with methods to note Start() or End() of the paste.  Content
comes in as normal rune events.  Programs must opt-in to this by
calling screen.EnablePaste().
2020-10-15 23:13:03 -07:00
Garrett D'Amore aeb3a11948 fixes #391 tcell panic on TERM=xterm-termite
This fixes the panic, but also adds defitions for xterm-termite
and tmux-256color.
2020-10-13 22:17:07 -07:00
Graham Clark 1f9685874a Attempted fix of a regression I introduced - breaking mouse support!
@tslocum reported that the commit at 2d6d7fbe broke mouse support in
cview (https://github.com/gdamore/tcell/pull/384#issuecomment-698422464). The
purpose of the original commit was to fix a terminfo background color
code parsing problem that I spotted using TERM=xterm-16color:

$ 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. The sequence '%d' will then pop from the stack and interpreting the
result as an integer.

My change above was to have tcell assume the sequence between two single
quotes was a single ASCII character e.g. '(' and push that to the
terminfo stack as an integer with the ASCII value of the character
e.g. push(40:int). I didn't find any counterexamples in my local
terminfo database that didn't line up with that assumption; but I did
break mouse support because tcell generates its own rules to enable
mouse support, if not specified in the terminfo DB - both when
generating its own Golang-style internal DB, and in the dynamic terminfo
generator that uses infocmp:

"%?%p1%{1}%=%t%'h'%Pa%e%'l'%Pa%;\x1b[?1000%ga%c\x1b[?1002%ga%c\x1b[?1003%ga%c\x1b[?1006%ga%c"

This rule will push 'h' or 'l', depending on whether mouse mode is to be
enabled or disabled, and then sets the variable named a to the result,
interpreted as a string. The result is that when mouse mode is enabled,
tcell needs to emit \x1b[?1000h - where the 'h' comes from variable a
i.e. it needs to be able to push a quoted argument as a string and not
be forced into an int.

This alternative fix preserves the fact the quoted argument is a string
and maintains that on the stack. However, if the integer Pop() function
is called when the top element of the stack is a string, tcell will now

- return the string converted to an int, if it converts e.g. in the case
  '123' is pushed to the stack as a string and popped as an int, the value
  is 123
- otherwise return the ASCII value of the first character of the string
  e.g. if '(' is pushed then popped as an int, the value returned is 40.

To be compatible with this logic, if a terminfo rule needs to push an
integer whose value is >= ascii('0')==48 and <= ascii('9')==57, it will
need to use the form e.g. {53} and not '5' because the form '5' will be
pushed as "5":string and if popped as an int will return the value 5 and
not 53.
2020-09-26 08:19:27 -07:00
Graham Clark 2d6d7fbe48 Change interpretation of pushing quoted character in terminfo parser
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;
2020-09-20 08:17:17 -07:00
Trevor Slocum da485f4734 Rename StrikeOut as StrikeThrough 2020-08-31 08:55:31 -07:00
Garrett D'Amore 368f8e092b fixes #376 Need ColorReset
This provides a ColorReset color that resets the color to
the default for the terminal.
2020-08-30 22:57:00 -07:00
Garrett D'Amore 9d283802ab fixes #350 Add strikeout support 2020-08-30 20:25:30 -07:00
Garrett D'Amore bf3f269ccb fixes #373 Check for and use RGB property in terminfo
This also regenerated some definitions, which should lead to
more accurate mouse mode for a few of the terminals.
2020-08-30 19:33:25 -07:00
Garrett D'Amore 2323e87243 fixes #372 tmux terminal entry needed 2020-08-30 18:53:47 -07:00
Garrett D'Amore 59ebfab322 fixes #309 Broken backtab key on st. 2020-08-30 02:36:32 -07:00
Garrett D'Amore 84d0c5503d fixes #369 Better support for modifier keys
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).
2020-08-30 02:11:39 -07:00
Garrett D'Amore cc28e81105 fixes #370 Retire some old terminals 2020-08-30 01:58:02 -07:00
Elliott Sales de Andrade b0881963db Add missing entries to models.txt.
Otherwise, deleting all `term.go` and re-running `bash gen.sh` does
_not_ produce everything again.
2020-08-27 11:05:36 -07:00
Hubert Hirtz a6386839fd Add italic code to alacritty terminfo 2020-08-26 07:01:04 -07:00
Garrett D'Amore 8a32d2b0c8 Version 2.0 work in progress. 2020-08-25 16:20:58 -07:00
Nojus Gudinavičius 8572f72a22 Add support for italics 2020-04-13 07:15:39 -07:00
Vedran Vidović bac2bbc5b3 Adding Shift modifier for PgUp/PgDn
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.
2020-02-05 21:47:23 -08:00
Graham Clark 0253335d5d Update terminfo DB to fix backspace issues
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(?)
2020-01-14 19:01:46 -08:00
Graham Clark de4e5c4494 Fix control-character encoding for non-alphabet characters
@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.
2020-01-13 20:44:03 -08:00
Cole Helbling ae1dc54d2c Add terminfo for Alacritty 2019-08-05 09:28:43 -07:00
Asger Hautop Drewsen 4e7865679e Add terminfo for kitty (#283) 2019-08-01 11:20:19 -07:00
Garrett D'Amore fef653e8d0 Update README for new mkinfo 2019-07-29 22:47:04 -07:00
Garrett D'Amore 1922b3786e fixes #252 database cannot be distributed in static binary 2019-07-23 19:39:55 -07:00
Garrett D'Amore 84b54971b4 fixes #294 Baud rate should not matter 2019-07-23 19:03:31 -07:00
Garrett D'Amore ca8fb5bcc9 fixes #279 process new terminal descriptions at application runtime
fixes #285 Loss of color/mangled formatting on GNU screen
fixes #93 use the terminfo database instead of the json database

This change falls back to using a dynamically generated terminal
description (using infocmp, which must be on the path) if the builtin
database doesn't have a suitable description.

For most users this should resolve the problem of unknown terminals.
2019-06-12 23:38:18 -07:00
Garrett D'Amore 77ab683d7d Improve 24-bit color support.
This expands support for 24-bit color for terminals that support the
ISO 8613-6:1994 escape sequences (same as xterm), allowing this support
to be enabled by setting % COLORTERM to "truecolor" (or 24bit or 24-bit),
or by setting TCELL_TRUECOLOR to "on", or by setting $TERM a value that
ends in the word "-truecolor".

As this is handled by the runtime now, we no longer need to create magical
database entries for -truecolor options.

A colors.go demo is provided to show off 24-bit color support.
2019-03-18 22:47:05 -07:00
Garrett D'Amore af444b941a Refactor tests to avoid go-convey.
While go-convey was pretty nice, it carries a rather large dependency
graph, which we think it is better not to burden our downstreams with.
It is easy enough to just refactor the tests to use the standard testing
package.
2018-12-18 21:33:43 -08:00
Garrett D'Amore 493f3b46b3 fixes #225 Kitty missing from terminfo database 2018-09-23 22:52:37 -07:00
Martin Angers 2efc922424 add termite terminfo 2018-06-23 12:51:08 -07:00
Thomas Wouters 5ddf16a669 Allow octal and hexadecimal conversion to int
Auto detect the base as implied by `0` or `0x` prefixes.

Fixes #212
2018-04-23 06:10:09 -07:00