Commit Graph

396 Commits

Author SHA1 Message Date
Joachim Nilsson
bc510b320e Follow-up #15: Clean up TODO, event loop callback now supported
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-03-24 19:34:19 +01:00
Joachim Nilsson
3cf0e89a68 Merge branch 'dev' 2018-03-22 16:06:19 +01:00
Joachim Nilsson
5b43c028c9 Revert "Travis-CI: Disable CLANG temporarily for Coverity Scan"
This reverts commit 6a7483532c.
2018-03-22 16:06:04 +01:00
Joachim Nilsson
1657da4f2e README: Minor whitespace changes
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-03-22 13:16:07 +01:00
Joachim Nilsson
fdda4f5cae README: Add license badge and add Wikipedia link to C News
The C News sources are referenced in the Wikipedia article, which is
useful to follow-up the license origins.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-03-22 10:49:49 +01:00
Joachim Nilsson
f8c6b7f208 Update .gitignore
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-03-22 10:49:39 +01:00
Joachim Nilsson
9e9f8b03d8 Fix Coverity Scan findings, missing return and bad strcpy()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-03-22 10:31:50 +01:00
Joachim Nilsson
0bfaf351aa Add support for Ctrl+Right and Ctrl+Left, forward/back word
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-03-22 08:42:32 +01:00
Joachim Nilsson
2ce0be942e Minor, reorder functions
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-03-22 08:38:04 +01:00
Joachim Nilsson
6a7483532c Travis-CI: Disable CLANG temporarily for Coverity Scan
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-03-22 08:17:03 +01:00
Joachim Nilsson
ad3b1c8a07 ChangeLog: Fix missing Markdown link to v1.15.3
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-03-09 20:29:52 +01:00
Joachim Nilsson
5be965deec Simplify and clarify example
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-27 14:01:54 +01:00
Joachim Nilsson
791508a3a1 Minor fix, whitespace
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-27 13:27:59 +01:00
Joachim Nilsson
6de69a406b Update example with build instructions, put it before API listing
This update should help with issues like that described in #16, "how do
I use this library?"

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-27 13:15:52 +01:00
Joachim Nilsson
197f3e1c32 Minor fixes, grammar + whitespace
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-27 13:15:02 +01:00
Joachim Nilsson
6adf0e98bb README: Add alternate interface docu
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-11 08:55:12 +01:00
Joachim Nilsson
bc7fc7e5c0 Fix #15: Alternate interface to plain readline(), for event loops
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>
2017-12-11 08:43:43 +01:00
Joachim Nilsson
935895bbf1 testit: Don't add history, readline() already does this
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-11 08:43:03 +01:00
Joachim Nilsson
2ec55cc9f1 Minor, simplify
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-11 08:42:33 +01:00
Joachim Nilsson
7f7bb5b45c Minor, use NULL not 0, and -1 not NULL
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-11 01:45:25 +01:00
Joachim Nilsson
9b7b3121c5 configure: Check for unistd.h
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-02 21:15:17 +01:00
Joachim Nilsson
53b160f6a1 examples: Define EDITLINE_LIBRARY when building locally
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-02 21:14:49 +01:00
Joachim Nilsson
779db8817e rl_refresh_line(): new (undocumented) readline compat fn
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-02 21:14:14 +01:00
Joachim Nilsson
29a71a53d0 rl_insert_text(): new readline compat fn
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-02 21:13:39 +01:00
Joachim Nilsson
a9824655ee excallback.c: Fix compilation errors against readline
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-02 18:54:29 +01:00
Joachim Nilsson
69d9e549a0 examples/excallback.c: Jeff Solomon's alternate interface example
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>
2017-12-02 18:46:48 +01:00
Joachim Nilsson
94b1a78444 src/Makefile: Add -Wextra to CFLAGS
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-02 18:25:49 +01:00
Joachim Nilsson
a9d4247c09 Minor, header cleanup, whitespace fixes, comments
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-30 18:20:29 +01:00
Joachim Nilsson
a1f0a81a31 Add documentation for rl_deprep_term*() function and callback
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-30 07:45:38 +01:00
Joachim Nilsson
ea79fe70f9 write_history(), read_history(): Check fclose() return value
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-29 21:40:38 +01:00
Joachim Nilsson
621f126128 Reflow paragraphs, add link to original comp.sources.unix posting
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-29 17:58:42 +01:00
Joachim Nilsson
6137feacdf Add new rl_uninitialize() function to README
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-29 17:58:09 +01:00
Joachim Nilsson
2075dedc80 Remove leading (superfluous) comment
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-29 17:22:08 +01:00
Joachim Nilsson
54714631e2 Move All rights reserved to next line
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>
2017-11-29 17:20:21 +01:00
Joachim Nilsson
a70a933698 Modify header guards, __FILE_H__ is reserved for system headers
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-29 17:17:50 +01:00
Joachim Nilsson
b613db2afb Whitespace + coding style cleanup
- 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>
2017-11-29 16:40:10 +01:00
Joachim Nilsson
6021e54dbc Bump version for v1.16.0 relese cycle
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-29 15:34:30 +01:00
Joachim Nilsson
1ace811722 rl_uninitialize(): also free old_search from previous i-search
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-29 15:32:59 +01:00
Claus Fischer
4b8333ad39 Remove duplicate unique history check
Signed-off-by: Claus Fischer <claus.fischer@clausfischer.com>
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-29 15:03:01 +01:00
Joachim Nilsson
ed37cef412 Minor whitespace fixes/cleanup
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-29 15:01:22 +01:00
Joachim Nilsson
2a3b422137 Fix negative array index triggered by i-search
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>
2017-11-29 14:53:14 +01:00
Claus Fischer
91937d970d testit: Test new rl_uninitialize() and load/store history
Signed-off-by: Claus Fischer <claus.fischer@clausfischer.com>
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-29 14:51:29 +01:00
Claus Fischer
317b43e488 rl_unintialize(): New function, free all memory after use
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>
2017-11-29 14:44:24 +01:00
Claus Fischer
ed87f37409 Initialize global variables and reset to NULL on free()
Signed-off-by: Claus Fischer <claus.fischer@clausfischer.com>
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-29 14:41:50 +01:00
Joachim Nilsson
b30c3479f5 Minor, spellcheck
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-09-07 01:32:17 +02:00
Joachim Nilsson
119db55bf2 Bump version for v1.15.3 bug fix release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-09-07 01:26:31 +02:00
Joachim Nilsson
2542f21ff1 Add support for building .deb packages
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-09-07 01:25:47 +02:00
Joachim Nilsson
36663d6acf Run distcheck in release target, verifies distribution files
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-09-07 01:25:25 +02:00
Joachim Nilsson
866f25ce10 Update ChangeLog(s) for v1.15.3 bug fix release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-09-07 01:25:01 +02:00
Joachim Nilsson
01f684ea19 debian/changelog: Add missing releases
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-09-07 01:24:38 +02:00