Commit Graph

70 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 581a114039 Windows: hyperlink support 2024-03-05 00:25:29 -08:00
Garrett D'Amore 18256bb692 Windows build fix. 2024-03-05 00:11:19 -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 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 d1364d5937 windows: restore cursor location correctly 2024-03-03 15:19:20 -08:00
Garrett D'Amore 6c95e8dbb3 Try not to clear screen on Windows if TCELL_ALTSCREEN=disable 2024-03-02 14:22:12 -08:00
Garrett D'Amore 552bf3cec1 windows: Use alt screen by default (supress with TCELL_ALTSCREEN=disable)
The alternate screen buffer right now only works in VT mode.
2024-03-02 12:47:28 -08:00
Garrett D'Amore 5a591d4275 Use automargin disable 2024-03-02 12:02:40 -08:00
Garrett D'Amore f6c43a3372 ConEmu fixes - we cannot go to 24-bit mode on that yet. 2024-03-02 11:55:11 -08:00
Garrett D'Amore cd0fe984d9 Windows: enable VT mode output by default
The special environment variable TCELL_VTMODE may be set to "disable"
to return to legacy console mode.  (This environment variable may
be removed in the future, if we determine it is no longer useful.)
2024-03-02 11:31:16 -08:00
Garrett D'Amore 547b1102d3 fixes #669 Focus event support for Windows console 2024-02-17 10:28:53 -08:00
Garrett D'Amore 15a4f4f1fb fixes #677 PollEvent() returns nil when screen is suspended 2024-02-15 22:25:45 -08:00
stk 96e2990564 Don't set modifiers for AltGr on Windows
AltGr is the same as ctrl+alt, and we don't want those to be set when you press
a key using AltGr.
2024-01-03 10:06:01 -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 2917c3801e fixes #647 Screen.Clear — Flickering on Windows 2023-12-03 13:50:52 -08:00
Garrett D'Amore 50882fce9f Update console_win.go 2023-12-03 12:10:55 -08:00
Junegunn Choi b4e2d68113 Implement missing methods in cScreen 2023-12-03 12:10:55 -08:00
Garrett D'Amore 8b8ed1d164 go fmt compliance fixes 2023-08-14 18:36:19 -07:00
stk 42b3beb245 fixup! Make focus reporting an opt-in feature, like mouse reporting 2023-08-14 17:07:05 -07:00
bjorndm 14bc04d6bb Fix underlines in Windows console mode.
The ENABLE_LVB_GRID_WORLDWIDE is neede to enable them.
2023-08-12 08:39:46 -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 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
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 0bfa151864 fixes #460 Possible race condition between Fini and PollEvent 2021-05-16 09:04:18 -07:00
Garrett D'Amore 0c349a85f4 Remove stale (unused) code in Windows finish. 2021-04-18 12:05:27 -07:00
Garrett D'Amore fb06997fe2 fixes #445 Prompt Cursor Lost after Suspend v2.2.0 Windows PowerShell 2021-04-18 12:04:21 -07:00
bobo liu e37d20eeec fixes PollEvent() hung after Fini() on windows 2021-04-18 11:31:00 -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 7d87d8188c fixes #406 Windows 7 terminal - screen is shifted up one row 2020-11-08 21:26: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 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 5216188a4f fixes #324 Fini() is not idempotent 2020-08-30 19:00:54 -07:00
Garrett D'Amore 23606a43e2 fixes #319 Pasting on windows still does a maximum of 10 characters
The Windows input scanner does not hold the screen lock, so we can
safely just block if we need to, so we use PostEventWait().
2020-08-30 03:03:47 -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 0c473b86d8 fixes #187 24-bit color for Windows 10 console
This works well on the new Windows 10 Terminal, as well as recent
Windows 10 ConHost.  Support for this is automatically enabled if
we detect that the terminal supports ANSI escapes, except for
ConEmu, which has a fairly severe scrolling bug with truecolor.

To opt-in anyway, set TCELL_TRUECOLOR to "enable" in your environment.

To opt-out, set TCELL_TRUECOLOR to "disable" in your environment.
2020-08-25 08:10:11 -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
Graham Clark 6d0b0fa74e On windows, don't change cursor position if about to hide cursor.
A gowid user reported that mouse movement in their gowid(tcell) application
was causing the console cursor to flicker on windows, jumping from the current
position in the console to the top left corner, and back again. In part, this
is an artifact of the way I render a gowid "canvas" - calling HideCursor()
unilaterally, then calling ShowCursor(x, y) if the canvas contains a logical
cursor that is within bounds. Because currently every mouse event causes a
gowid application redraw, on windows the effect is to cause the cursor to jump
to the top left briefly, disappear, then reappear in the previous
position. You can see it most easily by moving the mouse rapidly left and
right.

An upstream fix is for me to only call HideCursor() if I know I'm not going to
call ShowCursor(x, y). But the flicker can also be eliminated by removing the
call to setCursorPos(0, 0) in console_win.go before hiding the cursor. The
single call to showCursor() in console_win.go is preceded by setting cursor
coordinates explicitly, so I don't think anything depends on the assumption
that a hidden cursor has been set to position (0, 0) first.
2019-06-11 17:21:45 -07:00
Garrett D'Amore 48f88019c3 fixes #243 Ordering of SetConsoleWindowInfo and SetConsoleScreenBufferSize 2019-03-19 00:22:32 -07:00
otani_koji f0cffc65c6 fixes #250 Some characters disappear on Windows 2019-03-18 23:57:44 -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
Xurane 91a5452278 disable quick edit mode on EnableMouse() in win10 2018-04-23 06:06:46 -07:00