The filename completion handler fallback will now be enabled by default.
To disable it a new GNU Readline function pointer will be added.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
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>
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>
- 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>
Forcing update should flush, otherwise weird stuff happen when writing
to console asynchronously (cursor is moved, text is not displayed).
Signed-off-by: Jakub Pawlowski <jakubpawlo@gmail.com>
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
At least when building with Clang on OS X, there is an error on
[line 1120 of editline.c][err] caused by using the `ioctl()` function
without first declaring it by including its header `<sys/ioctl.h>`.
Adding this line makes the build complete without error.
[err]: https://github.com/troglobit/editline/blob/master/src/editline.c#L1120
Signed-off-by: C0deH4cker <c0deh4cker@gmail.com>
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch adds support for `--disable-eof` and `--disable-sigint` to
the Editline configure script. With either of these two switches the
`tty_special()` function bypasses the special TTY checks making it
possible to bind Ctrl-C and Ctrl-D to custom callbacks. This can be
useful if you want to emulate a Cisco style CLI rather than traditional
UNIX.
The user can of course also redefine the VINTR and VEOF special terminal
control characters, but these configure script switches may be easier to
use for some.
Also, the CLI example has been updated to bind Ctrl-D, Ctrl-C and Ctrl-Z
for testing purposes.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit reverts parts of 111fc5e, which originally was intended to
add support for custom key bindings at pos 0, or more specifically, to
be able to change the behavior of Ctrl-D. However this completely broke
compatibility with the original EOF behavior.
Signed-off-by: Toby Goodwin <toby@paccrat.org>
Signed-off-by: Joachim Nilsson <joachim.nilsson@westermo.se>
The word 'new' is a reserved keyword in C++ and C#, replacing it
with something else is one step further to making it possible to
build editline with a C++ compiler.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit adds a new global variable 'el_no_hist' which can be used
to disable auto-save of history as well as access to history using prev
and next keybindings (up/down arrows).
Signed-off-by: Mattias Walström <lazzer@gmail.com>
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Handle tcgetattr(), tcsetattr() and ioctl() by wrapping them in
a retry-loop and restarting them when receiving EINTR.
Should fix problem with sporadic error messages on the console
like this one:
'Failed tcsetattr: Interrupted system call'
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
The two functions el_bind_key() and el_bind_key_in_metamap() should
not print status message on stderr, but rather return the status of
the key binding operation.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
When adding support for rl_reset_termial() the tty_info() code was also
refactored. This however led to the introduction of a bug that caused
tty_cols to be set to zero. This in turn caused c_possible() to fail
with SIGFPE in el_print_columns().
Regression was introduced in 1c89c9886c
This changeset refactors el_bind_key_in_metamap() into two functions,
adding el_bind_key(), to provide the ability for the user to bind keys
in both the regular and the meta-key maps.
Several useful, but previously internal, functions have been made global to
facilitate the example code mentioned above. These are likely useful to the
user of this library as well:
el_print_columns() - Display words in columns across a tty_cols wide screen.
el_ring_bell() - Can be used as default key binding function.
el_find_word() - Returns a copy of the word at rl_point.
This changeset adds support for:
* rl_prep_terminal(),
* rl_deprep_terminal(), both of which are only wrappers to rl_ttyset().
* rl_getc()
and:
* (*rl_getc_function), defaults to rl_getc()
* (*rl_event_hook)
* (*rl_prep_term_function), defaults to rl_prep_terminal()
* (*rl_deprep_term_function), defaults to rl_deprep_terminal()
For further details, see http://www.cs.unc.edu/~tell/dist/magic-readline.README
Differences from Steve's commit include: signal safety in rl_getc(), restart
read() on EINTR, and make sure to support "int meta_flag" to rl_prep_terminal()
which is the GNU syntax. To that end I reused the inverse of rl_meta_chars.
After the revert of function pointers for rl_complete() and rl_list_possib(),
introduced in v0.2.2, we need to build complete.c for all configurations. The
user should use the rl_set_*_func() calls merged from the Heimdal project's
readline fork.
1. Simplify code in reposition()
2. Add tty_push() for commonly used operation, reduce code duplication.
3. Fix left() so that it treats 8-bit chars as one when not in meta-mode.
4. Replace isalnum() with homegrown implementation that understands 8-bit
and control chars.
5. Fix ceol() before introducing ANSI "kill-to-end-of-line" escape code.
This actually seems to work, previously I erronesouly used an UTF-8
terminal for testing. Which of course broke the test on an ISO-8859-1
[only] terminal.
This changeset fixes an old Debian patch that attempted to fix the display
of 8-bit characters in the function emacs(). It accidentally crippled the
function of M-d and M-DEL. The latter was however also broken by being
mapped to wipe(), more on that below.
The real fix is to set rl_meta_chars to 0 by default and in the tty_show()
function, which tried to be smart and output control and meta characters
(in the wrong order as well). Simply disabling the special code for output
of control characters fixes 8-bit input.
We also nuke the old and broken wipe() function that was mapped to M-DEL,
instead we map that key binding to bk_kill_word(), which works.
Instead merge afd8b4de9dca8ec6afc3 from http://github.com/heimdal/heimdal.git project.
This lets rl_complete() and rl_list_possib() become wrapper functions calling a set of
function pointers, set using rl_set_complete_func() and rl_set_list_possib_funct().
Each wrapper has a fallback to do filename completion, which in turn can be disabled
by leaving out --enable-default-complete from the configure line.
This change, admittedly quite intrusive for a library, is a better implementation in
many ways. For one it is much more readable, but it also enables further adoption of
other editline forks as well as a simpler implementation of GNU Readline function
pointers rl_completion_entry_function and rl_attempted_completion_function at a later
stage.
My apologies to everyone for whom this change breaks backwards compatibility. For
help on converting your code, please see examples/cli.c.
The ordering of alternative rl_ttyset() implementations is important.
We have chosen to place the most common, most portable, code first
and then in lesser order. Ending with the sgtty.h based code, which
I cannot test on GNU/Linux. Will test on OpenBSD later.
Also added Emacs indentation style to make it easier to follow the
original style of Mr Turner and Salz.