[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
combining ncurses and gnu readline
From: |
John Greco |
Subject: |
combining ncurses and gnu readline |
Date: |
Sun, 31 Oct 2010 13:42:29 -0700 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
The ncurses FAQ's section on readline (linked below) seems out of date,
or at least a little unclear. Using gnu readline's "alternate
interface" (also linked below), it's relatively trivial to combine
ncurses with gnu readline.
http://invisible-island.net/ncurses/ncurses.faq.html#readline_library
http://tiswww.case.edu/php/chet/readline/readline.html#SEC41
The basic idea is to use call rl_callback_read_char() when input from
the user is available (determined with select, or similar), then print
'rl_line_buffer' as you would any other string in ncurses, and
optionally set A_REVERSE on the position indicated by rl_point. (or
just reposition the cursor I guess, either works...)
This is a quick and dirty example that I threw together, and seems to
work fine: (just search rl_callback_read_char to find the relevant
section).
http://github.com/jgreco/agora/blob/develop/main.c
regards,
-John L. Greco
- combining ncurses and gnu readline,
John Greco <=