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

106 Commits

Author SHA1 Message Date
Garrett D'Amore
168f47f0f7 fixes #623 Cursor style is not reset when closing 2023-12-03 12:04:00 -08:00
Tim Culverhouse
c5c66b8427 tty: modify WindowSize method to return windowsize object
Modify the WindowSize method of the Tty interface to return a WindowSize
object. This object includes the window size in pixels, for use in
direct drawing of sixels. Terminals that do not support this feature
will have pixel sizes of 0,0.
2023-08-15 06:57:42 -07:00
Tim Culverhouse
fa6cd3ec5b screen: extend interface with Tty method
Extend the Screen interface with a new Tty method, which returns the
underlying tty when the screen is a terminal. This enables direct
drawing to the Tty.

Implement the interface for the three screen implementatinos included in
the library.
2023-08-15 06:57:42 -07:00
Tim Culverhouse
ae2c4a8044 screen: extend interface with LockRegion method
Extend the Screen interface with a new LockRegion method. This method
sets or unsets a lock on a region of cells. This will be used in
subsequent commits to enable direct drawing to the underlying TTY. The
locks are necessary in order to prevent cells from being drawn on top of
a directly drawn cell.

Implement this interface for the three screen implementations included
in the library.
2023-08-15 06:57:42 -07:00
Garrett D'Amore
8b8ed1d164 go fmt compliance fixes 2023-08-14 18:36:19 -07:00
stk
f028121cb8 Make focus reporting an opt-in feature, like mouse reporting 2023-08-14 17:07:05 -07: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
stk
85dc29bf8a Implement focus events 2023-08-14 17:07:05 -07:00
Matthew Roseman
a92c043b0b simplified bitwise math to determine if mouse scrolling 2023-08-14 17:05:00 -07:00
Matthew Roseman
b9a2bbda10 don't record buttondn on scroll events 2023-08-14 17:05:00 -07:00
Garrett D'Amore
615b4b1821 fixes #589 unexpected character linux console 2023-02-20 21:30:37 -08:00
Ahoys123
edb6434493 created wscreen.go
updated readme
2023-02-19 17:48:50 -04:00
Ahoys123
b86f5127ac added webfiles directory
updated README.md
organized functions into original order
2023-02-19 17:48:50 -04:00
Ahoys123
49cc9d21db added wasm support 2023-02-19 17:48:50 -04:00
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