Check out my first novel, midnight's simulacra!
Ncurses: Difference between revisions
From dankwiki
(→Colors) |
(add note about ESCDELAY and notimeout) |
||
Line 1: | Line 1: | ||
==Escape== | |||
You can get Escape with no delay by using <tt>notimeout(3ncurses)</tt>, but this eliminates use of the function and arrow keys on terminals where those sequences are composed with Escape. You probably don't want that. You can use the ESCDELAY environment variable (see <tt>ncurses(3ncurses)</tt>) to change this (ncurses also provides a global of the same name). [[Vim]] uses a 25ms default. The ncurses default appears to be 1s (1000ms), which makes one's application feel kinda seasick when running on any reasonable connection (not to mention locally). This seems difficult to manipulate programaticly, though. :/ | |||
==Colors== | ==Colors== | ||
* When modifying the palette via <tt>init_color()</tt>, this only affects the normal form of the color. Using <tt>A_BOLD</tt> with the color, for instance, will not reflect palette changes. | * When modifying the palette via <tt>init_color()</tt>, this only affects the normal form of the color. Using <tt>A_BOLD</tt> with the color, for instance, will not reflect palette changes. |
Revision as of 06:38, 19 July 2012
Escape
You can get Escape with no delay by using notimeout(3ncurses), but this eliminates use of the function and arrow keys on terminals where those sequences are composed with Escape. You probably don't want that. You can use the ESCDELAY environment variable (see ncurses(3ncurses)) to change this (ncurses also provides a global of the same name). Vim uses a 25ms default. The ncurses default appears to be 1s (1000ms), which makes one's application feel kinda seasick when running on any reasonable connection (not to mention locally). This seems difficult to manipulate programaticly, though. :/
Colors
- When modifying the palette via init_color(), this only affects the normal form of the color. Using A_BOLD with the color, for instance, will not reflect palette changes.
- Modifying the palette requires a terminal that supports it, like "linux" or "xterm-256color"
- The latter can be had from the ncurses-term package on Debian.
- ncurses will need have been compiled with --enable-ext-colors
Terminal emulator | Default terminfo | 256-color terminfo | Debian package |
---|---|---|---|
xterm | xterm | xterm-256color | ncurses-base |
Gnome-Terminal | gnome | gnome-256color | ncurses-term |
Konsole | konsole | konsole-256color | ncurses-term |
Unicode
- You need use ncursesw, which ought have been built with --enable-widec
- _XOPEN_SOURCE_EXTENDED must be #defined prior to including any ncurses headers (use -D_XOPEN_SOURCE_EXTENDED with gcc)
- setlocale() needs have been called prior to calling any ncurses functions
- ncurses assumes that the locale does not change once started