Commit Graph

20 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
77d483da02 Build fixes when building with GCC v4.3.2 and -W -Wall -Werror 2008-12-02 19:09:17 +01:00
Joachim Nilsson
62e900a061 Change rl_complete() and rl_list_possib() to be function pointers instead.
This is a much cleaner design and also works with or without the configure
--enable-default-complete option.

See the examples for details.
2008-10-02 09:09:09 +02:00
Joachim Nilsson
5c9f0047bb Basic support for custom completion handlers with the two "standard"
rl_complete() and rl_list_possib().  Simply leave out complete.o from
the default build and in all programs require these two functions to
be supplied.

A better alternative would be to use function pointers and check those
for NULL in the running code.  With this code, and no completion handler
the editline code will die.
2008-10-02 01:52:40 +02:00