Commit Graph

120 Commits

Author SHA1 Message Date
Garrett D'Amore 78110e30f8 fixes #561 Add clipboard support.
This is not supported for Windows or WebAssembly yet.
It's possible for applications to post to the clipboard using
Screen.SetClipboard (any data), and they can retrieve the clipboard
(if permitted) using GetClipboard.  The terminal may well reject either
of these.

Retrieval will arrive as a new EventClipboard, if it can.  (There is
no good way to make this synchronous.)

This work was inspired by a PR submitted by Consolatis (#562), and
has some work based on it, but it was also substantially improved and
now includes both sides of the clipboard access pattern.
2024-03-10 14:05:48 -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 9bc5c636ae Underline API change.
The underline styles are mutually exclusive.  And let's simplify
passing the color with the underline style in a single function call.
2024-03-04 23:56:23 -08:00
Garrett D'Amore 826c271964 Colored underlines.
This supports UNIX and Windows.
2024-03-04 21:19:42 -08:00
Garrett D'Amore 9a52dc2a4e terminals: move the import into tscreen_unix.go
(Rationale: we might want to use a *much* smaller database for
systems that have a fixed set of strings, such as xterm.js.)
2024-03-04 00:07:22 -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 6984e257e4 Allow use of TCELL_ALTSCREEN=disable to disable alternate screen.
This hack will also prevent the clearing of the screen at disengage
time.  This may be useful for certain kinds of applications that
want to draw the screen, then place the cursor at a specific location.
(The application will need to do a TGoto on it's own first.)
2024-03-02 14:18:52 -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 15a4f4f1fb fixes #677 PollEvent() returns nil when screen is suspended 2024-02-15 22:25:45 -08:00
Garrett D'Amore 8041b8e7ac Refactor event polling code.
This centralizes much of the logic (hopefully reducing duplication)
for polling events and the queue.  This will make it easier to make
further design changes to express a better, simpler, API to consumers.

While here addressed missing logic to handle Fini correctly on Windows.
2023-12-07 22:55:17 -08:00
Garrett D'Amore fb3659df9f refactoring: use common LockRegion implementation 2023-12-04 07:48:27 -08:00
Garrett D'Amore d82c270755 More refactoring, common cell buffer 2023-12-03 17:36:26 -08:00
Garrett D'Amore ef4f9ccd96 Start of base screen refactoring.
A lot of functionality is duplicated across screen implementations,
and adding convenience methods is onerous because one needs to touch
each implementation with what is mostly copy-paste coding.

This represents the start of refactoring to eliminate redundant code
from each implemenation and provide for it in a common layer.
2023-12-03 16:54:28 -08:00
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