This rather big patch adds support for the GNU Readline alternate
interface, for use with event loops:
void rl_callback_handler_install (const char *prompt, rl_vcpfunc_t *lhandler);
void rl_callback_read_char (void);
void rl_callback_handler_remove (void);
The code has been tested using the testit and excallback examples.
Both regular editing and searching works as intended.
Also, the problem with lingering artefacts on screen when scrolling
through the history has been fixed.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch adds the unmodified excallback.c from readline. It was
originally contributed by Jeff Solomon as an example of the alternate
interface to readline.
The following set of patches modify it to work with editline.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
All BSD style licenses put this text on a separate line, immediately
following the Copyright line. The C-News license is confusing enough
to most people, so let's align at least a bit with the norm.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
- Use Emacs K&R style
- Add missing braces to for() loops
- Fix coding style issues in cli.c example
- Add empty lines to separate sections
- Simplify and de-indent code, check error case first + continue
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This is a fix to a bug reported by Claus Fischer. When doing a reversed
i-search on the history, clear_line() sets rl_point to a negative value,
which is later used by ceol(). The intention is to clear the whole line
for the new Search: prompt, but indexing an array with a negative value
is strongly discouraged.
To prevent this negative indexing from happening we check in ceol() for
rl_point < 0, but we quickly notice another side effect: one lingering
character at the end of line when returning from i-search. The problem
manifests itself more cleary when having a looooo000ooonong prompt.
The fix is to rub out the extra space, insert the i-search string, and
*then* call ceol() again.
Thanks to Claus for pointing this out!
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Free all allocated internal memory and reset variables so
rl_initialize() or readline() may be called again later.
Signed-off-by: Claus Fischer <claus.fischer@clausfischer.com>
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Improper handling of AC_ARG_ENABLE() causes the configure script to
always enable CONFIG_USE_TERMCAP.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
- Move 'foreign' declaration from Makefile.am's to configure script
- Move CFLAGS from configure script to src/Makefile.am
- Remove faltering license blurb at top of configure script, no need
for this since we a) do not care, b) falls under project license
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This is a followup patch for issue #8. When the user elects
to enable Termcap checks for window resizing we need to check
what library on the system provides this functionality. Do
not assume -ltermcap, but instead check for tgetent() in all
possible libraries.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>