/dev/tty
device.dialog
or whiptail
utilities.For an editor that uses this module, take a look at orbiton.
Screen recording of the shooter
example, where you can control a small character with the arrow keys and shoot with space
.
Screen recording of the menu
example, which uses VT100 terminal codes and demonstrates a working menu.
A physical VT100 terminal. Photo by Jason Scott, CC BY 2.0
Output "hi" in blue:
vt100.Blue.Output("hi")
Erase the current line:
vt100.Do("Erase Line")
Move the cursor 3 steps up (it's a bit verbose, but it is memoized for better performance):
vt100.Set("Cursor Up", map[string]string{"{COUNT}": "3"})
The full overview of possible commands are at the top of vt100.go
.
See cmd/move
for a more advanced example, where a character can be moved around with the arrow keys.
vt100
The Orbiton editor that uses vt100
can be used for editing Go, Bash or for example C++ code.
Quick installation:
go install github.com/xyproto/o/v2@latest