Commit Graph

261 Commits

Author SHA1 Message Date
Garrett D'Amore 299cb413dc Add a sample style to hello world. 2021-04-18 12:26:17 -07:00
Garrett D'Amore 0c349a85f4 Remove stale (unused) code in Windows finish. 2021-04-18 12:05:27 -07:00
Garrett D'Amore fb06997fe2 fixes #445 Prompt Cursor Lost after Suspend v2.2.0 Windows PowerShell 2021-04-18 12:04:21 -07:00
Garrett D'Amore 356d48f50a Fix link display. Thanks to @noborus. 2021-04-18 11:54:14 -07:00
Graham Clark 1febfd418d Add tmux-wormhole to the list of tcell-dependent apps
I published this yesterday on github. It's a tmux plugin that scrapes
the active tmux pane for a magic wormhole code, then downloads and
optionally opens the file tied to the code. I wrote this to make it
easier to get pcaps from termshark into Wireshark. This plugin uses
gowid which itself depends wholly on tcell to manipulate the
terminal. Link: https://github.com/gcla/tmux-wormhole
2021-04-18 11:52:41 -07:00
Noboru Saito 7694d90821 Change to /dev/tty because term.GetState fails
The file descriptor of "os.Stdin"
may cause term.GetState to be an error.
2021-04-18 11:50:21 -07:00
Gokcehan 14c5375ccc send enter_keypad during terminal engage 2021-04-18 11:38:12 -07:00
Gokcehan d003d0a0a1 switch back to ca mode after suspend/resume
Suspend call currently exits ca mode. So after the first suspend/resume
the program does not use the alternate screen anymore. Therefore Resume
needs to enter ca mode again.
2021-04-18 11:38:12 -07:00
bobo liu e37d20eeec fixes PollEvent() hung after Fini() on windows 2021-04-18 11:31:00 -07:00
Noboru Saito f4d402906f Added terminal pager ov to examples 2021-03-04 22:05:00 -08:00
Garrett D'Amore c94849e7d5 Remove go1.11 from travis matrix. 2021-02-20 13:28:15 -08:00
Adrian Hesketh 68b5c49fcb Add https://github.com/a-h/min to the examples 2021-02-20 13:27:38 -08:00
Garrett D'Amore 16556370d7 Support for new Suspend and Resume API.
fixes #194 Starting multiple screen sessions (lost key event)

You can test this by using the mouse demo, which now supports pressing
CTRL-Z.  This does not actually suspend the demo, but starts a subshell
which takes over.  After the subshell is exited, the demo takes control
of the screen back.  This can be done multiple times, and it is possible
to start multiple "nested" iterations of the demo this way.
2021-02-20 13:20:58 -08:00
Garrett D'Amore 19e17097d8 Mark PostEventWait deprecated.
At some point in the future this is going to be replaced with
a simpler channel design, and the current blocking approach
is both non-idiomatic, and fragile.  Don't use it.
2021-01-24 16:48:47 -08:00
Garrett D'Amore 13bc6c2778 fixes #420 RFE: Mouse wheel only reporting
This adds optional MouseFlags that can be used to adjust what is
tracked for mouse reporting (leaving the other modes to be handled
by the terminal.)  This should work on all XTerm style terminals,
but on Windows we have no way to be selective here.
2021-01-24 15:18:06 -08:00
Garrett D'Amore f0c15689df Mintty (modern) works now. So remove the caveat. 2021-01-24 13:50:22 -08:00
Garrett D'Amore e9095fe4f1 fixes #394 Screen.Fini does not leave the terminal in a usable state in MacOS
This does sort the main problem of screen.Fini(), but really we
want to use a separate Pause() and Resume() function, because
screen.Fini() is not meant for reuse in this way.

Note that one side effect of this change is that applications which
redirect stdin and stdout and expect us to just use /dev/tty instead
are going to break -- we are now using stdin and stdout like nearly
every other screen oriented application.
2021-01-24 13:26:36 -08:00
Garrett D'Amore f2adc0cca0 fixes #423 Please upgrade mattn/go-runewidth 2021-01-15 22:35:06 -08:00
Travis Whitton 044d3f0490 Added example project uchess 2021-01-15 22:23:14 -08:00
Garrett D'Amore 29bb185874 Backout the change to tview, was incorrect. 2020-12-25 11:46:24 -08:00
Garrett D'Amore d664ce8c2b Remove deprecated examples, add cview. 2020-12-25 11:37:28 -08:00
Zhani Baramidze 49e9e720f7 Added example project gonano 2020-12-25 11:32:17 -08:00
mjarkk 3cc2a8dda5 Add gocui to readme 2020-12-25 11:31:37 -08:00
Ole Bulbuk c7f2b33a4d Fix endless loop
InjectKeyBytes would go into an endless loop for single bytes smaller than a blank.
2020-12-14 15:03:29 -08:00
Garrett D'Amore 7d87d8188c fixes #406 Windows 7 terminal - screen is shifted up one row 2020-11-08 21:26:06 -08:00
nagesh-ibm-power 20750b0d3e Add go 1.15 and power support ppc64le to travis 2020-10-30 10:21:12 -07:00
Garrett D'Amore 768da2b4f2 fixes #403 Recogize more truecolor terminals properly
(This just corrects the README to reflect reality.)
2020-10-29 17:30:53 -07:00
Trevor Slocum 6314995119 Add tutorial
Resolves #163.
2020-10-25 10:12:29 -07:00
Taras 1057d5591e Add another example project
Hopefully worthy of being in this list. termbox-go has similar touch-typing tutor in its examples, maybe tcell should too.
2020-10-19 07:26:33 -07:00
Oliver acf90d56d5 Fixed a typo. 2020-10-17 07:12:08 -07:00
Oliver 3907a8d921 Improved the new Style.Attributes() function. (Should not modify the existing Style object.) 2020-10-17 07:12:08 -07:00
Oliver 1575526e4d Added a function to Style that sets its attributes. Also fixed some comments. 2020-10-17 07:12:08 -07:00
Garrett D'Amore 260932a7ea Update documentation for V2. 2020-10-16 00:05:26 -07:00
Garrett D'Amore 197faf3eae fixes #120 Support for bracketed paste mode
This adds Bracketed Paste support for terminals that have mouse
support and support it.  The bracketing events are EventPaste,
with methods to note Start() or End() of the paste.  Content
comes in as normal rune events.  Programs must opt-in to this by
calling screen.EnablePaste().
2020-10-15 23:13:03 -07:00
Garrett D'Amore aeb3a11948 fixes #391 tcell panic on TERM=xterm-termite
This fixes the panic, but also adds defitions for xterm-termite
and tmux-256color.
2020-10-13 22:17:07 -07:00
Jai Flack 50e36d6c03 Fix CHANGESv2.adoc Import Path
The import path in CHANGESv2.adoc was wrong and didn't match README.adoc.
This fixes that.
2020-10-07 10:42:30 -07:00
qlcom 0fb77ddaa5 add github.com/gokcehan/lf to Examples 2020-09-26 08:21:01 -07:00
Graham Clark 1f9685874a Attempted fix of a regression I introduced - breaking mouse support!
@tslocum reported that the commit at 2d6d7fbe broke mouse support in
cview (https://github.com/gdamore/tcell/pull/384#issuecomment-698422464). The
purpose of the original commit was to fix a terminfo background color
code parsing problem that I spotted using TERM=xterm-16color:

$ infocmp xterm-16color | grep setab
	setab=\E[%?%p1%{8}%<%t%p1%'('%+%e%p1%{92}%+%;%dm,

The middle sections says "if p1<8 then push(p1+'(') ". '(' is ascii
40. The sequence '%d' will then pop from the stack and interpreting the
result as an integer.

My change above was to have tcell assume the sequence between two single
quotes was a single ASCII character e.g. '(' and push that to the
terminfo stack as an integer with the ASCII value of the character
e.g. push(40:int). I didn't find any counterexamples in my local
terminfo database that didn't line up with that assumption; but I did
break mouse support because tcell generates its own rules to enable
mouse support, if not specified in the terminfo DB - both when
generating its own Golang-style internal DB, and in the dynamic terminfo
generator that uses infocmp:

"%?%p1%{1}%=%t%'h'%Pa%e%'l'%Pa%;\x1b[?1000%ga%c\x1b[?1002%ga%c\x1b[?1003%ga%c\x1b[?1006%ga%c"

This rule will push 'h' or 'l', depending on whether mouse mode is to be
enabled or disabled, and then sets the variable named a to the result,
interpreted as a string. The result is that when mouse mode is enabled,
tcell needs to emit \x1b[?1000h - where the 'h' comes from variable a
i.e. it needs to be able to push a quoted argument as a string and not
be forced into an int.

This alternative fix preserves the fact the quoted argument is a string
and maintains that on the stack. However, if the integer Pop() function
is called when the top element of the stack is a string, tcell will now

- return the string converted to an int, if it converts e.g. in the case
  '123' is pushed to the stack as a string and popped as an int, the value
  is 123
- otherwise return the ASCII value of the first character of the string
  e.g. if '(' is pushed then popped as an int, the value returned is 40.

To be compatible with this logic, if a terminfo rule needs to push an
integer whose value is >= ascii('0')==48 and <= ascii('9')==57, it will
need to use the form e.g. {53} and not '5' because the form '5' will be
pushed as "5":string and if popped as an int will return the value 5 and
not 53.
2020-09-26 08:19:27 -07:00
Marcel Schramm 0cc2ea7214 Fixed typo in example link description
There was a typo in my previous PR, I didn't notice, sorry
2020-09-24 14:17:53 -07:00
Marcel Schramm 6c71be6801 Add Bios-Marcel/memoryalike to the readme
I added a link to https://github.com/Bios-Marcel/memoryalike.
It's a small terminal game written with tcell as it's sole dependency.
2020-09-21 11:39:46 -07:00
Graham Clark 2d6d7fbe48 Change interpretation of pushing quoted character in terminfo parser
I noticed this problem while running a gowid test program (palette.go)
with TERM=xterm-16color. This terminal type is not present in tcell's
built-in database, and so tcell falls back to the dynamic terminal type
by parsing the output of infocmp. The symptom was that foreground colors
were not correctly set, leaving a monochrome screen. This seems to be
caused by a problem interpreting the *background* color terminfo
rule. The attribute to set background color is defined like this (Ubuntu
20.04):

$ infocmp xterm-16color | grep setab
	setab=\E[%?%p1%{8}%<%t%p1%'('%+%e%p1%{92}%+%;%dm,

The middle sections says "if p1<8 then push(p1+'(') ". '(' is ascii
40. If I run

$ tput setab 5

the terminal sees 'ESC[45m'. This correctly sets the background color to
magenta. But if I tell tcell to emit a cell with background color set to
tcell.Color(5), the terminal sees 'ESC[0m'. This means in practice, my
app emits a code to set the foreground color, then an SGR code that
resets all attributes, then the ASCII character.

When tcell "runs" a terminfo rule in terminfo::TParm(), a push to the
stack preserves the type of the argument pushed - int or string. When a
single quote is encountered, the argument within is pushed to the stack
as a string. For the `setab` rule above, tcell will then pop as an int,
discarding the error and returning 0. The fix here is to have tcell push
the argument inside the single quotes as an integer, using the ascii
value of the argument e.g. "(" -> 40 - and assume the string is length
1, I suppose. Cross-referencing against
ncurses/tinfo/lib_tinfo.c::tparam_internal(), it looks like this code
assumes a single-quoted string is assumed to be length=1 and is also
interpreted as an integer with the ascii value of the character:

case S_QUOTE:
    cp++;
    npush(UChar(*cp));
    cp++;
    break;
2020-09-20 08:17:17 -07:00
Magnus 222a03c3db Added two more examples 2020-09-20 08:12:58 -07:00
Eze Olea Figueroa 0c5e1e1720 Added Tblogs to README 2020-09-08 05:12:50 -07:00
Trevor Slocum da485f4734 Rename StrikeOut as StrikeThrough 2020-08-31 08:55:31 -07:00
Garrett D'Amore c008cc6a3b Add CHANGESv2 to track important changes for V2 (breaking changes). 2020-08-30 23:40:01 -07:00
Garrett D'Amore 368f8e092b fixes #376 Need ColorReset
This provides a ColorReset color that resets the color to
the default for the terminal.
2020-08-30 22:57:00 -07:00
Garrett D'Amore 9d283802ab fixes #350 Add strikeout support 2020-08-30 20:25:30 -07:00
Garrett D'Amore 7e218720b8 Remove stray sleep 2020-08-30 20:11:55 -07:00
Garrett D'Amore bf3f269ccb fixes #373 Check for and use RGB property in terminfo
This also regenerated some definitions, which should lead to
more accurate mouse mode for a few of the terminals.
2020-08-30 19:33:25 -07:00
Garrett D'Amore 5216188a4f fixes #324 Fini() is not idempotent 2020-08-30 19:00:54 -07:00