Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: d45c38fa52
Fetching contributors…

Cannot retrieve contributors at this time

73 lines (56 sloc) 3.249 kb
Terminal input is a little bit messy. So, what's working in termbox?
1. Termbox supports only few special keys. Main reason for that, that
they are available on all major terminals.
Full list of functional keys:
F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12,
INSERT, DELETE, HOME, END, PGUP, PGDN,
KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT
And that's it. If you don't want input problems, stick to these.
2. Termbox supports all major ASCII combinations, but there are some
interesting moments. Particulary there are a lot of key clashes (few
keys or combos does the same thing). I can list all of these:
CTRL+I, TAB (0x09)
CTRL+2, CTRL+TILDE (0x00)
CTRL+H, BACKSPACE (0x08)
CTRL+M, ENTER (0x0D)
CTRL+3, ESC, CTRL+[ (0x1B) [alt emits ESC too]
CTRL+4, CTRL+BACKSLASH (0x1C)
CTRL+5, CTRL+] (0x1D)
CTRL+7, CTRL+SLASH, CTRL+UNDERSCORE (0x1F)
CTRL+8, BACKSPACE2 (0x7F) [ASCII 'DELETE' key]
Some terminals emit ASCII 'DELETE' as BACKSPACE, and real BACKSPACE
as CTRL+BACKSPACE. The point is, it is possible that some terminals
do things in different ways. I'm not sure right now, should I fix this.
You should keep these things in mind when developing a termbox application.
3. Termbox supports two input parsing modes:
- TB_INPUT_ESC - It checks known ESC sequences and if there is no match
0x1B (ESC) symbol is TB_KEY_ESC. Alt+<KEY> combinations don't work.
- TB_INPUT_ALT - It checks known ESC sequences and if there is no match
0x1B enables ALT modifier, and next known key event emits with
TB_MOD_ALT set.
You can switch between these two modes using tb_select_input_mode() func.
4. Termbox supports *only* the UTF-8 encoding on input and on output. Get a
decent terminal emulator with unicode support! Also it means that it will
probably work with ASCII keymaps. UTF-8 is backward compatible with ASCII.
5. The available color set and attribute set is restricted the same way as key
set. Even though there are 256-color terminals you will not be able to use
additional colors.
6. No mouse support.. Ever. :) But I guess it will be possible to create
termbox-compatible GUI library which has mouse support as an extension.
7. Probably you don't want to port existing applications to this library.
But you might want to develop new applications with it. Despite the fact
that library isn't super portable and super stable like ncurses, it will
do the job. If you complain about different Shift+F1, Ctrl+KEY_LEFT
combinations and other lacking capabilites, take a look at vim! It uses
very strict set of default keybindings.
(http://hea-www.harvard.edu/~fine/Tech/vi.html)
As you can see, it's generally all letters, their upper-case variants, and
ASCII control combinations. There are even no F1, F2, F3, etc. And hey, vim
has pretty nice interface. But on the other hand, other programs which
try to clone Windows apps or DOS apps, like Midnight Commander, just
completly fail. MC has this ugly ESC key (via ncurses) and all other
issues, it's plainly unusable and ugly. I personally prefer CLI over mc
for example and I bet a lot of people too.
So, the point is - turn on your imagination, you can create really nice
interface with this tiny set of available keys (khm.. tiny? it's pretty
big actually!).
Jump to Line
Something went wrong with that request. Please try again.