icon Top 9 categories map      RocketAware > man pages >


Tips: Browse or Search all pages for efficient awareness of more than 6000 of the most popular reusable and open source applications, functions, libraries, and FAQs.

The "RKT couplings" below include links to source code, updates, additional information, advice, FAQs, and overviews.


Search all pages


By activity
Professions, Sciences, Humanities, Business, ...

User Interface
Text-based, GUI, Audio, Video, Keyboards, Mouse, Images,...

Text Strings
Conversions, tests, processing, manipulation,...

Integer, Floating point, Matrix, Statistics, Boolean, ...

Algorithms, Memory, Process control, Debugging, ...

Stored Data
Data storage, Integrity, Encryption, Compression, ...

Networks, protocols, Interprocess, Remote, Client Server, ...

Hard World
Timing, Calendar and Clock, Audio, Video, Printer, Controls...

File System
Management, Filtering, File & Directory access, Viewers, ...


RocketLink!--> Man page versions: OpenBSD FreeBSD Others

EDITLINE(3)               OpenBSD Programmer's Manual              EDITLINE(3)

     editline, el_init, el_end, el_reset, el_gets, el_getc, el_push, el_parse,
     el_set, el_source, el_resize, el_line, el_insertstr, el_deletestr,
     history_init, history_end, history - line editor and history functions

     #include <histedit.h>

     EditLine *
     el_init(const char *prog, FILE *fin, FILE *fout);

     el_end(EditLine *e);

     el_reset(EditLine *e);

     const char *
     el_gets(EditLine *e, int *count);

     el_getc(EditLine *e, char *ch);

     el_push(EditLine *e, const char *str);

     el_parse(EditLine *e, int argc, char *argv[]);

     el_set(EditLine *e, int op, ...);

     el_source(EditLine *e, const char *file);

     el_resize(EditLine *e);

     const LineInfo *
     el_line(EditLine *e);

     el_insertstr(EditLine *e, char *str);

     el_deletestr(EditLine *e, int count);

     History *

     history_end(History *h);

     HistEvent *
     history(History *h, int op, ...);

     The editline library provides generic line editing and history functions,
     similar to those found in sh(1).

     These functions are available in the libedit library (which needs the
     libtermcap library).  Programs should be linked with -ledit -ltermcap.

     The line editing functions use a common data structure, editline, which
     is created by el_init() and freed by el_end().

     The following functions are available:

           Initialise the line editor, and return a data structure to be used
           by all other line editing functions.  prog is the name of the in-
           voking program, used when reading the editrc(5) file to determine
           which settings to use.  fin and fout are the input and output
           streams (respectively) to use.  In this documentation, references
           to ``the tty'' are actually to this input/output stream combina-

           Clean up and finish with e, assumed to have been created with

           Reset the tty and the parser.  This should be called after an error
           which may have upset the tty's state.

           Read a line from the tty.  count is modified to contain the number
           of characters read.  Returns the line read if successful, or NULL
           if no characters were read or if an error occurred.

           Read a character from the tty.  ch is modified to contain the char-
           acter read.  Returns the number of characters read if successful,
           -1 otherwise.

           Pushes str back onto the input stream.  This is used by the macro
           expansion mechanism.  Refer to the description of bind -s in ed-
           itrc(5) for more information.

           Parses the argv array (which is argc elements in size) to execute
           built-in editline commands.  If the command is prefixed with
           ``prog:'' then el_parse() will only execute the command if ``prog''
           matches the prog argument supplied to el_init().  The return value
           is -1 if the command is unknown, 0 if there was no error or
           ``prog'' didn't match, or 1 if the command returned an error.  Re-
           fer to editrc(5) for more information.

           NOTE: argv[0] may be modified by el_parse().  The colon between
           ``prog'' and the command, command, will be replaced with a NUL

           Set editline parameters.  op determines which parameter to set, and
           each operation has its own parameter list.

           The following values for op are supported, along with the required
           argument list:

           EL_PROMPT, char *(*f)(EditLine *)
                 Define prompt printing function as f, which is to return a
                 string that contains the prompt.

           EL_TERMINAL, const char *type
                 Define terminal type of the tty to be type, or to TERM if

                 type is NULL.

           EL_EDITOR, const char *mode
                 Set editing mode to mode, which must be one of ``emacs'' or

           EL_SIGNAL, int flag
                 If flag is non-zero, editline will install its own signal
                 handler for the following signals when reading command input:
                 and SIGWINCH. Otherwise, the current signal handlers will be

           EL_BIND, const char *, ..., NULL
                 Perform the bind built-in command.  Refer to editrc(5) for
                 more information.

           EL_ECHOTC, const char *, ..., NULL
                 Perform the echotc built-in command.  Refer to editrc(5) for
                 more information.

           EL_SETTC, const char *, ..., NULL
                 Perform the settc built-in command.  Refer to editrc(5) for
                 more information.

           EL_SETTY, const char *, ..., NULL
                 Perform the setty built-in command.  Refer to editrc(5) for
                 more information.

           EL_TELLTC, const char *, ..., NULL
                 Perform the telltc built-in command.  Refer to editrc(5) for
                 more information.

           EL_ADDFN, const char *name, const char *help, unsigned char
                 (*func)(EditLine *e, int ch)
                 Add a user defined function, func(), referred to as name
                 which is invoked when a key which is bound to name is en-
                 tered.  help is a description of name. At invocation time, ch
                 is the key which caused the invocation.  The return value of
                 func() should be one of:

                 CC_NORM       Add a normal character.

                 CC_NEWLINE    End of line was entered.

                 CC_EOF        EOF was entered.

                 CC_ARGHACK    Expecting further command input as arguments,
                               do nothing visually.

                 CC_REFRESH    Refresh display.

                 CC_CURSOR     Cursor moved, so update and perform CC_REFRESH.

                 CC_REDISPLAY  Redisplay entire input line.  This is useful if
                               a key binding outputs extra information.

                 CC_ERROR      An error occurred.  Beep, and flush tty.

                 CC_FATAL      Fatal error, reset tty to known state.

           EL_HIST, History *(*func)(History *, int op, ...), const char *ptr
                 Defines which history function to use, which is usually
                 history().  ptr should be the value returned by

           Initialise editline by reading the contents of file. el_parse() is
           called for each line in file. If file is NULL, try $PWD/.editrc
           then $HOME/.editrc. Refer to editrc(5) for details on the format of

           Must be called if the terminal size changes.  If EL_SIGNAL has been
           set with el_set(), then this is done automatically.  Otherwise,
           it's the responsibility of the application to call el_resize() on
           the appropriate occasions.

           Return the editing information for the current line in a lineinfo
           structure, which is defined as follows:

           typedef struct lineinfo {
               const char *buffer;    /* address of buffer */
               const char *cursor;    /* address of cursor */
               const char *lastchar;  /* address of last character */
           } LineInfo;

           Insert str into the line at the cursor.  Returns -1 if str is empty
           or won't fit, and 0 otherwise.

           Delete num characters before the cursor.

     The history functions use a common data structure, history, which is cre-
     ated by history_init() and freed by history_end().

     The following functions are available:

           Initialise the history list, and return a data structure to be used
           by all other history list functions.

           Clean up and finish with h, assumed to have been created with

           Perform operation op on the history list, with optional arguments
           as needed by the operation.  The following values for op are sup-
           ported, along with the required argument list:

           H_EVENT, int size
                 Set size of history to size elements.

                 Cleans up and finishes with h, assumed to be created with

                 Clear the history.

           H_FUNC, void *ptr, history_gfun_t first, history_gfun_t next, his-
                 tory_gfun_t last, history_gfun_t prev, history_gfun_t curr,
                 history_vfun_t clear, history_efun_t enter, history_efun_t
                 Define functions to perform various history operations.  ptr

                 is the argument given to a function when it's invoked.

                 Return the first element in the history.

                 Return the last element in the history.

                 Return the previous element in the history.

                 Return the next element in the history.

                 Return the current element in the history.

           H_ADD, const char *str
                 Append str to the current element of the history, or create
                 an element with H_ENTER if there isn't one.

           H_ENTER, const char *str
                 Add str as a new element to the history, and, if necessary,
                 removing the oldest entry to keep the list to the created

           H_PREV_STR, const char *str
                 Return the closest previous event that starts with str.

           H_NEXT_STR, const char *str
                 Return the closest next event that starts with str.

           H_PREV_EVENT, int e
                 Return the previous event numbered e.

           H_NEXT_EVENT, int e
                 Return the next event numbered e.

           H_LOAD, const char *file
                 Load the history list stored in file.

           H_SAVE, const char *file
                 Save the history list to file.

     sh(1),  signal(3),  termcap(3),  editrc(5)

     The editline library first appeared in 4.4BSD.

     The editline library was written by Christos Zoulas, and this manual was
     written by Luke Mewburn.

     This documentation is probably incomplete.

     el_parse() should not modify the supplied argv[0].

     The tokenization functions are not publically defined in <histedit.h>

OpenBSD 2.6                    January 11, 1997                              5

Source: OpenBSD 2.6 man pages. Copyright: Portions are copyrighted by BERKELEY
SOFTWARE DESIGN, INC., The Regents of the University of California, Massachusetts
Institute of Technology, Free Software Foundation, FreeBSD Inc., and others.

(Corrections, notes, and links courtesy of RocketAware.com)

[Detailed Topics]
FreeBSD Sources for editline(3) functions
OpenBSD sources for editline(3)

[Overview Topics]

Up to: Terminal I/O - low-level character based display (TTY) and keyboard routines.

RocketLink!--> Man page versions: OpenBSD FreeBSD Others

Rapid-Links: Search | About | Comments | Submit Path: RocketAware > man pages > editline.3/
RocketAware.com is a service of Mib Software
Copyright 1999, Forrest J. Cavalier III. All Rights Reserved.
We welcome submissions and comments