Commit Graph

37 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 337e381927 fixes #606 Want ColorNone to preserve existing color(s)
While here, consolidate the use of the Fill() function from
CellBuffer (eliminating redundant code).
2023-12-08 00:19:52 -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
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
stk f028121cb8 Make focus reporting an opt-in feature, like mouse reporting 2023-08-14 17:07:05 -07:00
Garrett D'Amore a642547922 fixes #576 Intermittent screen flashes 2022-12-30 14:55:11 -08: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 f631374ce3 Some minor language fixups. 2022-04-16 08:27:02 -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
Spenser Black 634d607d68
Name return values for `Screen.Size` (#487)
This adds names to the return values of the Size function to add
context. This also changes the return declarations to use the shortcut
when both named return values are the same type, by only specifying the
type once.
2021-09-26 09:15:22 -07:00
eNV25 b60a903b98
Add Screen.ChannelEvents v2 (#465) 2021-06-11 19:43:12 -07:00
Garrett D'Amore 7a0b45cce0 fixes #422 RFE: Handling events in batches 2021-05-16 09:21:17 -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 19e17097d8 Mark PostEventWait deprecated.
At some point in the future this is going to be replaced with
a simpler channel design, and the current blocking approach
is both non-idiomatic, and fragile.  Don't use it.
2021-01-24 16:48:47 -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
Ben Burwell 8ec73b6fa6 Implement Beep() API
Add a Beep() method to the Screen interface. On *nix systems, this
writes the bell character (0x07) to the tty. On Windows, we call the
MessageBeep syscall.

Fixes: #2
2020-03-15 10:36:32 -07:00
Garrett D'Amore 2fca0432ba Windows should always try for console first.
We had problems where if $TERM was set on a Windows console, we would
fail to allocate the screen because of missing termios.  This caused
lots of problems for many Windows users.  This should make this easier
for folks who might have set $TERM for other reasons, even in a Windows
console environment.

Eventually we will want to support emitting characters for 256 color
support, but that's later.
2019-03-19 00:07:29 -07:00
Jaime Piña 44772c121b Fix small lint & spelling issues 2016-12-06 09:19:16 -08:00
Garrett D'Amore 91d5e748ae fixes #114 Add Fill() method View API
fixes #113 Create SimpleStyledTextBar
2016-05-23 14:55:11 -07:00
Garrett D'Amore 5dc5326c0e fixes #44 Expose some capability info 2016-01-19 15:51:33 -08:00
Garrett D'Amore e7d14c2863 fixes #62 windows console may have FIFO hang
fixes #63 Initial views API integration
2015-10-30 12:18:06 -07:00
Garrett D'Amore 6939959660 fixes #50 Expose CanDisplay(rune) 2015-10-14 19:46:35 -07:00
Garrett D'Amore 5bef83acf3 fixes #45 Add fallback rune support 2015-10-14 19:09:00 -07:00
Garrett D'Amore 7322e40c26 fixes #37 Improve docs & fix golint
fixes #38 Broke wide characters in last update
fixes #39 Clean up logic for encodings, enhance fallback options
fixes #36 Support more mouse buttons on Windows.
2015-10-08 09:48:01 -07:00
Garrett D'Amore 02eef725e2 fixes #35 Inadequate buffering dirty/detection algorithm 2015-10-07 02:35:14 -07:00
Garrett D'Amore b19d7067f2 fixes #26 Improved docs desired 2015-10-05 15:46:51 -07:00
Garrett D'Amore 061768321e fixes #20 Wide characters & combining characters busted
fixes #21 Want unicode test program
fixes #15 Add ACS drawing support
2015-10-04 19:53:38 -07:00
Garrett D'Amore 434fc57169 fixes #10 Eliminate separate buffered implementation
fixes #9 Various API enhancements
fixes #8 Mouse demo improvements
fixes #7 Add support for handling $<delay> delays
fixes #6 mkinfo doesn't honor terminfo LINES and COLUMNS
fixes #5 Add better mouse tracking
fixes #3 Windows performance improvements
2015-10-02 21:49:13 -07:00
Garrett D'Amore b4ae936d42 Initial import of Tcell. 2015-09-26 23:37:54 -07:00