Did you know ... | Search Documentation: |
SWI-Prolog binding to BSD libedit |
This library wraps the BSD libedit command line editor. The binding provides a high level API to enable command line editing on the Prolog user streams and low level predicates to apply the library on other streams and program the library.
user_input
is connected to a terminal. This is the high level predicate used for
most purposes. The remainder of the library interface deals with low
level predicates that allows for applying and programming libedit in
non-standard situations.
The library is registered with ProgName set to swipl
(see
el_wrap/4).
ProgName | is the name of the invoking
program, used when reading the editrc(5) file to determine
which settings to use. |
forall(el_setup(Input), true)
after
the input stream has been wrapped, the default Prolog commands have been
added and the default user setup file has been sourced using
el_source/2. It can be used to
define and bind additional commands.FILE*
handles that cannot be closed and
thus wrapping and unwrapping implies a (modest) memory leak.$HOME/.editrc
bind
command with the given arguments.
The example below lists the current key bindings.
?- el_bind(user_input, ['-a']).
The predicate el_bind/2 is
typically used to bind commands defined using el_addfn/4.
Note that the C proxy function has only the last character of the
command as context to find the Prolog binding. This implies we cannot
both bind e.g., "^
[?" *and "?" to a Prolog function.
editrc(5)
for more information.bind -a
(see el_bind/2)
and Goal is called of the associated key-binding is
activated. Goal is called as
call(:Goal, +Input, +Char, -Continue)
where Input is the input stream providing access to the
editor, Char the activating character and Continue must be instantated
with one of the known continuation codes as defined by libedit: norm
,
newline
, eof
, arghack
, refresh
, refresh_beep
, cursor
,
redisplay
, error
or fatal
. In
addition, the following Continue code is provided.
The registered Goal typically used el_line/2 to fetch the input line and el_cursor/2, el_insertstr/2 and/or el_deletestr/2 to manipulate the input line.
Normally el_bind/2 is used to associate the defined command with a keyboard sequence.
el_set(3)
EL_ADDFN
for details.line(Before, After)
,
where Before is a string holding the text before the cursor
and After is a string holding the text after the cursor.history()
from libedit. Supported actions are:
Num-String
,
where
Num is the event number and String is the
associated string without terminating newline.File | is a file specification for absolute_file_name/3. |
File | is a file specification for absolute_file_name/3. |