1
0
mirror of https://github.com/gdamore/tcell.git synced 2025-04-26 13:48:53 +08:00

92 Commits

Author SHA1 Message Date
Garrett D'Amore
a642547922 fixes #576 Intermittent screen flashes 2022-12-30 14:55:11 -08:00
Garrett D'Amore
d3cbfcfb7a fixes #574 Mouse wheel events during click-drag misdelivered as button events 2022-10-18 18:13:50 -07:00
Garrett D'Amore
7557ac2a6c fixes #564 Excessive Ram usage for colors in direct / Tc mode 2022-10-16 22:39:04 -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
896efabe24 Better handling for monochrome.
We will automatically select an inverse video mode if we cannot
find any colors at all.  This should help some fallbacks.
2022-07-29 20:02:51 -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
Will Daly
1510fff44d
Send AttrOff when clearing the screen (#523)
In tcell v2.4, the following calls would reset the screen
to its default color:

1. SetContent() to change the bg color to maroon.
2. Clear()
3. Show()

In tcell v2.5, the behavior changed to clear the screen
to the last-used style passed to SetContent.

This happens because commit 62f5502f set the dirty flag
to false for all cells, on the assumption that sending
ti.Clear would clear the cells anyway. Unlike the drawCell
calls triggered by the dirty flag, however, clearScreen
does not send AttrOff. This causes the screen to clear
to the last-used background color.
2022-04-16 07:58:36 -07:00
Garrett D'Amore
78490bdc53 fixes #509 style disappears 2022-04-03 11:40:07 -07:00
MATSUDA Takashi
2a1a1b5864
enhanced mouse tracking mode (1006) is set improperly when exiting tcell (#512) 2022-03-13 13:30:54 -07:00
Garrett D'Amore
62f5502f7b
fixes #485 Optimize screen.Clear() (#491) 2021-10-10 22:40:26 -07: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
ramachandrasuresh
66f061b1fc
patch for mouse events not working in putty (#477)
Co-authored-by: Suresh Ramachandra <suresh.ramachandra@intelerad.com>
2021-09-26 09:29:09 -07:00
Alexander Tumin
2f3199b286
Add NewTerminfoScreenFromTtyTerminfo to allow creating Screen using (#479)
custom terminfo as well as custom tty.
2021-09-26 09:17:45 -07:00
Garrett D'Amore
f057f0a857
fixes #480 EventError fired after suspended Screen resumes (#484) 2021-09-04 17:28:22 -07:00
eNV25
b60a903b98
Add Screen.ChannelEvents v2 (#465) 2021-06-11 19:43:12 -07:00
Garrett D'Amore
da8f2067c0 Reset colors to default on suspend.
For most terminals this also is done with 'sgr0', but on some it
appears that we need to explicitly use the 'oc' capability.  (This
is the documented behavior in terminfo.)
2021-06-05 05:36:16 -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
5c5a66e2b0 fix panic on resize (regression) 2021-05-16 11:38:02 -07:00
Garrett D'Amore
7a0b45cce0 fixes #422 RFE: Handling events in batches 2021-05-16 09:21:17 -07:00
Garrett D'Amore
0bfa151864 fixes #460 Possible race condition between Fini and PollEvent 2021-05-16 09:04:18 -07:00
Garrett D'Amore
97c0480839 fixes #452 Lost a key event once when exiting or suspending in v2.2.1.
fixes #449 Lost keyboard input after suspend on Windows 10 PowerShell
fixes #148 Make tcell usable with any io.Reader and io.Writer

This introduces a new Tty interface so that applications can supply
their own implementation.  This should facilitate work for applications
that wish to provide e.g. a webasm version of the terminal, or that need
to use different kinds of file plumbing.
2021-05-16 08:27:27 -07:00
Gokcehan
d003d0a0a1 switch back to ca mode after suspend/resume
Suspend call currently exits ca mode. So after the first suspend/resume
the program does not use the alternate screen anymore. Therefore Resume
needs to enter ca mode again.
2021-04-18 11:38:12 -07:00
Garrett D'Amore
16556370d7 Support for new Suspend and Resume API.
fixes #194 Starting multiple screen sessions (lost key event)

You can test this by using the mouse demo, which now supports pressing
CTRL-Z.  This does not actually suspend the demo, but starts a subshell
which takes over.  After the subshell is exited, the demo takes control
of the screen back.  This can be done multiple times, and it is possible
to start multiple "nested" iterations of the demo this way.
2021-02-20 13:20:58 -08: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
e9095fe4f1 fixes #394 Screen.Fini does not leave the terminal in a usable state in MacOS
This does sort the main problem of screen.Fini(), but really we
want to use a separate Pause() and Resume() function, because
screen.Fini() is not meant for reuse in this way.

Note that one side effect of this change is that applications which
redirect stdin and stdout and expect us to just use /dev/tty instead
are going to break -- we are now using stdin and stdout like nearly
every other screen oriented application.
2021-01-24 13:26:36 -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
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
7e218720b8 Remove stray sleep 2020-08-30 20:11:55 -07:00
Garrett D'Amore
5216188a4f fixes #324 Fini() is not idempotent 2020-08-30 19:00:54 -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
5889c5f171 fixes #314 Implement setf & setb
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.
2020-08-25 22:26:48 -07:00
Garrett D'Amore
8a32d2b0c8 Version 2.0 work in progress. 2020-08-25 16:20:58 -07:00
Garrett D'Amore
5bef26acc2 fixes #358 EventMouse button mapping 2020-08-25 15:39:20 -07:00
Garrett D'Amore
4b435a5197 Revert "allocate buffer once, outside the key loop"
This reverts commit 1b5e88726b02c4d65b5a921ba06f016708ef0f9d.

Reuse of the buffer causes a subtle bug if the consumer
does not read from the slice fast enough.  This was a regression.
2020-06-07 13:38:21 -07:00
Nojus Gudinavičius
8572f72a22 Add support for italics 2020-04-13 07:15:39 -07:00
Martin Angers
1b5e88726b allocate buffer once, outside the key loop 2020-04-13 07:13:55 -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
Garrett D'Amore
4d152cc262 fixes #302 merge extended terminfo definitions into default
This makes the default build about 150k larger, but includes all
the good terminals needed to make most folks happy.  In addition,
it allows a build tag of tcell_minimal to suppress that.  Finally,
we do not include infocmp support on platforms unlikely to support
it, such as Windows, nacl, android, etc.
2019-09-22 11:15:39 -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
Graham Clark
12658f0d57 Another attempt to fix limited length of paste.
I humbly submit this patch as another attempt to address the issue that tcell
will only paste up to 11 characters at a time. The problem is caused by the
fact that events (key, mouse, etc) constructed from the stream of raw input
characters are sent to the consuming application over a length-10 channel via
screen.PostEvent() which, if the channel is full, will drop what can't be sent
immediately. If the input stream grows rapidly e.g. because the user pasted a
large section of text into the running tcell application, then more than 10
events will likely be built from the chunk of input read by scanInput().

A blocking channel send is not used (i.e. PostEventWait() instead of
PostEvent()) because the channel send is issued from a call stack in which the
screen struct's lock is held. If the receiving application is not consuming
events, then callers to other screen APIs will block waiting for the screen's
lock. If the receiving application needs to call another screen API before
reading from the channel, a deadlock may occur if that required screen API
tries to take the screen's lock.

This patch collects events extracted from the input stream into a slice while
the lock is held, then after releasing the screen lock, writes them in order
to the event channel with PostEventWait(). I chose the blocking API to ensure
events aren't dropped, since sending the events outside of the lock-held scope
should remove the risk of a deadlock (unless I've missed something important!)

This patch is similar in spirit to that submitted by @soyking:
9addd5bbe4.

I have not adjusted the windows cmd console screen because the paste problem
does not seem to be an issue in practice on that platform, at least according
to my testing.
2019-06-09 10:24:20 -07:00
gcla
ec71b09872 An attempt to speed up tcell screen rendering. (#247) 2019-03-19 00:31:05 -07:00
ia
de7e78efa4 all: gofmt
Run standard gofmt command on project root.

- go version go1.10.3 darwin/amd64

Signed-off-by: ia <isaac.ardis@gmail.com>
2018-06-23 12:52:09 -07:00
Tyler Sommer
aa381bce1b Fix data race in tScreen shutdown
Setting t.quit to nil while the mainLoop is running causes a
race condition when the Fini() method is called. This change
instead uses a select expression to avoid the nil check and set.
2018-03-20 19:13:36 -07:00
Tony Worm
535ff868b7 Fix panic when quit chan double closed
I've been experiencing  panics occasionally/randomly on this `close(t.quit)` for double closes.

The changes seem to fix some of the obscure panics.
2018-02-16 23:21:25 -08:00
Garrett D'Amore
061d51a604 fixes #169 data race between inputLoop and mainLoop 2017-11-24 15:55:02 -08:00