Commit Graph

282 Commits

Author SHA1 Message Date
VÖRÖSKŐI András b03a4607a4 Add GetModel() method to CellView
GetModel() returns CellView.model type CellModel
2020-02-28 11:53:41 -08:00
VÖRÖSKŐI András 66b1faf255 CeellView corsor remove
Do not store cursor info (cursorX, CursorY) in CellView, as it belongs to the model (CellModel)

Use GetCursor() to identify current cursor position from CellModel
2020-02-28 11:53:41 -08:00
Vedran Vidović bac2bbc5b3 Adding Shift modifier for PgUp/PgDn
Implemented key kombination of Shift + PgUp/PgDn for Gnome terminal.
Same combination copied to all other terminal implementations which use same
codes for Shift + Up/Down but since this is tested on Ubuntu 16.04 with Gnome
Terminal 3.18.3 it could be that it is not correctly implemented for some of the
other terminals.
2020-02-05 21:47:23 -08:00
Graham Clark bff4943f9a Provide a fallback terminal size if the OS returns (0,0)
Sometimes, the TIOCGWINSZ ioctl returns all zeroes (including columns,
rows) without an error. I found this when experimenting with the jexer
TUI toolkit for java e.g.

mvn dependency:get -Dartifact=com.gitlab.klamonte:jexer:0.3.2
jexer -jar ~/.m2/repository/com/gitlab/klamonte/jexer/0.3.2/jexer-0.3.2.jar

Once the demo starts, click the "Terminal" button, then type

stty size

it returns

0 0

My understanding is that this is normal, and happens until SIGWINCH is
received, or the size is set explicitly with TIOCSWINSZ.

My tcell application crashed under the jexer terminal because I didn't
anticipate a window size of (0,0).

If you run vim under the jexer terminal, it correctly sizes itself to
80x24. The shell's TERM variable is xterm, and infocmp xterm | grep cols
shows a default of 80 and a default of 24 for lines. The documentation
for vim explains how it computes the terminal size:

https://github.com/vim/vim/blob/master/runtime/doc/term.txt#L629

- an ioctl call (TIOCGSIZE or TIOCGWINSZ, depends on your system)
- the environment variables "LINES" and "COLUMNS"
- from the termcap entries "li" and "co"

This PR replicates that logic in the getWinSize() function. I think it
makes sense here because tScreen holds the TermInfo struct but the
tcell.Screen interface does not expose TermInfo to clients - of course
because the screen is abstracted to work on Windows too.
2020-01-14 19:03:18 -08:00
Graham Clark 0253335d5d Update terminfo DB to fix backspace issues
I have rerun gen.sh having pulled the latest tcell to include this PR:
https://github.com/gdamore/tcell/pull/325.

I am using Ubuntu 19.04 - running gen.sh changed more fields than just
those impacted by the above fix. I've removed those from this commit. (I
verified that gen.sh changed those fields I've removed without the fix
above, so it's not related). Based on TERMINALS.md, I suspect you
regenerate these typically on a Debian machine(?)
2020-01-14 19:01:46 -08:00
Garrett D'Amore ef4e0a2e86 fixes #323 Missing termbox key binding 2020-01-13 21:31:55 -08:00
Graham Clark de4e5c4494 Fix control-character encoding for non-alphabet characters
@klamonte opened this issue against gowid, a package that relies on tcell for
all its terminal handling: https://github.com/gcla/gowid/issues/24. It
describes how a shell inside a terminal widget that the TUI launches freezes
when the user hits backspace. The TUI loads a tcell TermInfo struct for the
screen-256color terminal and that struct codes KeyBackspace as the single byte
0xff - and so the byte 0xff was sent to the tty. On my Ubuntu 19.04 machine,
`infocmp screen-256color` shows `kbs` is `^?` According to
https://en.wikipedia.org/wiki/Caret_notation, `^?` should map to 0x7f (127) -
"The digraph stands for the control character whose ASCII code is the same as
the character's ASCII code with the uppermost bit, in a 7-bit encoding,
reversed". This affects both mkinfo.go, the generator of the JSON terminfo
database files, and the dynamic terminfo generator.
2020-01-13 20:44:03 -08:00
MichaelS11 d650ce5ff5 Added Go Tetris 2019-12-03 17:43:29 -08:00
Ben Hoyt 15a6351b65 Update runewidth to v0.0.7 to fix CP437 char width issues 2019-12-03 17:40:46 -08:00
Ben Hoyt b6a97de0c1 Update go-colorful to v1.0.3 to avoid go-sqlmock dependency 2019-11-14 17:44:13 -08:00
Garrett D'Amore aab872a249 Workflow for tcell Go 2019-11-14 17:43:26 -08:00
Garrett D'Amore 901f4de1e2
Insert GitHub and Tidelift sponsorship info. 2019-11-01 08:18:39 -07:00
Garrett D'Amore 3e3de19da0
Start with just Patreon for now. 2019-11-01 00:22:15 -07:00
Garrett D'Amore e38693ffb0
Fixes to FUNDING.yml 2019-11-01 00:15:04 -07:00
Garrett D'Amore 9400b55510 Create FUNDING.yml 2019-11-01 00:09:54 -07:00
Garrett D'Amore fc60a7c5fe
Add link to discord server (#310)
We're migrating to discord, because gitter usability has decreased to the point of being useless.

A few other minor cleanups.
2019-11-01 00:02:10 -07:00
Garrett D'Amore 4d152cc262 fixes #302 merge extended terminfo definitions into default
This makes the default build about 150k larger, but includes all
the good terminals needed to make most folks happy.  In addition,
it allows a build tag of tcell_minimal to suppress that.  Finally,
we do not include infocmp support on platforms unlikely to support
it, such as Windows, nacl, android, etc.
2019-09-22 11:15:39 -07:00
Cole Helbling ae1dc54d2c Add terminfo for Alacritty 2019-08-05 09:28:43 -07:00
Asger Hautop Drewsen 4e7865679e Add terminfo for kitty (#283) 2019-08-01 11:20:19 -07:00
Garrett D'Amore fef653e8d0 Update README for new mkinfo 2019-07-29 22:47:04 -07:00
Garrett D'Amore 1922b3786e fixes #252 database cannot be distributed in static binary 2019-07-23 19:39:55 -07:00
Garrett D'Amore 84b54971b4 fixes #294 Baud rate should not matter 2019-07-23 19:03:31 -07:00
Garrett D'Amore 061f3f89b0 fixes #277 Build fails on mips architectures 2019-06-27 18:33:09 -07:00
Garrett D'Amore 30e78c7859 it is really illumos/solaris 2019-06-26 11:47:15 -07:00
Garrett D'Amore 4d4b990045 fixes #257 Broken illumos Support
This change has refactored the illumos layer to make use of the
golang.org/x/sys/unix package to achieve a clean cgo-free solution
for illumos and Solaris.

The approach here should be a template for other systems.  I've
also made some changes to the Linux port.
2019-06-26 11:31:59 -07:00
Garrett D'Amore ca8fb5bcc9 fixes #279 process new terminal descriptions at application runtime
fixes #285 Loss of color/mangled formatting on GNU screen
fixes #93 use the terminfo database instead of the json database

This change falls back to using a dynamically generated terminal
description (using infocmp, which must be on the path) if the builtin
database doesn't have a suitable description.

For most users this should resolve the problem of unknown terminals.
2019-06-12 23:38:18 -07:00
Graham Clark 6d0b0fa74e On windows, don't change cursor position if about to hide cursor.
A gowid user reported that mouse movement in their gowid(tcell) application
was causing the console cursor to flicker on windows, jumping from the current
position in the console to the top left corner, and back again. In part, this
is an artifact of the way I render a gowid "canvas" - calling HideCursor()
unilaterally, then calling ShowCursor(x, y) if the canvas contains a logical
cursor that is within bounds. Because currently every mouse event causes a
gowid application redraw, on windows the effect is to cause the cursor to jump
to the top left briefly, disappear, then reappear in the previous
position. You can see it most easily by moving the mouse rapidly left and
right.

An upstream fix is for me to only call HideCursor() if I know I'm not going to
call ShowCursor(x, y). But the flicker can also be eliminated by removing the
call to setCursorPos(0, 0) in console_win.go before hiding the cursor. The
single call to showCursor() in console_win.go is preceded by setting cursor
coordinates explicitly, so I don't think anything depends on the assumption
that a hidden cursor has been set to position (0, 0) first.
2019-06-11 17:21:45 -07:00
Graham Clark 12658f0d57 Another attempt to fix limited length of paste.
I humbly submit this patch as another attempt to address the issue that tcell
will only paste up to 11 characters at a time. The problem is caused by the
fact that events (key, mouse, etc) constructed from the stream of raw input
characters are sent to the consuming application over a length-10 channel via
screen.PostEvent() which, if the channel is full, will drop what can't be sent
immediately. If the input stream grows rapidly e.g. because the user pasted a
large section of text into the running tcell application, then more than 10
events will likely be built from the chunk of input read by scanInput().

A blocking channel send is not used (i.e. PostEventWait() instead of
PostEvent()) because the channel send is issued from a call stack in which the
screen struct's lock is held. If the receiving application is not consuming
events, then callers to other screen APIs will block waiting for the screen's
lock. If the receiving application needs to call another screen API before
reading from the channel, a deadlock may occur if that required screen API
tries to take the screen's lock.

This patch collects events extracted from the input stream into a slice while
the lock is held, then after releasing the screen lock, writes them in order
to the event channel with PostEventWait(). I chose the blocking API to ensure
events aren't dropped, since sending the events outside of the lock-held scope
should remove the risk of a deadlock (unless I've missed something important!)

This patch is similar in spirit to that submitted by @soyking:
9addd5bbe4.

I have not adjusted the windows cmd console screen because the paste problem
does not seem to be an issue in practice on that platform, at least according
to my testing.
2019-06-09 10:24:20 -07:00
Graham Clark b5d0c1ac57 Shamelessly add my two tcell projects to the README ;-) 2019-05-07 18:29:39 -07:00
Simon Ser dcf1bb3077 Update go-colorful dependency
go-sqlmock, which is a dependency for go-colorful tests, have switched from
gopkg.in to Go modules. This repository still records the old gopkg.in import
path in the go.mod file, which confuses `go mod`:

    go: gopkg.in/DATA-DOG/go-sqlmock.v1@v1.3.3: go.mod has non-....v1 module path "github.com/DATA-DOG/go-sqlmock" at revision v1.3.3

This commit updates the go.mod file to use the new import path.
2019-04-11 22:49:14 -07:00
Simon Lehn cb2f436528 fix typo 2019-04-07 19:24:05 -07:00
Graham Clark 8925703e9e An attempt to work around a gopkg.in/module error in a dependency.
Specifically:

gcla@elgin:~/source/gowid$ go get -u -v github.com/gdamore/tcell
Fetching https://golang.org/x/text?go-get=1
Fetching https://gopkg.in/DATA-DOG/go-sqlmock.v1?go-get=1
Parsing meta tags from https://golang.org/x/text?go-get=1 (status code 200)
get "golang.org/x/text": found meta tag get.metaImport{Prefix:"golang.org/x/text", VCS:"git", RepoRoot:"https://go.googlesource.com/text"} at https://golang.org/x/text?go-get=1
Parsing meta tags from https://gopkg.in/DATA-DOG/go-sqlmock.v1?go-get=1 (status code 200)
get "gopkg.in/DATA-DOG/go-sqlmock.v1": found meta tag get.metaImport{Prefix:"gopkg.in/DATA-DOG/go-sqlmock.v1", VCS:"git", RepoRoot:"https://gopkg.in/DATA-DOG/go-sqlmock.v1"} at https://gopkg.in/DATA-DOG/go-sqlmock.v1?go-get=1
go: finding github.com/lucasb-eyer/go-colorful latest
go: gopkg.in/DATA-DOG/go-sqlmock.v1@v1.3.3: go.mod has non-....v1 module path "github.com/DATA-DOG/go-sqlmock" at revision v1.3.3
go get: error loading module requirements
2019-04-07 19:20:36 -07:00
gcla ec71b09872 An attempt to speed up tcell screen rendering. (#247) 2019-03-19 00:31:05 -07:00
Garrett D'Amore 48f88019c3 fixes #243 Ordering of SetConsoleWindowInfo and SetConsoleScreenBufferSize 2019-03-19 00:22:32 -07:00
Garrett D'Amore 2fca0432ba Windows should always try for console first.
We had problems where if $TERM was set on a Windows console, we would
fail to allocate the screen because of missing termios.  This caused
lots of problems for many Windows users.  This should make this easier
for folks who might have set $TERM for other reasons, even in a Windows
console environment.

Eventually we will want to support emitting characters for 256 color
support, but that's later.
2019-03-19 00:07:29 -07:00
otani_koji f0cffc65c6 fixes #250 Some characters disappear on Windows 2019-03-18 23:57:44 -07:00
Garrett D'Amore d195cc757c fixes #264 tcell breaks grapheme clusters 2019-03-18 23:41:32 -07:00
Garrett D'Amore 77ab683d7d Improve 24-bit color support.
This expands support for 24-bit color for terminals that support the
ISO 8613-6:1994 escape sequences (same as xterm), allowing this support
to be enabled by setting % COLORTERM to "truecolor" (or 24bit or 24-bit),
or by setting TCELL_TRUECOLOR to "on", or by setting $TERM a value that
ends in the word "-truecolor".

As this is handled by the runtime now, we no longer need to create magical
database entries for -truecolor options.

A colors.go demo is provided to show off 24-bit color support.
2019-03-18 22:47:05 -07:00
Sam Whited aaadc574a6 Support Go Modules 2018-12-20 13:25:34 -08:00
Garrett D'Amore af444b941a Refactor tests to avoid go-convey.
While go-convey was pretty nice, it carries a rather large dependency
graph, which we think it is better not to burden our downstreams with.
It is easy enough to just refactor the tests to use the standard testing
package.
2018-12-18 21:33:43 -08:00
Garrett D'Amore 017915a4d7
Remove grid from support table. 2018-10-29 16:12:21 -07:00
Garrett D'Amore 483884f06f Convert to asciidoctor, add more support details, incl. Tidelift. 2018-10-26 08:00:31 -04:00
Takumasa Sakao 8e3efba094 Update README.md 2018-10-24 09:14:50 -04:00
Garrett D'Amore 493f3b46b3 fixes #225 Kitty missing from terminfo database 2018-09-23 22:52:37 -07:00
Garrett D'Amore a5810f6e8f fixes #236 CellBuffer.Fill doesn't set cell.width 2018-09-23 19:58:37 -07:00
Garrett D'Amore a24b9b6b1c fixes #238 views: BoxLayout.Draw does unnecessary filling 2018-09-23 19:54:34 -07:00
Garrett D'Amore 86147f14ef fixes #233 Want zero-width joiners support 2018-09-05 18:42:39 -04:00
Tobi 61bec9bcda Update README.md
Add browsh to the list of examples.
2018-09-05 08:48:50 -04:00
ia de7e78efa4 all: gofmt
Run standard gofmt command on project root.

- go version go1.10.3 darwin/amd64

Signed-off-by: ia <isaac.ardis@gmail.com>
2018-06-23 12:52:09 -07:00
Martin Angers 2efc922424 add termite terminfo 2018-06-23 12:51:08 -07:00