chore: ⬆️ updated deps
This commit is contained in:
-13
@@ -1,13 +0,0 @@
|
||||
version: 1.0.{build}
|
||||
clone_folder: c:\gopath\src\github.com\gdamore\tcell
|
||||
environment:
|
||||
GOPATH: c:\gopath
|
||||
build_script:
|
||||
- go version
|
||||
- go env
|
||||
- SET PATH=%LOCALAPPDATA%\atom\bin;%GOPATH%\bin;%PATH%
|
||||
- go get -t ./...
|
||||
- go build
|
||||
- go install ./...
|
||||
test_script:
|
||||
- go test ./...
|
||||
+2
@@ -1 +1,3 @@
|
||||
coverage.txt
|
||||
.zed
|
||||
.idea
|
||||
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
language: go
|
||||
|
||||
go:
|
||||
- 1.15.x
|
||||
- master
|
||||
|
||||
arch:
|
||||
- amd64
|
||||
- ppc64le
|
||||
|
||||
before_install:
|
||||
- go get -t -v ./...
|
||||
|
||||
script:
|
||||
- go test -race -coverprofile=coverage.txt -covermode=atomic
|
||||
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
+2
-2
@@ -13,7 +13,7 @@ GOOS=js GOARCH=wasm go build -o yourfile.wasm
|
||||
|
||||
You also need 5 other files in the same directory as the wasm. Four (`tcell.html`, `tcell.js`, `termstyle.css`, and `beep.wav`) are provided in the `webfiles` directory. The last one, `wasm_exec.js`, can be copied from GOROOT into the current directory by executing
|
||||
```sh
|
||||
cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" ./
|
||||
cp "$(go env GOROOT)/lib/wasm/wasm_exec.js" ./
|
||||
```
|
||||
|
||||
In `tcell.js`, you also need to change the constant
|
||||
@@ -58,4 +58,4 @@ It is recommended to use an iframe if you want to embed the app into a webpage:
|
||||
|
||||
### Accessing files
|
||||
|
||||
`io.Open(filename)` and other related functions for reading file systems do not work; use `http.Get(filename)` instead.
|
||||
`io.Open(filename)` and other related functions for reading file systems do not work; use `http.Get(filename)` instead.
|
||||
|
||||
+25
-134
@@ -7,14 +7,14 @@ It was inspired by _termbox_, but includes many additional improvements.
|
||||
|
||||
[](https://stand-with-ukraine.pp.ua)
|
||||
[](https://github.com/gdamore/tcell/actions/workflows/linux.yml)
|
||||
[](https://github.com/gdamore/tcell/actions/workflows/windows.yml)
|
||||
[](https://github.com/gdamore/tcell/actions/workflows/windows.yml)
|
||||
[](https://github.com/gdamore/tcell/actions/workflows/webasm.yml)
|
||||
[](https://github.com/gdamore/tcell/blob/master/LICENSE)
|
||||
[](https://pkg.go.dev/github.com/gdamore/tcell/v2)
|
||||
[](https://discord.gg/urTTxDN)
|
||||
[](https://codecov.io/gh/gdamore/tcell)
|
||||
[](https://goreportcard.com/report/github.com/gdamore/tcell/v2)
|
||||
|
||||
Please see [here](UKRAINE.md) for an important message for the people of Russia.
|
||||
[](https://github.com/gdamore/tcell/releases)
|
||||
|
||||
NOTE: This is version 2 of _Tcell_. There are breaking changes relative to version 1.
|
||||
Version 1.x remains available using the import `github.com/gdamore/tcell`.
|
||||
@@ -25,59 +25,9 @@ A brief, and still somewhat rough, [tutorial](TUTORIAL.md) is available.
|
||||
|
||||
## Examples
|
||||
|
||||
- [proxima5](https://github.com/gdamore/proxima5) - space shooter ([video](https://youtu.be/jNxKTCmY_bQ))
|
||||
- [govisor](https://github.com/gdamore/govisor) - service management UI ([screenshot](http://2.bp.blogspot.com/--OsvnfzSNow/Vf7aqMw3zXI/AAAAAAAAARo/uOMtOvw4Sbg/s1600/Screen%2BShot%2B2015-09-20%2Bat%2B9.08.41%2BAM.png))
|
||||
- mouse demo - included mouse test ([screenshot](http://2.bp.blogspot.com/-fWvW5opT0es/VhIdItdKqJI/AAAAAAAAATE/7Ojc0L1SpB0/s1600/Screen%2BShot%2B2015-10-04%2Bat%2B11.47.13%2BPM.png))
|
||||
- [gomatrix](https://github.com/gdamore/gomatrix) - converted from Termbox
|
||||
- [micro](https://github.com/zyedidia/micro/) - lightweight text editor with syntax-highlighting and themes
|
||||
- [godu](https://github.com/viktomas/godu) - utility to discover large files/folders
|
||||
- [tview](https://github.com/rivo/tview/) - rich interactive widgets
|
||||
- [cview](https://code.rocketnine.space/tslocum/cview) - user interface toolkit (fork of _tview_)
|
||||
- [awesome gocui](https://github.com/awesome-gocui/gocui) - Go Console User Interface
|
||||
- [gomandelbrot](https://github.com/rgm3/gomandelbrot) - Mandelbrot!
|
||||
- [WTF](https://github.com/senorprogrammer/wtf) - personal information dashboard
|
||||
- [browsh](https://github.com/browsh-org/browsh) - modern web browser ([video](https://www.youtube.com/watch?v=HZq86XfBoRo))
|
||||
- [go-life](https://github.com/sachaos/go-life) - Conway's Game of Life
|
||||
- [gowid](https://github.com/gcla/gowid) - compositional widgets for terminal UIs, inspired by _urwid_
|
||||
- [termshark](https://termshark.io) - interface for _tshark_, inspired by Wireshark, built on _gowid_
|
||||
- [go-tetris](https://github.com/MichaelS11/go-tetris) - Go Tetris with AI option
|
||||
- [fzf](https://github.com/junegunn/fzf) - command-line fuzzy finder
|
||||
- [ascii-fluid](https://github.com/esimov/ascii-fluid) - fluid simulation controlled by webcam
|
||||
- [cbind](https://code.rocketnine.space/tslocum/cbind) - key event encoding, decoding and handling
|
||||
- [tpong](https://github.com/spinzed/tpong) - old-school Pong
|
||||
- [aerc](https://git.sr.ht/~sircmpwn/aerc) - email client
|
||||
- [tblogs](https://github.com/ezeoleaf/tblogs) - development blogs reader
|
||||
- [spinc](https://github.com/lallassu/spinc) - _irssi_ inspired chat application for Cisco Spark/WebEx
|
||||
- [gorss](https://github.com/lallassu/gorss) - RSS/Atom feed reader
|
||||
- [memoryalike](https://github.com/Bios-Marcel/memoryalike) - memorization game
|
||||
- [lf](https://github.com/gokcehan/lf) - file manager
|
||||
- [goful](https://github.com/anmitsu/goful) - CUI file manager
|
||||
- [gokeybr](https://github.com/bunyk/gokeybr) - deliberately practice your typing
|
||||
- [gonano](https://github.com/jbaramidze/gonano) - editor, mimics _nano_
|
||||
- [uchess](https://github.com/tmountain/uchess) - UCI chess client
|
||||
- [min](https://github.com/a-h/min) - Gemini browser
|
||||
- [ov](https://github.com/noborus/ov) - file pager
|
||||
- [tmux-wormhole](https://github.com/gcla/tmux-wormhole) - _tmux_ plugin to transfer files
|
||||
- [gruid-tcell](https://github.com/anaseto/gruid-tcell) - driver for the grid based UI and game framework
|
||||
- [aretext](https://github.com/aretext/aretext) - minimalist text editor with _vim_ key bindings
|
||||
- [sync](https://github.com/kyprifog/sync) - GitHub repo synchronization tool
|
||||
- [statusbar](https://github.com/kyprifog/statusbar) - statusbar motivation tool for tracking periodic tasks/goals
|
||||
- [todo](https://github.com/kyprifog/todo) - simple todo app
|
||||
- [gosnakego](https://github.com/liweiyi88/gosnakego) - a snake game
|
||||
- [gbb](https://github.com/sdemingo/gbb) - A classical bulletin board app for tildes or public unix servers
|
||||
- [lil](https://github.com/andrievsky/lil) - A simple and flexible interface for any service by implementing only list and get operations
|
||||
- [hero.go](https://github.com/barisbll/hero.go) - 2d monster shooter ([video](https://user-images.githubusercontent.com/40062673/277157369-240d7606-b471-4aa1-8c54-4379a513122b.mp4))
|
||||
- [go-tetris](https://github.com/aaronriekenberg/go-tetris) - simple tetris game for native terminal and WASM using github actions+pages
|
||||
- [oddshub](https://github.com/dos-2/oddshub) - A TUI designed for analyzing sports betting odds
|
||||
A number of example are posted up on our [Gallery](https://github.com/gdamore/tcell/wikis/Gallery/).
|
||||
|
||||
## Pure Go Terminfo Database
|
||||
|
||||
_Tcell_ includes a full parser and expander for terminfo capability strings,
|
||||
so that it can avoid hard coding escape strings for formatting. It also favors
|
||||
portability, and includes support for all POSIX systems.
|
||||
|
||||
The database is also flexible & extensible, and can be modified by either running
|
||||
a program to build the entire database, or an entry for just a single terminal.
|
||||
Let us know if you want to add your masterpiece to the list!
|
||||
|
||||
## More Portable
|
||||
|
||||
@@ -85,13 +35,10 @@ _Tcell_ is portable to a wide variety of systems, and is pure Go, without
|
||||
any need for CGO.
|
||||
_Tcell_ is believed to work with mainstream systems officially supported by golang.
|
||||
|
||||
## No Async IO
|
||||
|
||||
_Tcell_ is able to operate without requiring `SIGIO` signals (unlike _termbox_),
|
||||
or asynchronous I/O, and can instead use standard Go file objects and Go routines.
|
||||
This means it should be safe, especially for
|
||||
use with programs that use exec, or otherwise need to manipulate the tty streams.
|
||||
This model is also much closer to idiomatic Go, leading to fewer surprises.
|
||||
Following the Go support policy, _Tcell_ officially only supports the current ("stable") version of go,
|
||||
and the version immediately prior ("oldstable"). This policy is necessary to make sure that we can
|
||||
update dependencies to pick up security fixes and new features, and it allows us to adopt changes
|
||||
(such as library and language features) that are only supported in newer versions of Go.
|
||||
|
||||
## Rich Unicode & non-Unicode support
|
||||
|
||||
@@ -111,29 +58,11 @@ drawing certain characters.
|
||||
_Tcell_ also has richer support for a larger number of special keys that some
|
||||
terminals can send.
|
||||
|
||||
## Better Color Handling
|
||||
|
||||
_Tcell_ will respect your terminal's color space as specified within your terminfo entries.
|
||||
For example attempts to emit color sequences on VT100 terminals
|
||||
won't result in unintended consequences.
|
||||
|
||||
In legacy Windows mode, _Tcell_ supports 16 colors, bold, dim, and reverse,
|
||||
instead of just termbox's 8 colors with reverse. (Note that there is some
|
||||
conflation with bold/dim and colors.)
|
||||
Modern Windows 10 can benefit from much richer colors however.
|
||||
|
||||
_Tcell_ maps 16 colors down to 8, for terminals that need it.
|
||||
(The upper 8 colors are just brighter versions of the lower 8.)
|
||||
|
||||
## Better Mouse Support
|
||||
|
||||
_Tcell_ supports enhanced mouse tracking mode, so your application can receive
|
||||
regular mouse motion events, and wheel events, if your terminal supports it.
|
||||
|
||||
(Note: The Windows 10 Terminal application suffers from a flaw in this regard,
|
||||
and does not support mouse interaction. The stock Windows 10 console host
|
||||
fired up with cmd.exe or PowerShell works fine however.)
|
||||
|
||||
## _Termbox_ Compatibility
|
||||
|
||||
A compatibility layer for _termbox_ is provided in the `compat` directory.
|
||||
@@ -152,15 +81,15 @@ If you're lazy, and want them all anyway, see the `encoding` sub-directory.
|
||||
|
||||
## Wide & Combining Characters
|
||||
|
||||
The `SetContent()` API takes a primary rune, and an optional list of combining runes.
|
||||
If any of the runes is a wide (East Asian) rune occupying two cells,
|
||||
then the library will skip output from the following cell. Care must be
|
||||
taken in the application to avoid explicitly attempting to set content in the
|
||||
next cell, otherwise the results are undefined. (Normally the wide character
|
||||
is displayed, and the other character is not; do not depend on that behavior.)
|
||||
The `Put()` API takes a string, which should be legal UTF-8, and displays
|
||||
the first grapheme (which may composed of multiple runes). It returns the
|
||||
actual width displayed, which can be used to advance the column positiion
|
||||
for the next display grapheme. Alternatively, `PutStr()` or `PutStrStyled()`
|
||||
can be used to display a single line of text (which will be clipped at the
|
||||
edge of the screen).
|
||||
|
||||
Older terminal applications (especially on systems like Windows 8) lack support
|
||||
for advanced Unicode, and thus may not fare well.
|
||||
If a second character is displayed immediately in the cell adjacent to a
|
||||
wide character (offset by one instead of by two), then the results are undefined.
|
||||
|
||||
## Colors
|
||||
|
||||
@@ -175,11 +104,7 @@ a ticket.
|
||||
|
||||
_Tcell_ _supports 24-bit color!_ (That is, if your terminal can support it.)
|
||||
|
||||
NOTE: Technically the approach of using 24-bit RGB values for color is more
|
||||
accurately described as "direct color", but most people use the term "true color".
|
||||
We follow the (inaccurate) common convention.
|
||||
|
||||
There are a few ways you can enable (or disable) true color.
|
||||
There are a few ways you can enable (or disable) 24-bit color.
|
||||
|
||||
- For many terminals, we can detect it automatically if your terminal
|
||||
includes the `RGB` or `Tc` capabilities (or rather it did when the database
|
||||
@@ -197,8 +122,8 @@ There are a few ways you can enable (or disable) true color.
|
||||
- You can disable 24-bit color by setting `TCELL_TRUECOLOR=disable` in your
|
||||
environment.
|
||||
|
||||
When using TrueColor, programs will display the colors that the programmer
|
||||
intended, overriding any "`themes`" you may have set in your terminal
|
||||
When using 24-bit color, programs will display the colors that the programmer
|
||||
intended, overriding any "`themes`" the user may have set in their terminal
|
||||
emulator. (For some cases, accurate color fidelity is more important
|
||||
than respecting themes. For other cases, such as typical text apps that
|
||||
only use a few colors, its more desirable to respect the themes that
|
||||
@@ -209,38 +134,10 @@ the user has established.)
|
||||
Reasonable attempts have been made to minimize sending data to terminals,
|
||||
avoiding repeated sequences or drawing the same cell on refresh updates.
|
||||
|
||||
## Terminfo
|
||||
|
||||
(Not relevant for Windows users.)
|
||||
|
||||
The Terminfo implementation operates with a built-in database.
|
||||
This should satisfy most users. However, it can also (on systems
|
||||
with ncurses installed), dynamically parse the output from `infocmp`
|
||||
for terminals it does not already know about.
|
||||
|
||||
See the `terminfo/` directory for more information about generating
|
||||
new entries for the built-in database.
|
||||
|
||||
_Tcell_ requires that the terminal support the `cup` mode of cursor addressing.
|
||||
Ancient terminals without the ability to position the cursor directly
|
||||
are not supported.
|
||||
This is unlikely to be a problem; such terminals have not been mass-produced
|
||||
since the early 1970s.
|
||||
|
||||
## Mouse Support
|
||||
|
||||
Mouse support is detected via the `kmous` terminfo variable, however,
|
||||
enablement/disablement and decoding mouse events is done using hard coded
|
||||
sequences based on the XTerm X11 model. All popular
|
||||
terminals with mouse tracking support this model. (Full terminfo support
|
||||
is not possible as terminfo sequences are not defined.)
|
||||
|
||||
On Windows, the mouse works normally.
|
||||
|
||||
Mouse wheel buttons on various terminals are known to work, but the support
|
||||
in terminal emulators, as well as support for various buttons and
|
||||
live mouse tracking, varies widely.
|
||||
Modern _xterm_, macOS _Terminal_, and _iTerm_ all work well.
|
||||
Mouse tracking, buttons, and even wheel mice works fine on most terminal
|
||||
emulators, as well as Windows.
|
||||
|
||||
## Bracketed Paste
|
||||
|
||||
@@ -265,22 +162,16 @@ platforms (e.g., AIX) may need to be added. Pull requests are welcome!
|
||||
|
||||
Windows console mode applications are supported.
|
||||
|
||||
Modern console applications like ConEmu and the Windows 10 terminal,
|
||||
Modern console applications like ConEmu and the Windows Terminal,
|
||||
support all the good features (resize, mouse tracking, etc.)
|
||||
|
||||
### WASM
|
||||
|
||||
WASM is supported, but needs additional setup detailed in [README-wasm](README-wasm.md).
|
||||
|
||||
### Plan9 and others
|
||||
### Plan9 and its variants
|
||||
|
||||
These platforms won't work, but compilation stubs are supplied
|
||||
for folks that want to include parts of this in software for those
|
||||
platforms. The Simulation screen works, but as _Tcell_ doesn't know how to
|
||||
allocate a real screen object on those platforms, `NewScreen()` will fail.
|
||||
|
||||
If anyone has wisdom about how to improve support for these,
|
||||
please let me know. PRs are especially welcome.
|
||||
Plan 9 is supported on a limited basis. The Plan 9 backend opens `/dev/cons` for I/O, enables raw mode by writing `rawon`/`rawoff` to `/dev/consctl`, watches `/dev/wctl` for resize notifications, and then constructs a **terminfo-backed** `Screen` (so `NewScreen` works as on other platforms). Typical usage is inside `vt(1)` with `TERM=vt100`. Expect **monochrome text** and **no mouse reporting** under stock `vt(1)` (it generally does not emit ANSI color or xterm mouse sequences). If a Plan 9 terminal supplies ANSI color escape sequences and xterm-style mouse reporting, color can be picked up via **terminfo** and mouse support could be added by wiring those sequences into the Plan 9 TTY path; contributions that improve terminal detection and broaden feature support are welcome.
|
||||
|
||||
### Commercial Support
|
||||
|
||||
|
||||
+36
-21
@@ -107,23 +107,30 @@ s.SetStyle(defStyle)
|
||||
s.Clear()
|
||||
```
|
||||
|
||||
Text may be drawn on the screen using `SetContent`.
|
||||
Text may be drawn on the screen using `Put`, `PutStr`, or `PutStrStyled`.
|
||||
|
||||
```go
|
||||
s.SetContent(0, 0, 'H', nil, defStyle)
|
||||
s.SetContent(1, 0, 'i', nil, defStyle)
|
||||
s.SetContent(2, 0, '!', nil, defStyle)
|
||||
s.Put(0, 0, 'H', defStyle)
|
||||
s.Put(1, 0, 'i', defStyle)
|
||||
s.Put(2, 0, '!', defStyle)
|
||||
```
|
||||
|
||||
To draw text more easily, define a render function.
|
||||
which is equivalent to
|
||||
|
||||
```go
|
||||
s.PutStrStyled(0, 0, "Hi!", defStyle)
|
||||
````
|
||||
|
||||
To draw text more easily with wrapping, define a render function.
|
||||
|
||||
```go
|
||||
func drawText(s tcell.Screen, x1, y1, x2, y2 int, style tcell.Style, text string) {
|
||||
row := y1
|
||||
col := x1
|
||||
for _, r := range []rune(text) {
|
||||
s.SetContent(col, row, r, nil, style)
|
||||
col++
|
||||
var width int
|
||||
for text != "" {
|
||||
text, width = s.Put(col, row, text, style)
|
||||
col += width
|
||||
if col >= x2 {
|
||||
row++
|
||||
col = x1
|
||||
@@ -131,6 +138,10 @@ func drawText(s tcell.Screen, x1, y1, x2, y2 int, style tcell.Style, text string
|
||||
if row > y2 {
|
||||
break
|
||||
}
|
||||
if width == 0 {
|
||||
// incomplete grapheme at end of string
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -178,9 +189,10 @@ import (
|
||||
func drawText(s tcell.Screen, x1, y1, x2, y2 int, style tcell.Style, text string) {
|
||||
row := y1
|
||||
col := x1
|
||||
for _, r := range []rune(text) {
|
||||
s.SetContent(col, row, r, nil, style)
|
||||
col++
|
||||
var width int
|
||||
for text != "" {
|
||||
text, width = s.Put(col, row, text, style)
|
||||
col += width
|
||||
if col >= x2 {
|
||||
row++
|
||||
col = x1
|
||||
@@ -188,6 +200,10 @@ func drawText(s tcell.Screen, x1, y1, x2, y2 int, style tcell.Style, text string
|
||||
if row > y2 {
|
||||
break
|
||||
}
|
||||
if width == 0 {
|
||||
// incomplete grapheme at end of string
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,26 +218,26 @@ func drawBox(s tcell.Screen, x1, y1, x2, y2 int, style tcell.Style, text string)
|
||||
// Fill background
|
||||
for row := y1; row <= y2; row++ {
|
||||
for col := x1; col <= x2; col++ {
|
||||
s.SetContent(col, row, ' ', nil, style)
|
||||
s.Put(col, row, " ", style)
|
||||
}
|
||||
}
|
||||
|
||||
// Draw borders
|
||||
for col := x1; col <= x2; col++ {
|
||||
s.SetContent(col, y1, tcell.RuneHLine, nil, style)
|
||||
s.SetContent(col, y2, tcell.RuneHLine, nil, style)
|
||||
s.Put(col, y1, string(tcell.RuneHLine), style)
|
||||
s.Put(col, y2, string(tcell.RuneHLine), style)
|
||||
}
|
||||
for row := y1 + 1; row < y2; row++ {
|
||||
s.SetContent(x1, row, tcell.RuneVLine, nil, style)
|
||||
s.SetContent(x2, row, tcell.RuneVLine, nil, style)
|
||||
s.Put(x1, row, string(tcell.RuneVLine), style)
|
||||
s.Put(x2, row, string(tcell.RuneVLine), style)
|
||||
}
|
||||
|
||||
// Only draw corners if necessary
|
||||
if y1 != y2 && x1 != x2 {
|
||||
s.SetContent(x1, y1, tcell.RuneULCorner, nil, style)
|
||||
s.SetContent(x2, y1, tcell.RuneURCorner, nil, style)
|
||||
s.SetContent(x1, y2, tcell.RuneLLCorner, nil, style)
|
||||
s.SetContent(x2, y2, tcell.RuneLRCorner, nil, style)
|
||||
s.Put(x1, y1, string(tcell.RuneULCorner), style)
|
||||
s.Put(x2, y1, string(tcell.RuneURCorner), style)
|
||||
s.Put(x1, y2, string(tcell.RuneLLCorner), style)
|
||||
s.Put(x2, y2, string(tcell.RuneLRCorner), style)
|
||||
}
|
||||
|
||||
drawText(s, x1+1, y1+1, x2-1, y2-1, style, text)
|
||||
@@ -310,4 +326,3 @@ func main() {
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
-77
@@ -1,77 +0,0 @@
|
||||
# Ukraine, Russia, and a World Tragedy
|
||||
|
||||
## A message to those inside Russia
|
||||
|
||||
### Written March 4, 2022.
|
||||
|
||||
It is with a very heavy heart that I write this. I am normally opposed to the use of open source
|
||||
projects to communicate political positions or advocate for things outside the immediate relevancy
|
||||
to that project.
|
||||
|
||||
However, the events occurring in Ukraine, and specifically the unprecedented invasion of Ukraine by
|
||||
Russian forces operating under orders from Russian President Vladimir Putin compel me to speak out.
|
||||
|
||||
Those who know me, know that I have family, friends, and colleagues in Russia, and Ukraine both. My closest friends
|
||||
have historically been Russian friends my wife's hometown of Chelyabinsk. I myself have in the past
|
||||
frequently traveled to Russia, and indeed operated a software development firm with offices in St. Petersburg.
|
||||
I had a special kinship with Russia and its people.
|
||||
|
||||
I say "had", because I fear that the actions of Putin, and the massive disinformation campaign that his regime
|
||||
has waged inside Russia, mean that it's likely that I won't see those friends again. At present, I'm not sure
|
||||
my wife will see her own mother again. We no longer feel it's safe for either of us to return Russia given
|
||||
actions taken by the regime to crack down on those who express disagreement.
|
||||
|
||||
Russian citizens are being led to believe it is acting purely defensively, and that only legitimate military
|
||||
targets are being targeted, and that all the information we have received in the West are fakes.
|
||||
|
||||
I am confident that nothing could be further from the truth.
|
||||
|
||||
This has caused many in Russia, including people whom I respect and believe to be smarter than this, to
|
||||
stand by Putin, and endorse his actions. The claim is that the entirety of NATO is operating at the behest
|
||||
of the USA, and that the entirety of Europe was poised to attack Russia. While this is clearly absurd to those
|
||||
of us with any understanding of western politics, Russian citizens are being fed this lie, and believing it.
|
||||
|
||||
If you're reading this from inside Russia -- YOU are the person that I hope this message reaches. Your
|
||||
government is LYING to you. Of course, all governments lie all the time. But consider this. Almost the
|
||||
entire world has condemned the invasion of Ukraine as criminal, and has applied sanctions. Even countries
|
||||
which have poor relations with the US sanctioning Russia, as well as nations which historically have remained
|
||||
neutral. (Famously neutral -- even during World War II, Switzerland has acted to apply sanctions in
|
||||
concert with the rest of the world.)
|
||||
|
||||
Ask yourself, why does Putin fear a free press so much, if what he says is true? Why the crack-downs on
|
||||
children expressing only a desire for peace with Ukraine? Why would the entire world unified against him,
|
||||
if Putin was in the right? Why would the only countries that stood with Russia against
|
||||
the UN resolution to condemn these acts as crimes be Belarus, North Korea, and Syria? Even countries normally
|
||||
allied to Russia could not bring themselves to do more than abstain from the vote to condemn it.
|
||||
|
||||
To be clear, I do not claim that the actions taken by the West or by the Ukrainian government were completely
|
||||
blameless. On the contrary, I understand that Western media is biased, and the truth is rarely exactly
|
||||
as reported. I believe that there is a kernel of truth in the claims of fascists and ultra-nationalist
|
||||
militias operating in Ukraine and specifically Donbas. However, I am also equally certain that Putin's
|
||||
response is out of proportion, and that concerns about such militias are principally just a pretext to justify
|
||||
an invasion.
|
||||
|
||||
Europe is at war, unlike we've seen in my lifetime. The world is more divided, and closer to nuclear holocaust
|
||||
than it has been since the Cold War. And that is 100% the fault of Putin.
|
||||
|
||||
While Putin remains in power, there cannot really be any way for Russian international relations to return
|
||||
to normal. Putin has set your country on a path to return to the Cold War, likely because he fancies himself
|
||||
to be a new Stalin. However, unlike the Soviet Union, the Russian economy does not have the wherewithal to
|
||||
stand on its own, and the invasion of Ukraine has fully ensured that Russia will not find any friends anywhere
|
||||
else in Europe, and probably few places in Asia.
|
||||
|
||||
The *only* paths forward for Russia are either a Russia without Putin (and those who would support his agenda),
|
||||
or a complete breakdown of Russian prosperity, likely followed by the increasing international conflict that will
|
||||
be the natural escalation from a country that is isolated and impoverished. Those of us observing from the West are
|
||||
gravely concerned, because we cannot see any end to this madness that does not result in nuclear conflict,
|
||||
unless from within.
|
||||
|
||||
In the meantime, the worst prices will be paid for by innocents in Ukraine, and by young Russian mean
|
||||
forced to carry out the orders of Putin's corrupt regime.
|
||||
|
||||
And *that* is why I write this -- to appeal to those within Russia to open your eyes, and think with
|
||||
your minds. It is right and proper to be proud of your country and its rich heritage. But it is also
|
||||
right and proper to look for ways to save it from the ruinous path that its current leadership has set it upon,
|
||||
and to recognize when that leadership is no longer acting in interest of the country or its people.
|
||||
|
||||
- Garrett D'Amore, March 4, 2022
|
||||
+81
-66
@@ -1,4 +1,4 @@
|
||||
// Copyright 2024 The TCell Authors
|
||||
// Copyright 2025 The TCell Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use file except in compliance with the License.
|
||||
@@ -15,23 +15,30 @@
|
||||
package tcell
|
||||
|
||||
import (
|
||||
"os"
|
||||
"reflect"
|
||||
|
||||
runewidth "github.com/mattn/go-runewidth"
|
||||
"github.com/rivo/uniseg"
|
||||
)
|
||||
|
||||
type cell struct {
|
||||
currMain rune
|
||||
currComb []rune
|
||||
currStr string
|
||||
lastStr string
|
||||
currStyle Style
|
||||
lastMain rune
|
||||
lastStyle Style
|
||||
lastComb []rune
|
||||
width int
|
||||
lock bool
|
||||
}
|
||||
|
||||
func (c *cell) setDirty(dirty bool) {
|
||||
if dirty {
|
||||
c.lastStr = ""
|
||||
} else {
|
||||
if c.currStr == "" {
|
||||
c.currStr = " "
|
||||
}
|
||||
c.lastStr = c.currStr
|
||||
c.lastStyle = c.currStyle
|
||||
}
|
||||
}
|
||||
|
||||
// CellBuffer represents a two-dimensional array of character cells.
|
||||
// This is primarily intended for use by Screen implementors; it
|
||||
// contains much of the common code they need. To create one, just
|
||||
@@ -48,28 +55,47 @@ type CellBuffer struct {
|
||||
// and style) for a cell at a given location. If the background or
|
||||
// foreground of the style is set to ColorNone, then the respective
|
||||
// color is left un changed.
|
||||
func (cb *CellBuffer) SetContent(x int, y int,
|
||||
mainc rune, combc []rune, style Style,
|
||||
) {
|
||||
//
|
||||
// Deprecated: Use Put instead, which this is implemented in terms of.
|
||||
func (cb *CellBuffer) SetContent(x int, y int, mainc rune, combc []rune, style Style) {
|
||||
cb.Put(x, y, string(append([]rune{mainc}, combc...)), style)
|
||||
}
|
||||
|
||||
// Put a single styled grapheme using the given string and style
|
||||
// at the same location. Note that only the first grapheme in the string
|
||||
// will bre displayed, using only the 1 or 2 (depending on width) cells
|
||||
// located at x, y. It returns the rest of the string, and the width used.
|
||||
func (cb *CellBuffer) Put(x int, y int, str string, style Style) (string, int) {
|
||||
var width int = 0
|
||||
if x >= 0 && y >= 0 && x < cb.w && y < cb.h {
|
||||
var cl string
|
||||
c := &cb.cells[(y*cb.w)+x]
|
||||
state := -1
|
||||
for width == 0 && str != "" {
|
||||
var g string
|
||||
g, str, width, state = uniseg.FirstGraphemeClusterInString(str, state)
|
||||
cl += g
|
||||
if g == "" {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// Wide characters: we want to mark the "wide" cells
|
||||
// dirty as well as the base cell, to make sure we consider
|
||||
// both cells as dirty together. We only need to do this
|
||||
// if we're changing content
|
||||
if (c.width > 0) && (mainc != c.currMain || len(combc) != len(c.currComb) || (len(combc) > 0 && !reflect.DeepEqual(combc, c.currComb))) {
|
||||
for i := 0; i < c.width; i++ {
|
||||
if width > 0 && cl != c.currStr {
|
||||
// Prevent unnecessary boundchecks for first cell, since we already
|
||||
// received that one.
|
||||
c.setDirty(true)
|
||||
for i := 1; i < width; i++ {
|
||||
cb.SetDirty(x+i, y, true)
|
||||
}
|
||||
}
|
||||
|
||||
c.currComb = append([]rune{}, combc...)
|
||||
c.currStr = cl
|
||||
c.width = width
|
||||
|
||||
if c.currMain != mainc {
|
||||
c.width = runewidth.RuneWidth(mainc)
|
||||
}
|
||||
c.currMain = mainc
|
||||
if style.fg == ColorNone {
|
||||
style.fg = c.currStyle.fg
|
||||
}
|
||||
@@ -78,23 +104,45 @@ func (cb *CellBuffer) SetContent(x int, y int,
|
||||
}
|
||||
c.currStyle = style
|
||||
}
|
||||
return str, width
|
||||
}
|
||||
|
||||
// Get the contents of a character cell (or two adjacent cells), including the
|
||||
// the style and the display width in cells. (The width can be either 1, normally,
|
||||
// or 2 for East Asian full-width characters. If the width is 0, then the cell is
|
||||
// is empty.)
|
||||
func (cb *CellBuffer) Get(x, y int) (string, Style, int) {
|
||||
var style Style
|
||||
var width int
|
||||
var str string
|
||||
if x >= 0 && y >= 0 && x < cb.w && y < cb.h {
|
||||
c := &cb.cells[(y*cb.w)+x]
|
||||
str, style = c.currStr, c.currStyle
|
||||
if width = c.width; width == 0 || str == "" {
|
||||
width = 1
|
||||
str = " "
|
||||
}
|
||||
}
|
||||
return str, style, width
|
||||
}
|
||||
|
||||
// GetContent returns the contents of a character cell, including the
|
||||
// primary rune, any combining character runes (which will usually be
|
||||
// nil), the style, and the display width in cells. (The width can be
|
||||
// either 1, normally, or 2 for East Asian full-width characters.)
|
||||
//
|
||||
// Deprecated: Use Get, which this implemented in terms of.
|
||||
func (cb *CellBuffer) GetContent(x, y int) (rune, []rune, Style, int) {
|
||||
var mainc rune
|
||||
var combc []rune
|
||||
var style Style
|
||||
var width int
|
||||
if x >= 0 && y >= 0 && x < cb.w && y < cb.h {
|
||||
c := &cb.cells[(y*cb.w)+x]
|
||||
mainc, combc, style = c.currMain, c.currComb, c.currStyle
|
||||
if width = c.width; width == 0 || mainc < ' ' {
|
||||
width = 1
|
||||
mainc = ' '
|
||||
var mainc rune
|
||||
var combc []rune
|
||||
str, style, width := cb.Get(x, y)
|
||||
for i, r := range str {
|
||||
if i == 0 {
|
||||
mainc = r
|
||||
} else {
|
||||
combc = append(combc, r)
|
||||
}
|
||||
}
|
||||
return mainc, combc, style, width
|
||||
@@ -108,7 +156,7 @@ func (cb *CellBuffer) Size() (int, int) {
|
||||
// Invalidate marks all characters within the buffer as dirty.
|
||||
func (cb *CellBuffer) Invalidate() {
|
||||
for i := range cb.cells {
|
||||
cb.cells[i].lastMain = rune(0)
|
||||
cb.cells[i].lastStr = ""
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,23 +169,12 @@ func (cb *CellBuffer) Dirty(x, y int) bool {
|
||||
if c.lock {
|
||||
return false
|
||||
}
|
||||
if c.lastMain == rune(0) {
|
||||
return true
|
||||
}
|
||||
if c.lastMain != c.currMain {
|
||||
return true
|
||||
}
|
||||
if c.lastStyle != c.currStyle {
|
||||
return true
|
||||
}
|
||||
if len(c.lastComb) != len(c.currComb) {
|
||||
if c.lastStr != c.currStr {
|
||||
return true
|
||||
}
|
||||
for i := range c.lastComb {
|
||||
if c.lastComb[i] != c.currComb[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -148,16 +185,7 @@ func (cb *CellBuffer) Dirty(x, y int) bool {
|
||||
func (cb *CellBuffer) SetDirty(x, y int, dirty bool) {
|
||||
if x >= 0 && y >= 0 && x < cb.w && y < cb.h {
|
||||
c := &cb.cells[(y*cb.w)+x]
|
||||
if dirty {
|
||||
c.lastMain = rune(0)
|
||||
} else {
|
||||
if c.currMain == rune(0) {
|
||||
c.currMain = ' '
|
||||
}
|
||||
c.lastMain = c.currMain
|
||||
c.lastComb = c.currComb
|
||||
c.lastStyle = c.currStyle
|
||||
}
|
||||
c.setDirty(dirty)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,11 +231,10 @@ func (cb *CellBuffer) Resize(w, h int) {
|
||||
for x := 0; x < w && x < cb.w; x++ {
|
||||
oc := &cb.cells[(y*cb.w)+x]
|
||||
nc := &newc[(y*w)+x]
|
||||
nc.currMain = oc.currMain
|
||||
nc.currComb = oc.currComb
|
||||
nc.currStr = oc.currStr
|
||||
nc.currStyle = oc.currStyle
|
||||
nc.width = oc.width
|
||||
nc.lastMain = rune(0)
|
||||
nc.lastStr = ""
|
||||
}
|
||||
}
|
||||
cb.cells = newc
|
||||
@@ -223,8 +250,7 @@ func (cb *CellBuffer) Resize(w, h int) {
|
||||
func (cb *CellBuffer) Fill(r rune, style Style) {
|
||||
for i := range cb.cells {
|
||||
c := &cb.cells[i]
|
||||
c.currMain = r
|
||||
c.currComb = nil
|
||||
c.currStr = string(r)
|
||||
cs := style
|
||||
if cs.fg == ColorNone {
|
||||
cs.fg = c.currStyle.fg
|
||||
@@ -236,14 +262,3 @@ func (cb *CellBuffer) Fill(r rune, style Style) {
|
||||
c.width = 1
|
||||
}
|
||||
}
|
||||
|
||||
var runeConfig *runewidth.Condition
|
||||
|
||||
func init() {
|
||||
// The defaults for the runewidth package are poorly chosen for terminal
|
||||
// applications. We however will honor the setting in the environment if
|
||||
// it is set.
|
||||
if os.Getenv("RUNEWIDTH_EASTASIAN") == "" {
|
||||
runewidth.DefaultCondition.EastAsianWidth = false
|
||||
}
|
||||
}
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
//go:build plan9
|
||||
// +build plan9
|
||||
|
||||
// Copyright 2025 The TCell Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use file except in compliance with the License.
|
||||
// You may obtain a copy of the license at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package tcell
|
||||
|
||||
// Plan 9 uses UTF-8 system-wide, so we return "UTF-8" unconditionally.
|
||||
func getCharset() string {
|
||||
return "UTF-8"
|
||||
}
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
//go:build plan9 || nacl
|
||||
// +build plan9 nacl
|
||||
//go:build nacl
|
||||
// +build nacl
|
||||
|
||||
// Copyright 2015 The TCell Authors
|
||||
//
|
||||
|
||||
+1
-1
@@ -18,5 +18,5 @@
|
||||
package tcell
|
||||
|
||||
func getCharset() string {
|
||||
return "UTF-16"
|
||||
return "UTF-8"
|
||||
}
|
||||
|
||||
+90
-213
@@ -1,7 +1,7 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
// Copyright 2024 The TCell Authors
|
||||
// Copyright 2025 The TCell Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use file except in compliance with the License.
|
||||
@@ -38,7 +38,6 @@ type cScreen struct {
|
||||
cury int
|
||||
style Style
|
||||
fini bool
|
||||
vten bool
|
||||
truecolor bool
|
||||
running bool
|
||||
disableAlt bool // disable the alternate screen
|
||||
@@ -106,7 +105,6 @@ var winColors = map[Color]Color{
|
||||
}
|
||||
|
||||
var (
|
||||
k32 = syscall.NewLazyDLL("kernel32.dll")
|
||||
u32 = syscall.NewLazyDLL("user32.dll")
|
||||
)
|
||||
|
||||
@@ -117,18 +115,8 @@ var (
|
||||
// characters (Unicode) are in use. The documentation refers to them
|
||||
// without this suffix, as the resolution is made via preprocessor.
|
||||
var (
|
||||
procReadConsoleInput = k32.NewProc("ReadConsoleInputW")
|
||||
procWaitForMultipleObjects = k32.NewProc("WaitForMultipleObjects")
|
||||
procCreateEvent = k32.NewProc("CreateEventW")
|
||||
procSetEvent = k32.NewProc("SetEvent")
|
||||
procGetConsoleCursorInfo = k32.NewProc("GetConsoleCursorInfo")
|
||||
procSetConsoleCursorInfo = k32.NewProc("SetConsoleCursorInfo")
|
||||
procSetConsoleCursorPosition = k32.NewProc("SetConsoleCursorPosition")
|
||||
procSetConsoleMode = k32.NewProc("SetConsoleMode")
|
||||
procGetConsoleMode = k32.NewProc("GetConsoleMode")
|
||||
procGetConsoleScreenBufferInfo = k32.NewProc("GetConsoleScreenBufferInfo")
|
||||
procFillConsoleOutputAttribute = k32.NewProc("FillConsoleOutputAttribute")
|
||||
procFillConsoleOutputCharacter = k32.NewProc("FillConsoleOutputCharacterW")
|
||||
procSetConsoleWindowInfo = k32.NewProc("SetConsoleWindowInfo")
|
||||
procSetConsoleScreenBufferSize = k32.NewProc("SetConsoleScreenBufferSize")
|
||||
procSetConsoleTextAttribute = k32.NewProc("SetConsoleTextAttribute")
|
||||
@@ -195,6 +183,10 @@ var vtCursorStyles = map[CursorStyle]string{
|
||||
// NewConsoleScreen returns a Screen for the Windows console associated
|
||||
// with the current process. The Screen makes use of the Windows Console
|
||||
// API to display content and read events.
|
||||
//
|
||||
// Deprecated: The console API based implementation will be fully replaced
|
||||
// with the VT based model. Use NewScreen() to get a reasonable screen
|
||||
// by default.
|
||||
func NewConsoleScreen() (Screen, error) {
|
||||
return &baseScreen{screenImpl: &cScreen{}}, nil
|
||||
}
|
||||
@@ -217,22 +209,11 @@ func (s *cScreen) Init() error {
|
||||
|
||||
s.truecolor = true
|
||||
|
||||
// ConEmu handling of colors and scrolling when in VT output mode is extremely poor.
|
||||
// The color palette will scroll even though characters do not, when
|
||||
// emitting stuff for the last character. In the future we might change this to
|
||||
// look at specific versions of ConEmu if they fix the bug.
|
||||
// We can also try disabling auto margin mode.
|
||||
tryVt := true
|
||||
if os.Getenv("ConEmuPID") != "" {
|
||||
s.truecolor = false
|
||||
tryVt = false
|
||||
}
|
||||
switch os.Getenv("TCELL_TRUECOLOR") {
|
||||
case "disable":
|
||||
s.truecolor = false
|
||||
case "enable":
|
||||
s.truecolor = true
|
||||
tryVt = true
|
||||
}
|
||||
|
||||
s.Lock()
|
||||
@@ -249,33 +230,17 @@ func (s *cScreen) Init() error {
|
||||
s.fini = false
|
||||
s.setInMode(modeResizeEn | modeExtendFlg)
|
||||
|
||||
// If a user needs to force old style console, they may do so
|
||||
// by setting TCELL_VTMODE to disable. This is an undocumented safety net for now.
|
||||
// It may be removed in the future. (This mostly exists because of ConEmu.)
|
||||
switch os.Getenv("TCELL_VTMODE") {
|
||||
case "disable":
|
||||
tryVt = false
|
||||
case "enable":
|
||||
tryVt = true
|
||||
}
|
||||
switch os.Getenv("TCELL_ALTSCREEN") {
|
||||
case "enable":
|
||||
s.disableAlt = false // also the default
|
||||
case "disable":
|
||||
s.disableAlt = true
|
||||
}
|
||||
if tryVt {
|
||||
s.setOutMode(modeVtOutput | modeNoAutoNL | modeCookedOut | modeUnderline)
|
||||
var om uint32
|
||||
s.getOutMode(&om)
|
||||
if om&modeVtOutput == modeVtOutput {
|
||||
s.vten = true
|
||||
} else {
|
||||
s.truecolor = false
|
||||
s.setOutMode(0)
|
||||
}
|
||||
} else {
|
||||
s.setOutMode(0)
|
||||
s.setOutMode(modeVtOutput | modeNoAutoNL | modeCookedOut | modeUnderline)
|
||||
var om uint32
|
||||
s.getOutMode(&om)
|
||||
if om&modeVtOutput != modeVtOutput {
|
||||
return errors.New("failed to initialize: VT output not supported?")
|
||||
}
|
||||
|
||||
s.Unlock()
|
||||
@@ -349,17 +314,12 @@ func (s *cScreen) disengage() {
|
||||
|
||||
s.wg.Wait()
|
||||
|
||||
if s.vten {
|
||||
s.emitVtString(vtCursorStyles[CursorStyleDefault])
|
||||
s.emitVtString(vtCursorColorReset)
|
||||
s.emitVtString(vtEnableAm)
|
||||
if !s.disableAlt {
|
||||
s.emitVtString(vtRestoreTitle)
|
||||
s.emitVtString(vtExitCA)
|
||||
}
|
||||
} else if !s.disableAlt {
|
||||
s.clearScreen(StyleDefault, s.vten)
|
||||
s.setCursorPos(0, 0, false)
|
||||
s.emitVtString(vtCursorStyles[CursorStyleDefault])
|
||||
s.emitVtString(vtCursorColorReset)
|
||||
s.emitVtString(vtEnableAm)
|
||||
if !s.disableAlt {
|
||||
s.emitVtString(vtRestoreTitle)
|
||||
s.emitVtString(vtExitCA)
|
||||
}
|
||||
s.setCursorInfo(&s.ocursor)
|
||||
s.setBufferSize(int(s.oscreen.size.x), int(s.oscreen.size.y))
|
||||
@@ -388,22 +348,18 @@ func (s *cScreen) engage() error {
|
||||
s.running = true
|
||||
s.cancelflag = syscall.Handle(cf)
|
||||
s.enableMouse(s.mouseEnabled)
|
||||
|
||||
if s.vten {
|
||||
s.setOutMode(modeVtOutput | modeNoAutoNL | modeCookedOut | modeUnderline)
|
||||
if !s.disableAlt {
|
||||
s.emitVtString(vtSaveTitle)
|
||||
s.emitVtString(vtEnterCA)
|
||||
}
|
||||
s.emitVtString(vtDisableAm)
|
||||
if s.title != "" {
|
||||
s.emitVtString(fmt.Sprintf(vtSetTitle, s.title))
|
||||
}
|
||||
} else {
|
||||
s.setOutMode(0)
|
||||
s.setInMode(modeVtInput | modeResizeEn | modeExtendFlg)
|
||||
s.setOutMode(modeVtOutput | modeNoAutoNL | modeCookedOut | modeUnderline)
|
||||
if !s.disableAlt {
|
||||
s.emitVtString(vtSaveTitle)
|
||||
s.emitVtString(vtEnterCA)
|
||||
}
|
||||
s.emitVtString(vtDisableAm)
|
||||
if s.title != "" {
|
||||
s.emitVtString(fmt.Sprintf(vtSetTitle, s.title))
|
||||
}
|
||||
|
||||
s.clearScreen(s.style, s.vten)
|
||||
s.clearScreen(s.style)
|
||||
s.hideCursor()
|
||||
|
||||
s.cells.Invalidate()
|
||||
@@ -445,26 +401,18 @@ func (s *cScreen) emitVtString(vs string) {
|
||||
}
|
||||
|
||||
func (s *cScreen) showCursor() {
|
||||
if s.vten {
|
||||
s.emitVtString(vtShowCursor)
|
||||
s.emitVtString(vtCursorStyles[s.cursorStyle])
|
||||
if s.cursorColor == ColorReset {
|
||||
s.emitVtString(vtCursorColorReset)
|
||||
} else if s.cursorColor.Valid() {
|
||||
r, g, b := s.cursorColor.RGB()
|
||||
s.emitVtString(fmt.Sprintf(vtCursorColorRGB, r, g, b))
|
||||
}
|
||||
} else {
|
||||
s.setCursorInfo(&cursorInfo{size: 100, visible: 1})
|
||||
s.emitVtString(vtShowCursor)
|
||||
s.emitVtString(vtCursorStyles[s.cursorStyle])
|
||||
if s.cursorColor == ColorReset {
|
||||
s.emitVtString(vtCursorColorReset)
|
||||
} else if s.cursorColor.Valid() {
|
||||
r, g, b := s.cursorColor.RGB()
|
||||
s.emitVtString(fmt.Sprintf(vtCursorColorRGB, r, g, b))
|
||||
}
|
||||
}
|
||||
|
||||
func (s *cScreen) hideCursor() {
|
||||
if s.vten {
|
||||
s.emitVtString(vtHideCursor)
|
||||
} else {
|
||||
s.setCursorInfo(&cursorInfo{size: 1, visible: 0})
|
||||
}
|
||||
s.emitVtString(vtHideCursor)
|
||||
}
|
||||
|
||||
func (s *cScreen) ShowCursor(x, y int) {
|
||||
@@ -495,7 +443,7 @@ func (s *cScreen) doCursor() {
|
||||
if x < 0 || y < 0 || x >= s.w || y >= s.h {
|
||||
s.hideCursor()
|
||||
} else {
|
||||
s.setCursorPos(x, y, s.vten)
|
||||
s.setCursorPos(x, y)
|
||||
s.showCursor()
|
||||
}
|
||||
}
|
||||
@@ -504,20 +452,6 @@ func (s *cScreen) HideCursor() {
|
||||
s.ShowCursor(-1, -1)
|
||||
}
|
||||
|
||||
type inputRecord struct {
|
||||
typ uint16
|
||||
_ uint16
|
||||
data [16]byte
|
||||
}
|
||||
|
||||
const (
|
||||
keyEvent uint16 = 1
|
||||
mouseEvent uint16 = 2
|
||||
resizeEvent uint16 = 4
|
||||
menuEvent uint16 = 8 // don't use
|
||||
focusEvent uint16 = 16
|
||||
)
|
||||
|
||||
type mouseRecord struct {
|
||||
x int16
|
||||
y int16
|
||||
@@ -655,25 +589,28 @@ var vkKeys = map[uint16]Key{
|
||||
func getu32(v []byte) uint32 {
|
||||
return uint32(v[0]) + (uint32(v[1]) << 8) + (uint32(v[2]) << 16) + (uint32(v[3]) << 24)
|
||||
}
|
||||
|
||||
func geti32(v []byte) int32 {
|
||||
return int32(getu32(v))
|
||||
}
|
||||
|
||||
func getu16(v []byte) uint16 {
|
||||
return uint16(v[0]) + (uint16(v[1]) << 8)
|
||||
}
|
||||
|
||||
func geti16(v []byte) int16 {
|
||||
return int16(getu16(v))
|
||||
}
|
||||
|
||||
// Convert windows dwControlKeyState to modifier mask
|
||||
func mod2mask(cks uint32) ModMask {
|
||||
func mod2mask(cks uint32, filter_ctrl_alt bool) ModMask {
|
||||
mm := ModNone
|
||||
// Left or right control
|
||||
ctrl := (cks & (0x0008 | 0x0004)) != 0
|
||||
// Left or right alt
|
||||
alt := (cks & (0x0002 | 0x0001)) != 0
|
||||
// Filter out ctrl+alt (it means AltGr)
|
||||
if !(ctrl && alt) {
|
||||
if !filter_ctrl_alt || !(ctrl && alt) {
|
||||
if ctrl {
|
||||
mm |= ModCtrl
|
||||
}
|
||||
@@ -787,11 +724,15 @@ func (s *cScreen) getConsoleInput() error {
|
||||
if krec.ch != 0 {
|
||||
// synthesized key code
|
||||
for krec.repeat > 0 {
|
||||
if krec.ch < ' ' && mod2mask(krec.mod, false) == ModCtrl {
|
||||
krec.ch += '\x60'
|
||||
}
|
||||
|
||||
// convert shift+tab to backtab
|
||||
if mod2mask(krec.mod) == ModShift && krec.ch == vkTab {
|
||||
if mod2mask(krec.mod, false) == ModShift && krec.ch == vkTab {
|
||||
s.postEvent(NewEventKey(KeyBacktab, 0, ModNone))
|
||||
} else {
|
||||
s.postEvent(NewEventKey(KeyRune, rune(krec.ch), mod2mask(krec.mod)))
|
||||
s.postEvent(NewEventKey(KeyRune, rune(krec.ch), mod2mask(krec.mod, true)))
|
||||
}
|
||||
krec.repeat--
|
||||
}
|
||||
@@ -803,7 +744,7 @@ func (s *cScreen) getConsoleInput() error {
|
||||
return nil
|
||||
}
|
||||
for krec.repeat > 0 {
|
||||
s.postEvent(NewEventKey(key, rune(krec.ch), mod2mask(krec.mod)))
|
||||
s.postEvent(NewEventKey(key, rune(krec.ch), mod2mask(krec.mod, false)))
|
||||
krec.repeat--
|
||||
}
|
||||
|
||||
@@ -816,7 +757,7 @@ func (s *cScreen) getConsoleInput() error {
|
||||
mrec.flags = getu32(rec.data[12:])
|
||||
btns := mrec2btns(mrec.btns, mrec.flags)
|
||||
// we ignore double click, events are delivered normally
|
||||
s.postEvent(NewEventMouse(int(mrec.x), int(mrec.y), btns, mod2mask(mrec.mod)))
|
||||
s.postEvent(NewEventMouse(int(mrec.x), int(mrec.y), btns, mod2mask(mrec.mod, false)))
|
||||
|
||||
case resizeEvent:
|
||||
var rrec resizeRecord
|
||||
@@ -858,11 +799,10 @@ func (s *cScreen) scanInput(stopQ chan struct{}) {
|
||||
}
|
||||
|
||||
func (s *cScreen) Colors() int {
|
||||
if s.vten {
|
||||
return 1 << 24
|
||||
if !s.truecolor {
|
||||
return 16
|
||||
}
|
||||
// Windows console can display 8 colors, in either low or high intensity
|
||||
return 16
|
||||
return 1 << 24
|
||||
}
|
||||
|
||||
var vgaColors = map[Color]uint16{
|
||||
@@ -938,7 +878,7 @@ func (s *cScreen) mapStyle(style Style) uint16 {
|
||||
return attr
|
||||
}
|
||||
|
||||
func (s *cScreen) sendVtStyle(style Style) {
|
||||
func (s *cScreen) makeVtStyle(style Style) string {
|
||||
esc := &strings.Builder{}
|
||||
|
||||
fg, bg, attrs := style.fg, style.bg, style.attrs
|
||||
@@ -998,30 +938,32 @@ func (s *cScreen) sendVtStyle(style Style) {
|
||||
esc.WriteString(vtExitUrl)
|
||||
}
|
||||
|
||||
s.emitVtString(esc.String())
|
||||
return esc.String()
|
||||
}
|
||||
|
||||
func (s *cScreen) writeString(x, y int, style Style, ch []uint16) {
|
||||
func (s *cScreen) sendVtStyle(style Style) {
|
||||
s.emitVtString(s.makeVtStyle(style))
|
||||
}
|
||||
|
||||
func (s *cScreen) writeString(x, y int, style Style, vtBuf, ch []uint16) {
|
||||
// we assume the caller has hidden the cursor
|
||||
if len(ch) == 0 {
|
||||
return
|
||||
}
|
||||
s.setCursorPos(x, y, s.vten)
|
||||
|
||||
if s.vten {
|
||||
s.sendVtStyle(style)
|
||||
} else {
|
||||
_, _, _ = procSetConsoleTextAttribute.Call(
|
||||
uintptr(s.out),
|
||||
uintptr(s.mapStyle(style)))
|
||||
}
|
||||
_ = syscall.WriteConsole(s.out, &ch[0], uint32(len(ch)), nil, nil)
|
||||
vtBuf = append(vtBuf, utf16.Encode([]rune(fmt.Sprintf(vtCursorPos, y+1, x+1)))...)
|
||||
styleStr := s.makeVtStyle(style)
|
||||
vtBuf = append(vtBuf, utf16.Encode([]rune(styleStr))...)
|
||||
vtBuf = append(vtBuf, ch...)
|
||||
_ = syscall.WriteConsole(s.out, &vtBuf[0], uint32(len(vtBuf)), nil, nil)
|
||||
vtBuf = vtBuf[:0]
|
||||
}
|
||||
|
||||
func (s *cScreen) draw() {
|
||||
// allocate a scratch line bit enough for no combining chars.
|
||||
// if you have combining characters, you may pay for extra allocations.
|
||||
buf := make([]uint16, 0, s.w)
|
||||
var vtBuf []uint16
|
||||
wcs := buf[:]
|
||||
lstyle := styleInvalid
|
||||
|
||||
@@ -1040,7 +982,7 @@ func (s *cScreen) draw() {
|
||||
// write out any data queued thus far
|
||||
// because we are going to skip over some
|
||||
// cells, or because we need to change styles
|
||||
s.writeString(lx, ly, lstyle, wcs)
|
||||
s.writeString(lx, ly, lstyle, vtBuf, wcs)
|
||||
wcs = buf[0:0]
|
||||
lstyle = StyleDefault
|
||||
if !dirty {
|
||||
@@ -1067,7 +1009,7 @@ func (s *cScreen) draw() {
|
||||
}
|
||||
x += width - 1
|
||||
}
|
||||
s.writeString(lx, ly, lstyle, wcs)
|
||||
s.writeString(lx, ly, lstyle, vtBuf, wcs)
|
||||
wcs = buf[0:0]
|
||||
lstyle = styleInvalid
|
||||
}
|
||||
@@ -1122,15 +1064,9 @@ func (s *cScreen) setCursorInfo(info *cursorInfo) {
|
||||
uintptr(unsafe.Pointer(info)))
|
||||
}
|
||||
|
||||
func (s *cScreen) setCursorPos(x, y int, vtEnable bool) {
|
||||
if vtEnable {
|
||||
// Note that the string is Y first. Origin is 1,1.
|
||||
s.emitVtString(fmt.Sprintf(vtCursorPos, y+1, x+1))
|
||||
} else {
|
||||
_, _, _ = procSetConsoleCursorPosition.Call(
|
||||
uintptr(s.out),
|
||||
coord{int16(x), int16(y)}.uintptr())
|
||||
}
|
||||
func (s *cScreen) setCursorPos(x, y int) {
|
||||
// Note that the string is Y first. Origin is 1,1.
|
||||
s.emitVtString(fmt.Sprintf(vtCursorPos, y+1, x+1))
|
||||
}
|
||||
|
||||
func (s *cScreen) setBufferSize(x, y int) {
|
||||
@@ -1206,52 +1142,30 @@ func (s *cScreen) resize() {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *cScreen) clearScreen(style Style, vtEnable bool) {
|
||||
if vtEnable {
|
||||
s.sendVtStyle(style)
|
||||
row := strings.Repeat(" ", s.w)
|
||||
for y := 0; y < s.h; y++ {
|
||||
s.setCursorPos(0, y, vtEnable)
|
||||
s.emitVtString(row)
|
||||
}
|
||||
s.setCursorPos(0, 0, vtEnable)
|
||||
|
||||
} else {
|
||||
pos := coord{0, 0}
|
||||
attr := s.mapStyle(style)
|
||||
x, y := s.w, s.h
|
||||
scratch := uint32(0)
|
||||
count := uint32(x * y)
|
||||
|
||||
_, _, _ = procFillConsoleOutputAttribute.Call(
|
||||
uintptr(s.out),
|
||||
uintptr(attr),
|
||||
uintptr(count),
|
||||
pos.uintptr(),
|
||||
uintptr(unsafe.Pointer(&scratch)))
|
||||
_, _, _ = procFillConsoleOutputCharacter.Call(
|
||||
uintptr(s.out),
|
||||
uintptr(' '),
|
||||
uintptr(count),
|
||||
pos.uintptr(),
|
||||
uintptr(unsafe.Pointer(&scratch)))
|
||||
func (s *cScreen) clearScreen(style Style) {
|
||||
s.sendVtStyle(style)
|
||||
row := strings.Repeat(" ", s.w)
|
||||
for y := 0; y < s.h; y++ {
|
||||
s.setCursorPos(0, y)
|
||||
s.emitVtString(row)
|
||||
}
|
||||
s.setCursorPos(0, 0)
|
||||
}
|
||||
|
||||
const (
|
||||
// Input modes
|
||||
modeExtendFlg uint32 = 0x0080
|
||||
modeMouseEn = 0x0010
|
||||
modeResizeEn = 0x0008
|
||||
// modeCooked = 0x0001
|
||||
// modeVtInput = 0x0200
|
||||
modeExtendFlg = uint32(0x0080)
|
||||
modeMouseEn = uint32(0x0010)
|
||||
modeResizeEn = uint32(0x0008)
|
||||
modeVtInput = uint32(0x0200)
|
||||
// modeCooked = uint32(0x0001)
|
||||
|
||||
// Output modes
|
||||
modeCookedOut uint32 = 0x0001
|
||||
modeVtOutput = 0x0004
|
||||
modeNoAutoNL = 0x0008
|
||||
modeUnderline = 0x0010 // ENABLE_LVB_GRID_WORLDWIDE, needed for underlines
|
||||
// modeWrapEOL = 0x0002
|
||||
modeCookedOut = uint32(0x0001)
|
||||
modeVtOutput = uint32(0x0004)
|
||||
modeNoAutoNL = uint32(0x0008)
|
||||
modeUnderline = uint32(0x0010) // ENABLE_LVB_GRID_WORLDWIDE, needed for underlines
|
||||
// modeWrapEOL = uint32(0x0002)
|
||||
)
|
||||
|
||||
func (s *cScreen) setInMode(mode uint32) {
|
||||
@@ -1287,9 +1201,7 @@ func (s *cScreen) SetStyle(style Style) {
|
||||
func (s *cScreen) SetTitle(title string) {
|
||||
s.Lock()
|
||||
s.title = title
|
||||
if s.vten {
|
||||
s.emitVtString(fmt.Sprintf(vtSetTitle, title))
|
||||
}
|
||||
s.emitVtString(fmt.Sprintf(vtSetTitle, title))
|
||||
s.Unlock()
|
||||
}
|
||||
|
||||
@@ -1320,43 +1232,8 @@ func (s *cScreen) GetClipboard() {
|
||||
|
||||
func (s *cScreen) Resize(int, int, int, int) {}
|
||||
|
||||
func (s *cScreen) HasKey(k Key) bool {
|
||||
// Microsoft has codes for some keys, but they are unusual,
|
||||
// so we don't include them. We include all the typical
|
||||
// 101, 105 key layout keys.
|
||||
valid := map[Key]bool{
|
||||
KeyBackspace: true,
|
||||
KeyTab: true,
|
||||
KeyEscape: true,
|
||||
KeyPause: true,
|
||||
KeyPrint: true,
|
||||
KeyPgUp: true,
|
||||
KeyPgDn: true,
|
||||
KeyEnter: true,
|
||||
KeyEnd: true,
|
||||
KeyHome: true,
|
||||
KeyLeft: true,
|
||||
KeyUp: true,
|
||||
KeyRight: true,
|
||||
KeyDown: true,
|
||||
KeyInsert: true,
|
||||
KeyDelete: true,
|
||||
KeyF1: true,
|
||||
KeyF2: true,
|
||||
KeyF3: true,
|
||||
KeyF4: true,
|
||||
KeyF5: true,
|
||||
KeyF6: true,
|
||||
KeyF7: true,
|
||||
KeyF8: true,
|
||||
KeyF9: true,
|
||||
KeyF10: true,
|
||||
KeyF11: true,
|
||||
KeyF12: true,
|
||||
KeyRune: true,
|
||||
}
|
||||
|
||||
return valid[k]
|
||||
func (s *cScreen) HasKey(_ Key) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (s *cScreen) Beep() error {
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// Copyright 2025 The TCell Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use file except in compliance with the License.
|
||||
// You may obtain a copy of the license at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package tcell
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/rivo/uniseg"
|
||||
)
|
||||
|
||||
func init() {
|
||||
if rw := strings.ToLower(os.Getenv("RUNEWIDTH_EASTASIAN")); rw == "1" || rw == "true" || rw == "yes" {
|
||||
uniseg.EastAsianAmbiguousWidth = 2
|
||||
} else {
|
||||
uniseg.EastAsianAmbiguousWidth = 1
|
||||
}
|
||||
}
|
||||
+944
@@ -0,0 +1,944 @@
|
||||
// Copyright 2025 The TCell Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use file except in compliance with the License.
|
||||
// You may obtain a copy of the license at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// This file describes a generic VT input processor. It parses key sequences,
|
||||
// (input bytes) and loads them into events. It expects UTF-8 or UTF-16 as the input
|
||||
// feed, along with ECMA-48 sequences. The assumption here is that all potential
|
||||
// key sequences are unambiguous between terminal variants (analysis of extant terminfo
|
||||
// data appears to support this conjecture). This allows us to implement this once,
|
||||
// in the most efficient and terminal-agnostic way possible.
|
||||
//
|
||||
// There is unfortunately *one* conflict, with aixterm, for CSI-P - which is KeyDelete
|
||||
// in aixterm, but F1 in others.
|
||||
|
||||
package tcell
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
"unicode/utf16"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
type inpState int
|
||||
|
||||
const (
|
||||
inpStateInit = inpState(iota)
|
||||
inpStateUtf
|
||||
inpStateEsc
|
||||
inpStateCsi // control sequence introducer
|
||||
inpStateOsc // operating system command
|
||||
inpStateDcs // device control string
|
||||
inpStateSos // start of string (unused)
|
||||
inpStatePm // privacy message (unused)
|
||||
inpStateApc // application program command
|
||||
inpStateSt // string terminator
|
||||
inpStateSs2 // single shift 2
|
||||
inpStateSs3 // single shift 3
|
||||
inpStateLFK // linux F-key (not ECMA-48 compliant - bogus CSI)
|
||||
)
|
||||
|
||||
type InputProcessor interface {
|
||||
ScanUTF8([]byte)
|
||||
ScanUTF16([]uint16)
|
||||
SetSize(rows, cols int)
|
||||
}
|
||||
|
||||
func NewInputProcessor(eq chan<- Event) InputProcessor {
|
||||
return &inputProcessor{
|
||||
evch: eq,
|
||||
buf: make([]rune, 0, 128),
|
||||
}
|
||||
}
|
||||
|
||||
type inputProcessor struct {
|
||||
ut8 []byte
|
||||
ut16 []uint16
|
||||
buf []rune
|
||||
scratch []byte
|
||||
csiParams []byte
|
||||
csiInterm []byte
|
||||
escaped bool
|
||||
btnDown bool // mouse button tracking for broken terms
|
||||
state inpState
|
||||
strState inpState // saved str state (needed for ST)
|
||||
timer *time.Timer
|
||||
expire time.Time
|
||||
l sync.Mutex
|
||||
encBuf []rune
|
||||
evch chan<- Event
|
||||
rows int // used for clipping mouse coordinates
|
||||
cols int // used for clipping mouse coordinates
|
||||
surrogate rune
|
||||
nested *inputProcessor
|
||||
}
|
||||
|
||||
func (ip *inputProcessor) SetSize(w, h int) {
|
||||
if ip.nested != nil {
|
||||
ip.nested.SetSize(w, h)
|
||||
return
|
||||
}
|
||||
go func() {
|
||||
ip.l.Lock()
|
||||
ip.rows = h
|
||||
ip.cols = w
|
||||
ip.post(NewEventResize(w, h))
|
||||
ip.l.Unlock()
|
||||
}()
|
||||
}
|
||||
func (ip *inputProcessor) post(ev Event) {
|
||||
if ip.escaped {
|
||||
ip.escaped = false
|
||||
if ke, ok := ev.(*EventKey); ok {
|
||||
ev = NewEventKey(ke.Key(), ke.Rune(), ke.Modifiers()|ModAlt)
|
||||
}
|
||||
} else if ke, ok := ev.(*EventKey); ok {
|
||||
switch ke.Key() {
|
||||
case keyPasteStart:
|
||||
ev = NewEventPaste(true)
|
||||
case keyPasteEnd:
|
||||
ev = NewEventPaste(false)
|
||||
}
|
||||
}
|
||||
|
||||
ip.evch <- ev
|
||||
}
|
||||
|
||||
func (ip *inputProcessor) escTimeout() {
|
||||
ip.l.Lock()
|
||||
defer ip.l.Unlock()
|
||||
if ip.state == inpStateEsc && ip.expire.Before(time.Now()) {
|
||||
// post it
|
||||
ip.state = inpStateInit
|
||||
ip.escaped = false
|
||||
ip.post(NewEventKey(KeyEsc, 0, ModNone))
|
||||
}
|
||||
}
|
||||
|
||||
type csiParamMode struct {
|
||||
M rune // Mode
|
||||
P int // Parameter (first)
|
||||
}
|
||||
|
||||
type keyMap struct {
|
||||
Key Key
|
||||
Mod ModMask
|
||||
Rune rune
|
||||
}
|
||||
|
||||
var csiAllKeys = map[csiParamMode]keyMap{
|
||||
{M: 'A'}: {Key: KeyUp},
|
||||
{M: 'B'}: {Key: KeyDown},
|
||||
{M: 'C'}: {Key: KeyRight},
|
||||
{M: 'D'}: {Key: KeyLeft},
|
||||
{M: 'F'}: {Key: KeyEnd},
|
||||
{M: 'H'}: {Key: KeyHome},
|
||||
{M: 'L'}: {Key: KeyInsert},
|
||||
{M: 'P'}: {Key: KeyF1}, // except for aixterm, where this is Delete
|
||||
{M: 'Q'}: {Key: KeyF2},
|
||||
{M: 'S'}: {Key: KeyF4},
|
||||
{M: 'Z'}: {Key: KeyBacktab},
|
||||
{M: 'a'}: {Key: KeyUp, Mod: ModShift},
|
||||
{M: 'b'}: {Key: KeyDown, Mod: ModShift},
|
||||
{M: 'c'}: {Key: KeyRight, Mod: ModShift},
|
||||
{M: 'd'}: {Key: KeyLeft, Mod: ModShift},
|
||||
{M: 'q', P: 1}: {Key: KeyF1}, // all these 'q' are for aixterm
|
||||
{M: 'q', P: 2}: {Key: KeyF2},
|
||||
{M: 'q', P: 3}: {Key: KeyF3},
|
||||
{M: 'q', P: 4}: {Key: KeyF4},
|
||||
{M: 'q', P: 5}: {Key: KeyF5},
|
||||
{M: 'q', P: 6}: {Key: KeyF6},
|
||||
{M: 'q', P: 7}: {Key: KeyF7},
|
||||
{M: 'q', P: 8}: {Key: KeyF8},
|
||||
{M: 'q', P: 9}: {Key: KeyF9},
|
||||
{M: 'q', P: 10}: {Key: KeyF10},
|
||||
{M: 'q', P: 11}: {Key: KeyF11},
|
||||
{M: 'q', P: 12}: {Key: KeyF12},
|
||||
{M: 'q', P: 13}: {Key: KeyF13},
|
||||
{M: 'q', P: 14}: {Key: KeyF14},
|
||||
{M: 'q', P: 15}: {Key: KeyF15},
|
||||
{M: 'q', P: 16}: {Key: KeyF16},
|
||||
{M: 'q', P: 17}: {Key: KeyF17},
|
||||
{M: 'q', P: 18}: {Key: KeyF18},
|
||||
{M: 'q', P: 19}: {Key: KeyF19},
|
||||
{M: 'q', P: 20}: {Key: KeyF20},
|
||||
{M: 'q', P: 21}: {Key: KeyF21},
|
||||
{M: 'q', P: 22}: {Key: KeyF22},
|
||||
{M: 'q', P: 23}: {Key: KeyF23},
|
||||
{M: 'q', P: 24}: {Key: KeyF24},
|
||||
{M: 'q', P: 25}: {Key: KeyF25},
|
||||
{M: 'q', P: 26}: {Key: KeyF26},
|
||||
{M: 'q', P: 27}: {Key: KeyF27},
|
||||
{M: 'q', P: 28}: {Key: KeyF28},
|
||||
{M: 'q', P: 29}: {Key: KeyF29},
|
||||
{M: 'q', P: 30}: {Key: KeyF30},
|
||||
{M: 'q', P: 31}: {Key: KeyF31},
|
||||
{M: 'q', P: 32}: {Key: KeyF32},
|
||||
{M: 'q', P: 33}: {Key: KeyF33},
|
||||
{M: 'q', P: 34}: {Key: KeyF34},
|
||||
{M: 'q', P: 35}: {Key: KeyF35},
|
||||
{M: 'q', P: 36}: {Key: KeyF36},
|
||||
{M: 'q', P: 144}: {Key: KeyClear},
|
||||
{M: 'q', P: 146}: {Key: KeyEnd},
|
||||
{M: 'q', P: 150}: {Key: KeyPgUp},
|
||||
{M: 'q', P: 154}: {Key: KeyPgDn},
|
||||
{M: 'z', P: 214}: {Key: KeyHome},
|
||||
{M: 'z', P: 216}: {Key: KeyPgUp},
|
||||
{M: 'z', P: 220}: {Key: KeyEnd},
|
||||
{M: 'z', P: 222}: {Key: KeyPgDn},
|
||||
{M: 'z', P: 224}: {Key: KeyF1},
|
||||
{M: 'z', P: 225}: {Key: KeyF2},
|
||||
{M: 'z', P: 226}: {Key: KeyF3},
|
||||
{M: 'z', P: 227}: {Key: KeyF4},
|
||||
{M: 'z', P: 228}: {Key: KeyF5},
|
||||
{M: 'z', P: 229}: {Key: KeyF6},
|
||||
{M: 'z', P: 230}: {Key: KeyF7},
|
||||
{M: 'z', P: 231}: {Key: KeyF8},
|
||||
{M: 'z', P: 232}: {Key: KeyF9},
|
||||
{M: 'z', P: 233}: {Key: KeyF10},
|
||||
{M: 'z', P: 234}: {Key: KeyF11},
|
||||
{M: 'z', P: 235}: {Key: KeyF12},
|
||||
{M: 'z', P: 247}: {Key: KeyInsert},
|
||||
{M: '^', P: 7}: {Key: KeyHome, Mod: ModCtrl},
|
||||
{M: '^', P: 8}: {Key: KeyEnd, Mod: ModCtrl},
|
||||
{M: '^', P: 11}: {Key: KeyF23},
|
||||
{M: '^', P: 12}: {Key: KeyF24},
|
||||
{M: '^', P: 13}: {Key: KeyF25},
|
||||
{M: '^', P: 14}: {Key: KeyF26},
|
||||
{M: '^', P: 15}: {Key: KeyF27},
|
||||
{M: '^', P: 17}: {Key: KeyF28}, // 16 is a gap
|
||||
{M: '^', P: 18}: {Key: KeyF29},
|
||||
{M: '^', P: 19}: {Key: KeyF30},
|
||||
{M: '^', P: 20}: {Key: KeyF31},
|
||||
{M: '^', P: 21}: {Key: KeyF32},
|
||||
{M: '^', P: 23}: {Key: KeyF33}, // 22 is a gap
|
||||
{M: '^', P: 24}: {Key: KeyF34},
|
||||
{M: '^', P: 25}: {Key: KeyF35},
|
||||
{M: '^', P: 26}: {Key: KeyF36}, // 27 is a gap
|
||||
{M: '^', P: 28}: {Key: KeyF37},
|
||||
{M: '^', P: 29}: {Key: KeyF38}, // 30 is a gap
|
||||
{M: '^', P: 31}: {Key: KeyF39},
|
||||
{M: '^', P: 32}: {Key: KeyF40},
|
||||
{M: '^', P: 33}: {Key: KeyF41},
|
||||
{M: '^', P: 34}: {Key: KeyF42},
|
||||
{M: '@', P: 23}: {Key: KeyF43},
|
||||
{M: '@', P: 24}: {Key: KeyF44},
|
||||
{M: '$', P: 2}: {Key: KeyInsert, Mod: ModShift},
|
||||
{M: '$', P: 3}: {Key: KeyDelete, Mod: ModShift},
|
||||
{M: '$', P: 7}: {Key: KeyHome, Mod: ModShift},
|
||||
{M: '$', P: 8}: {Key: KeyEnd, Mod: ModShift},
|
||||
{M: '$', P: 23}: {Key: KeyF21},
|
||||
{M: '$', P: 24}: {Key: KeyF22},
|
||||
{M: '~', P: 1}: {Key: KeyHome},
|
||||
{M: '~', P: 2}: {Key: KeyInsert},
|
||||
{M: '~', P: 3}: {Key: KeyDelete},
|
||||
{M: '~', P: 4}: {Key: KeyEnd},
|
||||
{M: '~', P: 5}: {Key: KeyPgUp},
|
||||
{M: '~', P: 6}: {Key: KeyPgDn},
|
||||
{M: '~', P: 7}: {Key: KeyHome},
|
||||
{M: '~', P: 8}: {Key: KeyEnd},
|
||||
{M: '~', P: 11}: {Key: KeyF1},
|
||||
{M: '~', P: 12}: {Key: KeyF2},
|
||||
{M: '~', P: 13}: {Key: KeyF3},
|
||||
{M: '~', P: 14}: {Key: KeyF4},
|
||||
{M: '~', P: 15}: {Key: KeyF5},
|
||||
{M: '~', P: 17}: {Key: KeyF6},
|
||||
{M: '~', P: 18}: {Key: KeyF7},
|
||||
{M: '~', P: 19}: {Key: KeyF8},
|
||||
{M: '~', P: 20}: {Key: KeyF9},
|
||||
{M: '~', P: 21}: {Key: KeyF10},
|
||||
{M: '~', P: 23}: {Key: KeyF11},
|
||||
{M: '~', P: 24}: {Key: KeyF12},
|
||||
{M: '~', P: 25}: {Key: KeyF13},
|
||||
{M: '~', P: 26}: {Key: KeyF14},
|
||||
{M: '~', P: 28}: {Key: KeyF15}, // aka KeyHelp
|
||||
{M: '~', P: 29}: {Key: KeyF16},
|
||||
{M: '~', P: 31}: {Key: KeyF17},
|
||||
{M: '~', P: 32}: {Key: KeyF18},
|
||||
{M: '~', P: 33}: {Key: KeyF19},
|
||||
{M: '~', P: 34}: {Key: KeyF20},
|
||||
{M: '~', P: 200}: {Key: keyPasteStart},
|
||||
{M: '~', P: 201}: {Key: keyPasteEnd},
|
||||
}
|
||||
|
||||
// keys reported using Kitty csi-u protocol
|
||||
var csiUKeys = map[int]keyMap{
|
||||
27: {Key: KeyESC},
|
||||
9: {Key: KeyTAB},
|
||||
13: {Key: KeyEnter},
|
||||
127: {Key: KeyBS},
|
||||
57358: {Key: KeyCapsLock},
|
||||
57359: {Key: KeyScrollLock},
|
||||
57360: {Key: KeyNumLock},
|
||||
57361: {Key: KeyPrint},
|
||||
57362: {Key: KeyPause},
|
||||
57363: {Key: KeyMenu},
|
||||
57376: {Key: KeyF13},
|
||||
57377: {Key: KeyF14},
|
||||
57378: {Key: KeyF15},
|
||||
57379: {Key: KeyF16},
|
||||
57380: {Key: KeyF17},
|
||||
57381: {Key: KeyF18},
|
||||
57382: {Key: KeyF19},
|
||||
57383: {Key: KeyF20},
|
||||
57384: {Key: KeyF21},
|
||||
57385: {Key: KeyF22},
|
||||
57386: {Key: KeyF23},
|
||||
57387: {Key: KeyF24},
|
||||
57388: {Key: KeyF25},
|
||||
57389: {Key: KeyF26},
|
||||
57390: {Key: KeyF27},
|
||||
57391: {Key: KeyF28},
|
||||
57392: {Key: KeyF29},
|
||||
57393: {Key: KeyF30},
|
||||
57394: {Key: KeyF31},
|
||||
57395: {Key: KeyF32},
|
||||
57396: {Key: KeyF33},
|
||||
57397: {Key: KeyF34},
|
||||
57398: {Key: KeyF35},
|
||||
57399: {Key: KeyRune, Rune: '0'}, // KP 0
|
||||
57400: {Key: KeyRune, Rune: '1'}, // KP 1
|
||||
57401: {Key: KeyRune, Rune: '2'}, // KP 2
|
||||
57402: {Key: KeyRune, Rune: '3'}, // KP 3
|
||||
57403: {Key: KeyRune, Rune: '4'}, // KP 4
|
||||
57404: {Key: KeyRune, Rune: '5'}, // KP 5
|
||||
57405: {Key: KeyRune, Rune: '6'}, // KP 6
|
||||
57406: {Key: KeyRune, Rune: '7'}, // KP 7
|
||||
57407: {Key: KeyRune, Rune: '8'}, // KP 8
|
||||
57408: {Key: KeyRune, Rune: '9'}, // KP 9
|
||||
57409: {Key: KeyRune, Rune: '.'}, // KP_DECIMAL
|
||||
57410: {Key: KeyRune, Rune: '/'}, // KP_DIVIDE
|
||||
57411: {Key: KeyRune, Rune: '*'}, // KP_MULTIPLY
|
||||
57412: {Key: KeyRune, Rune: '-'}, // KP_SUBTRACT
|
||||
57413: {Key: KeyRune, Rune: '+'}, // KP_ADD
|
||||
57414: {Key: KeyEnter}, // KP_ENTER
|
||||
57415: {Key: KeyRune, Rune: '='}, // KP_EQUAL
|
||||
57416: {Key: KeyClear}, // KP_SEPARATOR
|
||||
57417: {Key: KeyLeft}, // KP_LEFT
|
||||
57418: {Key: KeyRight}, // KP_RIGHT
|
||||
57419: {Key: KeyUp}, // KP_UP
|
||||
57420: {Key: KeyDown}, // KP_DOWN
|
||||
57421: {Key: KeyPgUp}, // KP_PG_UP
|
||||
57422: {Key: KeyPgDn}, // KP_PG_DN
|
||||
57423: {Key: KeyHome}, // KP_HOME
|
||||
57424: {Key: KeyEnd}, // KP_END
|
||||
57425: {Key: KeyInsert}, // KP_INSERT
|
||||
57426: {Key: KeyDelete}, // KP_DELETE
|
||||
// 57427: {Key: KeyBegin}, // KP_BEGIN
|
||||
|
||||
// TODO: Media keys
|
||||
}
|
||||
|
||||
// windows virtual key codes per microsoft
|
||||
var winKeys = map[int]Key{
|
||||
0x03: KeyCancel, // vkCancel
|
||||
0x08: KeyBackspace, // vkBackspace
|
||||
0x09: KeyTab, // vkTab
|
||||
0x0c: KeyClear, // vClear
|
||||
0x0d: KeyEnter, // vkReturn
|
||||
0x13: KeyPause, // vkPause
|
||||
0x1b: KeyEscape, // vkEscape
|
||||
0x21: KeyPgUp, // vkPrior
|
||||
0x22: KeyPgDn, // vkNext
|
||||
0x23: KeyEnd, // vkEnd
|
||||
0x24: KeyHome, // vkHome
|
||||
0x25: KeyLeft, // vkLeft
|
||||
0x26: KeyUp, // vkUp
|
||||
0x27: KeyRight, // vkRight
|
||||
0x28: KeyDown, // vkDown
|
||||
0x2a: KeyPrint, // vkPrint
|
||||
0x2c: KeyPrint, // vkPrtScr
|
||||
0x2d: KeyInsert, // vkInsert
|
||||
0x2e: KeyDelete, // vkDelete
|
||||
0x2f: KeyHelp, // vkHelp
|
||||
0x70: KeyF1, // vkF1
|
||||
0x71: KeyF2, // vkF2
|
||||
0x72: KeyF3, // vkF3
|
||||
0x73: KeyF4, // vkF4
|
||||
0x74: KeyF5, // vkF5
|
||||
0x75: KeyF6, // vkF6
|
||||
0x76: KeyF7, // vkF7
|
||||
0x77: KeyF8, // vkF8
|
||||
0x78: KeyF9, // vkF9
|
||||
0x79: KeyF10, // vkF10
|
||||
0x7a: KeyF11, // vkF11
|
||||
0x7b: KeyF12, // vkF12
|
||||
0x7c: KeyF13, // vkF13
|
||||
0x7d: KeyF14, // vkF14
|
||||
0x7e: KeyF15, // vkF15
|
||||
0x7f: KeyF16, // vkF16
|
||||
0x80: KeyF17, // vkF17
|
||||
0x81: KeyF18, // vkF18
|
||||
0x82: KeyF19, // vkF19
|
||||
0x83: KeyF20, // vkF20
|
||||
0x84: KeyF21, // vkF21
|
||||
0x85: KeyF22, // vkF22
|
||||
0x86: KeyF23, // vkF23
|
||||
0x87: KeyF24, // vkF24
|
||||
}
|
||||
|
||||
// keys by their SS3 - used in application mode usually (legacy VT-style)
|
||||
var ss3Keys = map[rune]Key{
|
||||
'A': KeyUp,
|
||||
'B': KeyDown,
|
||||
'C': KeyRight,
|
||||
'D': KeyLeft,
|
||||
'F': KeyEnd,
|
||||
'H': KeyHome,
|
||||
'P': KeyF1,
|
||||
'Q': KeyF2,
|
||||
'R': KeyF3,
|
||||
'S': KeyF4,
|
||||
't': KeyF5,
|
||||
'u': KeyF6,
|
||||
'v': KeyF7,
|
||||
'l': KeyF8,
|
||||
'w': KeyF9,
|
||||
'x': KeyF10,
|
||||
}
|
||||
|
||||
// linux terminal uses these non ECMA keys prefixed by CSI-[
|
||||
var linuxFKeys = map[rune]Key{
|
||||
'A': KeyF1,
|
||||
'B': KeyF2,
|
||||
'C': KeyF3,
|
||||
'D': KeyF4,
|
||||
'E': KeyF5,
|
||||
}
|
||||
|
||||
func (ip *inputProcessor) scan() {
|
||||
for _, r := range ip.buf {
|
||||
ip.buf = ip.buf[1:]
|
||||
if r > 0x7F {
|
||||
// 8-bit extended Unicode we just treat as such - this will swallow anything else queued up
|
||||
ip.state = inpStateInit
|
||||
ip.post(NewEventKey(KeyRune, r, ModNone))
|
||||
continue
|
||||
}
|
||||
switch ip.state {
|
||||
case inpStateInit:
|
||||
switch r {
|
||||
case '\x1b':
|
||||
// escape.. pending
|
||||
ip.state = inpStateEsc
|
||||
if len(ip.buf) == 0 && ip.nested == nil {
|
||||
ip.expire = time.Now().Add(time.Millisecond * 50)
|
||||
ip.timer = time.AfterFunc(time.Millisecond*60, ip.escTimeout)
|
||||
}
|
||||
case '\t':
|
||||
ip.post(NewEventKey(KeyTab, 0, ModNone))
|
||||
case '\b', '\x7F':
|
||||
ip.post(NewEventKey(KeyBackspace, 0, ModNone))
|
||||
case '\r':
|
||||
ip.post(NewEventKey(KeyEnter, 0, ModNone))
|
||||
default:
|
||||
// Control keys - legacy handling
|
||||
if r < ' ' {
|
||||
ip.post(NewEventKey(KeyCtrlSpace+Key(r), 0, ModCtrl))
|
||||
} else {
|
||||
ip.post(NewEventKey(KeyRune, r, ModNone))
|
||||
}
|
||||
}
|
||||
case inpStateEsc:
|
||||
switch r {
|
||||
case '[':
|
||||
ip.state = inpStateCsi
|
||||
ip.csiInterm = nil
|
||||
ip.csiParams = nil
|
||||
case ']':
|
||||
ip.state = inpStateOsc
|
||||
ip.scratch = nil
|
||||
case 'N':
|
||||
ip.state = inpStateSs2 // no known uses
|
||||
ip.scratch = nil
|
||||
case 'O':
|
||||
ip.state = inpStateSs3
|
||||
ip.scratch = nil
|
||||
case 'X':
|
||||
ip.state = inpStateSos
|
||||
ip.scratch = nil
|
||||
case '^':
|
||||
ip.state = inpStatePm
|
||||
ip.scratch = nil
|
||||
case '_':
|
||||
ip.state = inpStateApc
|
||||
ip.scratch = nil
|
||||
case '\\':
|
||||
// string terminator reached, (orphaned?)
|
||||
ip.state = inpStateInit
|
||||
case '\t':
|
||||
// Linux console only, does not conform to ECMA
|
||||
ip.state = inpStateInit
|
||||
ip.post(NewEventKey(KeyBacktab, 0, ModNone))
|
||||
default:
|
||||
if r == '\x1b' {
|
||||
// leading ESC to capture alt
|
||||
ip.escaped = true
|
||||
} else {
|
||||
// treat as alt-key ... legacy emulators only (no CSI-u or other)
|
||||
ip.state = inpStateInit
|
||||
mod := ModAlt
|
||||
if r < ' ' {
|
||||
mod |= ModCtrl
|
||||
r += 0x60
|
||||
}
|
||||
ip.post(NewEventKey(KeyRune, r, mod))
|
||||
}
|
||||
}
|
||||
case inpStateCsi:
|
||||
// usual case for incoming keys
|
||||
if r == '\x1b' {
|
||||
// Per ECMA-48 §5.3.1, ESC restarts the escape
|
||||
// sequence machine from any intermediate state.
|
||||
ip.state = inpStateEsc
|
||||
if len(ip.buf) == 0 && ip.nested == nil {
|
||||
ip.expire = time.Now().Add(time.Millisecond * 50)
|
||||
ip.timer = time.AfterFunc(time.Millisecond*60, ip.escTimeout)
|
||||
}
|
||||
} else if r >= 0x30 && r <= 0x3F { // parameter bytes
|
||||
ip.csiParams = append(ip.csiParams, byte(r))
|
||||
} else if r >= 0x20 && r <= 0x2F { // intermediate bytes, rarely used
|
||||
ip.csiInterm = append(ip.csiInterm, byte(r))
|
||||
} else if r >= 0x40 && r <= 0x7F { // final byte
|
||||
ip.handleCsi(r, ip.csiParams, ip.csiInterm)
|
||||
} else {
|
||||
// bad parse, just swallow it all
|
||||
ip.state = inpStateInit
|
||||
}
|
||||
case inpStateSs2:
|
||||
// No known uses for SS2
|
||||
ip.state = inpStateInit
|
||||
|
||||
case inpStateSs3: // typically application mode keys or older terminals
|
||||
ip.state = inpStateInit
|
||||
if r == '\x1b' {
|
||||
// Per ECMA-48 §5.3.1, ESC restarts the escape
|
||||
// sequence machine from any intermediate state.
|
||||
ip.state = inpStateEsc
|
||||
if len(ip.buf) == 0 && ip.nested == nil {
|
||||
ip.expire = time.Now().Add(time.Millisecond * 50)
|
||||
ip.timer = time.AfterFunc(time.Millisecond*60, ip.escTimeout)
|
||||
}
|
||||
} else if k, ok := ss3Keys[r]; ok {
|
||||
ip.post(NewEventKey(k, 0, ModNone))
|
||||
}
|
||||
|
||||
case inpStatePm, inpStateApc, inpStateSos, inpStateDcs: // these we just eat
|
||||
switch r {
|
||||
case '\x1b':
|
||||
ip.strState = ip.state
|
||||
ip.state = inpStateSt
|
||||
case '\x07': // bell - some send this instead of ST
|
||||
ip.state = inpStateInit
|
||||
}
|
||||
|
||||
case inpStateOsc: // not sure if used
|
||||
switch r {
|
||||
case '\x1b':
|
||||
ip.strState = ip.state
|
||||
ip.state = inpStateSt
|
||||
case '\x07':
|
||||
ip.handleOsc(string(ip.scratch))
|
||||
default:
|
||||
ip.scratch = append(ip.scratch, byte(r&0x7f))
|
||||
}
|
||||
case inpStateSt:
|
||||
if r == '\\' || r == '\x07' {
|
||||
ip.state = inpStateInit
|
||||
switch ip.strState {
|
||||
case inpStateOsc:
|
||||
ip.handleOsc(string(ip.scratch))
|
||||
case inpStatePm, inpStateApc, inpStateSos, inpStateDcs:
|
||||
ip.state = inpStateInit
|
||||
}
|
||||
} else {
|
||||
ip.scratch = append(ip.scratch, '\x1b', byte(r))
|
||||
ip.state = ip.strState
|
||||
}
|
||||
case inpStateLFK:
|
||||
// linux console does not follow ECMA
|
||||
if k, ok := linuxFKeys[r]; ok {
|
||||
ip.post(NewEventKey(k, 0, ModNone))
|
||||
}
|
||||
ip.state = inpStateInit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (ip *inputProcessor) handleOsc(str string) {
|
||||
ip.state = inpStateInit
|
||||
if content, ok := strings.CutPrefix(str, "52;c;"); ok {
|
||||
decoded := make([]byte, base64.StdEncoding.DecodedLen(len(content)))
|
||||
if count, err := base64.StdEncoding.Decode(decoded, []byte(content)); err == nil {
|
||||
ip.post(NewEventClipboard(decoded[:count]))
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func calcModifier(n int) ModMask {
|
||||
n--
|
||||
m := ModNone
|
||||
if n&1 != 0 {
|
||||
m |= ModShift
|
||||
}
|
||||
if n&2 != 0 {
|
||||
m |= ModAlt
|
||||
}
|
||||
if n&4 != 0 {
|
||||
m |= ModCtrl
|
||||
}
|
||||
if n&8 != 0 {
|
||||
m |= ModMeta // kitty calls this Super
|
||||
}
|
||||
if n&16 != 0 {
|
||||
m |= ModHyper
|
||||
}
|
||||
if n&32 != 0 {
|
||||
m |= ModMeta // for now not separating from Super
|
||||
}
|
||||
// Not doing (kitty only):
|
||||
// caps_lock 0b1000000 (64)
|
||||
// num_lock 0b10000000 (128)
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
// func (ip *inputProcessor) handleMouse(x, y, btn int, down bool) *EventMouse {
|
||||
func (ip *inputProcessor) handleMouse(mode rune, params []int) {
|
||||
|
||||
// XTerm mouse events only report at most one button at a time,
|
||||
// which may include a wheel button. Wheel motion events are
|
||||
// reported as single impulses, while other button events are reported
|
||||
// as separate press & release events.
|
||||
if len(params) < 3 {
|
||||
return
|
||||
}
|
||||
btn := params[0]
|
||||
// Some terminals will report mouse coordinates outside the
|
||||
// screen, especially with click-drag events. Clip the coordinates
|
||||
// to the screen in that case.
|
||||
x := max(min(params[1]-1, ip.cols-1), 0)
|
||||
y := max(min(params[2]-1, ip.rows-1), 0)
|
||||
motion := (btn & 0x20) != 0
|
||||
scroll := (btn & 0x42) == 0x40
|
||||
btn &^= 0x20
|
||||
if mode == 'm' {
|
||||
// mouse release, clear all buttons
|
||||
btn |= 3
|
||||
btn &^= 0x40
|
||||
ip.btnDown = false
|
||||
} else if motion {
|
||||
/*
|
||||
* Some broken terminals appear to send
|
||||
* mouse button one motion events, instead of
|
||||
* encoding 35 (no buttons) into these events.
|
||||
* We resolve these by looking for a non-motion
|
||||
* event first.
|
||||
*/
|
||||
if !ip.btnDown {
|
||||
btn |= 3
|
||||
btn &^= 0x40
|
||||
}
|
||||
} else if !scroll {
|
||||
ip.btnDown = true
|
||||
}
|
||||
|
||||
button := ButtonNone
|
||||
mod := ModNone
|
||||
|
||||
// Mouse wheel has bit 6 set, no release events. It should be noted
|
||||
// that wheel events are sometimes misdelivered as mouse button events
|
||||
// during a click-drag, so we debounce these, considering them to be
|
||||
// button press events unless we see an intervening release event.
|
||||
switch btn & 0x43 {
|
||||
case 0:
|
||||
button = Button1
|
||||
case 1:
|
||||
button = Button3 // Note we prefer to treat right as button 2
|
||||
case 2:
|
||||
button = Button2 // And the middle button as button 3
|
||||
case 3:
|
||||
button = ButtonNone
|
||||
case 0x40:
|
||||
button = WheelUp
|
||||
case 0x41:
|
||||
button = WheelDown
|
||||
case 0x42:
|
||||
button = WheelLeft
|
||||
case 0x43:
|
||||
button = WheelRight
|
||||
}
|
||||
|
||||
if btn&0x4 != 0 {
|
||||
mod |= ModShift
|
||||
}
|
||||
if btn&0x8 != 0 {
|
||||
mod |= ModAlt
|
||||
}
|
||||
if btn&0x10 != 0 {
|
||||
mod |= ModCtrl
|
||||
}
|
||||
|
||||
ip.post(NewEventMouse(x, y, button, mod))
|
||||
}
|
||||
|
||||
func (ip *inputProcessor) handleWinKey(P []int) {
|
||||
// win32-input-mode
|
||||
// ^[ [ Vk ; Sc ; Uc ; Kd ; Cs ; Rc _
|
||||
// Vk: the value of wVirtualKeyCode - any number. If omitted, defaults to '0'.
|
||||
// Sc: the value of wVirtualScanCode - any number. If omitted, defaults to '0'.
|
||||
// Uc: the decimal value of UnicodeChar - for example, NUL is "0", LF is
|
||||
// "10", the character 'A' is "65". If omitted, defaults to '0'.
|
||||
// Kd: the value of bKeyDown - either a '0' or '1'. If omitted, defaults to '0'.
|
||||
// Cs: the value of dwControlKeyState - any number. If omitted, defaults to '0'.
|
||||
// Rc: the value of wRepeatCount - any number. If omitted, defaults to '1'.
|
||||
//
|
||||
// Note that some 3rd party terminal emulators (not Terminal) suffer from a bug
|
||||
// where other events, such as mouse events, are doubly encoded, using Vk 0
|
||||
// for each character. (So a CSI-M sequence is encoded as a series of CSI-_
|
||||
// sequences.) We consider this a bug in those terminal emulators -- Windows 11
|
||||
// Terminal does not suffer this brain damage. (We've observed this with both Alacritty
|
||||
// and WezTerm.)
|
||||
for len(P) < 6 {
|
||||
P = append(P, 0) // ensure sufficient length
|
||||
}
|
||||
if P[3] == 0 {
|
||||
// key up event ignore ignore
|
||||
return
|
||||
}
|
||||
|
||||
if P[0] == 0 && P[1] == 0 && P[2] > 0 && P[2] < 0x80 { // only ASCII in win32-input-mode
|
||||
if ip.nested == nil {
|
||||
ip.nested = &inputProcessor{
|
||||
evch: ip.evch,
|
||||
rows: ip.rows,
|
||||
cols: ip.cols,
|
||||
}
|
||||
}
|
||||
|
||||
ip.nested.ScanUTF8([]byte{byte(P[2])})
|
||||
return
|
||||
}
|
||||
|
||||
key := KeyRune
|
||||
chr := rune(P[2])
|
||||
mod := ModNone
|
||||
rpt := max(1, P[5])
|
||||
if k1, ok := winKeys[P[0]]; ok {
|
||||
chr = 0
|
||||
key = k1
|
||||
} else if chr == 0 && P[0] >= 0x30 && P[0] <= 0x39 {
|
||||
chr = rune(P[0])
|
||||
} else if chr < ' ' && P[0] >= 0x41 && P[0] <= 0x5a {
|
||||
key = Key(P[0])
|
||||
chr = 0
|
||||
|
||||
} else if chr >= 0xD800 && chr <= 0xDBFF {
|
||||
// high surrogate pair
|
||||
ip.surrogate = chr
|
||||
return
|
||||
} else if chr >= 0xDC00 && chr <= 0xDFFF {
|
||||
// low surrogate pair
|
||||
chr = utf16.DecodeRune(ip.surrogate, chr)
|
||||
} else if P[0] == 0x10 || P[0] == 0x11 || P[0] == 0x12 || P[0] == 0x14 {
|
||||
// lone modifiers
|
||||
ip.surrogate = 0
|
||||
return
|
||||
}
|
||||
|
||||
ip.surrogate = 0
|
||||
|
||||
// Modifiers
|
||||
if P[4]&0x010 != 0 {
|
||||
mod |= ModShift
|
||||
}
|
||||
if P[4]&0x000c != 0 {
|
||||
mod |= ModCtrl
|
||||
}
|
||||
if P[4]&0x0003 != 0 {
|
||||
mod |= ModAlt
|
||||
}
|
||||
if key == KeyRune && chr > ' ' && mod == ModShift {
|
||||
// filter out lone shift for printable chars
|
||||
mod = ModNone
|
||||
}
|
||||
if chr != 0 && mod&(ModCtrl|ModAlt) == ModCtrl|ModAlt {
|
||||
// Filter out ctrl+alt (it means AltGr)
|
||||
mod = ModNone
|
||||
}
|
||||
|
||||
for range rpt {
|
||||
if key != KeyRune || chr != 0 {
|
||||
ip.post(NewEventKey(key, chr, mod))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (ip *inputProcessor) handleCsi(mode rune, params []byte, intermediate []byte) {
|
||||
|
||||
// reset state
|
||||
ip.state = inpStateInit
|
||||
|
||||
if len(intermediate) != 0 {
|
||||
// we don't know what to do with these for now
|
||||
return
|
||||
}
|
||||
|
||||
var parts []string
|
||||
var P []int
|
||||
hasLT := false
|
||||
pstr := string(params)
|
||||
// extract numeric parameters
|
||||
if strings.HasPrefix(pstr, "<") {
|
||||
hasLT = true
|
||||
pstr = pstr[1:]
|
||||
}
|
||||
if pstr != "" && pstr[0] >= '0' && pstr[0] <= '9' {
|
||||
parts = strings.Split(pstr, ";")
|
||||
for i := range parts {
|
||||
if parts[i] != "" {
|
||||
if n, e := strconv.ParseInt(parts[i], 10, 32); e == nil {
|
||||
P = append(P, int(n))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var P0 int
|
||||
if len(P) > 0 {
|
||||
P0 = P[0]
|
||||
}
|
||||
|
||||
if hasLT {
|
||||
switch mode {
|
||||
case 'm', 'M': // mouse event, we only do SGR tracking
|
||||
ip.handleMouse(mode, P)
|
||||
}
|
||||
}
|
||||
|
||||
switch mode {
|
||||
case 'I': // focus in
|
||||
ip.post(NewEventFocus(true))
|
||||
return
|
||||
case 'O': // focus out
|
||||
ip.post(NewEventFocus(false))
|
||||
return
|
||||
case '[':
|
||||
// linux console F-key - CSI-[ modifies next key
|
||||
ip.state = inpStateLFK
|
||||
return
|
||||
case 'u':
|
||||
// CSI-u kitty keyboard protocol
|
||||
if len(P) > 0 && !hasLT {
|
||||
mod := ModNone
|
||||
key := KeyRune
|
||||
chr := rune(0)
|
||||
if k1, ok := csiUKeys[P0]; ok {
|
||||
key = k1.Key
|
||||
chr = k1.Rune
|
||||
} else {
|
||||
chr = rune(P0)
|
||||
}
|
||||
if len(P) > 1 {
|
||||
mod = calcModifier(P[1])
|
||||
}
|
||||
ip.post(NewEventKey(key, chr, mod))
|
||||
}
|
||||
return
|
||||
case '_':
|
||||
if len(intermediate) == 0 && len(P) > 0 {
|
||||
ip.handleWinKey(P)
|
||||
return
|
||||
}
|
||||
case '~':
|
||||
if len(intermediate) == 0 && len(P) >= 2 {
|
||||
mod := calcModifier(P[1])
|
||||
if ks, ok := csiAllKeys[csiParamMode{M: mode, P: P0}]; ok {
|
||||
ip.post(NewEventKey(ks.Key, 0, mod))
|
||||
return
|
||||
}
|
||||
if P0 == 27 && len(P) > 2 && P[2] > 0 && P[2] <= 0xff {
|
||||
if P[2] < ' ' || P[2] == 0x7F {
|
||||
ip.post(NewEventKey(Key(P[2]), 0, mod))
|
||||
} else {
|
||||
ip.post(NewEventKey(KeyRune, rune(P[2]), mod))
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ks, ok := csiAllKeys[csiParamMode{M: mode, P: P0}]; ok && !hasLT {
|
||||
if mode == '~' && len(P) > 1 && ks.Mod == ModNone {
|
||||
// apply modifiers if present
|
||||
ks.Mod = calcModifier(P[1])
|
||||
} else if mode == 'P' && os.Getenv("TERM") == "aixterm" {
|
||||
ks.Key = KeyDelete // aixterm hack - conflicts with kitty protocol
|
||||
}
|
||||
ip.post(NewEventKey(ks.Key, 0, ks.Mod))
|
||||
return
|
||||
}
|
||||
|
||||
// this might have been an SS3 style key with modifiers applied
|
||||
if k, ok := ss3Keys[mode]; ok && P0 == 1 && len(P) > 1 {
|
||||
ip.post(NewEventKey(k, 0, calcModifier(P[1])))
|
||||
return
|
||||
}
|
||||
// if we got here we just swallow the unknown sequence
|
||||
}
|
||||
|
||||
func (ip *inputProcessor) ScanUTF8(b []byte) {
|
||||
ip.l.Lock()
|
||||
defer ip.l.Unlock()
|
||||
|
||||
ip.ut8 = append(ip.ut8, b...)
|
||||
for len(ip.ut8) > 0 {
|
||||
// fast path, basic ascii
|
||||
if ip.ut8[0] < 0x7F {
|
||||
ip.buf = append(ip.buf, rune(ip.ut8[0]))
|
||||
ip.ut8 = ip.ut8[1:]
|
||||
} else {
|
||||
r, len := utf8.DecodeRune(ip.ut8)
|
||||
if r == utf8.RuneError {
|
||||
r = rune(ip.ut8[0])
|
||||
len = 1
|
||||
}
|
||||
ip.buf = append(ip.buf, r)
|
||||
ip.ut8 = ip.ut8[len:]
|
||||
}
|
||||
}
|
||||
|
||||
ip.scan()
|
||||
}
|
||||
|
||||
func (ip *inputProcessor) ScanUTF16(u []uint16) {
|
||||
ip.l.Lock()
|
||||
defer ip.l.Unlock()
|
||||
ip.ut16 = append(ip.ut16, u...)
|
||||
for len(ip.ut16) > 0 {
|
||||
if !utf16.IsSurrogate(rune(ip.ut16[0])) {
|
||||
ip.buf = append(ip.buf, rune(ip.ut16[0]))
|
||||
ip.ut16 = ip.ut16[1:]
|
||||
} else if len(ip.ut16) > 1 {
|
||||
ip.buf = append(ip.buf, utf16.DecodeRune(rune(ip.ut16[0]), rune(ip.ut16[1])))
|
||||
ip.ut16 = ip.ut16[2:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
+69
-12
@@ -1,4 +1,4 @@
|
||||
// Copyright 2016 The TCell Authors
|
||||
// Copyright 2025 The TCell Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use file except in compliance with the License.
|
||||
@@ -171,6 +171,11 @@ var KeyNames = map[Key]string{
|
||||
KeyF62: "F62",
|
||||
KeyF63: "F63",
|
||||
KeyF64: "F64",
|
||||
KeyMenu: "Menu",
|
||||
KeyCapsLock: "CapsLock",
|
||||
KeyScrollLock: "ScrollLock",
|
||||
KeyNumLock: "NumLock",
|
||||
KeyCtrlSpace: "Ctrl-Space",
|
||||
KeyCtrlA: "Ctrl-A",
|
||||
KeyCtrlB: "Ctrl-B",
|
||||
KeyCtrlC: "Ctrl-C",
|
||||
@@ -178,9 +183,12 @@ var KeyNames = map[Key]string{
|
||||
KeyCtrlE: "Ctrl-E",
|
||||
KeyCtrlF: "Ctrl-F",
|
||||
KeyCtrlG: "Ctrl-G",
|
||||
KeyCtrlH: "Ctrl-H",
|
||||
KeyCtrlI: "Ctrl-I",
|
||||
KeyCtrlJ: "Ctrl-J",
|
||||
KeyCtrlK: "Ctrl-K",
|
||||
KeyCtrlL: "Ctrl-L",
|
||||
KeyCtrlM: "Ctrl-M",
|
||||
KeyCtrlN: "Ctrl-N",
|
||||
KeyCtrlO: "Ctrl-O",
|
||||
KeyCtrlP: "Ctrl-P",
|
||||
@@ -194,11 +202,11 @@ var KeyNames = map[Key]string{
|
||||
KeyCtrlX: "Ctrl-X",
|
||||
KeyCtrlY: "Ctrl-Y",
|
||||
KeyCtrlZ: "Ctrl-Z",
|
||||
KeyCtrlSpace: "Ctrl-Space",
|
||||
KeyCtrlUnderscore: "Ctrl-_",
|
||||
KeyCtrlLeftSq: "Ctrl-[",
|
||||
KeyCtrlRightSq: "Ctrl-]",
|
||||
KeyCtrlBackslash: "Ctrl-\\",
|
||||
KeyCtrlCarat: "Ctrl-^",
|
||||
KeyCtrlUnderscore: "Ctrl-_",
|
||||
}
|
||||
|
||||
// Name returns a printable value or the key stroke. This can be used
|
||||
@@ -218,6 +226,9 @@ func (ev *EventKey) Name() string {
|
||||
if ev.mod&ModCtrl != 0 {
|
||||
m = append(m, "Ctrl")
|
||||
}
|
||||
if ev.mod&ModHyper != 0 {
|
||||
m = append(m, "Hyper")
|
||||
}
|
||||
|
||||
ok := false
|
||||
if s, ok = KeyNames[ev.key]; !ok {
|
||||
@@ -246,15 +257,52 @@ func NewEventKey(k Key, ch rune, mod ModMask) *EventKey {
|
||||
// control characters and the DEL.
|
||||
k = Key(ch)
|
||||
if mod == ModNone && ch < ' ' {
|
||||
switch Key(ch) {
|
||||
switch k {
|
||||
case KeyBackspace, KeyTab, KeyEsc, KeyEnter:
|
||||
// these keys are directly typeable without CTRL
|
||||
default:
|
||||
// most likely entered with a CTRL keypress
|
||||
mod = ModCtrl
|
||||
}
|
||||
ch = ch + '\x60'
|
||||
}
|
||||
}
|
||||
if k == KeyRune && ch >= 'A' && ch <= 'Z' && mod == ModCtrl {
|
||||
// We don't do Ctrl-[ or backslash or those specially.
|
||||
k = KeyCtrlA + Key(ch-'A')
|
||||
}
|
||||
|
||||
// Might be lower case
|
||||
if k == KeyRune && ch >= 'a' && ch <= 'z' && mod == ModCtrl {
|
||||
// We don't do Ctrl-[ or backslash or those specially.
|
||||
k = KeyCtrlA + Key(ch-'a')
|
||||
}
|
||||
|
||||
// Windows reports ModShift for shifted keys. This is inconsistent
|
||||
// with UNIX, lets harmonize this.
|
||||
if k == KeyRune && mod == ModShift && ch != 0 {
|
||||
mod = ModNone
|
||||
}
|
||||
|
||||
if k >= KeyCtrlA && k <= KeyCtrlZ {
|
||||
if mod&ModShift != 0 {
|
||||
ch = rune((k - KeyCtrlA) + 'A')
|
||||
} else {
|
||||
ch = rune((k - KeyCtrlA) + 'a')
|
||||
}
|
||||
}
|
||||
|
||||
// Backspace2 is just another name for backspace.
|
||||
if k == KeyBackspace2 {
|
||||
k = KeyBackspace
|
||||
}
|
||||
|
||||
// Shift-Tab should be Backtab.
|
||||
if k == KeyTab && (mod&ModShift) != 0 {
|
||||
k = KeyBacktab
|
||||
mod &^= ModShift
|
||||
}
|
||||
|
||||
return &EventKey{t: time.Now(), key: k, ch: ch, mod: mod}
|
||||
}
|
||||
|
||||
@@ -272,6 +320,7 @@ const (
|
||||
ModCtrl
|
||||
ModAlt
|
||||
ModMeta
|
||||
ModHyper
|
||||
ModNone ModMask = 0
|
||||
)
|
||||
|
||||
@@ -373,6 +422,10 @@ const (
|
||||
KeyF62
|
||||
KeyF63
|
||||
KeyF64
|
||||
KeyMenu
|
||||
KeyCapsLock
|
||||
KeyScrollLock
|
||||
KeyNumLock
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -381,10 +434,12 @@ const (
|
||||
keyPasteEnd
|
||||
)
|
||||
|
||||
// These are the control keys. Note that they overlap with other keys,
|
||||
// perhaps. For example, KeyCtrlH is the same as KeyBackspace.
|
||||
// These are the control keys, they will also be reported with the
|
||||
// rune (lower case) and control modifier. If the shift key
|
||||
// or other modifiers are present then these will *NOT* be reported,
|
||||
// but reported instead as KeyRune.
|
||||
const (
|
||||
KeyCtrlSpace Key = iota
|
||||
KeyCtrlSpace Key = iota + 64
|
||||
KeyCtrlA
|
||||
KeyCtrlB
|
||||
KeyCtrlC
|
||||
@@ -461,10 +516,12 @@ const (
|
||||
|
||||
// These keys are aliases for other names.
|
||||
const (
|
||||
KeyBackspace = KeyBS
|
||||
KeyTab = KeyTAB
|
||||
KeyEsc = KeyESC
|
||||
KeyEscape = KeyESC
|
||||
KeyEnter = KeyCR
|
||||
KeyBackspace = KeyBS
|
||||
KeyTab = KeyTAB
|
||||
KeyEsc = KeyESC
|
||||
KeyEscape = KeyESC
|
||||
KeyEnter = KeyCR
|
||||
|
||||
// NB: This key will be translated to KeyBackspace
|
||||
KeyBackspace2 = KeyDEL
|
||||
)
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2020 The TCell Authors
|
||||
// Copyright 2025 The TCell Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use file except in compliance with the License.
|
||||
|
||||
+70
-20
@@ -1,4 +1,4 @@
|
||||
// Copyright 2024 The TCell Authors
|
||||
// Copyright 2025 The TCell Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use file except in compliance with the License.
|
||||
@@ -35,17 +35,37 @@ type Screen interface {
|
||||
// is called (or Sync).
|
||||
Fill(rune, Style)
|
||||
|
||||
// SetCell is an older API, and will be removed. Please use
|
||||
// SetContent instead; SetCell is implemented in terms of SetContent.
|
||||
// Put writes the first graphme of the given string with th
|
||||
// given style at the given coordinates. (Only the first grapheme
|
||||
// occupying either one or two cells is stored.) It returns the
|
||||
// remainder of the string, and the width displayed.
|
||||
Put(x int, y int, str string, style Style) (string, int)
|
||||
|
||||
// PutStr writes a string starting at the given position, using the
|
||||
// default style. The content is clipped to the screen dimensions.
|
||||
PutStr(x int, y int, str string)
|
||||
|
||||
// PutStrStyled writes a string starting at the given position, using
|
||||
// the given style. The cont4ent is clipped to the screen dimensions.
|
||||
PutStrStyled(x int, y int, str string, style Style)
|
||||
|
||||
// SetCell is an older API, and will be removed.
|
||||
//jj
|
||||
// Deprecated: Please use Put instead.
|
||||
SetCell(x int, y int, style Style, ch ...rune)
|
||||
|
||||
// GetContent returns the contents at the given location. If the
|
||||
// Get the contents at the given location. If the
|
||||
// coordinates are out of range, then the values will be 0, nil,
|
||||
// StyleDefault. Note that the contents returned are logical contents
|
||||
// and may not actually be what is displayed, but rather are what will
|
||||
// be displayed if Show() or Sync() is called. The width is the width
|
||||
// in screen cells; most often this will be 1, but some East Asian
|
||||
// characters and emoji require two cells.
|
||||
Get(x, y int) (str string, style Style, width int)
|
||||
|
||||
// GetContent is the old way to get cell contents.
|
||||
//
|
||||
// Deprecated: Use Get() instead.
|
||||
GetContent(x, y int) (primary rune, combining []rune, style Style, width int)
|
||||
|
||||
// SetContent sets the contents of the given cell location. If
|
||||
@@ -221,6 +241,9 @@ type Screen interface {
|
||||
// fallbacks are registered, this will return true. This will
|
||||
// also return true if the terminal can replace the glyph with
|
||||
// one that is visually indistinguishable from the one requested.
|
||||
//
|
||||
// Deprecated: This is not a particularly useful or reliable function,
|
||||
// due to limitations in fonts, etc. It will be removed in the future.
|
||||
CanDisplay(r rune, checkFallbacks bool) bool
|
||||
|
||||
// Resize does nothing, since it's generally not possible to
|
||||
@@ -228,14 +251,13 @@ type Screen interface {
|
||||
// the View interface.
|
||||
Resize(int, int, int, int)
|
||||
|
||||
// HasKey returns true if the keyboard is believed to have the
|
||||
// key. In some cases a keyboard may have keys with this name
|
||||
// but no support for them, while in others a key may be reported
|
||||
// as supported but not actually be usable (such as some emulators
|
||||
// that hijack certain keys). Its best not to depend to strictly
|
||||
// on this function, but it can be used for hinting when building
|
||||
// menus, displayed hot-keys, etc. Note that KeyRune (literal
|
||||
// runes) is always true.
|
||||
// HasKey always returns true.
|
||||
//
|
||||
// Deprecated: This function always returns true. Applications
|
||||
// cannot reliably detect whether a key is supported or not with
|
||||
// modern terminal emulators. (The intended use here was to help
|
||||
// applications determine whether a given key stroke was supported
|
||||
// by the terminal, but it was never reliable.)
|
||||
HasKey(Key) bool
|
||||
|
||||
// Suspend pauses input and output processing. It also restores the
|
||||
@@ -288,10 +310,9 @@ type Screen interface {
|
||||
// NewScreen returns a default Screen suitable for the user's terminal
|
||||
// environment.
|
||||
func NewScreen() (Screen, error) {
|
||||
// Windows is happier if we try for a console screen first.
|
||||
if s, _ := NewConsoleScreen(); s != nil {
|
||||
if s, e := NewTerminfoScreen(); s != nil {
|
||||
return s, nil
|
||||
} else if s, e := NewTerminfoScreen(); s != nil {
|
||||
} else if s, _ := NewConsoleScreen(); s != nil {
|
||||
return s, nil
|
||||
} else {
|
||||
return nil, e
|
||||
@@ -382,11 +403,37 @@ type baseScreen struct {
|
||||
screenImpl
|
||||
}
|
||||
|
||||
func (b *baseScreen) Put(x int, y int, str string, style Style) (remain string, width int) {
|
||||
cells := b.GetCells()
|
||||
b.Lock()
|
||||
defer b.Unlock()
|
||||
return cells.Put(x, y, str, style)
|
||||
}
|
||||
|
||||
func (b *baseScreen) PutStrStyled(x int, y int, str string, style Style) {
|
||||
cells := b.GetCells()
|
||||
b.Lock()
|
||||
cols, rows := cells.Size()
|
||||
width := 0
|
||||
for str != "" && x < cols && y < rows {
|
||||
str, width = cells.Put(x, y, str, style)
|
||||
if width == 0 {
|
||||
break
|
||||
}
|
||||
x += width
|
||||
}
|
||||
defer b.Unlock()
|
||||
}
|
||||
|
||||
func (b *baseScreen) PutStr(x, y int, str string) {
|
||||
b.PutStrStyled(x, y, str, StyleDefault)
|
||||
}
|
||||
|
||||
func (b *baseScreen) SetCell(x int, y int, style Style, ch ...rune) {
|
||||
if len(ch) > 0 {
|
||||
b.SetContent(x, y, ch[0], ch[1:], style)
|
||||
b.Put(x, y, string(ch), style)
|
||||
} else {
|
||||
b.SetContent(x, y, ' ', nil, style)
|
||||
b.Put(x, y, " ", style)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -401,12 +448,15 @@ func (b *baseScreen) Fill(r rune, style Style) {
|
||||
b.Unlock()
|
||||
}
|
||||
|
||||
func (b *baseScreen) SetContent(x, y int, mainc rune, combc []rune, st Style) {
|
||||
func (b *baseScreen) SetContent(x, y int, mainc rune, combc []rune, style Style) {
|
||||
b.Put(x, y, string(append([]rune{mainc}, combc...)), style)
|
||||
}
|
||||
|
||||
func (b *baseScreen) Get(x, y int) (string, Style, int) {
|
||||
cells := b.GetCells()
|
||||
b.Lock()
|
||||
cells.SetContent(x, y, mainc, combc, st)
|
||||
b.Unlock()
|
||||
defer b.Unlock()
|
||||
return cells.Get(x, y)
|
||||
}
|
||||
|
||||
func (b *baseScreen) GetContent(x, y int) (rune, []rune, Style, int) {
|
||||
|
||||
+14
-3
@@ -143,6 +143,10 @@ func (s *simscreen) Init() error {
|
||||
|
||||
func (s *simscreen) Fini() {
|
||||
s.Lock()
|
||||
if s.fini {
|
||||
s.Unlock()
|
||||
return
|
||||
}
|
||||
s.fini = true
|
||||
s.back.Resize(0, 0)
|
||||
s.Unlock()
|
||||
@@ -356,11 +360,18 @@ outer:
|
||||
}
|
||||
|
||||
if b[0] < 0x80 {
|
||||
mod := ModNone
|
||||
// No encodings start with low numbered values
|
||||
if Key(b[0]) >= KeyCtrlA && Key(b[0]) <= KeyCtrlZ {
|
||||
mod = ModCtrl
|
||||
if b[0] > 0 && b[0] < ' ' { // control keys
|
||||
switch Key(b[0]) {
|
||||
case KeyESC, KeyEnter, KeyTAB:
|
||||
s.postEvent(NewEventKey(Key(b[0]), 0, 0))
|
||||
continue;
|
||||
default:
|
||||
s.postEvent(NewEventKey(Key(b[0]), rune(b[0])+'\x60', ModCtrl))
|
||||
continue
|
||||
}
|
||||
}
|
||||
mod := ModNone
|
||||
ev := NewEventKey(Key(b[0]), 0, mod)
|
||||
s.postEvent(ev)
|
||||
b = b[1:]
|
||||
|
||||
+42
-2
@@ -14,6 +14,11 @@
|
||||
|
||||
package tcell
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
// Style represents a complete text style, including both foreground color,
|
||||
// background color, and additional attributes such as "bold" or "underline".
|
||||
//
|
||||
@@ -164,6 +169,16 @@ func (s Style) Underline(params ...interface{}) Style {
|
||||
return s2
|
||||
}
|
||||
|
||||
// GetUnderlineStyle returns the underline style for the style.
|
||||
func (s Style) GetUnderlineStyle() UnderlineStyle {
|
||||
return s.ulStyle
|
||||
}
|
||||
|
||||
// GetUnderlineColor returns the underline color for the style.
|
||||
func (s Style) GetUnderlineColor() Color {
|
||||
return s.ulColor
|
||||
}
|
||||
|
||||
// Attributes returns a new style based on s, with its attributes set as
|
||||
// specified.
|
||||
func (s Style) Attributes(attrs AttrMask) Style {
|
||||
@@ -177,7 +192,7 @@ func (s Style) Attributes(attrs AttrMask) Style {
|
||||
// link to that Url. If the Url is empty, then this mode is turned off.
|
||||
func (s Style) Url(url string) Style {
|
||||
s2 := s
|
||||
s2.url = url
|
||||
s2.url = stripOSCControls(url)
|
||||
return s2
|
||||
}
|
||||
|
||||
@@ -187,6 +202,31 @@ func (s Style) Url(url string) Style {
|
||||
// were one Url, even if it spans multiple lines.
|
||||
func (s Style) UrlId(id string) Style {
|
||||
s2 := s
|
||||
s2.urlId = "id=" + id
|
||||
s2.urlId = "id=" + stripOSCControls(id)
|
||||
return s2
|
||||
}
|
||||
|
||||
func stripOSCControls(s string) string {
|
||||
var b strings.Builder
|
||||
b.Grow(len(s))
|
||||
for i := 0; i < len(s); {
|
||||
r, size := utf8.DecodeRuneInString(s[i:])
|
||||
if r == utf8.RuneError && size == 1 {
|
||||
c := s[i]
|
||||
if c <= 0x1f || c == 0x7f || (c >= 0x80 && c <= 0x9f) {
|
||||
i++
|
||||
continue
|
||||
}
|
||||
_ = b.WriteByte(c)
|
||||
i++
|
||||
continue
|
||||
}
|
||||
if r <= 0x1f || r == 0x7f || (r >= 0x80 && r <= 0x9f) {
|
||||
i += size
|
||||
continue
|
||||
}
|
||||
b.WriteString(s[i : i+size])
|
||||
i += size
|
||||
}
|
||||
return b.String()
|
||||
}
|
||||
|
||||
+19
-71
@@ -8,76 +8,24 @@ func init() {
|
||||
|
||||
// IBM Aixterm Terminal Emulator
|
||||
terminfo.AddTerminfo(&terminfo.Terminfo{
|
||||
Name: "aixterm",
|
||||
Columns: 80,
|
||||
Lines: 25,
|
||||
Colors: 8,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[J",
|
||||
AttrOff: "\x1b[0;10m\x1b(B",
|
||||
Underline: "\x1b[4m",
|
||||
Bold: "\x1b[1m",
|
||||
Reverse: "\x1b[7m",
|
||||
SetFg: "\x1b[3%p1%dm",
|
||||
SetBg: "\x1b[4%p1%dm",
|
||||
SetFgBg: "\x1b[3%p1%d;4%p2%dm",
|
||||
ResetFgBg: "\x1b[32m\x1b[40m",
|
||||
PadChar: "\x00",
|
||||
AltChars: "jjkkllmmnnqqttuuvvwwxx",
|
||||
EnterAcs: "\x1b(0",
|
||||
ExitAcs: "\x1b(B",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1b[A",
|
||||
KeyDown: "\x1b[B",
|
||||
KeyRight: "\x1b[C",
|
||||
KeyLeft: "\x1b[D",
|
||||
KeyInsert: "\x1b[139q",
|
||||
KeyDelete: "\x1b[P",
|
||||
KeyBackspace: "\b",
|
||||
KeyHome: "\x1b[H",
|
||||
KeyEnd: "\x1b[146q",
|
||||
KeyPgUp: "\x1b[150q",
|
||||
KeyPgDn: "\x1b[154q",
|
||||
KeyF1: "\x1b[001q",
|
||||
KeyF2: "\x1b[002q",
|
||||
KeyF3: "\x1b[003q",
|
||||
KeyF4: "\x1b[004q",
|
||||
KeyF5: "\x1b[005q",
|
||||
KeyF6: "\x1b[006q",
|
||||
KeyF7: "\x1b[007q",
|
||||
KeyF8: "\x1b[008q",
|
||||
KeyF9: "\x1b[009q",
|
||||
KeyF10: "\x1b[010q",
|
||||
KeyF11: "\x1b[011q",
|
||||
KeyF12: "\x1b[012q",
|
||||
KeyF13: "\x1b[013q",
|
||||
KeyF14: "\x1b[014q",
|
||||
KeyF15: "\x1b[015q",
|
||||
KeyF16: "\x1b[016q",
|
||||
KeyF17: "\x1b[017q",
|
||||
KeyF18: "\x1b[018q",
|
||||
KeyF19: "\x1b[019q",
|
||||
KeyF20: "\x1b[020q",
|
||||
KeyF21: "\x1b[021q",
|
||||
KeyF22: "\x1b[022q",
|
||||
KeyF23: "\x1b[023q",
|
||||
KeyF24: "\x1b[024q",
|
||||
KeyF25: "\x1b[025q",
|
||||
KeyF26: "\x1b[026q",
|
||||
KeyF27: "\x1b[027q",
|
||||
KeyF28: "\x1b[028q",
|
||||
KeyF29: "\x1b[029q",
|
||||
KeyF30: "\x1b[030q",
|
||||
KeyF31: "\x1b[031q",
|
||||
KeyF32: "\x1b[032q",
|
||||
KeyF33: "\x1b[033q",
|
||||
KeyF34: "\x1b[034q",
|
||||
KeyF35: "\x1b[035q",
|
||||
KeyF36: "\x1b[036q",
|
||||
KeyClear: "\x1b[144q",
|
||||
KeyBacktab: "\x1b[Z",
|
||||
AutoMargin: true,
|
||||
Name: "aixterm",
|
||||
Columns: 80,
|
||||
Lines: 25,
|
||||
Colors: 8,
|
||||
Clear: "\x1b[H\x1b[J",
|
||||
AttrOff: "\x1b[0;10m\x1b(B",
|
||||
Underline: "\x1b[4m",
|
||||
Bold: "\x1b[1m",
|
||||
Reverse: "\x1b[7m",
|
||||
SetFg: "\x1b[3%p1%dm",
|
||||
SetBg: "\x1b[4%p1%dm",
|
||||
SetFgBg: "\x1b[3%p1%d;4%p2%dm",
|
||||
ResetFgBg: "\x1b[32m\x1b[40m",
|
||||
PadChar: "\x00",
|
||||
AltChars: "jjkkllmmnnqqttuuvvwwxx",
|
||||
EnterAcs: "\x1b(0",
|
||||
ExitAcs: "\x1b(B",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
AutoMargin: true,
|
||||
})
|
||||
}
|
||||
|
||||
-28
@@ -12,7 +12,6 @@ func init() {
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 16777216,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[2J",
|
||||
EnterCA: "\x1b[?1049h\x1b[22;0;0t",
|
||||
ExitCA: "\x1b[?1049l\x1b[23;0;0t",
|
||||
@@ -36,33 +35,6 @@ func init() {
|
||||
StrikeThrough: "\x1b[9m",
|
||||
Mouse: "\x1b[M",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1bOA",
|
||||
KeyDown: "\x1bOB",
|
||||
KeyRight: "\x1bOC",
|
||||
KeyLeft: "\x1bOD",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\x7f",
|
||||
KeyHome: "\x1bOH",
|
||||
KeyEnd: "\x1bOF",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1bOP",
|
||||
KeyF2: "\x1bOQ",
|
||||
KeyF3: "\x1bOR",
|
||||
KeyF4: "\x1bOS",
|
||||
KeyF5: "\x1b[15~",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyBacktab: "\x1b[Z",
|
||||
Modifiers: 1,
|
||||
TrueColor: true,
|
||||
AutoMargin: true,
|
||||
})
|
||||
|
||||
-32
@@ -12,7 +12,6 @@ func init() {
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 256,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[2J",
|
||||
EnterCA: "\x1b[?1049h\x1b[22;0;0t",
|
||||
ExitCA: "\x1b[?1049l\x1b[23;0;0t",
|
||||
@@ -39,38 +38,7 @@ func init() {
|
||||
StrikeThrough: "\x1b[9m",
|
||||
Mouse: "\x1b[<",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1bOA",
|
||||
KeyDown: "\x1bOB",
|
||||
KeyRight: "\x1bOC",
|
||||
KeyLeft: "\x1bOD",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\x7f",
|
||||
KeyHome: "\x1bOH",
|
||||
KeyEnd: "\x1bOF",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1bOP",
|
||||
KeyF2: "\x1bOQ",
|
||||
KeyF3: "\x1bOR",
|
||||
KeyF4: "\x1bOS",
|
||||
KeyF5: "\x1b[15~",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyBacktab: "\x1b[Z",
|
||||
Modifiers: 1,
|
||||
AutoMargin: true,
|
||||
DoubleUnderline: "\x1b[4:2m",
|
||||
CurlyUnderline: "\x1b[4:3m",
|
||||
DottedUnderline: "\x1b[4:4m",
|
||||
DashedUnderline: "\x1b[4:5m",
|
||||
XTermLike: true,
|
||||
})
|
||||
}
|
||||
|
||||
+20
-31
@@ -8,36 +8,25 @@ func init() {
|
||||
|
||||
// ansi/pc-term compatible with color
|
||||
terminfo.AddTerminfo(&terminfo.Terminfo{
|
||||
Name: "ansi",
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 8,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[J",
|
||||
AttrOff: "\x1b[0;10m",
|
||||
Underline: "\x1b[4m",
|
||||
Bold: "\x1b[1m",
|
||||
Blink: "\x1b[5m",
|
||||
Reverse: "\x1b[7m",
|
||||
SetFg: "\x1b[3%p1%dm",
|
||||
SetBg: "\x1b[4%p1%dm",
|
||||
SetFgBg: "\x1b[3%p1%d;4%p2%dm",
|
||||
ResetFgBg: "\x1b[39;49m",
|
||||
PadChar: "\x00",
|
||||
AltChars: "+\x10,\x11-\x18.\x190\xdb`\x04a\xb1f\xf8g\xf1h\xb0j\xd9k\xbfl\xdam\xc0n\xc5o~p\xc4q\xc4r\xc4s_t\xc3u\xb4v\xc1w\xc2x\xb3y\xf3z\xf2{\xe3|\xd8}\x9c~\xfe",
|
||||
EnterAcs: "\x1b[11m",
|
||||
ExitAcs: "\x1b[10m",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\x1b[D",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1b[A",
|
||||
KeyDown: "\x1b[B",
|
||||
KeyRight: "\x1b[C",
|
||||
KeyLeft: "\x1b[D",
|
||||
KeyInsert: "\x1b[L",
|
||||
KeyBackspace: "\b",
|
||||
KeyHome: "\x1b[H",
|
||||
KeyBacktab: "\x1b[Z",
|
||||
AutoMargin: true,
|
||||
Name: "ansi",
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 8,
|
||||
Clear: "\x1b[H\x1b[J",
|
||||
AttrOff: "\x1b[0;10m",
|
||||
Underline: "\x1b[4m",
|
||||
Bold: "\x1b[1m",
|
||||
Blink: "\x1b[5m",
|
||||
Reverse: "\x1b[7m",
|
||||
SetFg: "\x1b[3%p1%dm",
|
||||
SetBg: "\x1b[4%p1%dm",
|
||||
SetFgBg: "\x1b[3%p1%d;4%p2%dm",
|
||||
ResetFgBg: "\x1b[39;49m",
|
||||
PadChar: "\x00",
|
||||
AltChars: "+\x10,\x11-\x18.\x190\xdb`\x04a\xb1f\xf8g\xf1h\xb0j\xd9k\xbfl\xdam\xc0n\xc5o~p\xc4q\xc4r\xc4s_t\xc3u\xb4v\xc1w\xc2x\xb3y\xf3z\xf2{\xe3|\xd8}\x9c~\xfe",
|
||||
EnterAcs: "\x1b[11m",
|
||||
ExitAcs: "\x1b[10m",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
AutoMargin: true,
|
||||
})
|
||||
}
|
||||
|
||||
-57
@@ -1,57 +0,0 @@
|
||||
// Generated automatically. DO NOT HAND-EDIT.
|
||||
|
||||
package beterm
|
||||
|
||||
import "github.com/gdamore/tcell/v2/terminfo"
|
||||
|
||||
func init() {
|
||||
|
||||
// BeOS Terminal
|
||||
terminfo.AddTerminfo(&terminfo.Terminfo{
|
||||
Name: "beterm",
|
||||
Columns: 80,
|
||||
Lines: 25,
|
||||
Colors: 8,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[J",
|
||||
AttrOff: "\x1b[0;10m",
|
||||
Underline: "\x1b[4m",
|
||||
Bold: "\x1b[1m",
|
||||
Reverse: "\x1b[7m",
|
||||
EnterKeypad: "\x1b[?4h",
|
||||
ExitKeypad: "\x1b[?4l",
|
||||
SetFg: "\x1b[3%p1%dm",
|
||||
SetBg: "\x1b[4%p1%dm",
|
||||
SetFgBg: "\x1b[3%p1%d;4%p2%dm",
|
||||
ResetFgBg: "\x1b[m",
|
||||
PadChar: "\x00",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1b[A",
|
||||
KeyDown: "\x1b[B",
|
||||
KeyRight: "\x1b[C",
|
||||
KeyLeft: "\x1b[D",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\b",
|
||||
KeyHome: "\x1b[1~",
|
||||
KeyEnd: "\x1b[4~",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1b[11~",
|
||||
KeyF2: "\x1b[12~",
|
||||
KeyF3: "\x1b[13~",
|
||||
KeyF4: "\x1b[14~",
|
||||
KeyF5: "\x1b[15~",
|
||||
KeyF6: "\x1b[16~",
|
||||
KeyF7: "\x1b[17~",
|
||||
KeyF8: "\x1b[18~",
|
||||
KeyF9: "\x1b[19~",
|
||||
KeyF10: "\x1b[20~",
|
||||
KeyF11: "\x1b[21~",
|
||||
KeyF12: "\x1b[22~",
|
||||
AutoMargin: true,
|
||||
InsertChar: "\x1b[@",
|
||||
})
|
||||
}
|
||||
+1
@@ -25,6 +25,7 @@ import (
|
||||
// The following imports just register themselves --
|
||||
// these are the terminal types we aggregate in this package.
|
||||
_ "github.com/gdamore/tcell/v2/terminfo/a/ansi"
|
||||
_ "github.com/gdamore/tcell/v2/terminfo/t/tmux"
|
||||
_ "github.com/gdamore/tcell/v2/terminfo/v/vt100"
|
||||
_ "github.com/gdamore/tcell/v2/terminfo/v/vt102"
|
||||
_ "github.com/gdamore/tcell/v2/terminfo/v/vt220"
|
||||
|
||||
+20
-54
@@ -8,59 +8,25 @@ func init() {
|
||||
|
||||
// ANSI emulation for Cygwin
|
||||
terminfo.AddTerminfo(&terminfo.Terminfo{
|
||||
Name: "cygwin",
|
||||
Colors: 8,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[J",
|
||||
EnterCA: "\x1b7\x1b[?47h",
|
||||
ExitCA: "\x1b[2J\x1b[?47l\x1b8",
|
||||
AttrOff: "\x1b[0;10m",
|
||||
Underline: "\x1b[4m",
|
||||
Bold: "\x1b[1m",
|
||||
Reverse: "\x1b[7m",
|
||||
SetFg: "\x1b[3%p1%dm",
|
||||
SetBg: "\x1b[4%p1%dm",
|
||||
SetFgBg: "\x1b[3%p1%d;4%p2%dm",
|
||||
ResetFgBg: "\x1b[39;49m",
|
||||
PadChar: "\x00",
|
||||
AltChars: "+\x10,\x11-\x18.\x190\xdb`\x04a\xb1f\xf8g\xf1h\xb0j\xd9k\xbfl\xdam\xc0n\xc5o~p\xc4q\xc4r\xc4s_t\xc3u\xb4v\xc1w\xc2x\xb3y\xf3z\xf2{\xe3|\xd8}\x9c~\xfe",
|
||||
EnterAcs: "\x1b[11m",
|
||||
ExitAcs: "\x1b[10m",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1b[A",
|
||||
KeyDown: "\x1b[B",
|
||||
KeyRight: "\x1b[C",
|
||||
KeyLeft: "\x1b[D",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\b",
|
||||
KeyHome: "\x1b[1~",
|
||||
KeyEnd: "\x1b[4~",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1b[[A",
|
||||
KeyF2: "\x1b[[B",
|
||||
KeyF3: "\x1b[[C",
|
||||
KeyF4: "\x1b[[D",
|
||||
KeyF5: "\x1b[[E",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyF13: "\x1b[25~",
|
||||
KeyF14: "\x1b[26~",
|
||||
KeyF15: "\x1b[28~",
|
||||
KeyF16: "\x1b[29~",
|
||||
KeyF17: "\x1b[31~",
|
||||
KeyF18: "\x1b[32~",
|
||||
KeyF19: "\x1b[33~",
|
||||
KeyF20: "\x1b[34~",
|
||||
AutoMargin: true,
|
||||
InsertChar: "\x1b[@",
|
||||
Name: "cygwin",
|
||||
Colors: 8,
|
||||
Clear: "\x1b[H\x1b[J",
|
||||
EnterCA: "\x1b7\x1b[?47h",
|
||||
ExitCA: "\x1b[2J\x1b[?47l\x1b8",
|
||||
AttrOff: "\x1b[0;10m",
|
||||
Underline: "\x1b[4m",
|
||||
Bold: "\x1b[1m",
|
||||
Reverse: "\x1b[7m",
|
||||
SetFg: "\x1b[3%p1%dm",
|
||||
SetBg: "\x1b[4%p1%dm",
|
||||
SetFgBg: "\x1b[3%p1%d;4%p2%dm",
|
||||
ResetFgBg: "\x1b[39;49m",
|
||||
PadChar: "\x00",
|
||||
AltChars: "+\x10,\x11-\x18.\x190\xdb`\x04a\xb1f\xf8g\xf1h\xb0j\xd9k\xbfl\xdam\xc0n\xc5o~p\xc4q\xc4r\xc4s_t\xc3u\xb4v\xc1w\xc2x\xb3y\xf3z\xf2{\xe3|\xd8}\x9c~\xfe",
|
||||
EnterAcs: "\x1b[11m",
|
||||
ExitAcs: "\x1b[10m",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
AutoMargin: true,
|
||||
InsertChar: "\x1b[@",
|
||||
})
|
||||
}
|
||||
|
||||
-33
@@ -12,7 +12,6 @@ func init() {
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 8,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[J",
|
||||
ShowCursor: "\x1b[?25h",
|
||||
HideCursor: "\x1b[?25l",
|
||||
@@ -34,38 +33,6 @@ func init() {
|
||||
EnableAutoMargin: "\x1b[?7h",
|
||||
DisableAutoMargin: "\x1b[?7l",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1b[A",
|
||||
KeyDown: "\x1b[B",
|
||||
KeyRight: "\x1b[C",
|
||||
KeyLeft: "\x1b[D",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\b",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1b[11~",
|
||||
KeyF2: "\x1b[12~",
|
||||
KeyF3: "\x1b[13~",
|
||||
KeyF4: "\x1b[14~",
|
||||
KeyF5: "\x1b[15~",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyF13: "\x1b[25~",
|
||||
KeyF14: "\x1b[26~",
|
||||
KeyF15: "\x1b[28~",
|
||||
KeyF16: "\x1b[29~",
|
||||
KeyF17: "\x1b[31~",
|
||||
KeyF18: "\x1b[32~",
|
||||
KeyF19: "\x1b[33~",
|
||||
KeyF20: "\x1b[34~",
|
||||
KeyHelp: "\x1b[28~",
|
||||
AutoMargin: true,
|
||||
})
|
||||
}
|
||||
|
||||
+3
-160
@@ -24,6 +24,7 @@ package dynamic
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strconv"
|
||||
@@ -126,7 +127,7 @@ func (tc *termcap) setupterm(name string) error {
|
||||
tc.nums = make(map[string]int)
|
||||
|
||||
if err := cmd.Run(); err != nil {
|
||||
return err
|
||||
return fmt.Errorf("couldn't open terminfo ($TERM) file for %s: %w", name, err)
|
||||
}
|
||||
|
||||
// Now parse the output.
|
||||
@@ -144,9 +145,7 @@ func (tc *termcap) setupterm(name string) error {
|
||||
lines = lines[:len(lines)-1]
|
||||
}
|
||||
header := lines[0]
|
||||
if strings.HasSuffix(header, ",") {
|
||||
header = header[:len(header)-1]
|
||||
}
|
||||
header = strings.TrimSuffix(header, ",")
|
||||
names := strings.Split(header, "|")
|
||||
tc.name = names[0]
|
||||
names = names[1:]
|
||||
@@ -193,7 +192,6 @@ func LoadTerminfo(name string) (*terminfo.Terminfo, string, error) {
|
||||
t.Colors = tc.getnum("colors")
|
||||
t.Columns = tc.getnum("cols")
|
||||
t.Lines = tc.getnum("lines")
|
||||
t.Bell = tc.getstr("bel")
|
||||
t.Clear = tc.getstr("clear")
|
||||
t.EnterCA = tc.getstr("smcup")
|
||||
t.ExitCA = tc.getstr("rmcup")
|
||||
@@ -211,166 +209,11 @@ func LoadTerminfo(name string) (*terminfo.Terminfo, string, error) {
|
||||
t.SetFg = tc.getstr("setaf")
|
||||
t.SetBg = tc.getstr("setab")
|
||||
t.SetCursor = tc.getstr("cup")
|
||||
t.CursorBack1 = tc.getstr("cub1")
|
||||
t.CursorUp1 = tc.getstr("cuu1")
|
||||
t.KeyF1 = tc.getstr("kf1")
|
||||
t.KeyF2 = tc.getstr("kf2")
|
||||
t.KeyF3 = tc.getstr("kf3")
|
||||
t.KeyF4 = tc.getstr("kf4")
|
||||
t.KeyF5 = tc.getstr("kf5")
|
||||
t.KeyF6 = tc.getstr("kf6")
|
||||
t.KeyF7 = tc.getstr("kf7")
|
||||
t.KeyF8 = tc.getstr("kf8")
|
||||
t.KeyF9 = tc.getstr("kf9")
|
||||
t.KeyF10 = tc.getstr("kf10")
|
||||
t.KeyF11 = tc.getstr("kf11")
|
||||
t.KeyF12 = tc.getstr("kf12")
|
||||
t.KeyF13 = tc.getstr("kf13")
|
||||
t.KeyF14 = tc.getstr("kf14")
|
||||
t.KeyF15 = tc.getstr("kf15")
|
||||
t.KeyF16 = tc.getstr("kf16")
|
||||
t.KeyF17 = tc.getstr("kf17")
|
||||
t.KeyF18 = tc.getstr("kf18")
|
||||
t.KeyF19 = tc.getstr("kf19")
|
||||
t.KeyF20 = tc.getstr("kf20")
|
||||
t.KeyF21 = tc.getstr("kf21")
|
||||
t.KeyF22 = tc.getstr("kf22")
|
||||
t.KeyF23 = tc.getstr("kf23")
|
||||
t.KeyF24 = tc.getstr("kf24")
|
||||
t.KeyF25 = tc.getstr("kf25")
|
||||
t.KeyF26 = tc.getstr("kf26")
|
||||
t.KeyF27 = tc.getstr("kf27")
|
||||
t.KeyF28 = tc.getstr("kf28")
|
||||
t.KeyF29 = tc.getstr("kf29")
|
||||
t.KeyF30 = tc.getstr("kf30")
|
||||
t.KeyF31 = tc.getstr("kf31")
|
||||
t.KeyF32 = tc.getstr("kf32")
|
||||
t.KeyF33 = tc.getstr("kf33")
|
||||
t.KeyF34 = tc.getstr("kf34")
|
||||
t.KeyF35 = tc.getstr("kf35")
|
||||
t.KeyF36 = tc.getstr("kf36")
|
||||
t.KeyF37 = tc.getstr("kf37")
|
||||
t.KeyF38 = tc.getstr("kf38")
|
||||
t.KeyF39 = tc.getstr("kf39")
|
||||
t.KeyF40 = tc.getstr("kf40")
|
||||
t.KeyF41 = tc.getstr("kf41")
|
||||
t.KeyF42 = tc.getstr("kf42")
|
||||
t.KeyF43 = tc.getstr("kf43")
|
||||
t.KeyF44 = tc.getstr("kf44")
|
||||
t.KeyF45 = tc.getstr("kf45")
|
||||
t.KeyF46 = tc.getstr("kf46")
|
||||
t.KeyF47 = tc.getstr("kf47")
|
||||
t.KeyF48 = tc.getstr("kf48")
|
||||
t.KeyF49 = tc.getstr("kf49")
|
||||
t.KeyF50 = tc.getstr("kf50")
|
||||
t.KeyF51 = tc.getstr("kf51")
|
||||
t.KeyF52 = tc.getstr("kf52")
|
||||
t.KeyF53 = tc.getstr("kf53")
|
||||
t.KeyF54 = tc.getstr("kf54")
|
||||
t.KeyF55 = tc.getstr("kf55")
|
||||
t.KeyF56 = tc.getstr("kf56")
|
||||
t.KeyF57 = tc.getstr("kf57")
|
||||
t.KeyF58 = tc.getstr("kf58")
|
||||
t.KeyF59 = tc.getstr("kf59")
|
||||
t.KeyF60 = tc.getstr("kf60")
|
||||
t.KeyF61 = tc.getstr("kf61")
|
||||
t.KeyF62 = tc.getstr("kf62")
|
||||
t.KeyF63 = tc.getstr("kf63")
|
||||
t.KeyF64 = tc.getstr("kf64")
|
||||
t.KeyInsert = tc.getstr("kich1")
|
||||
t.KeyDelete = tc.getstr("kdch1")
|
||||
t.KeyBackspace = tc.getstr("kbs")
|
||||
t.KeyHome = tc.getstr("khome")
|
||||
t.KeyEnd = tc.getstr("kend")
|
||||
t.KeyUp = tc.getstr("kcuu1")
|
||||
t.KeyDown = tc.getstr("kcud1")
|
||||
t.KeyRight = tc.getstr("kcuf1")
|
||||
t.KeyLeft = tc.getstr("kcub1")
|
||||
t.KeyPgDn = tc.getstr("knp")
|
||||
t.KeyPgUp = tc.getstr("kpp")
|
||||
t.KeyBacktab = tc.getstr("kcbt")
|
||||
t.KeyExit = tc.getstr("kext")
|
||||
t.KeyCancel = tc.getstr("kcan")
|
||||
t.KeyPrint = tc.getstr("kprt")
|
||||
t.KeyHelp = tc.getstr("khlp")
|
||||
t.KeyClear = tc.getstr("kclr")
|
||||
t.AltChars = tc.getstr("acsc")
|
||||
t.EnterAcs = tc.getstr("smacs")
|
||||
t.ExitAcs = tc.getstr("rmacs")
|
||||
t.EnableAcs = tc.getstr("enacs")
|
||||
t.Mouse = tc.getstr("kmous")
|
||||
t.KeyShfRight = tc.getstr("kRIT")
|
||||
t.KeyShfLeft = tc.getstr("kLFT")
|
||||
t.KeyShfHome = tc.getstr("kHOM")
|
||||
t.KeyShfEnd = tc.getstr("kEND")
|
||||
|
||||
// Terminfo lacks descriptions for a bunch of modified keys,
|
||||
// but modern XTerm and emulators often have them. Let's add them,
|
||||
// if the shifted right and left arrows are defined.
|
||||
if t.KeyShfRight == "\x1b[1;2C" && t.KeyShfLeft == "\x1b[1;2D" {
|
||||
t.Modifiers = terminfo.ModifiersXTerm
|
||||
|
||||
t.KeyShfUp = "\x1b[1;2A"
|
||||
t.KeyShfDown = "\x1b[1;2B"
|
||||
t.KeyMetaUp = "\x1b[1;9A"
|
||||
t.KeyMetaDown = "\x1b[1;9B"
|
||||
t.KeyMetaRight = "\x1b[1;9C"
|
||||
t.KeyMetaLeft = "\x1b[1;9D"
|
||||
t.KeyAltUp = "\x1b[1;3A"
|
||||
t.KeyAltDown = "\x1b[1;3B"
|
||||
t.KeyAltRight = "\x1b[1;3C"
|
||||
t.KeyAltLeft = "\x1b[1;3D"
|
||||
t.KeyCtrlUp = "\x1b[1;5A"
|
||||
t.KeyCtrlDown = "\x1b[1;5B"
|
||||
t.KeyCtrlRight = "\x1b[1;5C"
|
||||
t.KeyCtrlLeft = "\x1b[1;5D"
|
||||
t.KeyAltShfUp = "\x1b[1;4A"
|
||||
t.KeyAltShfDown = "\x1b[1;4B"
|
||||
t.KeyAltShfRight = "\x1b[1;4C"
|
||||
t.KeyAltShfLeft = "\x1b[1;4D"
|
||||
|
||||
t.KeyMetaShfUp = "\x1b[1;10A"
|
||||
t.KeyMetaShfDown = "\x1b[1;10B"
|
||||
t.KeyMetaShfRight = "\x1b[1;10C"
|
||||
t.KeyMetaShfLeft = "\x1b[1;10D"
|
||||
|
||||
t.KeyCtrlShfUp = "\x1b[1;6A"
|
||||
t.KeyCtrlShfDown = "\x1b[1;6B"
|
||||
t.KeyCtrlShfRight = "\x1b[1;6C"
|
||||
t.KeyCtrlShfLeft = "\x1b[1;6D"
|
||||
|
||||
t.KeyShfPgUp = "\x1b[5;2~"
|
||||
t.KeyShfPgDn = "\x1b[6;2~"
|
||||
}
|
||||
// And also for Home and End
|
||||
if t.KeyShfHome == "\x1b[1;2H" && t.KeyShfEnd == "\x1b[1;2F" {
|
||||
t.KeyCtrlHome = "\x1b[1;5H"
|
||||
t.KeyCtrlEnd = "\x1b[1;5F"
|
||||
t.KeyAltHome = "\x1b[1;9H"
|
||||
t.KeyAltEnd = "\x1b[1;9F"
|
||||
t.KeyCtrlShfHome = "\x1b[1;6H"
|
||||
t.KeyCtrlShfEnd = "\x1b[1;6F"
|
||||
t.KeyAltShfHome = "\x1b[1;4H"
|
||||
t.KeyAltShfEnd = "\x1b[1;4F"
|
||||
t.KeyMetaShfHome = "\x1b[1;10H"
|
||||
t.KeyMetaShfEnd = "\x1b[1;10F"
|
||||
}
|
||||
|
||||
// And the same thing for rxvt and workalikes (Eterm, aterm, etc.)
|
||||
// It seems that urxvt at least send escaped as ALT prefix for these,
|
||||
// although some places seem to indicate a separate ALT key sesquence.
|
||||
if t.KeyShfRight == "\x1b[c" && t.KeyShfLeft == "\x1b[d" {
|
||||
t.KeyShfUp = "\x1b[a"
|
||||
t.KeyShfDown = "\x1b[b"
|
||||
t.KeyCtrlUp = "\x1b[Oa"
|
||||
t.KeyCtrlDown = "\x1b[Ob"
|
||||
t.KeyCtrlRight = "\x1b[Oc"
|
||||
t.KeyCtrlLeft = "\x1b[Od"
|
||||
}
|
||||
if t.KeyShfHome == "\x1b[7$" && t.KeyShfEnd == "\x1b[8$" {
|
||||
t.KeyCtrlHome = "\x1b[7^"
|
||||
t.KeyCtrlEnd = "\x1b[8^"
|
||||
}
|
||||
|
||||
// Technically the RGB flag that is provided for xterm-direct is not
|
||||
// quite right. The problem is that the -direct flag that was introduced
|
||||
|
||||
+32
-49
@@ -8,58 +8,41 @@ func init() {
|
||||
|
||||
// GNU Emacs term.el terminal emulation
|
||||
terminfo.AddTerminfo(&terminfo.Terminfo{
|
||||
Name: "eterm",
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[J",
|
||||
EnterCA: "\x1b7\x1b[?47h",
|
||||
ExitCA: "\x1b[2J\x1b[?47l\x1b8",
|
||||
AttrOff: "\x1b[m",
|
||||
Underline: "\x1b[4m",
|
||||
Bold: "\x1b[1m",
|
||||
Reverse: "\x1b[7m",
|
||||
PadChar: "\x00",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
AutoMargin: true,
|
||||
Name: "eterm",
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Clear: "\x1b[H\x1b[J",
|
||||
EnterCA: "\x1b7\x1b[?47h",
|
||||
ExitCA: "\x1b[2J\x1b[?47l\x1b8",
|
||||
AttrOff: "\x1b[m",
|
||||
Underline: "\x1b[4m",
|
||||
Bold: "\x1b[1m",
|
||||
Reverse: "\x1b[7m",
|
||||
PadChar: "\x00",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
AutoMargin: true,
|
||||
})
|
||||
|
||||
// Emacs term.el terminal emulator term-protocol-version 0.96
|
||||
terminfo.AddTerminfo(&terminfo.Terminfo{
|
||||
Name: "eterm-color",
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 8,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[J",
|
||||
EnterCA: "\x1b7\x1b[?47h",
|
||||
ExitCA: "\x1b[2J\x1b[?47l\x1b8",
|
||||
AttrOff: "\x1b[m",
|
||||
Underline: "\x1b[4m",
|
||||
Bold: "\x1b[1m",
|
||||
Blink: "\x1b[5m",
|
||||
Reverse: "\x1b[7m",
|
||||
SetFg: "\x1b[%p1%{30}%+%dm",
|
||||
SetBg: "\x1b[%p1%'('%+%dm",
|
||||
SetFgBg: "\x1b[%p1%{30}%+%d;%p2%'('%+%dm",
|
||||
ResetFgBg: "\x1b[39;49m",
|
||||
PadChar: "\x00",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1bOA",
|
||||
KeyDown: "\x1bOB",
|
||||
KeyRight: "\x1bOC",
|
||||
KeyLeft: "\x1bOD",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\x7f",
|
||||
KeyHome: "\x1b[1~",
|
||||
KeyEnd: "\x1b[4~",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
AutoMargin: true,
|
||||
Name: "eterm-color",
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 8,
|
||||
Clear: "\x1b[H\x1b[J",
|
||||
EnterCA: "\x1b7\x1b[?47h",
|
||||
ExitCA: "\x1b[2J\x1b[?47l\x1b8",
|
||||
AttrOff: "\x1b[m",
|
||||
Underline: "\x1b[4m",
|
||||
Bold: "\x1b[1m",
|
||||
Blink: "\x1b[5m",
|
||||
Reverse: "\x1b[7m",
|
||||
SetFg: "\x1b[%p1%{30}%+%dm",
|
||||
SetBg: "\x1b[%p1%'('%+%dm",
|
||||
SetFgBg: "\x1b[%p1%{30}%+%d;%p2%'('%+%dm",
|
||||
ResetFgBg: "\x1b[39;49m",
|
||||
PadChar: "\x00",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
AutoMargin: true,
|
||||
})
|
||||
}
|
||||
|
||||
-6
@@ -24,13 +24,11 @@ import (
|
||||
_ "github.com/gdamore/tcell/v2/terminfo/a/aixterm"
|
||||
_ "github.com/gdamore/tcell/v2/terminfo/a/alacritty"
|
||||
_ "github.com/gdamore/tcell/v2/terminfo/a/ansi"
|
||||
_ "github.com/gdamore/tcell/v2/terminfo/b/beterm"
|
||||
_ "github.com/gdamore/tcell/v2/terminfo/c/cygwin"
|
||||
_ "github.com/gdamore/tcell/v2/terminfo/d/dtterm"
|
||||
_ "github.com/gdamore/tcell/v2/terminfo/e/emacs"
|
||||
_ "github.com/gdamore/tcell/v2/terminfo/f/foot"
|
||||
_ "github.com/gdamore/tcell/v2/terminfo/g/gnome"
|
||||
_ "github.com/gdamore/tcell/v2/terminfo/h/hpterm"
|
||||
_ "github.com/gdamore/tcell/v2/terminfo/k/konsole"
|
||||
_ "github.com/gdamore/tcell/v2/terminfo/k/kterm"
|
||||
_ "github.com/gdamore/tcell/v2/terminfo/l/linux"
|
||||
@@ -46,10 +44,6 @@ import (
|
||||
_ "github.com/gdamore/tcell/v2/terminfo/v/vt320"
|
||||
_ "github.com/gdamore/tcell/v2/terminfo/v/vt400"
|
||||
_ "github.com/gdamore/tcell/v2/terminfo/v/vt420"
|
||||
_ "github.com/gdamore/tcell/v2/terminfo/v/vt52"
|
||||
_ "github.com/gdamore/tcell/v2/terminfo/w/wy50"
|
||||
_ "github.com/gdamore/tcell/v2/terminfo/w/wy60"
|
||||
_ "github.com/gdamore/tcell/v2/terminfo/w/wy99_ansi"
|
||||
_ "github.com/gdamore/tcell/v2/terminfo/x/xfce"
|
||||
_ "github.com/gdamore/tcell/v2/terminfo/x/xterm"
|
||||
_ "github.com/gdamore/tcell/v2/terminfo/x/xterm_ghostty"
|
||||
|
||||
-28
@@ -13,7 +13,6 @@ func init() {
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 256,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[2J",
|
||||
EnterCA: "\x1b[?1049h\x1b[22;0;0t",
|
||||
ExitCA: "\x1b[?1049l\x1b[23;0;0t",
|
||||
@@ -38,33 +37,6 @@ func init() {
|
||||
StrikeThrough: "\x1b[9m",
|
||||
Mouse: "\x1b[M",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1bOA",
|
||||
KeyDown: "\x1bOB",
|
||||
KeyRight: "\x1bOC",
|
||||
KeyLeft: "\x1bOD",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\u007f",
|
||||
KeyHome: "\x1bOH",
|
||||
KeyEnd: "\x1bOF",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1bOP",
|
||||
KeyF2: "\x1bOQ",
|
||||
KeyF3: "\x1bOR",
|
||||
KeyF4: "\x1bOS",
|
||||
KeyF5: "\x1b[15~",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyBacktab: "\x1b[Z",
|
||||
Modifiers: 1,
|
||||
AutoMargin: true,
|
||||
})
|
||||
}
|
||||
|
||||
-56
@@ -12,7 +12,6 @@ func init() {
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 8,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[2J",
|
||||
EnterCA: "\x1b7\x1b[?47h",
|
||||
ExitCA: "\x1b[2J\x1b[?47l\x1b8",
|
||||
@@ -39,33 +38,6 @@ func init() {
|
||||
DisableAutoMargin: "\x1b[?7l",
|
||||
Mouse: "\x1b[M",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1bOA",
|
||||
KeyDown: "\x1bOB",
|
||||
KeyRight: "\x1bOC",
|
||||
KeyLeft: "\x1bOD",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\x7f",
|
||||
KeyHome: "\x1bOH",
|
||||
KeyEnd: "\x1bOF",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1bOP",
|
||||
KeyF2: "\x1bOQ",
|
||||
KeyF3: "\x1bOR",
|
||||
KeyF4: "\x1bOS",
|
||||
KeyF5: "\x1b[15~",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyBacktab: "\x1b[Z",
|
||||
Modifiers: 1,
|
||||
AutoMargin: true,
|
||||
XTermLike: true,
|
||||
})
|
||||
@@ -76,7 +48,6 @@ func init() {
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 256,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[2J",
|
||||
EnterCA: "\x1b7\x1b[?47h",
|
||||
ExitCA: "\x1b[2J\x1b[?47l\x1b8",
|
||||
@@ -103,33 +74,6 @@ func init() {
|
||||
DisableAutoMargin: "\x1b[?7l",
|
||||
Mouse: "\x1b[M",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1bOA",
|
||||
KeyDown: "\x1bOB",
|
||||
KeyRight: "\x1bOC",
|
||||
KeyLeft: "\x1bOD",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\x7f",
|
||||
KeyHome: "\x1bOH",
|
||||
KeyEnd: "\x1bOF",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1bOP",
|
||||
KeyF2: "\x1bOQ",
|
||||
KeyF3: "\x1bOR",
|
||||
KeyF4: "\x1bOS",
|
||||
KeyF5: "\x1b[15~",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyBacktab: "\x1b[Z",
|
||||
Modifiers: 1,
|
||||
AutoMargin: true,
|
||||
XTermLike: true,
|
||||
})
|
||||
|
||||
-51
@@ -1,51 +0,0 @@
|
||||
// Generated automatically. DO NOT HAND-EDIT.
|
||||
|
||||
package hpterm
|
||||
|
||||
import "github.com/gdamore/tcell/v2/terminfo"
|
||||
|
||||
func init() {
|
||||
|
||||
// HP X11 terminal emulator (old)
|
||||
terminfo.AddTerminfo(&terminfo.Terminfo{
|
||||
Name: "hpterm",
|
||||
Aliases: []string{"X-hpterm"},
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b&a0y0C\x1bJ",
|
||||
AttrOff: "\x1b&d@\x0f",
|
||||
Underline: "\x1b&dD",
|
||||
Bold: "\x1b&dB",
|
||||
Dim: "\x1b&dH",
|
||||
Reverse: "\x1b&dB",
|
||||
EnterKeypad: "\x1b&s1A",
|
||||
ExitKeypad: "\x1b&s0A",
|
||||
PadChar: "\x00",
|
||||
EnterAcs: "\x0e",
|
||||
ExitAcs: "\x0f",
|
||||
SetCursor: "\x1b&a%p1%dy%p2%dC",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1bA",
|
||||
KeyUp: "\x1bA",
|
||||
KeyDown: "\x1bB",
|
||||
KeyRight: "\x1bC",
|
||||
KeyLeft: "\x1bD",
|
||||
KeyInsert: "\x1bQ",
|
||||
KeyDelete: "\x1bP",
|
||||
KeyBackspace: "\b",
|
||||
KeyHome: "\x1bh",
|
||||
KeyPgUp: "\x1bV",
|
||||
KeyPgDn: "\x1bU",
|
||||
KeyF1: "\x1bp",
|
||||
KeyF2: "\x1bq",
|
||||
KeyF3: "\x1br",
|
||||
KeyF4: "\x1bs",
|
||||
KeyF5: "\x1bt",
|
||||
KeyF6: "\x1bu",
|
||||
KeyF7: "\x1bv",
|
||||
KeyF8: "\x1bw",
|
||||
KeyClear: "\x1bJ",
|
||||
AutoMargin: true,
|
||||
})
|
||||
}
|
||||
-56
@@ -12,7 +12,6 @@ func init() {
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 8,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[2J",
|
||||
EnterCA: "\x1b7\x1b[?47h",
|
||||
ExitCA: "\x1b[2J\x1b[?47l\x1b8",
|
||||
@@ -40,33 +39,6 @@ func init() {
|
||||
StrikeThrough: "\x1b[9m",
|
||||
Mouse: "\x1b[<",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1bOA",
|
||||
KeyDown: "\x1bOB",
|
||||
KeyRight: "\x1bOC",
|
||||
KeyLeft: "\x1bOD",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\x7f",
|
||||
KeyHome: "\x1bOH",
|
||||
KeyEnd: "\x1bOF",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1bOP",
|
||||
KeyF2: "\x1bOQ",
|
||||
KeyF3: "\x1bOR",
|
||||
KeyF4: "\x1bOS",
|
||||
KeyF5: "\x1b[15~",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyBacktab: "\x1b[Z",
|
||||
Modifiers: 1,
|
||||
AutoMargin: true,
|
||||
XTermLike: true,
|
||||
})
|
||||
@@ -77,7 +49,6 @@ func init() {
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 256,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[2J",
|
||||
EnterCA: "\x1b7\x1b[?47h",
|
||||
ExitCA: "\x1b[2J\x1b[?47l\x1b8",
|
||||
@@ -105,33 +76,6 @@ func init() {
|
||||
StrikeThrough: "\x1b[9m",
|
||||
Mouse: "\x1b[<",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1bOA",
|
||||
KeyDown: "\x1bOB",
|
||||
KeyRight: "\x1bOC",
|
||||
KeyLeft: "\x1bOD",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\x7f",
|
||||
KeyHome: "\x1bOH",
|
||||
KeyEnd: "\x1bOF",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1bOP",
|
||||
KeyF2: "\x1bOQ",
|
||||
KeyF3: "\x1bOR",
|
||||
KeyF4: "\x1bOS",
|
||||
KeyF5: "\x1b[15~",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyBacktab: "\x1b[Z",
|
||||
Modifiers: 1,
|
||||
AutoMargin: true,
|
||||
XTermLike: true,
|
||||
})
|
||||
|
||||
-32
@@ -12,7 +12,6 @@ func init() {
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 8,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[2J",
|
||||
EnterCA: "\x1b7\x1b[?47h",
|
||||
ExitCA: "\x1b[2J\x1b[?47l\x1b8",
|
||||
@@ -34,37 +33,6 @@ func init() {
|
||||
DisableAutoMargin: "\x1b[?7l",
|
||||
Mouse: "\x1b[M",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1bOA",
|
||||
KeyDown: "\x1bOB",
|
||||
KeyRight: "\x1bOC",
|
||||
KeyLeft: "\x1bOD",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\x7f",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1b[11~",
|
||||
KeyF2: "\x1b[12~",
|
||||
KeyF3: "\x1b[13~",
|
||||
KeyF4: "\x1b[14~",
|
||||
KeyF5: "\x1b[15~",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyF13: "\x1b[25~",
|
||||
KeyF14: "\x1b[26~",
|
||||
KeyF15: "\x1b[28~",
|
||||
KeyF16: "\x1b[29~",
|
||||
KeyF17: "\x1b[31~",
|
||||
KeyF18: "\x1b[32~",
|
||||
KeyF19: "\x1b[33~",
|
||||
KeyF20: "\x1b[34~",
|
||||
AutoMargin: true,
|
||||
XTermLike: true,
|
||||
})
|
||||
|
||||
-35
@@ -10,7 +10,6 @@ func init() {
|
||||
terminfo.AddTerminfo(&terminfo.Terminfo{
|
||||
Name: "linux",
|
||||
Colors: 8,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[J",
|
||||
ShowCursor: "\x1b[?25h\x1b[?0c",
|
||||
HideCursor: "\x1b[?25l\x1b[?1c",
|
||||
@@ -33,40 +32,6 @@ func init() {
|
||||
DisableAutoMargin: "\x1b[?7l",
|
||||
Mouse: "\x1b[M",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1b[A",
|
||||
KeyDown: "\x1b[B",
|
||||
KeyRight: "\x1b[C",
|
||||
KeyLeft: "\x1b[D",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\x7f",
|
||||
KeyHome: "\x1b[1~",
|
||||
KeyEnd: "\x1b[4~",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1b[[A",
|
||||
KeyF2: "\x1b[[B",
|
||||
KeyF3: "\x1b[[C",
|
||||
KeyF4: "\x1b[[D",
|
||||
KeyF5: "\x1b[[E",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyF13: "\x1b[25~",
|
||||
KeyF14: "\x1b[26~",
|
||||
KeyF15: "\x1b[28~",
|
||||
KeyF16: "\x1b[29~",
|
||||
KeyF17: "\x1b[31~",
|
||||
KeyF18: "\x1b[32~",
|
||||
KeyF19: "\x1b[33~",
|
||||
KeyF20: "\x1b[34~",
|
||||
KeyBacktab: "\x1b\t",
|
||||
AutoMargin: true,
|
||||
InsertChar: "\x1b[@",
|
||||
})
|
||||
|
||||
-2
@@ -1,7 +1,6 @@
|
||||
aixterm
|
||||
alacritty
|
||||
ansi
|
||||
beterm
|
||||
cygwin
|
||||
dtterm
|
||||
eterm,eterm-color|emacs
|
||||
@@ -15,7 +14,6 @@ rxvt,rxvt-256color,rxvt-88color,rxvt-unicode,rxvt-unicode-256color
|
||||
screen,screen-256color
|
||||
st,st-256color|simpleterm
|
||||
tmux,tmux-256color
|
||||
vt52
|
||||
vt100
|
||||
vt102
|
||||
vt220
|
||||
|
||||
+20
-29
@@ -8,34 +8,25 @@ func init() {
|
||||
|
||||
// ibm-pc terminal programs claiming to be ANSI
|
||||
terminfo.AddTerminfo(&terminfo.Terminfo{
|
||||
Name: "pcansi",
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 8,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[J",
|
||||
AttrOff: "\x1b[0;10m",
|
||||
Underline: "\x1b[4m",
|
||||
Bold: "\x1b[1m",
|
||||
Blink: "\x1b[5m",
|
||||
Reverse: "\x1b[7m",
|
||||
SetFg: "\x1b[3%p1%dm",
|
||||
SetBg: "\x1b[4%p1%dm",
|
||||
SetFgBg: "\x1b[3%p1%d;4%p2%dm",
|
||||
ResetFgBg: "\x1b[37;40m",
|
||||
PadChar: "\x00",
|
||||
AltChars: "+\x10,\x11-\x18.\x190\xdb`\x04a\xb1f\xf8g\xf1h\xb0j\xd9k\xbfl\xdam\xc0n\xc5o~p\xc4q\xc4r\xc4s_t\xc3u\xb4v\xc1w\xc2x\xb3y\xf3z\xf2{\xe3|\xd8}\x9c~\xfe",
|
||||
EnterAcs: "\x1b[12m",
|
||||
ExitAcs: "\x1b[10m",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\x1b[D",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1b[A",
|
||||
KeyDown: "\x1b[B",
|
||||
KeyRight: "\x1b[C",
|
||||
KeyLeft: "\x1b[D",
|
||||
KeyBackspace: "\b",
|
||||
KeyHome: "\x1b[H",
|
||||
AutoMargin: true,
|
||||
Name: "pcansi",
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 8,
|
||||
Clear: "\x1b[H\x1b[J",
|
||||
AttrOff: "\x1b[0;10m",
|
||||
Underline: "\x1b[4m",
|
||||
Bold: "\x1b[1m",
|
||||
Blink: "\x1b[5m",
|
||||
Reverse: "\x1b[7m",
|
||||
SetFg: "\x1b[3%p1%dm",
|
||||
SetBg: "\x1b[4%p1%dm",
|
||||
SetFgBg: "\x1b[3%p1%d;4%p2%dm",
|
||||
ResetFgBg: "\x1b[37;40m",
|
||||
PadChar: "\x00",
|
||||
AltChars: "+\x10,\x11-\x18.\x190\xdb`\x04a\xb1f\xf8g\xf1h\xb0j\xd9k\xbfl\xdam\xc0n\xc5o~p\xc4q\xc4r\xc4s_t\xc3u\xb4v\xc1w\xc2x\xb3y\xf3z\xf2{\xe3|\xd8}\x9c~\xfe",
|
||||
EnterAcs: "\x1b[12m",
|
||||
ExitAcs: "\x1b[10m",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
AutoMargin: true,
|
||||
})
|
||||
}
|
||||
|
||||
+88
-405
@@ -8,321 +8,102 @@ func init() {
|
||||
|
||||
// rxvt terminal emulator (X Window System)
|
||||
terminfo.AddTerminfo(&terminfo.Terminfo{
|
||||
Name: "rxvt",
|
||||
Aliases: []string{"rxvt-color"},
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 8,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[2J",
|
||||
EnterCA: "\x1b7\x1b[?47h",
|
||||
ExitCA: "\x1b[2J\x1b[?47l\x1b8",
|
||||
ShowCursor: "\x1b[?25h",
|
||||
HideCursor: "\x1b[?25l",
|
||||
AttrOff: "\x1b[m\x0f",
|
||||
Underline: "\x1b[4m",
|
||||
Bold: "\x1b[1m",
|
||||
Blink: "\x1b[5m",
|
||||
Reverse: "\x1b[7m",
|
||||
EnterKeypad: "\x1b=",
|
||||
ExitKeypad: "\x1b>",
|
||||
SetFg: "\x1b[3%p1%dm",
|
||||
SetBg: "\x1b[4%p1%dm",
|
||||
SetFgBg: "\x1b[3%p1%d;4%p2%dm",
|
||||
ResetFgBg: "\x1b[39;49m",
|
||||
PadChar: "\x00",
|
||||
AltChars: "``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~",
|
||||
EnterAcs: "\x0e",
|
||||
ExitAcs: "\x0f",
|
||||
EnableAcs: "\x1b(B\x1b)0",
|
||||
Mouse: "\x1b[M",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1b[A",
|
||||
KeyDown: "\x1b[B",
|
||||
KeyRight: "\x1b[C",
|
||||
KeyLeft: "\x1b[D",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\x7f",
|
||||
KeyHome: "\x1b[7~",
|
||||
KeyEnd: "\x1b[8~",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1b[11~",
|
||||
KeyF2: "\x1b[12~",
|
||||
KeyF3: "\x1b[13~",
|
||||
KeyF4: "\x1b[14~",
|
||||
KeyF5: "\x1b[15~",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyF13: "\x1b[25~",
|
||||
KeyF14: "\x1b[26~",
|
||||
KeyF15: "\x1b[28~",
|
||||
KeyF16: "\x1b[29~",
|
||||
KeyF17: "\x1b[31~",
|
||||
KeyF18: "\x1b[32~",
|
||||
KeyF19: "\x1b[33~",
|
||||
KeyF20: "\x1b[34~",
|
||||
KeyF21: "\x1b[23$",
|
||||
KeyF22: "\x1b[24$",
|
||||
KeyF23: "\x1b[11^",
|
||||
KeyF24: "\x1b[12^",
|
||||
KeyF25: "\x1b[13^",
|
||||
KeyF26: "\x1b[14^",
|
||||
KeyF27: "\x1b[15^",
|
||||
KeyF28: "\x1b[17^",
|
||||
KeyF29: "\x1b[18^",
|
||||
KeyF30: "\x1b[19^",
|
||||
KeyF31: "\x1b[20^",
|
||||
KeyF32: "\x1b[21^",
|
||||
KeyF33: "\x1b[23^",
|
||||
KeyF34: "\x1b[24^",
|
||||
KeyF35: "\x1b[25^",
|
||||
KeyF36: "\x1b[26^",
|
||||
KeyF37: "\x1b[28^",
|
||||
KeyF38: "\x1b[29^",
|
||||
KeyF39: "\x1b[31^",
|
||||
KeyF40: "\x1b[32^",
|
||||
KeyF41: "\x1b[33^",
|
||||
KeyF42: "\x1b[34^",
|
||||
KeyF43: "\x1b[23@",
|
||||
KeyF44: "\x1b[24@",
|
||||
KeyBacktab: "\x1b[Z",
|
||||
KeyShfLeft: "\x1b[d",
|
||||
KeyShfRight: "\x1b[c",
|
||||
KeyShfUp: "\x1b[a",
|
||||
KeyShfDown: "\x1b[b",
|
||||
KeyShfHome: "\x1b[7$",
|
||||
KeyShfEnd: "\x1b[8$",
|
||||
KeyShfInsert: "\x1b[2$",
|
||||
KeyShfDelete: "\x1b[3$",
|
||||
KeyCtrlUp: "\x1b[Oa",
|
||||
KeyCtrlDown: "\x1b[Ob",
|
||||
KeyCtrlRight: "\x1b[Oc",
|
||||
KeyCtrlLeft: "\x1b[Od",
|
||||
KeyCtrlHome: "\x1b[7^",
|
||||
KeyCtrlEnd: "\x1b[8^",
|
||||
AutoMargin: true,
|
||||
XTermLike: true,
|
||||
Name: "rxvt",
|
||||
Aliases: []string{"rxvt-color"},
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 8,
|
||||
Clear: "\x1b[H\x1b[2J",
|
||||
EnterCA: "\x1b7\x1b[?47h",
|
||||
ExitCA: "\x1b[2J\x1b[?47l\x1b8",
|
||||
ShowCursor: "\x1b[?25h",
|
||||
HideCursor: "\x1b[?25l",
|
||||
AttrOff: "\x1b[m\x0f",
|
||||
Underline: "\x1b[4m",
|
||||
Bold: "\x1b[1m",
|
||||
Blink: "\x1b[5m",
|
||||
Reverse: "\x1b[7m",
|
||||
EnterKeypad: "\x1b=",
|
||||
ExitKeypad: "\x1b>",
|
||||
SetFg: "\x1b[3%p1%dm",
|
||||
SetBg: "\x1b[4%p1%dm",
|
||||
SetFgBg: "\x1b[3%p1%d;4%p2%dm",
|
||||
ResetFgBg: "\x1b[39;49m",
|
||||
PadChar: "\x00",
|
||||
AltChars: "``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~",
|
||||
EnterAcs: "\x0e",
|
||||
ExitAcs: "\x0f",
|
||||
EnableAcs: "\x1b(B\x1b)0",
|
||||
Mouse: "\x1b[M",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
AutoMargin: true,
|
||||
XTermLike: true,
|
||||
})
|
||||
|
||||
// rxvt 2.7.9 with xterm 256-colors
|
||||
terminfo.AddTerminfo(&terminfo.Terminfo{
|
||||
Name: "rxvt-256color",
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 256,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[2J",
|
||||
EnterCA: "\x1b7\x1b[?47h",
|
||||
ExitCA: "\x1b[2J\x1b[?47l\x1b8",
|
||||
ShowCursor: "\x1b[?25h",
|
||||
HideCursor: "\x1b[?25l",
|
||||
AttrOff: "\x1b[m\x0f",
|
||||
Underline: "\x1b[4m",
|
||||
Bold: "\x1b[1m",
|
||||
Blink: "\x1b[5m",
|
||||
Reverse: "\x1b[7m",
|
||||
EnterKeypad: "\x1b=",
|
||||
ExitKeypad: "\x1b>",
|
||||
SetFg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m",
|
||||
SetBg: "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m",
|
||||
SetFgBg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;;%?%p2%{8}%<%t4%p2%d%e%p2%{16}%<%t10%p2%{8}%-%d%e48;5;%p2%d%;m",
|
||||
ResetFgBg: "\x1b[39;49m",
|
||||
PadChar: "\x00",
|
||||
AltChars: "``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~",
|
||||
EnterAcs: "\x0e",
|
||||
ExitAcs: "\x0f",
|
||||
EnableAcs: "\x1b(B\x1b)0",
|
||||
Mouse: "\x1b[M",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1b[A",
|
||||
KeyDown: "\x1b[B",
|
||||
KeyRight: "\x1b[C",
|
||||
KeyLeft: "\x1b[D",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\x7f",
|
||||
KeyHome: "\x1b[7~",
|
||||
KeyEnd: "\x1b[8~",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1b[11~",
|
||||
KeyF2: "\x1b[12~",
|
||||
KeyF3: "\x1b[13~",
|
||||
KeyF4: "\x1b[14~",
|
||||
KeyF5: "\x1b[15~",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyF13: "\x1b[25~",
|
||||
KeyF14: "\x1b[26~",
|
||||
KeyF15: "\x1b[28~",
|
||||
KeyF16: "\x1b[29~",
|
||||
KeyF17: "\x1b[31~",
|
||||
KeyF18: "\x1b[32~",
|
||||
KeyF19: "\x1b[33~",
|
||||
KeyF20: "\x1b[34~",
|
||||
KeyF21: "\x1b[23$",
|
||||
KeyF22: "\x1b[24$",
|
||||
KeyF23: "\x1b[11^",
|
||||
KeyF24: "\x1b[12^",
|
||||
KeyF25: "\x1b[13^",
|
||||
KeyF26: "\x1b[14^",
|
||||
KeyF27: "\x1b[15^",
|
||||
KeyF28: "\x1b[17^",
|
||||
KeyF29: "\x1b[18^",
|
||||
KeyF30: "\x1b[19^",
|
||||
KeyF31: "\x1b[20^",
|
||||
KeyF32: "\x1b[21^",
|
||||
KeyF33: "\x1b[23^",
|
||||
KeyF34: "\x1b[24^",
|
||||
KeyF35: "\x1b[25^",
|
||||
KeyF36: "\x1b[26^",
|
||||
KeyF37: "\x1b[28^",
|
||||
KeyF38: "\x1b[29^",
|
||||
KeyF39: "\x1b[31^",
|
||||
KeyF40: "\x1b[32^",
|
||||
KeyF41: "\x1b[33^",
|
||||
KeyF42: "\x1b[34^",
|
||||
KeyF43: "\x1b[23@",
|
||||
KeyF44: "\x1b[24@",
|
||||
KeyBacktab: "\x1b[Z",
|
||||
KeyShfLeft: "\x1b[d",
|
||||
KeyShfRight: "\x1b[c",
|
||||
KeyShfUp: "\x1b[a",
|
||||
KeyShfDown: "\x1b[b",
|
||||
KeyShfHome: "\x1b[7$",
|
||||
KeyShfEnd: "\x1b[8$",
|
||||
KeyShfInsert: "\x1b[2$",
|
||||
KeyShfDelete: "\x1b[3$",
|
||||
KeyCtrlUp: "\x1b[Oa",
|
||||
KeyCtrlDown: "\x1b[Ob",
|
||||
KeyCtrlRight: "\x1b[Oc",
|
||||
KeyCtrlLeft: "\x1b[Od",
|
||||
KeyCtrlHome: "\x1b[7^",
|
||||
KeyCtrlEnd: "\x1b[8^",
|
||||
AutoMargin: true,
|
||||
XTermLike: true,
|
||||
Name: "rxvt-256color",
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 256,
|
||||
Clear: "\x1b[H\x1b[2J",
|
||||
EnterCA: "\x1b7\x1b[?47h",
|
||||
ExitCA: "\x1b[2J\x1b[?47l\x1b8",
|
||||
ShowCursor: "\x1b[?25h",
|
||||
HideCursor: "\x1b[?25l",
|
||||
AttrOff: "\x1b[m\x0f",
|
||||
Underline: "\x1b[4m",
|
||||
Bold: "\x1b[1m",
|
||||
Blink: "\x1b[5m",
|
||||
Reverse: "\x1b[7m",
|
||||
EnterKeypad: "\x1b=",
|
||||
ExitKeypad: "\x1b>",
|
||||
SetFg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m",
|
||||
SetBg: "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m",
|
||||
SetFgBg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;;%?%p2%{8}%<%t4%p2%d%e%p2%{16}%<%t10%p2%{8}%-%d%e48;5;%p2%d%;m",
|
||||
ResetFgBg: "\x1b[39;49m",
|
||||
PadChar: "\x00",
|
||||
AltChars: "``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~",
|
||||
EnterAcs: "\x0e",
|
||||
ExitAcs: "\x0f",
|
||||
EnableAcs: "\x1b(B\x1b)0",
|
||||
Mouse: "\x1b[M",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
AutoMargin: true,
|
||||
XTermLike: true,
|
||||
})
|
||||
|
||||
// rxvt 2.7.9 with xterm 88-colors
|
||||
terminfo.AddTerminfo(&terminfo.Terminfo{
|
||||
Name: "rxvt-88color",
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 88,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[2J",
|
||||
EnterCA: "\x1b7\x1b[?47h",
|
||||
ExitCA: "\x1b[2J\x1b[?47l\x1b8",
|
||||
ShowCursor: "\x1b[?25h",
|
||||
HideCursor: "\x1b[?25l",
|
||||
AttrOff: "\x1b[m\x0f",
|
||||
Underline: "\x1b[4m",
|
||||
Bold: "\x1b[1m",
|
||||
Blink: "\x1b[5m",
|
||||
Reverse: "\x1b[7m",
|
||||
EnterKeypad: "\x1b=",
|
||||
ExitKeypad: "\x1b>",
|
||||
SetFg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m",
|
||||
SetBg: "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m",
|
||||
SetFgBg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;;%?%p2%{8}%<%t4%p2%d%e%p2%{16}%<%t10%p2%{8}%-%d%e48;5;%p2%d%;m",
|
||||
ResetFgBg: "\x1b[39;49m",
|
||||
PadChar: "\x00",
|
||||
AltChars: "``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~",
|
||||
EnterAcs: "\x0e",
|
||||
ExitAcs: "\x0f",
|
||||
EnableAcs: "\x1b(B\x1b)0",
|
||||
Mouse: "\x1b[M",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1b[A",
|
||||
KeyDown: "\x1b[B",
|
||||
KeyRight: "\x1b[C",
|
||||
KeyLeft: "\x1b[D",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\x7f",
|
||||
KeyHome: "\x1b[7~",
|
||||
KeyEnd: "\x1b[8~",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1b[11~",
|
||||
KeyF2: "\x1b[12~",
|
||||
KeyF3: "\x1b[13~",
|
||||
KeyF4: "\x1b[14~",
|
||||
KeyF5: "\x1b[15~",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyF13: "\x1b[25~",
|
||||
KeyF14: "\x1b[26~",
|
||||
KeyF15: "\x1b[28~",
|
||||
KeyF16: "\x1b[29~",
|
||||
KeyF17: "\x1b[31~",
|
||||
KeyF18: "\x1b[32~",
|
||||
KeyF19: "\x1b[33~",
|
||||
KeyF20: "\x1b[34~",
|
||||
KeyF21: "\x1b[23$",
|
||||
KeyF22: "\x1b[24$",
|
||||
KeyF23: "\x1b[11^",
|
||||
KeyF24: "\x1b[12^",
|
||||
KeyF25: "\x1b[13^",
|
||||
KeyF26: "\x1b[14^",
|
||||
KeyF27: "\x1b[15^",
|
||||
KeyF28: "\x1b[17^",
|
||||
KeyF29: "\x1b[18^",
|
||||
KeyF30: "\x1b[19^",
|
||||
KeyF31: "\x1b[20^",
|
||||
KeyF32: "\x1b[21^",
|
||||
KeyF33: "\x1b[23^",
|
||||
KeyF34: "\x1b[24^",
|
||||
KeyF35: "\x1b[25^",
|
||||
KeyF36: "\x1b[26^",
|
||||
KeyF37: "\x1b[28^",
|
||||
KeyF38: "\x1b[29^",
|
||||
KeyF39: "\x1b[31^",
|
||||
KeyF40: "\x1b[32^",
|
||||
KeyF41: "\x1b[33^",
|
||||
KeyF42: "\x1b[34^",
|
||||
KeyF43: "\x1b[23@",
|
||||
KeyF44: "\x1b[24@",
|
||||
KeyBacktab: "\x1b[Z",
|
||||
KeyShfLeft: "\x1b[d",
|
||||
KeyShfRight: "\x1b[c",
|
||||
KeyShfUp: "\x1b[a",
|
||||
KeyShfDown: "\x1b[b",
|
||||
KeyShfHome: "\x1b[7$",
|
||||
KeyShfEnd: "\x1b[8$",
|
||||
KeyShfInsert: "\x1b[2$",
|
||||
KeyShfDelete: "\x1b[3$",
|
||||
KeyCtrlUp: "\x1b[Oa",
|
||||
KeyCtrlDown: "\x1b[Ob",
|
||||
KeyCtrlRight: "\x1b[Oc",
|
||||
KeyCtrlLeft: "\x1b[Od",
|
||||
KeyCtrlHome: "\x1b[7^",
|
||||
KeyCtrlEnd: "\x1b[8^",
|
||||
AutoMargin: true,
|
||||
XTermLike: true,
|
||||
Name: "rxvt-88color",
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 88,
|
||||
Clear: "\x1b[H\x1b[2J",
|
||||
EnterCA: "\x1b7\x1b[?47h",
|
||||
ExitCA: "\x1b[2J\x1b[?47l\x1b8",
|
||||
ShowCursor: "\x1b[?25h",
|
||||
HideCursor: "\x1b[?25l",
|
||||
AttrOff: "\x1b[m\x0f",
|
||||
Underline: "\x1b[4m",
|
||||
Bold: "\x1b[1m",
|
||||
Blink: "\x1b[5m",
|
||||
Reverse: "\x1b[7m",
|
||||
EnterKeypad: "\x1b=",
|
||||
ExitKeypad: "\x1b>",
|
||||
SetFg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m",
|
||||
SetBg: "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m",
|
||||
SetFgBg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;;%?%p2%{8}%<%t4%p2%d%e%p2%{16}%<%t10%p2%{8}%-%d%e48;5;%p2%d%;m",
|
||||
ResetFgBg: "\x1b[39;49m",
|
||||
PadChar: "\x00",
|
||||
AltChars: "``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~",
|
||||
EnterAcs: "\x0e",
|
||||
ExitAcs: "\x0f",
|
||||
EnableAcs: "\x1b(B\x1b)0",
|
||||
Mouse: "\x1b[M",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
AutoMargin: true,
|
||||
XTermLike: true,
|
||||
})
|
||||
|
||||
// rxvt-unicode terminal (X Window System)
|
||||
@@ -331,7 +112,6 @@ func init() {
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 88,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[2J",
|
||||
EnterCA: "\x1b[?1049h",
|
||||
ExitCA: "\x1b[r\x1b[?1049l",
|
||||
@@ -356,54 +136,6 @@ func init() {
|
||||
DisableAutoMargin: "\x1b[?7l",
|
||||
Mouse: "\x1b[M",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1b[A",
|
||||
KeyDown: "\x1b[B",
|
||||
KeyRight: "\x1b[C",
|
||||
KeyLeft: "\x1b[D",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\x7f",
|
||||
KeyHome: "\x1b[7~",
|
||||
KeyEnd: "\x1b[8~",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1b[11~",
|
||||
KeyF2: "\x1b[12~",
|
||||
KeyF3: "\x1b[13~",
|
||||
KeyF4: "\x1b[14~",
|
||||
KeyF5: "\x1b[15~",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyF13: "\x1b[25~",
|
||||
KeyF14: "\x1b[26~",
|
||||
KeyF15: "\x1b[28~",
|
||||
KeyF16: "\x1b[29~",
|
||||
KeyF17: "\x1b[31~",
|
||||
KeyF18: "\x1b[32~",
|
||||
KeyF19: "\x1b[33~",
|
||||
KeyF20: "\x1b[34~",
|
||||
KeyBacktab: "\x1b[Z",
|
||||
KeyShfLeft: "\x1b[d",
|
||||
KeyShfRight: "\x1b[c",
|
||||
KeyShfUp: "\x1b[a",
|
||||
KeyShfDown: "\x1b[b",
|
||||
KeyShfHome: "\x1b[7$",
|
||||
KeyShfEnd: "\x1b[8$",
|
||||
KeyShfInsert: "\x1b[2$",
|
||||
KeyShfDelete: "\x1b[3$",
|
||||
KeyCtrlUp: "\x1b[Oa",
|
||||
KeyCtrlDown: "\x1b[Ob",
|
||||
KeyCtrlRight: "\x1b[Oc",
|
||||
KeyCtrlLeft: "\x1b[Od",
|
||||
KeyCtrlHome: "\x1b[7^",
|
||||
KeyCtrlEnd: "\x1b[8^",
|
||||
AutoMargin: true,
|
||||
InsertChar: "\x1b[@",
|
||||
})
|
||||
@@ -414,7 +146,6 @@ func init() {
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 256,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[2J",
|
||||
EnterCA: "\x1b[?1049h",
|
||||
ExitCA: "\x1b[r\x1b[?1049l",
|
||||
@@ -439,54 +170,6 @@ func init() {
|
||||
DisableAutoMargin: "\x1b[?7l",
|
||||
Mouse: "\x1b[M",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1b[A",
|
||||
KeyDown: "\x1b[B",
|
||||
KeyRight: "\x1b[C",
|
||||
KeyLeft: "\x1b[D",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\x7f",
|
||||
KeyHome: "\x1b[7~",
|
||||
KeyEnd: "\x1b[8~",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1b[11~",
|
||||
KeyF2: "\x1b[12~",
|
||||
KeyF3: "\x1b[13~",
|
||||
KeyF4: "\x1b[14~",
|
||||
KeyF5: "\x1b[15~",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyF13: "\x1b[25~",
|
||||
KeyF14: "\x1b[26~",
|
||||
KeyF15: "\x1b[28~",
|
||||
KeyF16: "\x1b[29~",
|
||||
KeyF17: "\x1b[31~",
|
||||
KeyF18: "\x1b[32~",
|
||||
KeyF19: "\x1b[33~",
|
||||
KeyF20: "\x1b[34~",
|
||||
KeyBacktab: "\x1b[Z",
|
||||
KeyShfLeft: "\x1b[d",
|
||||
KeyShfRight: "\x1b[c",
|
||||
KeyShfUp: "\x1b[a",
|
||||
KeyShfDown: "\x1b[b",
|
||||
KeyShfHome: "\x1b[7$",
|
||||
KeyShfEnd: "\x1b[8$",
|
||||
KeyShfInsert: "\x1b[2$",
|
||||
KeyShfDelete: "\x1b[3$",
|
||||
KeyCtrlUp: "\x1b[Oa",
|
||||
KeyCtrlDown: "\x1b[Ob",
|
||||
KeyCtrlRight: "\x1b[Oc",
|
||||
KeyCtrlLeft: "\x1b[Od",
|
||||
KeyCtrlHome: "\x1b[7^",
|
||||
KeyCtrlEnd: "\x1b[8^",
|
||||
AutoMargin: true,
|
||||
InsertChar: "\x1b[@",
|
||||
})
|
||||
|
||||
+58
-112
@@ -8,121 +8,67 @@ func init() {
|
||||
|
||||
// VT 100/ANSI X3.64 virtual terminal
|
||||
terminfo.AddTerminfo(&terminfo.Terminfo{
|
||||
Name: "screen",
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 8,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[J",
|
||||
EnterCA: "\x1b[?1049h",
|
||||
ExitCA: "\x1b[?1049l",
|
||||
ShowCursor: "\x1b[34h\x1b[?25h",
|
||||
HideCursor: "\x1b[?25l",
|
||||
AttrOff: "\x1b[m\x0f",
|
||||
Underline: "\x1b[4m",
|
||||
Bold: "\x1b[1m",
|
||||
Dim: "\x1b[2m",
|
||||
Blink: "\x1b[5m",
|
||||
Reverse: "\x1b[7m",
|
||||
EnterKeypad: "\x1b[?1h\x1b=",
|
||||
ExitKeypad: "\x1b[?1l\x1b>",
|
||||
SetFg: "\x1b[3%p1%dm",
|
||||
SetBg: "\x1b[4%p1%dm",
|
||||
SetFgBg: "\x1b[3%p1%d;4%p2%dm",
|
||||
ResetFgBg: "\x1b[39;49m",
|
||||
PadChar: "\x00",
|
||||
AltChars: "++,,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~",
|
||||
EnterAcs: "\x0e",
|
||||
ExitAcs: "\x0f",
|
||||
EnableAcs: "\x1b(B\x1b)0",
|
||||
Mouse: "\x1b[M",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1bM",
|
||||
KeyUp: "\x1bOA",
|
||||
KeyDown: "\x1bOB",
|
||||
KeyRight: "\x1bOC",
|
||||
KeyLeft: "\x1bOD",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\x7f",
|
||||
KeyHome: "\x1b[1~",
|
||||
KeyEnd: "\x1b[4~",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1bOP",
|
||||
KeyF2: "\x1bOQ",
|
||||
KeyF3: "\x1bOR",
|
||||
KeyF4: "\x1bOS",
|
||||
KeyF5: "\x1b[15~",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyBacktab: "\x1b[Z",
|
||||
AutoMargin: true,
|
||||
Name: "screen",
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 8,
|
||||
Clear: "\x1b[H\x1b[J",
|
||||
EnterCA: "\x1b[?1049h",
|
||||
ExitCA: "\x1b[?1049l",
|
||||
ShowCursor: "\x1b[34h\x1b[?25h",
|
||||
HideCursor: "\x1b[?25l",
|
||||
AttrOff: "\x1b[m\x0f",
|
||||
Underline: "\x1b[4m",
|
||||
Bold: "\x1b[1m",
|
||||
Dim: "\x1b[2m",
|
||||
Blink: "\x1b[5m",
|
||||
Reverse: "\x1b[7m",
|
||||
EnterKeypad: "\x1b[?1h\x1b=",
|
||||
ExitKeypad: "\x1b[?1l\x1b>",
|
||||
SetFg: "\x1b[3%p1%dm",
|
||||
SetBg: "\x1b[4%p1%dm",
|
||||
SetFgBg: "\x1b[3%p1%d;4%p2%dm",
|
||||
ResetFgBg: "\x1b[39;49m",
|
||||
PadChar: "\x00",
|
||||
AltChars: "++,,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~",
|
||||
EnterAcs: "\x0e",
|
||||
ExitAcs: "\x0f",
|
||||
EnableAcs: "\x1b(B\x1b)0",
|
||||
Mouse: "\x1b[M",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
AutoMargin: true,
|
||||
})
|
||||
|
||||
// GNU Screen with 256 colors
|
||||
terminfo.AddTerminfo(&terminfo.Terminfo{
|
||||
Name: "screen-256color",
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 256,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[J",
|
||||
EnterCA: "\x1b[?1049h",
|
||||
ExitCA: "\x1b[?1049l",
|
||||
ShowCursor: "\x1b[34h\x1b[?25h",
|
||||
HideCursor: "\x1b[?25l",
|
||||
AttrOff: "\x1b[m\x0f",
|
||||
Underline: "\x1b[4m",
|
||||
Bold: "\x1b[1m",
|
||||
Dim: "\x1b[2m",
|
||||
Blink: "\x1b[5m",
|
||||
Reverse: "\x1b[7m",
|
||||
EnterKeypad: "\x1b[?1h\x1b=",
|
||||
ExitKeypad: "\x1b[?1l\x1b>",
|
||||
SetFg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m",
|
||||
SetBg: "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m",
|
||||
SetFgBg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;;%?%p2%{8}%<%t4%p2%d%e%p2%{16}%<%t10%p2%{8}%-%d%e48;5;%p2%d%;m",
|
||||
ResetFgBg: "\x1b[39;49m",
|
||||
PadChar: "\x00",
|
||||
AltChars: "++,,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~",
|
||||
EnterAcs: "\x0e",
|
||||
ExitAcs: "\x0f",
|
||||
EnableAcs: "\x1b(B\x1b)0",
|
||||
Mouse: "\x1b[M",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1bM",
|
||||
KeyUp: "\x1bOA",
|
||||
KeyDown: "\x1bOB",
|
||||
KeyRight: "\x1bOC",
|
||||
KeyLeft: "\x1bOD",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\x7f",
|
||||
KeyHome: "\x1b[1~",
|
||||
KeyEnd: "\x1b[4~",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1bOP",
|
||||
KeyF2: "\x1bOQ",
|
||||
KeyF3: "\x1bOR",
|
||||
KeyF4: "\x1bOS",
|
||||
KeyF5: "\x1b[15~",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyBacktab: "\x1b[Z",
|
||||
AutoMargin: true,
|
||||
Name: "screen-256color",
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 256,
|
||||
Clear: "\x1b[H\x1b[J",
|
||||
EnterCA: "\x1b[?1049h",
|
||||
ExitCA: "\x1b[?1049l",
|
||||
ShowCursor: "\x1b[34h\x1b[?25h",
|
||||
HideCursor: "\x1b[?25l",
|
||||
AttrOff: "\x1b[m\x0f",
|
||||
Underline: "\x1b[4m",
|
||||
Bold: "\x1b[1m",
|
||||
Dim: "\x1b[2m",
|
||||
Blink: "\x1b[5m",
|
||||
Reverse: "\x1b[7m",
|
||||
EnterKeypad: "\x1b[?1h\x1b=",
|
||||
ExitKeypad: "\x1b[?1l\x1b>",
|
||||
SetFg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m",
|
||||
SetBg: "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m",
|
||||
SetFgBg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;;%?%p2%{8}%<%t4%p2%d%e%p2%{16}%<%t10%p2%{8}%-%d%e48;5;%p2%d%;m",
|
||||
ResetFgBg: "\x1b[39;49m",
|
||||
PadChar: "\x00",
|
||||
AltChars: "++,,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~",
|
||||
EnterAcs: "\x0e",
|
||||
ExitAcs: "\x0f",
|
||||
EnableAcs: "\x1b(B\x1b)0",
|
||||
Mouse: "\x1b[M",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
AutoMargin: true,
|
||||
})
|
||||
}
|
||||
|
||||
-56
@@ -13,7 +13,6 @@ func init() {
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 8,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[2J",
|
||||
EnterCA: "\x1b[?1049h",
|
||||
ExitCA: "\x1b[?1049l",
|
||||
@@ -39,33 +38,6 @@ func init() {
|
||||
StrikeThrough: "\x1b[9m",
|
||||
Mouse: "\x1b[M",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1bOA",
|
||||
KeyDown: "\x1bOB",
|
||||
KeyRight: "\x1bOC",
|
||||
KeyLeft: "\x1bOD",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\x7f",
|
||||
KeyHome: "\x1b[1~",
|
||||
KeyEnd: "\x1b[4~",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1bOP",
|
||||
KeyF2: "\x1bOQ",
|
||||
KeyF3: "\x1bOR",
|
||||
KeyF4: "\x1bOS",
|
||||
KeyF5: "\x1b[15~",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyClear: "\x1b[3;5~",
|
||||
Modifiers: 1,
|
||||
AutoMargin: true,
|
||||
XTermLike: true,
|
||||
})
|
||||
@@ -77,7 +49,6 @@ func init() {
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 256,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[2J",
|
||||
EnterCA: "\x1b[?1049h",
|
||||
ExitCA: "\x1b[?1049l",
|
||||
@@ -103,33 +74,6 @@ func init() {
|
||||
StrikeThrough: "\x1b[9m",
|
||||
Mouse: "\x1b[M",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1bOA",
|
||||
KeyDown: "\x1bOB",
|
||||
KeyRight: "\x1bOC",
|
||||
KeyLeft: "\x1bOD",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\x7f",
|
||||
KeyHome: "\x1b[1~",
|
||||
KeyEnd: "\x1b[4~",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1bOP",
|
||||
KeyF2: "\x1bOQ",
|
||||
KeyF3: "\x1bOR",
|
||||
KeyF4: "\x1bOS",
|
||||
KeyF5: "\x1b[15~",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyClear: "\x1b[3;5~",
|
||||
Modifiers: 1,
|
||||
AutoMargin: true,
|
||||
XTermLike: true,
|
||||
})
|
||||
|
||||
+26
-78
@@ -26,87 +26,35 @@ func init() {
|
||||
|
||||
// Sun Microsystems Inc. workstation console
|
||||
terminfo.AddTerminfo(&terminfo.Terminfo{
|
||||
Name: "sun",
|
||||
Aliases: []string{"sun1", "sun2"},
|
||||
Columns: 80,
|
||||
Lines: 34,
|
||||
Bell: "\a",
|
||||
Clear: "\f",
|
||||
AttrOff: "\x1b[m",
|
||||
Reverse: "\x1b[7m",
|
||||
PadChar: "\x00",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1b[A",
|
||||
KeyDown: "\x1b[B",
|
||||
KeyRight: "\x1b[C",
|
||||
KeyLeft: "\x1b[D",
|
||||
KeyInsert: "\x1b[247z",
|
||||
KeyDelete: "\u007f",
|
||||
KeyBackspace: "\b",
|
||||
KeyHome: "\x1b[214z",
|
||||
KeyEnd: "\x1b[220z",
|
||||
KeyPgUp: "\x1b[216z",
|
||||
KeyPgDn: "\x1b[222z",
|
||||
KeyF1: "\x1b[224z",
|
||||
KeyF2: "\x1b[225z",
|
||||
KeyF3: "\x1b[226z",
|
||||
KeyF4: "\x1b[227z",
|
||||
KeyF5: "\x1b[228z",
|
||||
KeyF6: "\x1b[229z",
|
||||
KeyF7: "\x1b[230z",
|
||||
KeyF8: "\x1b[231z",
|
||||
KeyF9: "\x1b[232z",
|
||||
KeyF10: "\x1b[233z",
|
||||
KeyF11: "\x1b[234z",
|
||||
KeyF12: "\x1b[235z",
|
||||
AutoMargin: true,
|
||||
InsertChar: "\x1b[@",
|
||||
Name: "sun",
|
||||
Aliases: []string{"sun1", "sun2"},
|
||||
Columns: 80,
|
||||
Lines: 34,
|
||||
Clear: "\f",
|
||||
AttrOff: "\x1b[m",
|
||||
Reverse: "\x1b[7m",
|
||||
PadChar: "\x00",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
AutoMargin: true,
|
||||
InsertChar: "\x1b[@",
|
||||
})
|
||||
|
||||
// Sun Microsystems Workstation console with color support (IA systems)
|
||||
terminfo.AddTerminfo(&terminfo.Terminfo{
|
||||
Name: "sun-color",
|
||||
Columns: 80,
|
||||
Lines: 34,
|
||||
Colors: 256,
|
||||
Bell: "\a",
|
||||
Clear: "\f",
|
||||
AttrOff: "\x1b[m",
|
||||
Bold: "\x1b[1m",
|
||||
Reverse: "\x1b[7m",
|
||||
SetFg: "\x1b[38;5;%p1%dm",
|
||||
SetBg: "\x1b[48;5;%p1%dm",
|
||||
ResetFgBg: "\x1b[0m",
|
||||
PadChar: "\x00",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1b[A",
|
||||
KeyDown: "\x1b[B",
|
||||
KeyRight: "\x1b[C",
|
||||
KeyLeft: "\x1b[D",
|
||||
KeyInsert: "\x1b[247z",
|
||||
KeyDelete: "\u007f",
|
||||
KeyBackspace: "\b",
|
||||
KeyHome: "\x1b[214z",
|
||||
KeyEnd: "\x1b[220z",
|
||||
KeyPgUp: "\x1b[216z",
|
||||
KeyPgDn: "\x1b[222z",
|
||||
KeyF1: "\x1b[224z",
|
||||
KeyF2: "\x1b[225z",
|
||||
KeyF3: "\x1b[226z",
|
||||
KeyF4: "\x1b[227z",
|
||||
KeyF5: "\x1b[228z",
|
||||
KeyF6: "\x1b[229z",
|
||||
KeyF7: "\x1b[230z",
|
||||
KeyF8: "\x1b[231z",
|
||||
KeyF9: "\x1b[232z",
|
||||
KeyF10: "\x1b[233z",
|
||||
KeyF11: "\x1b[234z",
|
||||
KeyF12: "\x1b[235z",
|
||||
AutoMargin: true,
|
||||
InsertChar: "\x1b[@",
|
||||
Name: "sun-color",
|
||||
Columns: 80,
|
||||
Lines: 34,
|
||||
Colors: 256,
|
||||
Clear: "\f",
|
||||
AttrOff: "\x1b[m",
|
||||
Bold: "\x1b[1m",
|
||||
Reverse: "\x1b[7m",
|
||||
SetFg: "\x1b[38;5;%p1%dm",
|
||||
SetBg: "\x1b[48;5;%p1%dm",
|
||||
ResetFgBg: "\x1b[0m",
|
||||
PadChar: "\x00",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
AutoMargin: true,
|
||||
InsertChar: "\x1b[@",
|
||||
})
|
||||
}
|
||||
|
||||
+64
-126
@@ -8,135 +8,73 @@ func init() {
|
||||
|
||||
// tmux terminal multiplexer
|
||||
terminfo.AddTerminfo(&terminfo.Terminfo{
|
||||
Name: "tmux",
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 8,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[J",
|
||||
EnterCA: "\x1b[?1049h",
|
||||
ExitCA: "\x1b[?1049l",
|
||||
ShowCursor: "\x1b[34h\x1b[?25h",
|
||||
HideCursor: "\x1b[?25l",
|
||||
AttrOff: "\x1b[m\x0f",
|
||||
Underline: "\x1b[4m",
|
||||
Bold: "\x1b[1m",
|
||||
Dim: "\x1b[2m",
|
||||
Italic: "\x1b[3m",
|
||||
Blink: "\x1b[5m",
|
||||
Reverse: "\x1b[7m",
|
||||
EnterKeypad: "\x1b[?1h\x1b=",
|
||||
ExitKeypad: "\x1b[?1l\x1b>",
|
||||
SetFg: "\x1b[3%p1%dm",
|
||||
SetBg: "\x1b[4%p1%dm",
|
||||
SetFgBg: "\x1b[3%p1%d;4%p2%dm",
|
||||
ResetFgBg: "\x1b[39;49m",
|
||||
PadChar: "\x00",
|
||||
AltChars: "++,,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~",
|
||||
EnterAcs: "\x0e",
|
||||
ExitAcs: "\x0f",
|
||||
EnableAcs: "\x1b(B\x1b)0",
|
||||
StrikeThrough: "\x1b[9m",
|
||||
Mouse: "\x1b[M",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1bM",
|
||||
KeyUp: "\x1bOA",
|
||||
KeyDown: "\x1bOB",
|
||||
KeyRight: "\x1bOC",
|
||||
KeyLeft: "\x1bOD",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\x7f",
|
||||
KeyHome: "\x1b[1~",
|
||||
KeyEnd: "\x1b[4~",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1bOP",
|
||||
KeyF2: "\x1bOQ",
|
||||
KeyF3: "\x1bOR",
|
||||
KeyF4: "\x1bOS",
|
||||
KeyF5: "\x1b[15~",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyBacktab: "\x1b[Z",
|
||||
Modifiers: 1,
|
||||
AutoMargin: true,
|
||||
DoubleUnderline: "\x1b[4:2m",
|
||||
CurlyUnderline: "\x1b[4:3m",
|
||||
DottedUnderline: "\x1b[4:4m",
|
||||
DashedUnderline: "\x1b[4:5m",
|
||||
Name: "tmux",
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 8,
|
||||
Clear: "\x1b[H\x1b[J",
|
||||
EnterCA: "\x1b[?1049h",
|
||||
ExitCA: "\x1b[?1049l",
|
||||
ShowCursor: "\x1b[34h\x1b[?25h",
|
||||
HideCursor: "\x1b[?25l",
|
||||
AttrOff: "\x1b[m\x0f",
|
||||
Underline: "\x1b[4m",
|
||||
Bold: "\x1b[1m",
|
||||
Dim: "\x1b[2m",
|
||||
Italic: "\x1b[3m",
|
||||
Blink: "\x1b[5m",
|
||||
Reverse: "\x1b[7m",
|
||||
EnterKeypad: "\x1b[?1h\x1b=",
|
||||
ExitKeypad: "\x1b[?1l\x1b>",
|
||||
SetFg: "\x1b[3%p1%dm",
|
||||
SetBg: "\x1b[4%p1%dm",
|
||||
SetFgBg: "\x1b[3%p1%d;4%p2%dm",
|
||||
ResetFgBg: "\x1b[39;49m",
|
||||
PadChar: "\x00",
|
||||
AltChars: "++,,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~",
|
||||
EnterAcs: "\x0e",
|
||||
ExitAcs: "\x0f",
|
||||
EnableAcs: "\x1b(B\x1b)0",
|
||||
StrikeThrough: "\x1b[9m",
|
||||
Mouse: "\x1b[M",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
AutoMargin: true,
|
||||
XTermLike: true,
|
||||
})
|
||||
|
||||
// tmux with 256 colors
|
||||
terminfo.AddTerminfo(&terminfo.Terminfo{
|
||||
Name: "tmux-256color",
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 256,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[J",
|
||||
EnterCA: "\x1b[?1049h",
|
||||
ExitCA: "\x1b[?1049l",
|
||||
ShowCursor: "\x1b[34h\x1b[?25h",
|
||||
HideCursor: "\x1b[?25l",
|
||||
AttrOff: "\x1b[m\x0f",
|
||||
Underline: "\x1b[4m",
|
||||
Bold: "\x1b[1m",
|
||||
Dim: "\x1b[2m",
|
||||
Italic: "\x1b[3m",
|
||||
Blink: "\x1b[5m",
|
||||
Reverse: "\x1b[7m",
|
||||
EnterKeypad: "\x1b[?1h\x1b=",
|
||||
ExitKeypad: "\x1b[?1l\x1b>",
|
||||
SetFg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m",
|
||||
SetBg: "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m",
|
||||
SetFgBg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;;%?%p2%{8}%<%t4%p2%d%e%p2%{16}%<%t10%p2%{8}%-%d%e48;5;%p2%d%;m",
|
||||
ResetFgBg: "\x1b[39;49m",
|
||||
PadChar: "\x00",
|
||||
AltChars: "++,,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~",
|
||||
EnterAcs: "\x0e",
|
||||
ExitAcs: "\x0f",
|
||||
EnableAcs: "\x1b(B\x1b)0",
|
||||
StrikeThrough: "\x1b[9m",
|
||||
Mouse: "\x1b[M",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1bM",
|
||||
KeyUp: "\x1bOA",
|
||||
KeyDown: "\x1bOB",
|
||||
KeyRight: "\x1bOC",
|
||||
KeyLeft: "\x1bOD",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\x7f",
|
||||
KeyHome: "\x1b[1~",
|
||||
KeyEnd: "\x1b[4~",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1bOP",
|
||||
KeyF2: "\x1bOQ",
|
||||
KeyF3: "\x1bOR",
|
||||
KeyF4: "\x1bOS",
|
||||
KeyF5: "\x1b[15~",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyBacktab: "\x1b[Z",
|
||||
Modifiers: 1,
|
||||
AutoMargin: true,
|
||||
DoubleUnderline: "\x1b[4:2m",
|
||||
CurlyUnderline: "\x1b[4:3m",
|
||||
DottedUnderline: "\x1b[4:4m",
|
||||
DashedUnderline: "\x1b[4:5m",
|
||||
Name: "tmux-256color",
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 256,
|
||||
Clear: "\x1b[H\x1b[J",
|
||||
EnterCA: "\x1b[?1049h",
|
||||
ExitCA: "\x1b[?1049l",
|
||||
ShowCursor: "\x1b[34h\x1b[?25h",
|
||||
HideCursor: "\x1b[?25l",
|
||||
AttrOff: "\x1b[m\x0f",
|
||||
Underline: "\x1b[4m",
|
||||
Bold: "\x1b[1m",
|
||||
Dim: "\x1b[2m",
|
||||
Italic: "\x1b[3m",
|
||||
Blink: "\x1b[5m",
|
||||
Reverse: "\x1b[7m",
|
||||
EnterKeypad: "\x1b[?1h\x1b=",
|
||||
ExitKeypad: "\x1b[?1l\x1b>",
|
||||
SetFg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m",
|
||||
SetBg: "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m",
|
||||
SetFgBg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;;%?%p2%{8}%<%t4%p2%d%e%p2%{16}%<%t10%p2%{8}%-%d%e48;5;%p2%d%;m",
|
||||
ResetFgBg: "\x1b[39;49m",
|
||||
PadChar: "\x00",
|
||||
AltChars: "++,,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~",
|
||||
EnterAcs: "\x0e",
|
||||
ExitAcs: "\x0f",
|
||||
EnableAcs: "\x1b(B\x1b)0",
|
||||
StrikeThrough: "\x1b[9m",
|
||||
Mouse: "\x1b[M",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
AutoMargin: true,
|
||||
XTermLike: true,
|
||||
})
|
||||
}
|
||||
|
||||
+55
-208
@@ -1,4 +1,4 @@
|
||||
// Copyright 2024 The TCell Authors
|
||||
// Copyright 2025 The TCell Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use file except in compliance with the License.
|
||||
@@ -41,125 +41,35 @@ var (
|
||||
// in Go, but when we write out JSON, we use the same names as terminfo.
|
||||
// The name, aliases and smous, rmous fields do not come from terminfo directly.
|
||||
type Terminfo struct {
|
||||
Name string
|
||||
Aliases []string
|
||||
Columns int // cols
|
||||
Lines int // lines
|
||||
Colors int // colors
|
||||
Bell string // bell
|
||||
Clear string // clear
|
||||
EnterCA string // smcup
|
||||
ExitCA string // rmcup
|
||||
ShowCursor string // cnorm
|
||||
HideCursor string // civis
|
||||
AttrOff string // sgr0
|
||||
Underline string // smul
|
||||
Bold string // bold
|
||||
Blink string // blink
|
||||
Reverse string // rev
|
||||
Dim string // dim
|
||||
Italic string // sitm
|
||||
EnterKeypad string // smkx
|
||||
ExitKeypad string // rmkx
|
||||
SetFg string // setaf
|
||||
SetBg string // setab
|
||||
ResetFgBg string // op
|
||||
SetCursor string // cup
|
||||
CursorBack1 string // cub1
|
||||
CursorUp1 string // cuu1
|
||||
PadChar string // pad
|
||||
KeyBackspace string // kbs
|
||||
KeyF1 string // kf1
|
||||
KeyF2 string // kf2
|
||||
KeyF3 string // kf3
|
||||
KeyF4 string // kf4
|
||||
KeyF5 string // kf5
|
||||
KeyF6 string // kf6
|
||||
KeyF7 string // kf7
|
||||
KeyF8 string // kf8
|
||||
KeyF9 string // kf9
|
||||
KeyF10 string // kf10
|
||||
KeyF11 string // kf11
|
||||
KeyF12 string // kf12
|
||||
KeyF13 string // kf13
|
||||
KeyF14 string // kf14
|
||||
KeyF15 string // kf15
|
||||
KeyF16 string // kf16
|
||||
KeyF17 string // kf17
|
||||
KeyF18 string // kf18
|
||||
KeyF19 string // kf19
|
||||
KeyF20 string // kf20
|
||||
KeyF21 string // kf21
|
||||
KeyF22 string // kf22
|
||||
KeyF23 string // kf23
|
||||
KeyF24 string // kf24
|
||||
KeyF25 string // kf25
|
||||
KeyF26 string // kf26
|
||||
KeyF27 string // kf27
|
||||
KeyF28 string // kf28
|
||||
KeyF29 string // kf29
|
||||
KeyF30 string // kf30
|
||||
KeyF31 string // kf31
|
||||
KeyF32 string // kf32
|
||||
KeyF33 string // kf33
|
||||
KeyF34 string // kf34
|
||||
KeyF35 string // kf35
|
||||
KeyF36 string // kf36
|
||||
KeyF37 string // kf37
|
||||
KeyF38 string // kf38
|
||||
KeyF39 string // kf39
|
||||
KeyF40 string // kf40
|
||||
KeyF41 string // kf41
|
||||
KeyF42 string // kf42
|
||||
KeyF43 string // kf43
|
||||
KeyF44 string // kf44
|
||||
KeyF45 string // kf45
|
||||
KeyF46 string // kf46
|
||||
KeyF47 string // kf47
|
||||
KeyF48 string // kf48
|
||||
KeyF49 string // kf49
|
||||
KeyF50 string // kf50
|
||||
KeyF51 string // kf51
|
||||
KeyF52 string // kf52
|
||||
KeyF53 string // kf53
|
||||
KeyF54 string // kf54
|
||||
KeyF55 string // kf55
|
||||
KeyF56 string // kf56
|
||||
KeyF57 string // kf57
|
||||
KeyF58 string // kf58
|
||||
KeyF59 string // kf59
|
||||
KeyF60 string // kf60
|
||||
KeyF61 string // kf61
|
||||
KeyF62 string // kf62
|
||||
KeyF63 string // kf63
|
||||
KeyF64 string // kf64
|
||||
KeyInsert string // kich1
|
||||
KeyDelete string // kdch1
|
||||
KeyHome string // khome
|
||||
KeyEnd string // kend
|
||||
KeyHelp string // khlp
|
||||
KeyPgUp string // kpp
|
||||
KeyPgDn string // knp
|
||||
KeyUp string // kcuu1
|
||||
KeyDown string // kcud1
|
||||
KeyLeft string // kcub1
|
||||
KeyRight string // kcuf1
|
||||
KeyBacktab string // kcbt
|
||||
KeyExit string // kext
|
||||
KeyClear string // kclr
|
||||
KeyPrint string // kprt
|
||||
KeyCancel string // kcan
|
||||
Mouse string // kmous
|
||||
AltChars string // acsc
|
||||
EnterAcs string // smacs
|
||||
ExitAcs string // rmacs
|
||||
EnableAcs string // enacs
|
||||
KeyShfRight string // kRIT
|
||||
KeyShfLeft string // kLFT
|
||||
KeyShfHome string // kHOM
|
||||
KeyShfEnd string // kEND
|
||||
KeyShfInsert string // kIC
|
||||
KeyShfDelete string // kDC
|
||||
Name string
|
||||
Aliases []string
|
||||
Columns int // cols
|
||||
Lines int // lines
|
||||
Colors int // colors
|
||||
Clear string // clear
|
||||
EnterCA string // smcup
|
||||
ExitCA string // rmcup
|
||||
ShowCursor string // cnorm
|
||||
HideCursor string // civis
|
||||
AttrOff string // sgr0
|
||||
Underline string // smul
|
||||
Bold string // bold
|
||||
Blink string // blink
|
||||
Reverse string // rev
|
||||
Dim string // dim
|
||||
Italic string // sitm
|
||||
EnterKeypad string // smkx
|
||||
ExitKeypad string // rmkx
|
||||
SetFg string // setaf
|
||||
SetBg string // setab
|
||||
ResetFgBg string // op
|
||||
SetCursor string // cup
|
||||
PadChar string // pad
|
||||
Mouse string // kmous
|
||||
AltChars string // acsc
|
||||
EnterAcs string // smacs
|
||||
ExitAcs string // rmacs
|
||||
EnableAcs string // enacs
|
||||
|
||||
// These are non-standard extensions to terminfo. This includes
|
||||
// true color support, and some additional keys. Its kind of bizarre
|
||||
@@ -167,95 +77,22 @@ type Terminfo struct {
|
||||
// Terminal support for these are going to vary amongst XTerm
|
||||
// emulations, so don't depend too much on them in your application.
|
||||
|
||||
StrikeThrough string // smxx
|
||||
SetFgBg string // setfgbg
|
||||
SetFgBgRGB string // setfgbgrgb
|
||||
SetFgRGB string // setfrgb
|
||||
SetBgRGB string // setbrgb
|
||||
KeyShfUp string // shift-up
|
||||
KeyShfDown string // shift-down
|
||||
KeyShfPgUp string // shift-kpp
|
||||
KeyShfPgDn string // shift-knp
|
||||
KeyCtrlUp string // ctrl-up
|
||||
KeyCtrlDown string // ctrl-left
|
||||
KeyCtrlRight string // ctrl-right
|
||||
KeyCtrlLeft string // ctrl-left
|
||||
KeyMetaUp string // meta-up
|
||||
KeyMetaDown string // meta-left
|
||||
KeyMetaRight string // meta-right
|
||||
KeyMetaLeft string // meta-left
|
||||
KeyAltUp string // alt-up
|
||||
KeyAltDown string // alt-left
|
||||
KeyAltRight string // alt-right
|
||||
KeyAltLeft string // alt-left
|
||||
KeyCtrlHome string
|
||||
KeyCtrlEnd string
|
||||
KeyMetaHome string
|
||||
KeyMetaEnd string
|
||||
KeyAltHome string
|
||||
KeyAltEnd string
|
||||
KeyAltShfUp string
|
||||
KeyAltShfDown string
|
||||
KeyAltShfLeft string
|
||||
KeyAltShfRight string
|
||||
KeyMetaShfUp string
|
||||
KeyMetaShfDown string
|
||||
KeyMetaShfLeft string
|
||||
KeyMetaShfRight string
|
||||
KeyCtrlShfUp string
|
||||
KeyCtrlShfDown string
|
||||
KeyCtrlShfLeft string
|
||||
KeyCtrlShfRight string
|
||||
KeyCtrlShfHome string
|
||||
KeyCtrlShfEnd string
|
||||
KeyAltShfHome string
|
||||
KeyAltShfEnd string
|
||||
KeyMetaShfHome string
|
||||
KeyMetaShfEnd string
|
||||
EnablePaste string // bracketed paste mode
|
||||
DisablePaste string
|
||||
PasteStart string
|
||||
PasteEnd string
|
||||
Modifiers int
|
||||
InsertChar string // string to insert a character (ich1)
|
||||
AutoMargin bool // true if writing to last cell in line advances
|
||||
TrueColor bool // true if the terminal supports direct color
|
||||
CursorDefault string
|
||||
CursorBlinkingBlock string
|
||||
CursorSteadyBlock string
|
||||
CursorBlinkingUnderline string
|
||||
CursorSteadyUnderline string
|
||||
CursorBlinkingBar string
|
||||
CursorSteadyBar string
|
||||
CursorColor string // nothing uses it yet
|
||||
CursorColorRGB string // Cs (but not really because Cs uses X11 color string)
|
||||
CursorColorReset string // Cr
|
||||
EnterUrl string
|
||||
ExitUrl string
|
||||
SetWindowSize string
|
||||
SetWindowTitle string // no terminfo extension
|
||||
EnableFocusReporting string
|
||||
DisableFocusReporting string
|
||||
DisableAutoMargin string // smam
|
||||
EnableAutoMargin string // rmam
|
||||
DoubleUnderline string // Smulx with param 2
|
||||
CurlyUnderline string // Smulx with param 3
|
||||
DottedUnderline string // Smulx with param 4
|
||||
DashedUnderline string // Smulx with param 5
|
||||
UnderlineColor string // Setuc1
|
||||
UnderlineColorRGB string // Setulc
|
||||
UnderlineColorReset string // ol
|
||||
XTermLike bool // (XT) has XTerm extensions
|
||||
StrikeThrough string // smxx
|
||||
SetFgBg string // setfgbg
|
||||
SetFgBgRGB string // setfgbgrgb
|
||||
SetFgRGB string // setfrgb
|
||||
SetBgRGB string // setbrgb
|
||||
InsertChar string // string to insert a character (ich1)
|
||||
AutoMargin bool // true if writing to last cell in line advances
|
||||
TrueColor bool // true if the terminal supports direct color
|
||||
DisableAutoMargin string // smam
|
||||
EnableAutoMargin string // rmam
|
||||
XTermLike bool // (XT) has XTerm extensions
|
||||
}
|
||||
|
||||
const (
|
||||
ModifiersNone = 0
|
||||
ModifiersXTerm = 1
|
||||
)
|
||||
type stack []any
|
||||
|
||||
type stack []interface{}
|
||||
|
||||
func (st stack) Push(v interface{}) stack {
|
||||
func (st stack) Push(v any) stack {
|
||||
if b, ok := v.(bool); ok {
|
||||
if b {
|
||||
return append(st, 1)
|
||||
@@ -337,12 +174,12 @@ func (pb *paramsBuffer) PutString(s string) {
|
||||
// TParm takes a terminfo parameterized string, such as setaf or cup, and
|
||||
// evaluates the string, and returns the result with the parameter
|
||||
// applied.
|
||||
func (t *Terminfo) TParm(s string, p ...interface{}) string {
|
||||
func (t *Terminfo) TParm(s string, p ...any) string {
|
||||
var stk stack
|
||||
var a string
|
||||
var ai, bi int
|
||||
var dvars [26]string
|
||||
var params [9]interface{}
|
||||
var params [9]any
|
||||
var pb = ¶msBuffer{}
|
||||
|
||||
pb.Start(s)
|
||||
@@ -682,6 +519,7 @@ var (
|
||||
// AddTerminfo can be called to register a new Terminfo entry.
|
||||
func AddTerminfo(t *Terminfo) {
|
||||
dblock.Lock()
|
||||
|
||||
terminfos[t.Name] = t
|
||||
for _, x := range t.Aliases {
|
||||
terminfos[x] = t
|
||||
@@ -777,5 +615,14 @@ func LookupTerminfo(name string) (*Terminfo, error) {
|
||||
t.SetFgBg = "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;;%?%p2%{8}%<%t4%p2%d%e%p2%{16}%<%t10%p2%{8}%-%d%e48;5;%p2%d%;m"
|
||||
t.ResetFgBg = "\x1b[39;49m"
|
||||
}
|
||||
|
||||
return t, nil
|
||||
}
|
||||
|
||||
func TerminfoNames() []string {
|
||||
res := make([]string, 0, len(terminfos))
|
||||
for m := range terminfos {
|
||||
res = append(res, m)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
-18
@@ -12,7 +12,6 @@ func init() {
|
||||
Aliases: []string{"vt100-am"},
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[J$<50>",
|
||||
AttrOff: "\x1b[m\x0f$<2>",
|
||||
Underline: "\x1b[4m$<2>",
|
||||
@@ -29,23 +28,6 @@ func init() {
|
||||
EnableAutoMargin: "\x1b[?7h",
|
||||
DisableAutoMargin: "\x1b[?7l",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH$<5>",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A$<2>",
|
||||
KeyUp: "\x1bOA",
|
||||
KeyDown: "\x1bOB",
|
||||
KeyRight: "\x1bOC",
|
||||
KeyLeft: "\x1bOD",
|
||||
KeyBackspace: "\b",
|
||||
KeyF1: "\x1bOP",
|
||||
KeyF2: "\x1bOQ",
|
||||
KeyF3: "\x1bOR",
|
||||
KeyF4: "\x1bOS",
|
||||
KeyF5: "\x1bOt",
|
||||
KeyF6: "\x1bOu",
|
||||
KeyF7: "\x1bOv",
|
||||
KeyF8: "\x1bOl",
|
||||
KeyF9: "\x1bOw",
|
||||
KeyF10: "\x1bOx",
|
||||
AutoMargin: true,
|
||||
})
|
||||
}
|
||||
|
||||
-18
@@ -11,7 +11,6 @@ func init() {
|
||||
Name: "vt102",
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[J$<50>",
|
||||
AttrOff: "\x1b[m\x0f$<2>",
|
||||
Underline: "\x1b[4m$<2>",
|
||||
@@ -28,23 +27,6 @@ func init() {
|
||||
EnableAutoMargin: "\x1b[?7h",
|
||||
DisableAutoMargin: "\x1b[?7l",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH$<5>",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A$<2>",
|
||||
KeyUp: "\x1bOA",
|
||||
KeyDown: "\x1bOB",
|
||||
KeyRight: "\x1bOC",
|
||||
KeyLeft: "\x1bOD",
|
||||
KeyBackspace: "\b",
|
||||
KeyF1: "\x1bOP",
|
||||
KeyF2: "\x1bOQ",
|
||||
KeyF3: "\x1bOR",
|
||||
KeyF4: "\x1bOS",
|
||||
KeyF5: "\x1bOt",
|
||||
KeyF6: "\x1bOu",
|
||||
KeyF7: "\x1bOv",
|
||||
KeyF8: "\x1bOl",
|
||||
KeyF9: "\x1bOw",
|
||||
KeyF10: "\x1bOx",
|
||||
AutoMargin: true,
|
||||
})
|
||||
}
|
||||
|
||||
-30
@@ -12,7 +12,6 @@ func init() {
|
||||
Aliases: []string{"vt200"},
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[J",
|
||||
ShowCursor: "\x1b[?25h",
|
||||
HideCursor: "\x1b[?25l",
|
||||
@@ -29,35 +28,6 @@ func init() {
|
||||
EnableAutoMargin: "\x1b[?7h",
|
||||
DisableAutoMargin: "\x1b[?7l",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1b[A",
|
||||
KeyDown: "\x1b[B",
|
||||
KeyRight: "\x1b[C",
|
||||
KeyLeft: "\x1b[D",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\b",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1bOP",
|
||||
KeyF2: "\x1bOQ",
|
||||
KeyF3: "\x1bOR",
|
||||
KeyF4: "\x1bOS",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyF13: "\x1b[25~",
|
||||
KeyF14: "\x1b[26~",
|
||||
KeyF17: "\x1b[31~",
|
||||
KeyF18: "\x1b[32~",
|
||||
KeyF19: "\x1b[33~",
|
||||
KeyF20: "\x1b[34~",
|
||||
KeyHelp: "\x1b[28~",
|
||||
AutoMargin: true,
|
||||
})
|
||||
}
|
||||
|
||||
-32
@@ -12,7 +12,6 @@ func init() {
|
||||
Aliases: []string{"vt300"},
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[2J",
|
||||
ShowCursor: "\x1b[?25h",
|
||||
HideCursor: "\x1b[?25l",
|
||||
@@ -30,37 +29,6 @@ func init() {
|
||||
EnableAutoMargin: "\x1b[?7h",
|
||||
DisableAutoMargin: "\x1b[?7l",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1bOA",
|
||||
KeyDown: "\x1bOB",
|
||||
KeyRight: "\x1bOC",
|
||||
KeyLeft: "\x1bOD",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\x7f",
|
||||
KeyHome: "\x1b[1~",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1bOP",
|
||||
KeyF2: "\x1bOQ",
|
||||
KeyF3: "\x1bOR",
|
||||
KeyF4: "\x1bOS",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyF13: "\x1b[25~",
|
||||
KeyF14: "\x1b[26~",
|
||||
KeyF15: "\x1b[28~",
|
||||
KeyF16: "\x1b[29~",
|
||||
KeyF17: "\x1b[31~",
|
||||
KeyF18: "\x1b[32~",
|
||||
KeyF19: "\x1b[33~",
|
||||
KeyF20: "\x1b[34~",
|
||||
AutoMargin: true,
|
||||
})
|
||||
}
|
||||
|
||||
-15
@@ -29,21 +29,6 @@ func init() {
|
||||
EnableAutoMargin: "\x1b[?7h",
|
||||
DisableAutoMargin: "\x1b[?7l",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1bOA",
|
||||
KeyDown: "\x1bOB",
|
||||
KeyRight: "\x1bOC",
|
||||
KeyLeft: "\x1bOD",
|
||||
KeyBackspace: "\b",
|
||||
KeyF1: "\x1bOP",
|
||||
KeyF2: "\x1bOQ",
|
||||
KeyF3: "\x1bOR",
|
||||
KeyF4: "\x1bOS",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
AutoMargin: true,
|
||||
InsertChar: "\x1b[@",
|
||||
})
|
||||
|
||||
+4
-23
@@ -1,4 +1,7 @@
|
||||
// Generated automatically. DO NOT HAND-EDIT.
|
||||
// This file was originally generated automatically,
|
||||
// but it is edited to correct for errors in the VT420
|
||||
// terminfo data. Additionally we have added extended
|
||||
// information for the extended F-keys.
|
||||
|
||||
package vt420
|
||||
|
||||
@@ -11,7 +14,6 @@ func init() {
|
||||
Name: "vt420",
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[2J$<50>",
|
||||
ShowCursor: "\x1b[?25h",
|
||||
HideCursor: "\x1b[?25l",
|
||||
@@ -30,27 +32,6 @@ func init() {
|
||||
EnableAutoMargin: "\x1b[?7h",
|
||||
DisableAutoMargin: "\x1b[?7l",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH$<10>",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1b[A",
|
||||
KeyDown: "\x1b[B",
|
||||
KeyRight: "\x1b[C",
|
||||
KeyLeft: "\x1b[D",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\b",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1bOP",
|
||||
KeyF2: "\x1bOQ",
|
||||
KeyF3: "\x1bOR",
|
||||
KeyF4: "\x1bOS",
|
||||
KeyF5: "\x1b[17~",
|
||||
KeyF6: "\x1b[18~",
|
||||
KeyF7: "\x1b[19~",
|
||||
KeyF8: "\x1b[20~",
|
||||
KeyF9: "\x1b[21~",
|
||||
KeyF10: "\x1b[29~",
|
||||
AutoMargin: true,
|
||||
})
|
||||
}
|
||||
|
||||
-39
@@ -1,39 +0,0 @@
|
||||
// Generated automatically. DO NOT HAND-EDIT.
|
||||
|
||||
package vt52
|
||||
|
||||
import "github.com/gdamore/tcell/v2/terminfo"
|
||||
|
||||
func init() {
|
||||
|
||||
// DEC VT52
|
||||
terminfo.AddTerminfo(&terminfo.Terminfo{
|
||||
Name: "vt52",
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Bell: "\a",
|
||||
Clear: "\x1bH\x1bJ",
|
||||
EnterKeypad: "\x1b=",
|
||||
ExitKeypad: "\x1b>",
|
||||
PadChar: "\x00",
|
||||
AltChars: "+h.k0affggolpnqprrss",
|
||||
EnterAcs: "\x1bF",
|
||||
ExitAcs: "\x1bG",
|
||||
SetCursor: "\x1bY%p1%' '%+%c%p2%' '%+%c",
|
||||
CursorBack1: "\x1bD",
|
||||
CursorUp1: "\x1bA",
|
||||
KeyUp: "\x1bA",
|
||||
KeyDown: "\x1bB",
|
||||
KeyRight: "\x1bC",
|
||||
KeyLeft: "\x1bD",
|
||||
KeyBackspace: "\b",
|
||||
KeyF1: "\x1bP",
|
||||
KeyF2: "\x1bQ",
|
||||
KeyF3: "\x1bR",
|
||||
KeyF5: "\x1b?t",
|
||||
KeyF6: "\x1b?u",
|
||||
KeyF7: "\x1b?v",
|
||||
KeyF8: "\x1b?w",
|
||||
KeyF9: "\x1b?x",
|
||||
})
|
||||
}
|
||||
-60
@@ -1,60 +0,0 @@
|
||||
// Generated automatically. DO NOT HAND-EDIT.
|
||||
|
||||
package wy50
|
||||
|
||||
import "github.com/gdamore/tcell/v2/terminfo"
|
||||
|
||||
func init() {
|
||||
|
||||
// Wyse 50
|
||||
terminfo.AddTerminfo(&terminfo.Terminfo{
|
||||
Name: "wy50",
|
||||
Aliases: []string{"wyse50"},
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b+$<20>",
|
||||
ShowCursor: "\x1b`1",
|
||||
HideCursor: "\x1b`0",
|
||||
AttrOff: "\x1b(\x1bH\x03",
|
||||
Dim: "\x1b`7\x1b)",
|
||||
Reverse: "\x1b`6\x1b)",
|
||||
PadChar: "\x00",
|
||||
AltChars: "a;j5k3l2m1n8q:t4u9v=w0x6",
|
||||
EnterAcs: "\x1bH\x02",
|
||||
ExitAcs: "\x1bH\x03",
|
||||
SetCursor: "\x1b=%p1%' '%+%c%p2%' '%+%c",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\v",
|
||||
KeyUp: "\v",
|
||||
KeyDown: "\n",
|
||||
KeyRight: "\f",
|
||||
KeyLeft: "\b",
|
||||
KeyInsert: "\x1bQ",
|
||||
KeyDelete: "\x1bW",
|
||||
KeyBackspace: "\b",
|
||||
KeyHome: "\x1e",
|
||||
KeyPgUp: "\x1bJ",
|
||||
KeyPgDn: "\x1bK",
|
||||
KeyF1: "\x01@\r",
|
||||
KeyF2: "\x01A\r",
|
||||
KeyF3: "\x01B\r",
|
||||
KeyF4: "\x01C\r",
|
||||
KeyF5: "\x01D\r",
|
||||
KeyF6: "\x01E\r",
|
||||
KeyF7: "\x01F\r",
|
||||
KeyF8: "\x01G\r",
|
||||
KeyF9: "\x01H\r",
|
||||
KeyF10: "\x01I\r",
|
||||
KeyF11: "\x01J\r",
|
||||
KeyF12: "\x01K\r",
|
||||
KeyF13: "\x01L\r",
|
||||
KeyF14: "\x01M\r",
|
||||
KeyF15: "\x01N\r",
|
||||
KeyF16: "\x01O\r",
|
||||
KeyPrint: "\x1bP",
|
||||
KeyBacktab: "\x1bI",
|
||||
KeyShfHome: "\x1b{",
|
||||
AutoMargin: true,
|
||||
})
|
||||
}
|
||||
-66
@@ -1,66 +0,0 @@
|
||||
// Generated automatically. DO NOT HAND-EDIT.
|
||||
|
||||
package wy60
|
||||
|
||||
import "github.com/gdamore/tcell/v2/terminfo"
|
||||
|
||||
func init() {
|
||||
|
||||
// Wyse 60
|
||||
terminfo.AddTerminfo(&terminfo.Terminfo{
|
||||
Name: "wy60",
|
||||
Aliases: []string{"wyse60"},
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b+$<100>",
|
||||
EnterCA: "\x1bw0",
|
||||
ExitCA: "\x1bw1",
|
||||
ShowCursor: "\x1b`1",
|
||||
HideCursor: "\x1b`0",
|
||||
AttrOff: "\x1b(\x1bH\x03\x1bG0\x1bcD",
|
||||
Underline: "\x1bG8",
|
||||
Dim: "\x1bGp",
|
||||
Blink: "\x1bG2",
|
||||
Reverse: "\x1bG4",
|
||||
PadChar: "\x00",
|
||||
AltChars: "+/,.0[a2fxgqh1ihjYk?lZm@nEqDtCu4vAwBx3yszr{c~~",
|
||||
EnterAcs: "\x1bcE",
|
||||
ExitAcs: "\x1bcD",
|
||||
EnableAutoMargin: "\x1bd/",
|
||||
DisableAutoMargin: "\x1bd.",
|
||||
SetCursor: "\x1b=%p1%' '%+%c%p2%' '%+%c",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\v",
|
||||
KeyUp: "\v",
|
||||
KeyDown: "\n",
|
||||
KeyRight: "\f",
|
||||
KeyLeft: "\b",
|
||||
KeyInsert: "\x1bQ",
|
||||
KeyDelete: "\x1bW",
|
||||
KeyBackspace: "\b",
|
||||
KeyHome: "\x1e",
|
||||
KeyPgUp: "\x1bJ",
|
||||
KeyPgDn: "\x1bK",
|
||||
KeyF1: "\x01@\r",
|
||||
KeyF2: "\x01A\r",
|
||||
KeyF3: "\x01B\r",
|
||||
KeyF4: "\x01C\r",
|
||||
KeyF5: "\x01D\r",
|
||||
KeyF6: "\x01E\r",
|
||||
KeyF7: "\x01F\r",
|
||||
KeyF8: "\x01G\r",
|
||||
KeyF9: "\x01H\r",
|
||||
KeyF10: "\x01I\r",
|
||||
KeyF11: "\x01J\r",
|
||||
KeyF12: "\x01K\r",
|
||||
KeyF13: "\x01L\r",
|
||||
KeyF14: "\x01M\r",
|
||||
KeyF15: "\x01N\r",
|
||||
KeyF16: "\x01O\r",
|
||||
KeyPrint: "\x1bP",
|
||||
KeyBacktab: "\x1bI",
|
||||
KeyShfHome: "\x1b{",
|
||||
AutoMargin: true,
|
||||
})
|
||||
}
|
||||
-120
@@ -1,120 +0,0 @@
|
||||
// Generated automatically. DO NOT HAND-EDIT.
|
||||
|
||||
package wy99_ansi
|
||||
|
||||
import "github.com/gdamore/tcell/v2/terminfo"
|
||||
|
||||
func init() {
|
||||
|
||||
// Wyse WY-99GT in ANSI mode (int'l PC keyboard)
|
||||
terminfo.AddTerminfo(&terminfo.Terminfo{
|
||||
Name: "wy99-ansi",
|
||||
Columns: 80,
|
||||
Lines: 25,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[J$<200>",
|
||||
ShowCursor: "\x1b[34h\x1b[?25h",
|
||||
HideCursor: "\x1b[?25l",
|
||||
AttrOff: "\x1b[m\x0f\x1b[\"q",
|
||||
Underline: "\x1b[4m",
|
||||
Bold: "\x1b[1m",
|
||||
Dim: "\x1b[2m",
|
||||
Blink: "\x1b[5m",
|
||||
Reverse: "\x1b[7m",
|
||||
EnterKeypad: "\x1b[?1h",
|
||||
ExitKeypad: "\x1b[?1l",
|
||||
PadChar: "\x00",
|
||||
AltChars: "``aaffggjjkkllmmnnooqqssttuuvvwwxx{{||}}~~",
|
||||
EnterAcs: "\x0e",
|
||||
ExitAcs: "\x0f",
|
||||
EnableAcs: "\x1b)0",
|
||||
EnableAutoMargin: "\x1b[?7h",
|
||||
DisableAutoMargin: "\x1b[?7l",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b$<1>",
|
||||
CursorUp1: "\x1bM",
|
||||
KeyUp: "\x1bOA",
|
||||
KeyDown: "\x1bOB",
|
||||
KeyRight: "\x1bOC",
|
||||
KeyLeft: "\x1bOD",
|
||||
KeyBackspace: "\b",
|
||||
KeyF1: "\x1bOP",
|
||||
KeyF2: "\x1bOQ",
|
||||
KeyF3: "\x1bOR",
|
||||
KeyF4: "\x1bOS",
|
||||
KeyF5: "\x1b[M",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyF17: "\x1b[K",
|
||||
KeyF18: "\x1b[31~",
|
||||
KeyF19: "\x1b[32~",
|
||||
KeyF20: "\x1b[33~",
|
||||
KeyF21: "\x1b[34~",
|
||||
KeyF22: "\x1b[35~",
|
||||
KeyF23: "\x1b[1~",
|
||||
KeyF24: "\x1b[2~",
|
||||
KeyBacktab: "\x1b[z",
|
||||
AutoMargin: true,
|
||||
})
|
||||
|
||||
// Wyse WY-99GT in ANSI mode (US PC keyboard)
|
||||
terminfo.AddTerminfo(&terminfo.Terminfo{
|
||||
Name: "wy99a-ansi",
|
||||
Columns: 80,
|
||||
Lines: 25,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[J$<200>",
|
||||
ShowCursor: "\x1b[34h\x1b[?25h",
|
||||
HideCursor: "\x1b[?25l",
|
||||
AttrOff: "\x1b[m\x0f\x1b[\"q",
|
||||
Underline: "\x1b[4m",
|
||||
Bold: "\x1b[1m",
|
||||
Dim: "\x1b[2m",
|
||||
Blink: "\x1b[5m",
|
||||
Reverse: "\x1b[7m",
|
||||
EnterKeypad: "\x1b[?1h",
|
||||
ExitKeypad: "\x1b[?1l",
|
||||
PadChar: "\x00",
|
||||
AltChars: "``aaffggjjkkllmmnnooqqssttuuvvwwxx{{||}}~~",
|
||||
EnterAcs: "\x0e",
|
||||
ExitAcs: "\x0f",
|
||||
EnableAcs: "\x1b)0",
|
||||
EnableAutoMargin: "\x1b[?7h",
|
||||
DisableAutoMargin: "\x1b[?7l",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b$<1>",
|
||||
CursorUp1: "\x1bM",
|
||||
KeyUp: "\x1bOA",
|
||||
KeyDown: "\x1bOB",
|
||||
KeyRight: "\x1bOC",
|
||||
KeyLeft: "\x1bOD",
|
||||
KeyBackspace: "\b",
|
||||
KeyF1: "\x1bOP",
|
||||
KeyF2: "\x1bOQ",
|
||||
KeyF3: "\x1bOR",
|
||||
KeyF4: "\x1bOS",
|
||||
KeyF5: "\x1b[M",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyF17: "\x1b[K",
|
||||
KeyF18: "\x1b[31~",
|
||||
KeyF19: "\x1b[32~",
|
||||
KeyF20: "\x1b[33~",
|
||||
KeyF21: "\x1b[34~",
|
||||
KeyF22: "\x1b[35~",
|
||||
KeyF23: "\x1b[1~",
|
||||
KeyF24: "\x1b[2~",
|
||||
KeyBacktab: "\x1b[z",
|
||||
AutoMargin: true,
|
||||
})
|
||||
}
|
||||
-28
@@ -12,7 +12,6 @@ func init() {
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 8,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[2J",
|
||||
EnterCA: "\x1b7\x1b[?47h",
|
||||
ExitCA: "\x1b[2J\x1b[?47l\x1b8",
|
||||
@@ -37,33 +36,6 @@ func init() {
|
||||
DisableAutoMargin: "\x1b[?7l",
|
||||
Mouse: "\x1b[M",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1bOA",
|
||||
KeyDown: "\x1bOB",
|
||||
KeyRight: "\x1bOC",
|
||||
KeyLeft: "\x1bOD",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\x7f",
|
||||
KeyHome: "\x1bOH",
|
||||
KeyEnd: "\x1bOF",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1bOP",
|
||||
KeyF2: "\x1bOQ",
|
||||
KeyF3: "\x1bOR",
|
||||
KeyF4: "\x1bOS",
|
||||
KeyF5: "\x1b[15~",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyBacktab: "\x1b[Z",
|
||||
Modifiers: 1,
|
||||
AutoMargin: true,
|
||||
XTermLike: true,
|
||||
})
|
||||
|
||||
-28
@@ -31,7 +31,6 @@ func init() {
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 256,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[2J",
|
||||
EnterCA: "\x1b[?1049h\x1b[22;0;0t",
|
||||
ExitCA: "\x1b[?1049l\x1b[23;0;0t",
|
||||
@@ -59,33 +58,6 @@ func init() {
|
||||
StrikeThrough: "\x1b[9m",
|
||||
Mouse: "\x1b[M",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1bOA",
|
||||
KeyDown: "\x1bOB",
|
||||
KeyRight: "\x1bOC",
|
||||
KeyLeft: "\x1bOD",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\u007f",
|
||||
KeyHome: "\x1bOH",
|
||||
KeyEnd: "\x1bOF",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1bOP",
|
||||
KeyF2: "\x1bOQ",
|
||||
KeyF3: "\x1bOR",
|
||||
KeyF4: "\x1bOS",
|
||||
KeyF5: "\x1b[15~",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyBacktab: "\x1b[Z",
|
||||
Modifiers: 1,
|
||||
AutoMargin: true,
|
||||
TrueColor: true,
|
||||
})
|
||||
|
||||
-84
@@ -13,7 +13,6 @@ func init() {
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 8,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[2J",
|
||||
EnterCA: "\x1b[?1049h\x1b[22;0;0t",
|
||||
ExitCA: "\x1b[?1049l\x1b[23;0;0t",
|
||||
@@ -40,33 +39,6 @@ func init() {
|
||||
StrikeThrough: "\x1b[9m",
|
||||
Mouse: "\x1b[<",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1bOA",
|
||||
KeyDown: "\x1bOB",
|
||||
KeyRight: "\x1bOC",
|
||||
KeyLeft: "\x1bOD",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\x7f",
|
||||
KeyHome: "\x1bOH",
|
||||
KeyEnd: "\x1bOF",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1bOP",
|
||||
KeyF2: "\x1bOQ",
|
||||
KeyF3: "\x1bOR",
|
||||
KeyF4: "\x1bOS",
|
||||
KeyF5: "\x1b[15~",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyBacktab: "\x1b[Z",
|
||||
Modifiers: 1,
|
||||
AutoMargin: true,
|
||||
XTermLike: true,
|
||||
})
|
||||
@@ -77,7 +49,6 @@ func init() {
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 88,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[2J",
|
||||
EnterCA: "\x1b[?1049h\x1b[22;0;0t",
|
||||
ExitCA: "\x1b[?1049l\x1b[23;0;0t",
|
||||
@@ -104,33 +75,6 @@ func init() {
|
||||
StrikeThrough: "\x1b[9m",
|
||||
Mouse: "\x1b[<",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1bOA",
|
||||
KeyDown: "\x1bOB",
|
||||
KeyRight: "\x1bOC",
|
||||
KeyLeft: "\x1bOD",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\x7f",
|
||||
KeyHome: "\x1bOH",
|
||||
KeyEnd: "\x1bOF",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1bOP",
|
||||
KeyF2: "\x1bOQ",
|
||||
KeyF3: "\x1bOR",
|
||||
KeyF4: "\x1bOS",
|
||||
KeyF5: "\x1b[15~",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyBacktab: "\x1b[Z",
|
||||
Modifiers: 1,
|
||||
AutoMargin: true,
|
||||
XTermLike: true,
|
||||
})
|
||||
@@ -141,7 +85,6 @@ func init() {
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 256,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[2J",
|
||||
EnterCA: "\x1b[?1049h\x1b[22;0;0t",
|
||||
ExitCA: "\x1b[?1049l\x1b[23;0;0t",
|
||||
@@ -168,33 +111,6 @@ func init() {
|
||||
StrikeThrough: "\x1b[9m",
|
||||
Mouse: "\x1b[<",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1bOA",
|
||||
KeyDown: "\x1bOB",
|
||||
KeyRight: "\x1bOC",
|
||||
KeyLeft: "\x1bOD",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\x7f",
|
||||
KeyHome: "\x1bOH",
|
||||
KeyEnd: "\x1bOF",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1bOP",
|
||||
KeyF2: "\x1bOQ",
|
||||
KeyF3: "\x1bOR",
|
||||
KeyF4: "\x1bOS",
|
||||
KeyF5: "\x1b[15~",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyBacktab: "\x1b[Z",
|
||||
Modifiers: 1,
|
||||
AutoMargin: true,
|
||||
XTermLike: true,
|
||||
})
|
||||
|
||||
-32
@@ -13,7 +13,6 @@ func init() {
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 256,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[2J",
|
||||
EnterCA: "\x1b[?1049h",
|
||||
ExitCA: "\x1b[?1049l",
|
||||
@@ -40,40 +39,9 @@ func init() {
|
||||
StrikeThrough: "\x1b[9m",
|
||||
Mouse: "\x1b[<",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1bOA",
|
||||
KeyDown: "\x1bOB",
|
||||
KeyRight: "\x1bOC",
|
||||
KeyLeft: "\x1bOD",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\x7f",
|
||||
KeyHome: "\x1bOH",
|
||||
KeyEnd: "\x1bOF",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1bOP",
|
||||
KeyF2: "\x1bOQ",
|
||||
KeyF3: "\x1bOR",
|
||||
KeyF4: "\x1bOS",
|
||||
KeyF5: "\x1b[15~",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyBacktab: "\x1b[Z",
|
||||
Modifiers: 1,
|
||||
TrueColor: true,
|
||||
AutoMargin: true,
|
||||
InsertChar: "\x1b[@",
|
||||
DoubleUnderline: "\x1b[4:2m",
|
||||
CurlyUnderline: "\x1b[4:3m",
|
||||
DottedUnderline: "\x1b[4:4m",
|
||||
DashedUnderline: "\x1b[4:5m",
|
||||
XTermLike: true,
|
||||
})
|
||||
}
|
||||
|
||||
+1
-32
@@ -12,7 +12,6 @@ func init() {
|
||||
Columns: 80,
|
||||
Lines: 24,
|
||||
Colors: 256,
|
||||
Bell: "\a",
|
||||
Clear: "\x1b[H\x1b[2J",
|
||||
EnterCA: "\x1b[?1049h",
|
||||
ExitCA: "\x1b[?1049l",
|
||||
@@ -38,38 +37,8 @@ func init() {
|
||||
StrikeThrough: "\x1b[9m",
|
||||
Mouse: "\x1b[M",
|
||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||
CursorBack1: "\b",
|
||||
CursorUp1: "\x1b[A",
|
||||
KeyUp: "\x1bOA",
|
||||
KeyDown: "\x1bOB",
|
||||
KeyRight: "\x1bOC",
|
||||
KeyLeft: "\x1bOD",
|
||||
KeyInsert: "\x1b[2~",
|
||||
KeyDelete: "\x1b[3~",
|
||||
KeyBackspace: "\x7f",
|
||||
KeyHome: "\x1bOH",
|
||||
KeyEnd: "\x1bOF",
|
||||
KeyPgUp: "\x1b[5~",
|
||||
KeyPgDn: "\x1b[6~",
|
||||
KeyF1: "\x1bOP",
|
||||
KeyF2: "\x1bOQ",
|
||||
KeyF3: "\x1bOR",
|
||||
KeyF4: "\x1bOS",
|
||||
KeyF5: "\x1b[15~",
|
||||
KeyF6: "\x1b[17~",
|
||||
KeyF7: "\x1b[18~",
|
||||
KeyF8: "\x1b[19~",
|
||||
KeyF9: "\x1b[20~",
|
||||
KeyF10: "\x1b[21~",
|
||||
KeyF11: "\x1b[23~",
|
||||
KeyF12: "\x1b[24~",
|
||||
KeyBacktab: "\x1b[Z",
|
||||
Modifiers: 1,
|
||||
TrueColor: true,
|
||||
AutoMargin: true,
|
||||
DoubleUnderline: "\x1b[4:2m",
|
||||
CurlyUnderline: "\x1b[4:3m",
|
||||
DottedUnderline: "\x1b[4:4m",
|
||||
DashedUnderline: "\x1b[4:5m",
|
||||
XTermLike: true,
|
||||
})
|
||||
}
|
||||
|
||||
+174
-1006
File diff suppressed because it is too large
Load Diff
Generated
Vendored
+14
-10
@@ -1,7 +1,7 @@
|
||||
//go:build plan9 || windows
|
||||
// +build plan9 windows
|
||||
//go:build plan9
|
||||
// +build plan9
|
||||
|
||||
// Copyright 2022 The TCell Authors
|
||||
// Copyright 2025 The TCell Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use file except in compliance with the License.
|
||||
@@ -17,16 +17,20 @@
|
||||
|
||||
package tcell
|
||||
|
||||
// NB: We might someday wish to move Windows to this model. However,
|
||||
// that would probably mean sacrificing some of the richer key reporting
|
||||
// that we can obtain with the console API present on Windows.
|
||||
import "os"
|
||||
|
||||
// initialize on Plan 9: if no TTY was provided, use the Plan 9 TTY.
|
||||
func (t *tScreen) initialize() error {
|
||||
if os.Getenv("TERM") == "" {
|
||||
// TERM should be "vt100" in a vt(1) window; color/mouse support will be limited.
|
||||
_ = os.Setenv("TERM", "vt100")
|
||||
}
|
||||
if t.tty == nil {
|
||||
return ErrNoScreen
|
||||
tty, err := NewDevTty()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
t.tty = tty
|
||||
}
|
||||
// If a tty was supplied (custom), it should work.
|
||||
// Custom screen implementations will need to provide a TTY
|
||||
// implementation that we can use.
|
||||
return nil
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
// Copyright 2025 The TCell Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use file except in compliance with the License.
|
||||
// You may obtain a copy of the license at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package tcell
|
||||
|
||||
import (
|
||||
// import the stock terminals
|
||||
_ "github.com/gdamore/tcell/v2/terminfo/base"
|
||||
)
|
||||
|
||||
// initialize is used at application startup, and sets up the initial values
|
||||
// including file descriptors used for terminals and saving the initial state
|
||||
// so that it can be restored when the application terminates.
|
||||
func (t *tScreen) initialize() error {
|
||||
var err error
|
||||
if t.tty == nil {
|
||||
t.tty, err = NewDevTty()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
defaultTerm = "xterm-truecolor"
|
||||
}
|
||||
+270
@@ -0,0 +1,270 @@
|
||||
//go:build plan9
|
||||
// +build plan9
|
||||
|
||||
// Copyright 2025 The TCell Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use file except in compliance with the License.
|
||||
// You may obtain a copy of the license at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package tcell
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
// p9Tty implements tcell.Tty using Plan 9's /dev/cons and /dev/consctl.
|
||||
// Raw mode is enabled by writing "rawon" to /dev/consctl while the fd stays open.
|
||||
// Resize notifications are read from /dev/wctl: the first read returns geometry,
|
||||
// subsequent reads block until the window changes (rio(4)).
|
||||
//
|
||||
// References:
|
||||
// - kbdfs(8): cons/consctl rawon|rawoff semantics
|
||||
// - rio(4): wctl geometry and blocking-on-change behavior
|
||||
// - vt(1): VT100 emulator typically used for TUI programs on Plan 9
|
||||
//
|
||||
// Limitations:
|
||||
// - We assume VT100-level capabilities (often no colors, no mouse).
|
||||
// - Window size is conservative: we return 80x24 unless overridden.
|
||||
// Set LINES/COLUMNS (or TCELL_LINES/TCELL_COLS) to refine.
|
||||
// - Mouse and bracketed paste are not wired; terminfo/xterm queries
|
||||
// are not attempted because vt(1) may not support them.
|
||||
type p9Tty struct {
|
||||
cons *os.File // /dev/cons (read+write)
|
||||
consctl *os.File // /dev/consctl (write "rawon"/"rawoff")
|
||||
wctl *os.File // /dev/wctl (resize notifications)
|
||||
|
||||
// protect close/stop; Read/Write are serialized by os.File
|
||||
mu sync.Mutex
|
||||
closed atomic.Bool
|
||||
|
||||
// resize callback
|
||||
onResize atomic.Value // func()
|
||||
wg sync.WaitGroup
|
||||
stopCh chan struct{}
|
||||
}
|
||||
|
||||
func NewDevTty() (Tty, error) { // tcell signature
|
||||
return newPlan9TTY()
|
||||
}
|
||||
|
||||
func NewStdIoTty() (Tty, error) { // also required by tcell
|
||||
// On Plan 9 there is no POSIX tty discipline on stdin/stdout;
|
||||
// use /dev/cons explicitly for robustness.
|
||||
return newPlan9TTY()
|
||||
}
|
||||
|
||||
func NewDevTtyFromDev(_ string) (Tty, error) { // required by tcell
|
||||
// Plan 9 does not have multiple "ttys" in the POSIX sense;
|
||||
// always bind to /dev/cons and /dev/consctl.
|
||||
return newPlan9TTY()
|
||||
}
|
||||
|
||||
func newPlan9TTY() (Tty, error) {
|
||||
cons, err := os.OpenFile("/dev/cons", os.O_RDWR, 0)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("open /dev/cons: %w", err)
|
||||
}
|
||||
consctl, err := os.OpenFile("/dev/consctl", os.O_WRONLY, 0)
|
||||
if err != nil {
|
||||
_ = cons.Close()
|
||||
return nil, fmt.Errorf("open /dev/consctl: %w", err)
|
||||
}
|
||||
// /dev/wctl may not exist (console without rio); best-effort.
|
||||
wctl, _ := os.OpenFile("/dev/wctl", os.O_RDWR, 0)
|
||||
|
||||
t := &p9Tty{
|
||||
cons: cons,
|
||||
consctl: consctl,
|
||||
wctl: wctl,
|
||||
stopCh: make(chan struct{}),
|
||||
}
|
||||
return t, nil
|
||||
}
|
||||
|
||||
func (t *p9Tty) Start() error {
|
||||
t.mu.Lock()
|
||||
defer t.mu.Unlock()
|
||||
|
||||
if t.closed.Load() {
|
||||
return errors.New("tty closed")
|
||||
}
|
||||
|
||||
// Recreate stop channel if absent or closed (supports resume).
|
||||
if t.stopCh == nil || isClosed(t.stopCh) {
|
||||
t.stopCh = make(chan struct{})
|
||||
}
|
||||
|
||||
// Put console into raw mode; remains active while consctl is open.
|
||||
if _, err := t.consctl.Write([]byte("rawon")); err != nil {
|
||||
return fmt.Errorf("enable raw mode: %w", err)
|
||||
}
|
||||
|
||||
// Reopen /dev/wctl on resume; best-effort (system console may lack it).
|
||||
if t.wctl == nil {
|
||||
if f, err := os.OpenFile("/dev/wctl", os.O_RDWR, 0); err == nil {
|
||||
t.wctl = f
|
||||
}
|
||||
}
|
||||
|
||||
if t.wctl != nil {
|
||||
t.wg.Add(1)
|
||||
go t.watchResize()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *p9Tty) Drain() error {
|
||||
// Per tcell docs, this may reasonably be a no-op on non-POSIX ttys.
|
||||
// Read deadlines are not available on plan9 os.File; we rely on Stop().
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *p9Tty) Stop() error {
|
||||
t.mu.Lock()
|
||||
defer t.mu.Unlock()
|
||||
|
||||
// Signal watcher to stop (if not already).
|
||||
if t.stopCh != nil && !isClosed(t.stopCh) {
|
||||
close(t.stopCh)
|
||||
}
|
||||
|
||||
// Exit raw mode first.
|
||||
_, _ = t.consctl.Write([]byte("rawoff"))
|
||||
|
||||
// Closing wctl unblocks watchResize; nil it so Start() can reopen later.
|
||||
if t.wctl != nil {
|
||||
_ = t.wctl.Close()
|
||||
t.wctl = nil
|
||||
}
|
||||
|
||||
// Ensure watcher goroutine has exited before returning.
|
||||
t.wg.Wait()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *p9Tty) Close() error {
|
||||
t.mu.Lock()
|
||||
defer t.mu.Unlock()
|
||||
|
||||
if t.closed.Swap(true) {
|
||||
return nil
|
||||
}
|
||||
|
||||
if t.stopCh != nil && !isClosed(t.stopCh) {
|
||||
close(t.stopCh)
|
||||
}
|
||||
_, _ = t.consctl.Write([]byte("rawoff"))
|
||||
|
||||
_ = t.cons.Close()
|
||||
_ = t.consctl.Close()
|
||||
if t.wctl != nil {
|
||||
_ = t.wctl.Close()
|
||||
t.wctl = nil
|
||||
}
|
||||
|
||||
t.wg.Wait()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *p9Tty) Read(p []byte) (int, error) {
|
||||
return t.cons.Read(p)
|
||||
}
|
||||
|
||||
func (t *p9Tty) Write(p []byte) (int, error) {
|
||||
return t.cons.Write(p)
|
||||
}
|
||||
|
||||
func (t *p9Tty) NotifyResize(cb func()) {
|
||||
if cb == nil {
|
||||
t.onResize.Store((func())(nil))
|
||||
return
|
||||
}
|
||||
t.onResize.Store(cb)
|
||||
}
|
||||
|
||||
func (t *p9Tty) WindowSize() (WindowSize, error) {
|
||||
// Strategy:
|
||||
// 1) honor explicit overrides (TCELL_LINES/TCELL_COLS, LINES/COLUMNS),
|
||||
// 2) otherwise return conservative 80x24.
|
||||
// Reading /dev/wctl gives pixel geometry, but char cell metrics are
|
||||
// not generally available to non-draw clients; vt(1) is fixed-cell.
|
||||
lines, cols := envInt("TCELL_LINES"), envInt("TCELL_COLS")
|
||||
if lines == 0 {
|
||||
lines = envInt("LINES")
|
||||
}
|
||||
if cols == 0 {
|
||||
cols = envInt("COLUMNS")
|
||||
}
|
||||
if lines <= 0 {
|
||||
lines = 24
|
||||
}
|
||||
if cols <= 0 {
|
||||
cols = 80
|
||||
}
|
||||
return WindowSize{Width: cols, Height: lines}, nil
|
||||
}
|
||||
|
||||
// watchResize blocks on /dev/wctl reads; each read returns when the window
|
||||
// changes size/position/state, per rio(4). We ignore the parsed geometry and
|
||||
// just notify tcell to re-query WindowSize().
|
||||
func (t *p9Tty) watchResize() {
|
||||
defer t.wg.Done()
|
||||
|
||||
r := bufio.NewReader(t.wctl)
|
||||
for {
|
||||
select {
|
||||
case <-t.stopCh:
|
||||
return
|
||||
default:
|
||||
}
|
||||
// Each read delivers something like:
|
||||
// " minx miny maxx maxy visible current\n"
|
||||
// We don't need to parse here; just signal.
|
||||
_, err := r.ReadString('\n')
|
||||
if err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
return
|
||||
}
|
||||
// transient errors: continue
|
||||
}
|
||||
if cb, _ := t.onResize.Load().(func()); cb != nil {
|
||||
cb()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func envInt(name string) int {
|
||||
if s := strings.TrimSpace(os.Getenv(name)); s != "" {
|
||||
if v, err := strconv.Atoi(s); err == nil {
|
||||
return v
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// helper: safe check if a channel is closed
|
||||
func isClosed(ch <-chan struct{}) bool {
|
||||
select {
|
||||
case <-ch:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
+290
@@ -0,0 +1,290 @@
|
||||
// Copyright 2026 The TCell Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use file except in compliance with the License.
|
||||
// You may obtain a copy of the license at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package tcell
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
"unicode/utf16"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
var (
|
||||
k32 = syscall.NewLazyDLL("kernel32.dll")
|
||||
)
|
||||
|
||||
var (
|
||||
procReadConsoleInput = k32.NewProc("ReadConsoleInputW")
|
||||
procGetNumberOfConsoleInputEvents = k32.NewProc("GetNumberOfConsoleInputEvents")
|
||||
procFlushConsoleInputBuffer = k32.NewProc("FlushConsoleInputBuffer")
|
||||
procWaitForMultipleObjects = k32.NewProc("WaitForMultipleObjects")
|
||||
procSetConsoleMode = k32.NewProc("SetConsoleMode")
|
||||
procGetConsoleMode = k32.NewProc("GetConsoleMode")
|
||||
procGetConsoleScreenBufferInfo = k32.NewProc("GetConsoleScreenBufferInfo")
|
||||
procCreateEvent = k32.NewProc("CreateEventW")
|
||||
procSetEvent = k32.NewProc("SetEvent")
|
||||
)
|
||||
|
||||
const (
|
||||
keyEvent uint16 = 1
|
||||
mouseEvent uint16 = 2
|
||||
resizeEvent uint16 = 4
|
||||
menuEvent uint16 = 8 // don't use
|
||||
focusEvent uint16 = 16
|
||||
)
|
||||
|
||||
type inputRecord struct {
|
||||
typ uint16
|
||||
_ uint16
|
||||
data [16]byte
|
||||
}
|
||||
|
||||
type winTty struct {
|
||||
buf chan byte
|
||||
out syscall.Handle
|
||||
in syscall.Handle
|
||||
cancelFlag syscall.Handle
|
||||
running bool
|
||||
stopQ chan struct{}
|
||||
resizeCb func()
|
||||
cols uint16
|
||||
rows uint16
|
||||
pair []uint16 // for surrogate pairs (UTF-16)
|
||||
oimode uint32 // original input mode
|
||||
oomode uint32 // original output mode
|
||||
oscreen consoleInfo
|
||||
wg sync.WaitGroup
|
||||
surrogate rune
|
||||
sync.Mutex
|
||||
}
|
||||
|
||||
func (w *winTty) Read(b []byte) (int, error) {
|
||||
// first character read blocks
|
||||
var num int
|
||||
select {
|
||||
case c := <-w.buf:
|
||||
b[0] = c
|
||||
num++
|
||||
case <-w.stopQ:
|
||||
// stopping, so make sure we eat everything, which might require
|
||||
// very short sleeps to ensure all buffered data is consumed.
|
||||
break
|
||||
}
|
||||
|
||||
// second character read is non-blocking
|
||||
for ; num < len(b); num++ {
|
||||
select {
|
||||
case c := <-w.buf:
|
||||
b[num] = c
|
||||
case <-time.After(time.Millisecond * 10):
|
||||
return num, nil
|
||||
}
|
||||
}
|
||||
return num, nil
|
||||
}
|
||||
|
||||
func (w *winTty) Write(b []byte) (int, error) {
|
||||
esc := utf16.Encode([]rune(string(b)))
|
||||
if len(esc) > 0 {
|
||||
err := syscall.WriteConsole(w.out, &esc[0], uint32(len(esc)), nil, nil)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
return len(b), nil
|
||||
}
|
||||
|
||||
func (w *winTty) Close() error {
|
||||
_ = syscall.Close(w.in)
|
||||
_ = syscall.Close(w.out)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *winTty) Drain() error {
|
||||
close(w.stopQ)
|
||||
time.Sleep(time.Millisecond * 10)
|
||||
_, _, _ = procSetEvent.Call(uintptr(w.cancelFlag))
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *winTty) getConsoleInput() error {
|
||||
// cancelFlag comes first as WaitForMultipleObjects returns the lowest index
|
||||
// in the event that both events are signaled.
|
||||
waitObjects := []syscall.Handle{w.cancelFlag, w.in}
|
||||
|
||||
// As arrays are contiguous in memory, a pointer to the first object is the
|
||||
// same as a pointer to the array itself.
|
||||
pWaitObjects := unsafe.Pointer(&waitObjects[0])
|
||||
|
||||
rv, _, er := procWaitForMultipleObjects.Call(
|
||||
uintptr(len(waitObjects)),
|
||||
uintptr(pWaitObjects),
|
||||
uintptr(0),
|
||||
w32Infinite)
|
||||
|
||||
// WaitForMultipleObjects returns WAIT_OBJECT_0 + the index.
|
||||
switch rv {
|
||||
case w32WaitObject0: // w.cancelFlag
|
||||
return errors.New("cancelled")
|
||||
case w32WaitObject0 + 1: // w.in
|
||||
// rec := &inputRecord{}
|
||||
var nrec int32
|
||||
rv, _, er := procGetNumberOfConsoleInputEvents.Call(
|
||||
uintptr(w.in),
|
||||
uintptr(unsafe.Pointer(&nrec)))
|
||||
rec := make([]inputRecord, nrec)
|
||||
rv, _, er = procReadConsoleInput.Call(
|
||||
uintptr(w.in),
|
||||
uintptr(unsafe.Pointer(&rec[0])),
|
||||
uintptr(nrec),
|
||||
uintptr(unsafe.Pointer(&nrec)))
|
||||
if rv == 0 {
|
||||
return er
|
||||
}
|
||||
loop:
|
||||
for i := range nrec {
|
||||
ir := rec[i]
|
||||
switch ir.typ {
|
||||
case keyEvent:
|
||||
// we normally only expect to see ascii, but paste data may come in as UTF-16.
|
||||
wc := rune(binary.LittleEndian.Uint16(ir.data[10:]))
|
||||
if wc >= 0xD800 && wc <= 0xDBFF {
|
||||
// if it was a high surrogate, which happens for pasted UTF-16,
|
||||
// then save it until we get the low and can decode it.
|
||||
w.surrogate = wc
|
||||
continue
|
||||
} else if wc >= 0xDC00 && wc <= 0xDFFF {
|
||||
wc = utf16.DecodeRune(w.surrogate, wc)
|
||||
}
|
||||
w.surrogate = 0
|
||||
for _, chr := range []byte(string(wc)) {
|
||||
// We normally expect only to see ASCII (win32-input-mode),
|
||||
// but apparently pasted data can arrive in UTF-16 here.
|
||||
select {
|
||||
case w.buf <- chr:
|
||||
case <-w.stopQ:
|
||||
break loop
|
||||
}
|
||||
}
|
||||
|
||||
case resizeEvent:
|
||||
w.Lock()
|
||||
w.cols = binary.LittleEndian.Uint16(ir.data[0:])
|
||||
w.rows = binary.LittleEndian.Uint16(ir.data[2:])
|
||||
cb := w.resizeCb
|
||||
w.Unlock()
|
||||
if cb != nil {
|
||||
cb()
|
||||
}
|
||||
|
||||
default:
|
||||
}
|
||||
}
|
||||
return nil
|
||||
default:
|
||||
return er
|
||||
}
|
||||
}
|
||||
|
||||
func (w *winTty) scanInput() {
|
||||
defer w.wg.Done()
|
||||
for {
|
||||
if e := w.getConsoleInput(); e != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (w *winTty) Start() error {
|
||||
|
||||
w.Lock()
|
||||
defer w.Unlock()
|
||||
|
||||
if w.running {
|
||||
return errors.New("already engaged")
|
||||
}
|
||||
_, _, _ = procFlushConsoleInputBuffer.Call(uintptr(w.in))
|
||||
w.stopQ = make(chan struct{})
|
||||
cf, _, err := procCreateEvent.Call(
|
||||
uintptr(0),
|
||||
uintptr(1),
|
||||
uintptr(0),
|
||||
uintptr(0))
|
||||
if cf == uintptr(0) {
|
||||
return err
|
||||
}
|
||||
w.running = true
|
||||
w.cancelFlag = syscall.Handle(cf)
|
||||
|
||||
_, _, _ = procSetConsoleMode.Call(uintptr(w.in),
|
||||
uintptr(modeVtInput|modeResizeEn|modeExtendFlg))
|
||||
_, _, _ = procSetConsoleMode.Call(uintptr(w.out),
|
||||
uintptr(modeVtOutput|modeNoAutoNL|modeCookedOut|modeUnderline))
|
||||
|
||||
w.wg.Add(1)
|
||||
go w.scanInput()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *winTty) Stop() error {
|
||||
w.wg.Wait()
|
||||
w.Lock()
|
||||
defer w.Unlock()
|
||||
_, _, _ = procSetConsoleMode.Call(uintptr(w.in), uintptr(w.oimode))
|
||||
_, _, _ = procSetConsoleMode.Call(uintptr(w.out), uintptr(w.oomode))
|
||||
_, _, _ = procFlushConsoleInputBuffer.Call(uintptr(w.in))
|
||||
w.running = false
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *winTty) NotifyResize(cb func()) {
|
||||
w.resizeCb = cb
|
||||
}
|
||||
|
||||
func (w *winTty) WindowSize() (WindowSize, error) {
|
||||
w.Lock()
|
||||
defer w.Unlock()
|
||||
return WindowSize{Width: int(w.cols), Height: int(w.rows)}, nil
|
||||
}
|
||||
|
||||
func NewDevTty() (Tty, error) {
|
||||
w := &winTty{}
|
||||
var err error
|
||||
w.in, err = syscall.Open("CONIN$", syscall.O_RDWR, 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
w.out, err = syscall.Open("CONOUT$", syscall.O_RDWR, 0)
|
||||
if err != nil {
|
||||
_ = syscall.Close(w.in)
|
||||
return nil, err
|
||||
}
|
||||
w.buf = make(chan byte, 128)
|
||||
|
||||
_, _, _ = procGetConsoleScreenBufferInfo.Call(uintptr(w.out), uintptr(unsafe.Pointer(&w.oscreen)))
|
||||
_, _, _ = procGetConsoleMode.Call(uintptr(w.out), uintptr(unsafe.Pointer(&w.oomode)))
|
||||
_, _, _ = procGetConsoleMode.Call(uintptr(w.in), uintptr(unsafe.Pointer(&w.oimode)))
|
||||
w.rows = uint16(w.oscreen.size.y)
|
||||
w.cols = uint16(w.oscreen.size.x)
|
||||
|
||||
return w, nil
|
||||
}
|
||||
+9
-50
@@ -1,4 +1,4 @@
|
||||
// Copyright 2024 The TCell Authors
|
||||
// Copyright 2025 The TCell Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use file except in compliance with the License.
|
||||
@@ -20,7 +20,6 @@ package tcell
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall/js"
|
||||
"unicode/utf8"
|
||||
@@ -121,7 +120,7 @@ func paletteColor(c Color) int32 {
|
||||
}
|
||||
|
||||
func (t *wScreen) drawCell(x, y int) int {
|
||||
mainc, combc, style, width := t.cells.GetContent(x, y)
|
||||
str, style, width := t.cells.Get(x, y)
|
||||
|
||||
if !t.cells.Dirty(x, y) {
|
||||
return width
|
||||
@@ -143,18 +142,8 @@ func (t *wScreen) drawCell(x, y int) int {
|
||||
uc = 0x000000
|
||||
}
|
||||
|
||||
s := ""
|
||||
if len(combc) > 0 {
|
||||
b := make([]rune, 0, 1 + len(combc))
|
||||
b = append(b, mainc)
|
||||
b = append(b, combc...)
|
||||
s = string(b)
|
||||
} else {
|
||||
s = string(mainc)
|
||||
}
|
||||
|
||||
t.cells.SetDirty(x, y, false)
|
||||
js.Global().Call("drawCell", x, y, s, fg, bg, int(style.attrs), int(us), int(uc))
|
||||
js.Global().Call("drawCell", x, y, str, fg, bg, int(style.attrs), int(us), int(uc))
|
||||
|
||||
return width
|
||||
}
|
||||
@@ -277,6 +266,12 @@ func (t *wScreen) DisableFocus() {
|
||||
t.Unlock()
|
||||
}
|
||||
|
||||
func (s *wScreen) GetClipboard() {
|
||||
}
|
||||
|
||||
func (s *wScreen) SetClipboard(_ []byte) {
|
||||
}
|
||||
|
||||
func (t *wScreen) Size() (int, int) {
|
||||
t.Lock()
|
||||
w, h := t.w, t.h
|
||||
@@ -376,14 +371,6 @@ func (t *wScreen) onKeyEvent(this js.Value, args []js.Value) interface{} {
|
||||
mod |= ModMeta
|
||||
}
|
||||
|
||||
// check for special case of Ctrl + key
|
||||
if mod == ModCtrl {
|
||||
if k, ok := WebKeyNames["Ctrl-"+strings.ToLower(key)]; ok {
|
||||
t.postEvent(NewEventKey(k, 0, mod))
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// next try function keys
|
||||
if k, ok := WebKeyNames[key]; ok {
|
||||
t.postEvent(NewEventKey(k, 0, mod))
|
||||
@@ -625,34 +612,6 @@ var WebKeyNames = map[string]Key{
|
||||
"F62": KeyF62,
|
||||
"F63": KeyF63,
|
||||
"F64": KeyF64,
|
||||
"Ctrl-a": KeyCtrlA, // not reported by HTML- need to do special check
|
||||
"Ctrl-b": KeyCtrlB, // not reported by HTML- need to do special check
|
||||
"Ctrl-c": KeyCtrlC, // not reported by HTML- need to do special check
|
||||
"Ctrl-d": KeyCtrlD, // not reported by HTML- need to do special check
|
||||
"Ctrl-e": KeyCtrlE, // not reported by HTML- need to do special check
|
||||
"Ctrl-f": KeyCtrlF, // not reported by HTML- need to do special check
|
||||
"Ctrl-g": KeyCtrlG, // not reported by HTML- need to do special check
|
||||
"Ctrl-j": KeyCtrlJ, // not reported by HTML- need to do special check
|
||||
"Ctrl-k": KeyCtrlK, // not reported by HTML- need to do special check
|
||||
"Ctrl-l": KeyCtrlL, // not reported by HTML- need to do special check
|
||||
"Ctrl-n": KeyCtrlN, // not reported by HTML- need to do special check
|
||||
"Ctrl-o": KeyCtrlO, // not reported by HTML- need to do special check
|
||||
"Ctrl-p": KeyCtrlP, // not reported by HTML- need to do special check
|
||||
"Ctrl-q": KeyCtrlQ, // not reported by HTML- need to do special check
|
||||
"Ctrl-r": KeyCtrlR, // not reported by HTML- need to do special check
|
||||
"Ctrl-s": KeyCtrlS, // not reported by HTML- need to do special check
|
||||
"Ctrl-t": KeyCtrlT, // not reported by HTML- need to do special check
|
||||
"Ctrl-u": KeyCtrlU, // not reported by HTML- need to do special check
|
||||
"Ctrl-v": KeyCtrlV, // not reported by HTML- need to do special check
|
||||
"Ctrl-w": KeyCtrlW, // not reported by HTML- need to do special check
|
||||
"Ctrl-x": KeyCtrlX, // not reported by HTML- need to do special check
|
||||
"Ctrl-y": KeyCtrlY, // not reported by HTML- need to do special check
|
||||
"Ctrl-z": KeyCtrlZ, // not reported by HTML- need to do special check
|
||||
"Ctrl- ": KeyCtrlSpace, // not reported by HTML- need to do special check
|
||||
"Ctrl-_": KeyCtrlUnderscore, // not reported by HTML- need to do special check
|
||||
"Ctrl-]": KeyCtrlRightSq, // not reported by HTML- need to do special check
|
||||
"Ctrl-\\": KeyCtrlBackslash, // not reported by HTML- need to do special check
|
||||
"Ctrl-^": KeyCtrlCarat, // not reported by HTML- need to do special check
|
||||
}
|
||||
|
||||
var curStyleClasses = map[CursorStyle]string{
|
||||
|
||||
Reference in New Issue
Block a user