EDITLINE(3) | Introduction to Library Functions | EDITLINE(3) |
EditLine *
el_init(const char *prog, FILE *fin, FILE *fout,
FILE *ferr);
EditLine *
el_init_fd(const char *prog, FILE *fin, FILE
*fout, FILE *ferr, int fdin, int fdout, int
fderr);
void
el_end(EditLine *e);
void
el_reset(EditLine *e);
const char *
el_gets(EditLine *e, int *count);
const wchar_t *
el_wgets(EditLine *e, int *count);
int
el_getc(EditLine *e, char *ch);
int
el_wgetc(EditLine *e, wchar_t *wc);
void
el_push(EditLine *e, const char *mbs);
void
el_wpush(EditLine *e, const wchar_t *wcs);
int
el_parse(EditLine *e, int argc, const char
*argv[]);
int
el_wparse(EditLine *e, int argc, const wchar_t
*argv[]);
int
el_set(EditLine *e, int op, ...);
int
el_wset(EditLine *e, int op, ...);
int
el_get(EditLine *e, int op, ...);
int
el_wget(EditLine *e, int op, ...);
int
el_source(EditLine *e, const char *file);
void
el_resize(EditLine *e);
int
el_cursor(EditLine *e, int count);
const LineInfo *
el_line(EditLine *e);
const LineInfoW *
el_wline(EditLine *e);
int
el_insertstr(EditLine *e, const char *str);
int
el_winsertstr(EditLine *e, const wchar_t *str);
void
el_deletestr(EditLine *e, int count);
void
el_wdeletestr(EditLine *e, int count);
History *
history_init(void );
HistoryW *
history_winit(void );
void
history_end(History *h);
void
history_wend(HistoryW *h);
int
history(History *h, HistEvent *ev, int op,
...);
int
history_w(HistoryW *h, HistEventW *ev, int op,
...);
Tokenizer *
tok_init(const char *IFS);
TokenizerW *
tok_winit(const wchar_t *IFS);
void
tok_end(Tokenizer *t);
void
tok_wend(TokenizerW *t);
void
tok_reset(Tokenizer *t);
void
tok_wreset(TokenizerW *t);
int
tok_line(Tokenizer *t, const LineInfo *li, int
*argc, const char **argv[], int *cursorc, int
*cursoro);
int
tok_wline(TokenizerW *t, const LineInfoW *li, int
*argc, const wchar_t **argv[], int *cursorc, int
*cursoro);
int
tok_str(Tokenizer *t, const char *str, int *argc,
const char **argv[]);
int
tok_wstr(TokenizerW *t, const wchar_t *str, int
*argc, const wchar_t **argv[]);
These functions are available in the libedit library (which needs the libtermcap library). Programs should be linked with -ledit ltermcap .
The editline library respects the LC_CTYPE locale set by the application program and never uses setlocale(3) to change the locale.
The wide-character functions behave the same way as their narrow counterparts.
The following functions are available:
The following values for op are supported, along with the required argument list:
If a start/stop literal character is found in the prompt, the character itself is not printed, but characters after it are printed directly to the terminal without affecting the state of the current line. A subsequent second start/stop literal character ends this behavior. This is typically used to embed literal escape sequences that change the color/style of the terminal in the prompt. Note that the literal escape character cannot be the last character in the prompt, as the escape sequence is attached to the next character in the prompt. 0 unsets it.
int
Fo f EditLine *e wchar_t *wc Fc which stores the character in
wc and returns 1 on success, 0 on end of file, or -1 on I/O or
encoding errors. Functions internally using it include el_wgets(),
el_wgetc(), el_gets(), and el_getc(). Initially, a
builtin function is installed, and replacing it is discouraged because
writing such a function is very error prone. The builtin function can be
restored at any time by passing the special value EL_BUILTIN_GETCFN instead
of a function pointer.
The following values for op are supported, along with actual type of result :
typedef struct lineinfo {
const char *buffer; /* address of buffer */
const char *cursor; /* address of cursor */
const char *lastchar; /* address of last character */
} LineInfo;
buffer is not NUL terminated. This function may be called after el_gets() to obtain the LineInfo structure pertaining to line returned by that function, and from within user defined functions added with EL_ADDFN .
The following functions are available:
FILE
pointer fp.
n
history entries to the opened
FILE
pointer fp.
history(); returns >= 0 if the operation op succeeds. Otherwise, -1 is returned and ev is updated to contain more details about the error.
The following functions are available:
Returns 0 if successful, -1 for an internal error, 1 for an unmatched single quote, 2 for an unmatched double quote, and 3 for a backslash quoted <newline .> A positive exit code indicates that another line should be read and tokenization attempted again.
Christos Zoulas .
Luke Mewburn wrote this manual and implemented CC_REDISPLAY , CC_REFRESH_BEEP , EL_EDITMODE , and EL_RPROMPT .
Jaromir Dolecek implemented the readline emulation.
Johny Mattsson implemented wide-character support.
August 15, 2021 |