Manual Pages for UNIX Darwin command on man el_push
MyWebUniversity

Manual Pages for UNIX Darwin command on man el_push

EDITLINE(3) BSD Library Functions Manual EDITLINE(3)

NAME

eeddiittlliinnee, eelliinniitt, eelleenndd, eellrreesseett, eellggeettss, eellggeettcc, eellppuusshh, eellppaarrssee, eellsseett, eellssoouurrccee, eellrreessiizzee, eelllliinnee, eelliinnsseerrttssttrr, eellddeelleetteessttrr,

hhiissttoorryyiinniitt, hhiissttoorryyeenndd, hhiissttoorryy - line editor and history functions

LLIIBBRRAARRYY

Command Line Editor Library (libedit, -ledit)

SYNOPSIS

##iinncclluuddee <>

EditLine * eelliinniitt(const char *prog, FILE *fin, FILE *fout, FILE *ferr); void eelleenndd(EditLine *e); void eellrreesseett(EditLine *e); const char * eellggeettss(EditLine *e, int *count); int eellggeettcc(EditLine *e, char *ch); void eellppuusshh(EditLine *e, const char *str); int eellppaarrssee(EditLine *e, int argc, const char *argv[]); int eellsseett(EditLine *e, int op, ...); int eellggeett(EditLine *e, int op, void *result); int eellssoouurrccee(EditLine *e, const char *file); void eellrreessiizzee(EditLine *e); const LineInfo * eelllliinnee(EditLine *e); int eelliinnsseerrttssttrr(EditLine *e, const char *str); void eellddeelleetteessttrr(EditLine *e, int count); History * hhiissttoorryyiinniitt(); void hhiissttoorryyeenndd(History *h); int hhiissttoorryy(History *h, HistEvent *ev, int op, ...);

DESCRIPTION

The eeddiittlliinnee library provides generic line editing and history functions, similar to those found in sh(1). These functions are available in the lliibbeeddiitt library (which needs the

lliibbtteerrmmccaapp library). Programs should be linked with -lleeddiitt -lltteerrmmccaapp.

LLIINNEE EEDDIITTIINNGG FFUUNNCCTTIIOONNSS The line editing functions use a common data structure, EditLine, which is created by eelliinniitt() and freed by eelleenndd(). The following functions are available: eelliinniitt() Initialise the line editor, and return a data structure to be used by all other line editing functions. prog is the name of the invoking program, used when reading the editrc(5) file to determine which settings to use. fin, fout and ferr are the input, output, and error streams (respectively) to use. In this documentation, references to ``the tty'' are actually to this input/output stream combination. eelleenndd() Clean up and finish with e, assumed to have been created with eelliinniitt(). eellrreesseett() Reset the tty and the parser. This should be called after an error which may have upset the tty's state. eellggeettss() 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. eellggeettcc()

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.

eellppuusshh() Pushes str back onto the input stream. This is used by the macro

expansion mechanism. Refer to the description of bbiinndd -ss in

editrc(5) for more information. eellppaarrssee() Parses the argv array (which is argc elements in size) to execute builtin eeddiittlliinnee commands. If the command is prefixed with ``prog'': then eellppaarrssee() will only execute the command if ``prog'' matches the prog argument supplied to eelliinniitt(). 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. Refer to editrc(5) for more information. eellsseett() Set eeddiittlliinnee 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: ELPROMPT, char *(*f)(EditLine *) Define prompt printing function as f, which is to return a string that contains the prompt. ELRPROMPT, char *(*f)(EditLine *) Define right side prompt printing function as f, which is to return a string that contains the prompt. ELTERMINAL, const char *type Define terminal type of the tty to be type, or to TERM if type is NULL. ELEDITOR, const char *mode Set editing mode to mode, which must be one of ``emacs'' or ``vi''. ELSIGNAL, int flag

If flag is non-zero, eeddiittlliinnee will install its own signal

handler for the following signals when reading command input: SIGCONT, SIGHUP, SIGINT, SIGQUIT, SIGSTOP, SIGTERM, SIGTSTP, and SIGWINCH. Otherwise, the current signal handlers will be used. ELBIND, const char *, ..., NULL Perform the bbiinndd builtin command. Refer to editrc(5) for more information. ELECHOTC, const char *, ..., NULL Perform the eecchhoottcc builtin command. Refer to editrc(5) for more information. ELSETTC, const char *, ..., NULL Perform the sseettttcc builtin command. Refer to editrc(5) for more information. ELSETTY, const char *, ..., NULL Perform the sseettttyy builtin command. Refer to editrc(5) for more information. ELTELLTC, const char *, ..., NULL Perform the tteellllttcc builtin command. Refer to editrc(5) for more information. ELADDFN, const char *name, const char *help, unsigned char (*func)(EditLine *e, int ch) Add a user defined function, ffuunncc(), referred to as name which is invoked when a key which is bound to name is entered. help is a description of name. At invocation time, ch is the key which caused the invocation. The return value of ffuunncc() should be one of: CCNORM Add a normal character. CCNEWLINE End of line was entered. CCEOF EOF was entered. CCARGHACK Expecting further command input as arguments, do nothing visually. CCREFRESH Refresh display. CCREFRESHBEEP Refresh display, and beep. CCCURSOR Cursor moved, so update and perform CCREFRESH. CCREDISPLAY Redisplay entire input line. This is useful if a key binding outputs extra information.

CCERROR An error occurred. Beep, and flush tty.

CCFATAL Fatal error, reset tty to known state. ELHIST, History *(*func)(History *, int op, ...), const char *ptr Defines which history function to use, which is usually hhiissttoorryy(). ptr should be the value returned by hhiissttoorryyiinniitt(). ELEDITMODE, int flag

If flag is non-zero, editing is enabled (the default). Note

that this is only an indication, and does not affect the operation of eeddiittlliinnee. At this time, it is the caller's responsibility to check this (using eellggeett()) to determine if editing should be enabled or not. ELGETCFN, int (*f)(EditLine *, char *c) Define the character reading function as f, which is to return the number of characters read and store them in c. This function is called internally by eellggeettss() and eellggeettcc(). The builtin function can be set or restored with the special function name ``ELBUILTINGETCFN''. ELCLIENTDATA, void *data Register data to be associated with this EditLine structure. It can be retrieved with the corresponding eellggeett() call. eellggeett() Get eeddiittlliinnee parameters. op determines which parameter to retrieve

into result. Returns 0 if successful, -1 otherwise.

The following values for op are supported, along with actual type of result: ELPROMPT, char *(*f)(EditLine *) Return a pointer to the function that displays the prompt. ELRPROMPT, char *(*f)(EditLine *) Return a pointer to the function that displays the rightside prompt. ELEDITOR, const char * Return the name of the editor, which will be one of ``emacs'' or ``vi''. ELSIGNAL, int *

Return non-zero if eeddiittlliinnee has installed private signal han-

dlers (see eellggeett() above). ELEDITMODE, int *

Return non-zero if editing is enabled.

ELGETCFN, int (**f)(EditLine *, char *) Return a pointer to the function that read characters, which is equal to ``ELBUILTINGETCFN'' in the case of the default builtin function. ELCLIENTDATA, void **data Retrieve data previously registered with the corresponding eellsseett() call. ELUNBUFFERED, int Sets or clears unbuffered mode. In this mode, eellggeettss() will return immediately after processing a single character. ELPREPTERM, int Sets or clears terminal editing mode. eellssoouurrccee() Initialise eeddiittlliinnee by reading the contents of file. eellppaarrssee() 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 file. eellrreessiizzee() Must be called if the terminal size changes. If ELSIGNAL has been set with eellsseett(), then this is done automatically. Otherwise, it's the responsibility of the application to call eellrreessiizzee() on the appropriate occasions. eelllliinnee() 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; eelliinnsseerrttssttrr()

Insert str into the line at the cursor. Returns -1 if str is empty

or won't fit, and 0 otherwise. eellddeelleetteessttrr() Delete num characters before the cursor. HISTORY LIST FUNCTIONS

The history functions use a common data structure, History, which is cre-

ated by hhiissttoorryyiinniitt() and freed by hhiissttoorryyeenndd(). The following functions are available: hhiissttoorryyiinniitt() Initialise the history list, and return a data structure to be used by all other history list functions. hhiissttoorryyeenndd() Clean up and finish with h, assumed to have been created with hhiissttoorryyiinniitt(). hhiissttoorryy() Perform operation op on the history list, with optional arguments

as needed by the operation. ev is changed accordingly to opera-

tion. The following values for op are supported, along with the required argument list: HSETSIZE, int size Set size of history to size elements. HGETSIZE Get number of events currently in history. HEND Cleans up and finishes with h, assumed to be created with hhiissttoorryyiinniitt(). HCLEAR Clear the history. HFUNC, void *ptr, historygfunt first, historygfunt next, historygfunt last, historygfunt prev, historygfunt curr, historysfunt set, historyvfunt clear, historyefunt enter, historyefunt add Define functions to perform various history operations. ptr is the argument given to a function when it's invoked. HFIRST Return the first element in the history. HLAST Return the last element in the history. HPREV Return the previous element in the history. HNEXT Return the next element in the history. HCURR Return the current element in the history. HSET Set the cursor to point to the requested element. HADD, const char *str Append str to the current element of the history, or perform the HENTER operation wth argument str if there is no current element. HAPPEND, const char *str Append str to the last new element of the history. HENTER, 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

size. If HSETUNIQUE was has been called with a non-zero

arguments, the element will not be entered into the history

if its contents match the ones of the current history ele-

ment. If the element is entered hhiissttoorryy() returns 1, if it is ignored as a duplicate returns 0. Finally hhiissttoorryy()

returns -1 if an error occurred.

HPREVSTR, const char *str Return the closest previous event that starts with str. HNEXTSTR, const char *str Return the closest next event that starts with str. HPREVEVENT, int e Return the previous event numbered e. HNEXTEVENT, int e Return the next event numbered e. HLOAD, const char *file Load the history list stored in file. HSAVE, const char *file Save the history list to file. HSETUNIQUE, int unique Set if the adjacent identical event strings should not be entered into the history. HGETUNIQUE Retrieve the current setting if if adjacent elements should be entered into the history.

hhiissttoorryy() returns >= 0 if the operation succeeds op succeeds. Oth-

erwise, -1 is returned and ev is updated to contain more details

about the error.

SEE ALSO

sh(1), signal(3), termcap(3), editrc(5) HISTORY The eeddiittlliinnee library first appeared in 4.4BSD. CCREDISPLAY appeared in NetBSD 1.3. CCREFRESHBEEP, ELEDITMODE and the readline emulation appeared in NetBSD 1.4. ELRPROMPT appeared in NetBSD 1.5. AUTHORS The eeddiittlliinnee library was written by Christos Zoulas. Luke Mewburn wrote this manual and implemented CCREDISPLAY, CCREFRESHBEEP, ELEDITMODE, and ELRPROMPT. Jaromir Dolecek implemented the readline emulation.

BUGS

The tokenization functions are not publicly defined in . At this time, it is the responsibility of the caller to check the result of the ELEDITMODE operation of eellggeett() (after an eellssoouurrccee() or eellppaarrssee()) to determine if eeddiittlliinnee should be used for further input. I.e., ELEDITMODE is purely an indication of the result of the most recent editrc(5) eeddiitt command. BSD October 17, 2003 BSD




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™