- Use same namespace like other tty movement functions
- Replace globally exposed itoa() and dangerous strcpy() with snprintf()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
The Ctrl-R search prompt and failed search text may be longer than
the regular CLI prompt. This patch clears the line to remove any
lingering artefacts.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
The screen should only be cleared on Ctrl-L *and* empty regular line,
not when searching with an empty string.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Like Ctrl-D, when on an empty line we clear the screen, when editing a
garbled line we refresh the line.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
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>