Fixes crash when dividing by the number of columns,
which was computed as zero in this situation.
Instead, always have at least one "column" even if it wraps.
When the point is on whitespace between two words skipping forward, or
killing forward, should result in the new point being moved to the next
word:
foo bar fox gnu
^
=>
foo bar fox gnu
^
Before this patch the point moved to 'b'. After this patch the point
moves to the first letter of the next word, 'f'. Kill forward word now
properly kills 'bar' and moves to the first whitespace letter after
'bar'. Both are now behaving like FSF Readline.
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>
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>