Commit Graph

71 Commits

Author SHA1 Message Date
Luis Davim fc16bf7007 fix: add tmux-256color terminfo 2024-10-06 09:45:10 -07:00
Andreas Deininger 1985c48151 Fix typos 2024-10-06 09:24:43 -07:00
Garrett D'Amore c9ba0cf327 fixes #710 Add support for setting the window title 2024-03-09 10:05:58 -08:00
Garrett D'Amore 887cf2766e fixes #666 cursor color
This adds a new optional parameter to screen.SetCursorStyle,
which is a color.  The cursors demo is enhanced to show this.

This ability is supported on screen types, provided the underlying
terminal supports the capability.
2024-03-07 08:32:39 -08:00
Garrett D'Amore 652ba11803 mkinfo typo for DottedUnderline 2024-03-07 06:10:54 -08:00
Garrett D'Amore 826c271964 Colored underlines.
This supports UNIX and Windows.
2024-03-04 21:19:42 -08:00
Garrett D'Amore ed7527708c Forgot to commit mkinfo.go 2024-03-04 19:59:29 -08:00
Garrett D'Amore 1fb8cfe768 feature: underline styles
This supports now curly, double, dashed, and dotted underline styles
where trhe terminal supports it.  This works well on Windows Terminal,
reasonably on iTerm2, Alacritty, Kitty, and probably others.

The wasm mode terminal includes support for this, dependent on the browser
capabilities.

The macOS Terminal just changes the background color.  Legacy Windows
console does nothing.

We will try to provide a regular underscore as a fallback.  A new style.go
demo is included to see some style combinations.
2024-03-03 19:04:45 -08:00
Garrett D'Amore de408507f9 terminfo: regenerate all entries
Previously we had lost StrikeThrough, and this fixes a few other
discrepancies.  This was generated on Ubuntu Noble (24.04), after
installing the following packages: ncurses-term kitty-terminfo
2024-03-03 08:30:47 -08:00
Garrett D'Amore 216e30afd7 fixes #679 Some emojis move entire line upwards when at bottom of terminal
This fix is not perfect, in that it will not fix every terminal that has
automargin support, but it fixes the *vast* majority of them by eliminating
the hacky workaround for the automargin - essentially using the rmam capability
to disable automatic wrapping at the margin.
2024-02-15 23:53:05 -08:00
Garrett D'Amore 5bdcc2579b Termite is dead/deprecated - drop it.
Fallback support will still work, but termite is no longer supported
and users of termite are advised to switch to Alacritty.
2024-02-15 23:51:10 -08:00
Garrett D'Amore e3a99dde75 Add shebang 2023-12-05 14:29:12 -08:00
Tim Culverhouse 20b65d615f
Fix dynamic terminfo when an alias is used (#639)
Co-authored-by: Garrett D'Amore <garrett@damore.org>
2023-12-03 15:40:31 -08:00
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