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>
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.
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.