bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: combining ncurses and gnu readline


From: Thomas Dickey
Subject: Re: combining ncurses and gnu readline
Date: Sun, 31 Oct 2010 18:17:12 -0400 (EDT)

On Sun, 31 Oct 2010, John Greco wrote:

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

thanks - I'll take a look. Generally the approach people have taken is to try to get readline to do the display itself (doesn't work well...).

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net



reply via email to

[Prev in Thread] Current Thread [Next in Thread]