Commit Graph

60 Commits

Author SHA1 Message Date
Terry Greeniaus
f53bebdbe9 Fix function prototypes.
This allows it to compile on macOS 15.3.2 using the default command-line
tools (clang-1600.0.26.6).
2025-04-05 23:17:20 -06:00
Joachim Wiberg
651c0bf38b examples: update prompt in fileman to show cwd
This shows off the rl_set_prompt() API to provide a more dynamic prompt.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-12-08 21:36:12 +01:00
Stephen Gregoratto
d4b25ca85e include <sys/select.h> in excallback
Fixes an build issue when cross-compiling for SerenityOS[1]

[1] https://github.com/SerenityOS/serenity
2020-06-09 00:21:11 +10:00
Joachim Nilsson
1305d05b75 examples: Refactor CLI unlock gimmick to fix possible Coverity issue
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-01-05 08:21:36 +01:00
Joachim Nilsson
4a17180d37 Add SIGINT notification to cli example, for debugging
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-05-08 17:03:49 +02:00
Joachim Nilsson
ee176c80d7 Only display return from readline() when there's something to show.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-05-06 01:20:46 +02:00
Joachim Nilsson
61d40f406f examples: Catch SIGINT instead of mapping Ctrl-C, use default Ctrl-D
We want Ctrl-C to work as in Bash, so let's just catch SIGINT (and do
nothing).  Also, the default Ctrl-D handler does what we want, i.e.
exit the CLI when we're on an empty line.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-05-06 00:52:13 +02:00
Joachim Nilsson
8f5a5da754 examples/fileman.c: Further code cleanup and simplification
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-12-31 22:51:39 +01:00
Joachim Nilsson
a237e39181 examples/fileman.c: Refactor and cleanup
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-12-31 22:49:28 +01:00
Joachim Nilsson
3cb74b6d87 examples/fileman.c: Remove unnecessary code
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-12-31 22:41:15 +01:00
Joachim Nilsson
5c8429dcee examples/fileman.c: Deregister
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-12-31 22:39:20 +01:00
Joachim Nilsson
8566eb8384 examples/fileman.c: Reindent to project coding style
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-12-31 22:30:45 +01:00
Joachim Nilsson
0b7142eb8e examples: cli: Add password prompt (hidden input) example
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-11-17 11:50:26 +01:00
Joachim Nilsson
2137b9df9f Revert "Merge pull request #21 from cogutvalera/issue_1171"
This reverts commit cddd8d8de0, reversing
changes made to 4ec7d26a9d.
2018-11-15 10:27:22 +01:00
Joachim Nilsson
66d8ae84e2 Revert "Coding style and const fixes to last PR"
This reverts commit fbb1f8800a.
2018-11-15 10:26:03 +01:00
Joachim Nilsson
fbb1f8800a Coding style and const fixes to last PR
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-10-24 08:28:34 +02:00
Valera Cogut
3cd9894747 Added example for hiding secret information 2018-10-18 12:58:14 +03:00
Joachim Nilsson
d4bef671b6 Minor, update .gitignore files
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-09-16 10:10:03 +02:00
Joachim Nilsson
b2f1cfbbcc fileman: New example, from libedit, and from GNU Readline originally
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-06-17 21:13:02 +02: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
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
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
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
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
ed37cef412 Minor whitespace fixes/cleanup
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-29 15:01:22 +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
Joachim Nilsson
6db7c7d440 Minor cleanup and simplification of build system
- 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>
2016-06-01 07:26:16 +02:00
Joachim Nilsson
e02339c3ae Do not assume -ltermcap, check for tgetent() instead
This is a followup patch for issue #8.  When the user elects
to enable Termcap checks for window resizing we need to check
what library on the system provides this functionality.  Do
not assume -ltermcap, but instead check for tgetent() in all
possible libraries.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2016-06-01 07:26:09 +02:00
Joachim Nilsson
a1002f6984 Update .gitignore with generated files
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2016-01-27 09:32:19 +01:00
Joachim Nilsson
8439f426fc Fix examples FTBFS for --enable-termcap builds
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-10-27 19:50:01 +01:00
Joachim Nilsson
9fbad9dbff Fix build problems after removal of generated files.
Restore custom INSTALL file, accidentally removed in 295f901.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-09-10 12:44:19 +02:00
Joachim Nilsson
6a8556733a Add support for disabling default SIGINT and EOF behavior.
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>
2015-04-06 14:53:47 +02:00
Joachim Nilsson
33ffb150f2 Cleanup configure.ac and regenerate default configure files. 2013-07-08 16:47:03 +02:00
Joachim Nilsson
5e9177fd18 Add support for el_bind_key() and example usage binding '?' in examples/cli.c
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.
2010-08-05 12:48:51 +02:00
Joachim Nilsson
bdf5384c5b Build examples (tests) as static, for easy debugging. 2010-08-04 02:44:20 +02:00
Joachim Nilsson
d04bdaf38f Add support for read_history(char *filename) and write_history(char *filename) 2010-08-04 02:23:05 +02:00
Joachim Nilsson
dbad0d0871 Minor. 2010-07-25 21:43:41 +02:00
Joachim Nilsson
d4aa5ac293 Minor cleanup 2010-07-24 02:15:18 +02:00
Joachim Nilsson
98b846c8b1 Revert function pointers for rl_complete() and rl_list_possib() introduced in 0.2.2.
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.
2010-07-24 00:50:40 +02:00
Joachim Nilsson
6d2f4c99a3 Add configurable support for using termcap library for terminal size. 2010-07-18 18:57:07 +02:00
Joachim Nilsson
d76ca9f1d6 Update Makefile.in's after last configure.ac change 2010-07-18 12:55:44 +02:00
Joachim Nilsson
4c4a7e808c Make scrollback history (HIST_SIZE) configurable 2010-07-18 05:19:03 +02:00
Joachim Nilsson
2d2ec7db98 Improve GCC warning and error triggers and also improve check of GCC version.
Configure snippets shamelessly stolen from http://www.libusb.org/browser/configure.ac
2010-07-18 02:51:25 +02:00
Joachim Nilsson
3c4cf96bfc More cleanup. Added license blurb to top of all source files.
Remove all old $Id:$ and similar constructs, they don't provide any
additional benefit anymore.

Add configure options for toggling terminal bell and  toying with
SIGSTOP using Ctrl-Z.  Rename config option for ANSI keys to get
a consistent namespace.

Also did some work on ANSI-fication of function definitions, lot's
of that was still lingering around.
2010-07-18 01:41:18 +02:00
Joachim Nilsson
4c9c71faae Cleanup and fix problems found by Sparse. 2010-07-17 22:23:21 +02:00
Joachim Nilsson
cbf276d9ff Make sure local functions are marked static.
Sparse (cgcc) is very picky about such things, which is great.
2010-07-17 22:18:17 +02:00
Joachim Nilsson
722dae35a2 Change mode 0644 on all source files. 2010-07-17 22:08:32 +02:00
Joachim Nilsson
e16f245672 Migrate to libtool and regenerate configure script 2010-07-17 22:00:06 +02:00