Add a Beep() method to the Screen interface. On *nix systems, this
writes the bell character (0x07) to the tty. On Windows, we call the
MessageBeep syscall.
Fixes: #2
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.
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.
fixes#164 KeyEscape does not work in Go 1.9 under Linux
This is a complete refactor of the input loop for UNIX systems.
We use a blocking reader on the TTY, and a separate select
loop for timers and other events. This means that our idle
use should be low now.