xref: /minix3/lib/libedit/editline.3 (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc.\"	$NetBSD: editline.3,v 1.84 2014/12/25 13:39:41 wiz Exp $
23e1db26aSLionel Sambuc.\"
3*0a6a1f1dSLionel Sambuc.\" Copyright (c) 1997-2014 The NetBSD Foundation, Inc.
43e1db26aSLionel Sambuc.\" All rights reserved.
53e1db26aSLionel Sambuc.\"
63e1db26aSLionel Sambuc.\" This file was contributed to The NetBSD Foundation by Luke Mewburn.
73e1db26aSLionel Sambuc.\"
83e1db26aSLionel Sambuc.\" Redistribution and use in source and binary forms, with or without
93e1db26aSLionel Sambuc.\" modification, are permitted provided that the following conditions
103e1db26aSLionel Sambuc.\" are met:
113e1db26aSLionel Sambuc.\" 1. Redistributions of source code must retain the above copyright
123e1db26aSLionel Sambuc.\"    notice, this list of conditions and the following disclaimer.
133e1db26aSLionel Sambuc.\" 2. Redistributions in binary form must reproduce the above copyright
143e1db26aSLionel Sambuc.\"    notice, this list of conditions and the following disclaimer in the
153e1db26aSLionel Sambuc.\"    documentation and/or other materials provided with the distribution.
163e1db26aSLionel Sambuc.\"
173e1db26aSLionel Sambuc.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
183e1db26aSLionel Sambuc.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
193e1db26aSLionel Sambuc.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
203e1db26aSLionel Sambuc.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
213e1db26aSLionel Sambuc.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
223e1db26aSLionel Sambuc.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
233e1db26aSLionel Sambuc.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
243e1db26aSLionel Sambuc.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
253e1db26aSLionel Sambuc.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
263e1db26aSLionel Sambuc.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
273e1db26aSLionel Sambuc.\" POSSIBILITY OF SUCH DAMAGE.
283e1db26aSLionel Sambuc.\"
29*0a6a1f1dSLionel Sambuc.Dd December 25, 2014
303e1db26aSLionel Sambuc.Dt EDITLINE 3
313e1db26aSLionel Sambuc.Os
323e1db26aSLionel Sambuc.Sh NAME
333e1db26aSLionel Sambuc.Nm editline ,
343e1db26aSLionel Sambuc.Nm el_init ,
3584d9c625SLionel Sambuc.Nm el_init_fd ,
363e1db26aSLionel Sambuc.Nm el_end ,
373e1db26aSLionel Sambuc.Nm el_reset ,
383e1db26aSLionel Sambuc.Nm el_gets ,
393e1db26aSLionel Sambuc.Nm el_wgets ,
403e1db26aSLionel Sambuc.Nm el_getc ,
413e1db26aSLionel Sambuc.Nm el_wgetc ,
423e1db26aSLionel Sambuc.Nm el_push ,
433e1db26aSLionel Sambuc.Nm el_wpush ,
443e1db26aSLionel Sambuc.Nm el_parse ,
453e1db26aSLionel Sambuc.Nm el_wparse ,
463e1db26aSLionel Sambuc.Nm el_set ,
473e1db26aSLionel Sambuc.Nm el_wset ,
483e1db26aSLionel Sambuc.Nm el_get ,
493e1db26aSLionel Sambuc.Nm el_wget ,
503e1db26aSLionel Sambuc.Nm el_source ,
513e1db26aSLionel Sambuc.Nm el_resize ,
5284d9c625SLionel Sambuc.Nm el_cursor ,
533e1db26aSLionel Sambuc.Nm el_line ,
543e1db26aSLionel Sambuc.Nm el_wline ,
553e1db26aSLionel Sambuc.Nm el_insertstr ,
563e1db26aSLionel Sambuc.Nm el_winsertstr ,
573e1db26aSLionel Sambuc.Nm el_deletestr ,
583e1db26aSLionel Sambuc.Nm el_wdeletestr ,
593e1db26aSLionel Sambuc.Nm history_init ,
603e1db26aSLionel Sambuc.Nm history_winit ,
613e1db26aSLionel Sambuc.Nm history_end ,
623e1db26aSLionel Sambuc.Nm history_wend ,
633e1db26aSLionel Sambuc.Nm history ,
643e1db26aSLionel Sambuc.Nm history_w ,
653e1db26aSLionel Sambuc.Nm tok_init ,
663e1db26aSLionel Sambuc.Nm tok_winit ,
673e1db26aSLionel Sambuc.Nm tok_end ,
683e1db26aSLionel Sambuc.Nm tok_wend ,
693e1db26aSLionel Sambuc.Nm tok_reset ,
703e1db26aSLionel Sambuc.Nm tok_wreset ,
713e1db26aSLionel Sambuc.Nm tok_line ,
723e1db26aSLionel Sambuc.Nm tok_wline ,
733e1db26aSLionel Sambuc.Nm tok_str
743e1db26aSLionel Sambuc.Nm tok_wstr
753e1db26aSLionel Sambuc.Nd line editor, history and tokenization functions
763e1db26aSLionel Sambuc.Sh LIBRARY
773e1db26aSLionel Sambuc.Lb libedit
783e1db26aSLionel Sambuc.Sh SYNOPSIS
793e1db26aSLionel Sambuc.In histedit.h
803e1db26aSLionel Sambuc.Ft EditLine *
813e1db26aSLionel Sambuc.Fn el_init "const char *prog" "FILE *fin" "FILE *fout" "FILE *ferr"
8284d9c625SLionel Sambuc.Ft EditLine *
8384d9c625SLionel Sambuc.Fn el_init_fd "const char *prog" "FILE *fin" "FILE *fout" "FILE *ferr" "int fdin" "int fdout" "int fderr"
843e1db26aSLionel Sambuc.Ft void
853e1db26aSLionel Sambuc.Fn el_end "EditLine *e"
863e1db26aSLionel Sambuc.Ft void
873e1db26aSLionel Sambuc.Fn el_reset "EditLine *e"
883e1db26aSLionel Sambuc.Ft const char *
893e1db26aSLionel Sambuc.Fn el_gets "EditLine *e" "int *count"
903e1db26aSLionel Sambuc.Ft const wchar_t *
913e1db26aSLionel Sambuc.Fn el_wgets "EditLine *e" "int *count"
923e1db26aSLionel Sambuc.Ft int
933e1db26aSLionel Sambuc.Fn el_getc "EditLine *e" "char *ch"
943e1db26aSLionel Sambuc.Ft int
953e1db26aSLionel Sambuc.Fn el_wgetc "EditLine *e" "wchar_t *ch"
963e1db26aSLionel Sambuc.Ft void
973e1db26aSLionel Sambuc.Fn el_push "EditLine *e" "const char *str"
983e1db26aSLionel Sambuc.Ft void
993e1db26aSLionel Sambuc.Fn el_wpush "EditLine *e" "const wchar_t *str"
1003e1db26aSLionel Sambuc.Ft int
1013e1db26aSLionel Sambuc.Fn el_parse "EditLine *e" "int argc" "const char *argv[]"
1023e1db26aSLionel Sambuc.Ft int
1033e1db26aSLionel Sambuc.Fn el_wparse "EditLine *e" "int argc" "const wchar_t *argv[]"
1043e1db26aSLionel Sambuc.Ft int
1053e1db26aSLionel Sambuc.Fn el_set "EditLine *e" "int op" "..."
1063e1db26aSLionel Sambuc.Ft int
1073e1db26aSLionel Sambuc.Fn el_wset "EditLine *e" "int op" "..."
1083e1db26aSLionel Sambuc.Ft int
1093e1db26aSLionel Sambuc.Fn el_get "EditLine *e" "int op" "..."
1103e1db26aSLionel Sambuc.Ft int
1113e1db26aSLionel Sambuc.Fn el_wget "EditLine *e" "int op" "..."
1123e1db26aSLionel Sambuc.Ft int
1133e1db26aSLionel Sambuc.Fn el_source "EditLine *e" "const char *file"
1143e1db26aSLionel Sambuc.Ft void
1153e1db26aSLionel Sambuc.Fn el_resize "EditLine *e"
11684d9c625SLionel Sambuc.Fn int
11784d9c625SLionel Sambuc.Fn el_cursor "EditLine *e" "int count"
1183e1db26aSLionel Sambuc.Ft const LineInfo *
1193e1db26aSLionel Sambuc.Fn el_line "EditLine *e"
12084d9c625SLionel Sambuc.Ft const LineInfoW *
12184d9c625SLionel Sambuc.Fn el_wline "EditLine *e"
1223e1db26aSLionel Sambuc.Ft int
1233e1db26aSLionel Sambuc.Fn el_insertstr "EditLine *e" "const char *str"
1243e1db26aSLionel Sambuc.Ft int
1253e1db26aSLionel Sambuc.Fn el_winsertstr "EditLine *e" "const wchar_t *str"
1263e1db26aSLionel Sambuc.Ft void
1273e1db26aSLionel Sambuc.Fn el_deletestr "EditLine *e" "int count"
1283e1db26aSLionel Sambuc.Ft void
1293e1db26aSLionel Sambuc.Fn el_wdeletestr "EditLine *e" "int count"
1303e1db26aSLionel Sambuc.Ft History *
1313e1db26aSLionel Sambuc.Fn history_init
1323e1db26aSLionel Sambuc.Ft HistoryW *
1333e1db26aSLionel Sambuc.Fn history_winit
1343e1db26aSLionel Sambuc.Ft void
1353e1db26aSLionel Sambuc.Fn history_end "History *h"
1363e1db26aSLionel Sambuc.Ft void
1373e1db26aSLionel Sambuc.Fn history_wend "HistoryW *h"
1383e1db26aSLionel Sambuc.Ft int
1393e1db26aSLionel Sambuc.Fn history "History *h" "HistEvent *ev" "int op" "..."
1403e1db26aSLionel Sambuc.Ft int
1413e1db26aSLionel Sambuc.Fn history_w "HistoryW *h" "HistEventW *ev" "int op" "..."
1423e1db26aSLionel Sambuc.Ft Tokenizer *
1433e1db26aSLionel Sambuc.Fn tok_init "const char *IFS"
1443e1db26aSLionel Sambuc.Ft TokenizerW *
1453e1db26aSLionel Sambuc.Fn tok_winit "const wchar_t *IFS"
1463e1db26aSLionel Sambuc.Ft void
1473e1db26aSLionel Sambuc.Fn tok_end "Tokenizer *t"
1483e1db26aSLionel Sambuc.Ft void
1493e1db26aSLionel Sambuc.Fn tok_wend "TokenizerW *t"
1503e1db26aSLionel Sambuc.Ft void
1513e1db26aSLionel Sambuc.Fn tok_reset "Tokenizer *t"
1523e1db26aSLionel Sambuc.Ft void
1533e1db26aSLionel Sambuc.Fn tok_wreset "TokenizerW *t"
1543e1db26aSLionel Sambuc.Ft int
1553e1db26aSLionel Sambuc.Fn tok_line "Tokenizer *t" "const LineInfo *li" "int *argc" "const char **argv[]" "int *cursorc" "int *cursoro"
1563e1db26aSLionel Sambuc.Ft int
1573e1db26aSLionel Sambuc.Fn tok_wline "TokenizerW *t" "const LineInfoW *li" "int *argc" "const wchar_t **argv[]" "int *cursorc" "int *cursoro"
1583e1db26aSLionel Sambuc.Ft int
1593e1db26aSLionel Sambuc.Fn tok_str "Tokenizer *t" "const char *str" "int *argc" "const char **argv[]"
1603e1db26aSLionel Sambuc.Ft int
1613e1db26aSLionel Sambuc.Fn tok_wstr "TokenizerW *t" "const wchar_t *str" "int *argc" "const wchar_t **argv[]"
1623e1db26aSLionel Sambuc.Sh DESCRIPTION
1633e1db26aSLionel SambucThe
1643e1db26aSLionel Sambuc.Nm
1653e1db26aSLionel Sambuclibrary provides generic line editing, history and tokenization functions,
1663e1db26aSLionel Sambucsimilar to those found in
1673e1db26aSLionel Sambuc.Xr sh 1 .
1683e1db26aSLionel Sambuc.Pp
1693e1db26aSLionel SambucThese functions are available in the
1703e1db26aSLionel Sambuc.Nm libedit
1713e1db26aSLionel Sambuclibrary (which needs the
1723e1db26aSLionel Sambuc.Nm libtermcap
1733e1db26aSLionel Sambuclibrary).
1743e1db26aSLionel SambucPrograms should be linked with
1753e1db26aSLionel Sambuc.Fl ledit ltermcap .
1763e1db26aSLionel Sambuc.Sh LINE EDITING FUNCTIONS
1773e1db26aSLionel SambucThe line editing functions use a common data structure,
1783e1db26aSLionel Sambuc.Fa EditLine ,
1793e1db26aSLionel Sambucwhich is created by
1803e1db26aSLionel Sambuc.Fn el_init
18184d9c625SLionel Sambucor
18284d9c625SLionel Sambuc.Fn el_init_fd
1833e1db26aSLionel Sambucand freed by
1843e1db26aSLionel Sambuc.Fn el_end .
1853e1db26aSLionel Sambuc.Pp
1863e1db26aSLionel SambucThe wide-character functions behave the same way as their narrow
1873e1db26aSLionel Sambuccounterparts.
1883e1db26aSLionel Sambuc.Pp
1893e1db26aSLionel SambucThe following functions are available:
1903e1db26aSLionel Sambuc.Bl -tag -width 4n
1913e1db26aSLionel Sambuc.It Fn el_init
1923e1db26aSLionel SambucInitialise the line editor, and return a data structure
193*0a6a1f1dSLionel Sambucto be used by all other line editing functions, or
194*0a6a1f1dSLionel Sambuc.Dv NULL
195*0a6a1f1dSLionel Sambucon failure.
1963e1db26aSLionel Sambuc.Fa prog
1973e1db26aSLionel Sambucis the name of the invoking program, used when reading the
1983e1db26aSLionel Sambuc.Xr editrc 5
1993e1db26aSLionel Sambucfile to determine which settings to use.
2003e1db26aSLionel Sambuc.Fa fin ,
2013e1db26aSLionel Sambuc.Fa fout
2023e1db26aSLionel Sambucand
2033e1db26aSLionel Sambuc.Fa ferr
2043e1db26aSLionel Sambucare the input, output, and error streams (respectively) to use.
2053e1db26aSLionel SambucIn this documentation, references to
2063e1db26aSLionel Sambuc.Dq the tty
2073e1db26aSLionel Sambucare actually to this input/output stream combination.
20884d9c625SLionel Sambuc.It Fn el_init_fd
20984d9c625SLionel SambucLike
21084d9c625SLionel Sambuc.Fn el_init
21184d9c625SLionel Sambucbut allows specifying file descriptors for the
21284d9c625SLionel Sambuc.Xr stdio 3
21384d9c625SLionel Sambuccorresponding streams, in case those were created with
21484d9c625SLionel Sambuc.Xr funopen 3 .
2153e1db26aSLionel Sambuc.It Fn el_end
2163e1db26aSLionel SambucClean up and finish with
2173e1db26aSLionel Sambuc.Fa e ,
2183e1db26aSLionel Sambucassumed to have been created with
21984d9c625SLionel Sambuc.Fn el_init
22084d9c625SLionel Sambucor
22184d9c625SLionel Sambuc.Fn el_init_fd .
2223e1db26aSLionel Sambuc.It Fn el_reset
2233e1db26aSLionel SambucReset the tty and the parser.
2243e1db26aSLionel SambucThis should be called after an error which may have upset the tty's
2253e1db26aSLionel Sambucstate.
2263e1db26aSLionel Sambuc.It Fn el_gets
2273e1db26aSLionel SambucRead a line from the tty.
2283e1db26aSLionel Sambuc.Fa count
2293e1db26aSLionel Sambucis modified to contain the number of characters read.
2303e1db26aSLionel SambucReturns the line read if successful, or
2313e1db26aSLionel Sambuc.Dv NULL
2323e1db26aSLionel Sambucif no characters were read or if an error occurred.
2333e1db26aSLionel SambucIf an error occurred,
2343e1db26aSLionel Sambuc.Fa count
2353e1db26aSLionel Sambucis set to \-1 and
2363e1db26aSLionel Sambuc.Dv errno
2373e1db26aSLionel Sambuccontains the error code that caused it.
2383e1db26aSLionel SambucThe return value may not remain valid across calls to
2393e1db26aSLionel Sambuc.Fn el_gets
2403e1db26aSLionel Sambucand must be copied if the data is to be retained.
2413e1db26aSLionel Sambuc.It Fn el_getc
2423e1db26aSLionel SambucRead a character from the tty.
2433e1db26aSLionel Sambuc.Fa ch
2443e1db26aSLionel Sambucis modified to contain the character read.
2453e1db26aSLionel SambucReturns the number of characters read if successful, \-1 otherwise,
2463e1db26aSLionel Sambucin which case
2473e1db26aSLionel Sambuc.Dv errno
2483e1db26aSLionel Sambuccan be inspected for the cause.
2493e1db26aSLionel Sambuc.It Fn el_push
2503e1db26aSLionel SambucPushes
2513e1db26aSLionel Sambuc.Fa str
2523e1db26aSLionel Sambucback onto the input stream.
2533e1db26aSLionel SambucThis is used by the macro expansion mechanism.
2543e1db26aSLionel SambucRefer to the description of
2553e1db26aSLionel Sambuc.Ic bind
2563e1db26aSLionel Sambuc.Fl s
2573e1db26aSLionel Sambucin
2583e1db26aSLionel Sambuc.Xr editrc 5
2593e1db26aSLionel Sambucfor more information.
2603e1db26aSLionel Sambuc.It Fn el_parse
2613e1db26aSLionel SambucParses the
2623e1db26aSLionel Sambuc.Fa argv
2633e1db26aSLionel Sambucarray (which is
2643e1db26aSLionel Sambuc.Fa argc
2653e1db26aSLionel Sambucelements in size)
2663e1db26aSLionel Sambucto execute builtin
2673e1db26aSLionel Sambuc.Nm
2683e1db26aSLionel Sambuccommands.
2693e1db26aSLionel SambucIf the command is prefixed with
2703e1db26aSLionel Sambuc.Dq prog :
2713e1db26aSLionel Sambucthen
2723e1db26aSLionel Sambuc.Fn el_parse
2733e1db26aSLionel Sambucwill only execute the command if
2743e1db26aSLionel Sambuc.Dq prog
2753e1db26aSLionel Sambucmatches the
2763e1db26aSLionel Sambuc.Fa prog
2773e1db26aSLionel Sambucargument supplied to
2783e1db26aSLionel Sambuc.Fn el_init .
2793e1db26aSLionel SambucThe return value is
2803e1db26aSLionel Sambuc\-1 if the command is unknown,
2813e1db26aSLionel Sambuc0 if there was no error or
2823e1db26aSLionel Sambuc.Dq prog
2833e1db26aSLionel Sambucdidn't match, or
2843e1db26aSLionel Sambuc1 if the command returned an error.
2853e1db26aSLionel SambucRefer to
2863e1db26aSLionel Sambuc.Xr editrc 5
2873e1db26aSLionel Sambucfor more information.
2883e1db26aSLionel Sambuc.It Fn el_set
2893e1db26aSLionel SambucSet
2903e1db26aSLionel Sambuc.Nm
2913e1db26aSLionel Sambucparameters.
2923e1db26aSLionel Sambuc.Fa op
2933e1db26aSLionel Sambucdetermines which parameter to set, and each operation has its
2943e1db26aSLionel Sambucown parameter list.
295*0a6a1f1dSLionel SambucReturns 0 on success, \-1 on failure.
2963e1db26aSLionel Sambuc.Pp
2973e1db26aSLionel SambucThe following values for
2983e1db26aSLionel Sambuc.Fa op
2993e1db26aSLionel Sambucare supported, along with the required argument list:
3003e1db26aSLionel Sambuc.Bl -tag -width 4n
3013e1db26aSLionel Sambuc.It Dv EL_PROMPT , Fa "char *(*f)(EditLine *)"
3023e1db26aSLionel SambucDefine prompt printing function as
3033e1db26aSLionel Sambuc.Fa f ,
3043e1db26aSLionel Sambucwhich is to return a string that contains the prompt.
3053e1db26aSLionel Sambuc.It Dv EL_PROMPT_ESC , Fa "char *(*f)(EditLine *)" , Fa "char c"
3063e1db26aSLionel SambucSame as
3073e1db26aSLionel Sambuc.Dv EL_PROMPT ,
3083e1db26aSLionel Sambucbut the
3093e1db26aSLionel Sambuc.Fa c
3103e1db26aSLionel Sambucargument indicates the start/stop literal prompt character.
3113e1db26aSLionel Sambuc.Pp
3123e1db26aSLionel SambucIf a start/stop literal character is found in the prompt, the
3133e1db26aSLionel Sambuccharacter itself
3143e1db26aSLionel Sambucis not printed, but characters after it are printed directly to the
3153e1db26aSLionel Sambucterminal without affecting the state of the current line.
3163e1db26aSLionel SambucA subsequent second start/stop literal character ends this behavior.
3173e1db26aSLionel SambucThis is typically used to embed literal escape sequences that change the
3183e1db26aSLionel Sambuccolor/style of the terminal in the prompt.
3193e1db26aSLionel Sambuc.Dv 0
3203e1db26aSLionel Sambucunsets it.
3213e1db26aSLionel Sambuc.It Dv EL_REFRESH
3223e1db26aSLionel SambucRe-display the current line on the next terminal line.
3233e1db26aSLionel Sambuc.It Dv EL_RPROMPT , Fa "char *(*f)(EditLine *)"
3243e1db26aSLionel SambucDefine right side prompt printing function as
3253e1db26aSLionel Sambuc.Fa f ,
3263e1db26aSLionel Sambucwhich is to return a string that contains the prompt.
3273e1db26aSLionel Sambuc.It Dv EL_RPROMPT_ESC , Fa "char *(*f)(EditLine *)" , Fa "char c"
3283e1db26aSLionel SambucDefine the right prompt printing function but with a literal escape character.
3293e1db26aSLionel Sambuc.It Dv EL_TERMINAL , Fa "const char *type"
3303e1db26aSLionel SambucDefine terminal type of the tty to be
3313e1db26aSLionel Sambuc.Fa type ,
3323e1db26aSLionel Sambucor to
3333e1db26aSLionel Sambuc.Ev TERM
3343e1db26aSLionel Sambucif
3353e1db26aSLionel Sambuc.Fa type
3363e1db26aSLionel Sambucis
3373e1db26aSLionel Sambuc.Dv NULL .
3383e1db26aSLionel Sambuc.It Dv EL_EDITOR , Fa "const char *mode"
3393e1db26aSLionel SambucSet editing mode to
3403e1db26aSLionel Sambuc.Fa mode ,
3413e1db26aSLionel Sambucwhich must be one of
3423e1db26aSLionel Sambuc.Dq emacs
3433e1db26aSLionel Sambucor
3443e1db26aSLionel Sambuc.Dq vi .
3453e1db26aSLionel Sambuc.It Dv EL_SIGNAL , Fa "int flag"
3463e1db26aSLionel SambucIf
3473e1db26aSLionel Sambuc.Fa flag
3483e1db26aSLionel Sambucis non-zero,
3493e1db26aSLionel Sambuc.Nm
3503e1db26aSLionel Sambucwill install its own signal handler for the following signals when
3513e1db26aSLionel Sambucreading command input:
3523e1db26aSLionel Sambuc.Dv SIGCONT ,
3533e1db26aSLionel Sambuc.Dv SIGHUP ,
3543e1db26aSLionel Sambuc.Dv SIGINT ,
3553e1db26aSLionel Sambuc.Dv SIGQUIT ,
3563e1db26aSLionel Sambuc.Dv SIGSTOP ,
3573e1db26aSLionel Sambuc.Dv SIGTERM ,
3583e1db26aSLionel Sambuc.Dv SIGTSTP ,
3593e1db26aSLionel Sambucand
3603e1db26aSLionel Sambuc.Dv SIGWINCH .
3613e1db26aSLionel SambucOtherwise, the current signal handlers will be used.
3623e1db26aSLionel Sambuc.It Dv EL_BIND , Fa "const char *" , Fa "..." , Dv NULL
3633e1db26aSLionel SambucPerform the
3643e1db26aSLionel Sambuc.Ic bind
3653e1db26aSLionel Sambucbuiltin command.
3663e1db26aSLionel SambucRefer to
3673e1db26aSLionel Sambuc.Xr editrc 5
3683e1db26aSLionel Sambucfor more information.
3693e1db26aSLionel Sambuc.It Dv EL_ECHOTC , Fa "const char *" , Fa "..." , Dv NULL
3703e1db26aSLionel SambucPerform the
3713e1db26aSLionel Sambuc.Ic echotc
3723e1db26aSLionel Sambucbuiltin command.
3733e1db26aSLionel SambucRefer to
3743e1db26aSLionel Sambuc.Xr editrc 5
3753e1db26aSLionel Sambucfor more information.
3763e1db26aSLionel Sambuc.It Dv EL_SETTC , Fa "const char *" , Fa "..." , Dv NULL
3773e1db26aSLionel SambucPerform the
3783e1db26aSLionel Sambuc.Ic settc
3793e1db26aSLionel Sambucbuiltin command.
3803e1db26aSLionel SambucRefer to
3813e1db26aSLionel Sambuc.Xr editrc 5
3823e1db26aSLionel Sambucfor more information.
3833e1db26aSLionel Sambuc.It Dv EL_SETTY , Fa "const char *" , Fa "..." , Dv NULL
3843e1db26aSLionel SambucPerform the
3853e1db26aSLionel Sambuc.Ic setty
3863e1db26aSLionel Sambucbuiltin command.
3873e1db26aSLionel SambucRefer to
3883e1db26aSLionel Sambuc.Xr editrc 5
3893e1db26aSLionel Sambucfor more information.
3903e1db26aSLionel Sambuc.It Dv EL_TELLTC , Fa "const char *" , Fa "..." , Dv NULL
3913e1db26aSLionel SambucPerform the
3923e1db26aSLionel Sambuc.Ic telltc
3933e1db26aSLionel Sambucbuiltin command.
3943e1db26aSLionel SambucRefer to
3953e1db26aSLionel Sambuc.Xr editrc 5
3963e1db26aSLionel Sambucfor more information.
3973e1db26aSLionel Sambuc.It Dv EL_ADDFN , Fa "const char *name" , Fa "const char *help" , \
3983e1db26aSLionel SambucFa "unsigned char (*func)(EditLine *e, int ch)"
3993e1db26aSLionel SambucAdd a user defined function,
4003e1db26aSLionel Sambuc.Fn func ,
4013e1db26aSLionel Sambucreferred to as
4023e1db26aSLionel Sambuc.Fa name
4033e1db26aSLionel Sambucwhich is invoked when a key which is bound to
4043e1db26aSLionel Sambuc.Fa name
4053e1db26aSLionel Sambucis entered.
4063e1db26aSLionel Sambuc.Fa help
4073e1db26aSLionel Sambucis a description of
4083e1db26aSLionel Sambuc.Fa name .
4093e1db26aSLionel SambucAt invocation time,
4103e1db26aSLionel Sambuc.Fa ch
4113e1db26aSLionel Sambucis the key which caused the invocation.
4123e1db26aSLionel SambucThe return value of
4133e1db26aSLionel Sambuc.Fn func
4143e1db26aSLionel Sambucshould be one of:
4153e1db26aSLionel Sambuc.Bl -tag -width "CC_REDISPLAY"
4163e1db26aSLionel Sambuc.It Dv CC_NORM
4173e1db26aSLionel SambucAdd a normal character.
4183e1db26aSLionel Sambuc.It Dv CC_NEWLINE
4193e1db26aSLionel SambucEnd of line was entered.
4203e1db26aSLionel Sambuc.It Dv CC_EOF
4213e1db26aSLionel SambucEOF was entered.
4223e1db26aSLionel Sambuc.It Dv CC_ARGHACK
4233e1db26aSLionel SambucExpecting further command input as arguments, do nothing visually.
4243e1db26aSLionel Sambuc.It Dv CC_REFRESH
4253e1db26aSLionel SambucRefresh display.
4263e1db26aSLionel Sambuc.It Dv CC_REFRESH_BEEP
4273e1db26aSLionel SambucRefresh display, and beep.
4283e1db26aSLionel Sambuc.It Dv CC_CURSOR
4293e1db26aSLionel SambucCursor moved, so update and perform
4303e1db26aSLionel Sambuc.Dv CC_REFRESH .
4313e1db26aSLionel Sambuc.It Dv CC_REDISPLAY
4323e1db26aSLionel SambucRedisplay entire input line.
4333e1db26aSLionel SambucThis is useful if a key binding outputs extra information.
4343e1db26aSLionel Sambuc.It Dv CC_ERROR
4353e1db26aSLionel SambucAn error occurred.
4363e1db26aSLionel SambucBeep, and flush tty.
4373e1db26aSLionel Sambuc.It Dv CC_FATAL
4383e1db26aSLionel SambucFatal error, reset tty to known state.
4393e1db26aSLionel Sambuc.El
4403e1db26aSLionel Sambuc.It Dv EL_HIST , Fa "History *(*func)(History *, int op, ...)" , \
4413e1db26aSLionel SambucFa "const char *ptr"
4423e1db26aSLionel SambucDefines which history function to use, which is usually
4433e1db26aSLionel Sambuc.Fn history .
4443e1db26aSLionel Sambuc.Fa ptr
4453e1db26aSLionel Sambucshould be the value returned by
4463e1db26aSLionel Sambuc.Fn history_init .
4473e1db26aSLionel Sambuc.It Dv EL_EDITMODE , Fa "int flag"
4483e1db26aSLionel SambucIf
4493e1db26aSLionel Sambuc.Fa flag
4503e1db26aSLionel Sambucis non-zero,
4513e1db26aSLionel Sambucediting is enabled (the default).
4523e1db26aSLionel SambucNote that this is only an indication, and does not
4533e1db26aSLionel Sambucaffect the operation of
4543e1db26aSLionel Sambuc.Nm .
4553e1db26aSLionel SambucAt this time, it is the caller's responsibility to
4563e1db26aSLionel Sambuccheck this
4573e1db26aSLionel Sambuc(using
4583e1db26aSLionel Sambuc.Fn el_get )
4593e1db26aSLionel Sambucto determine if editing should be enabled or not.
4603e1db26aSLionel Sambuc.It Dv EL_UNBUFFERED , Fa "int flag"
4613e1db26aSLionel SambucIf
4623e1db26aSLionel Sambuc.Fa flag
4633e1db26aSLionel Sambucis zero,
4643e1db26aSLionel Sambucunbuffered mode is disabled (the default).
4653e1db26aSLionel SambucIn unbuffered mode,
4663e1db26aSLionel Sambuc.Fn el_gets
4673e1db26aSLionel Sambucwill return immediately after processing a single character.
4683e1db26aSLionel Sambuc.It Dv EL_GETCFN , Fa "int (*f)(EditLine *, char *c)"
4693e1db26aSLionel SambucDefine the character reading function as
4703e1db26aSLionel Sambuc.Fa f ,
4713e1db26aSLionel Sambucwhich is to return the number of characters read and store them in
4723e1db26aSLionel Sambuc.Fa c .
4733e1db26aSLionel SambucThis function is called internally by
4743e1db26aSLionel Sambuc.Fn el_gets
4753e1db26aSLionel Sambucand
4763e1db26aSLionel Sambuc.Fn el_getc .
4773e1db26aSLionel SambucThe builtin function can be set or restored with the special function
4783e1db26aSLionel Sambucname
4793e1db26aSLionel Sambuc.Dq Dv EL_BUILTIN_GETCFN .
4803e1db26aSLionel Sambuc.It Dv EL_CLIENTDATA , Fa "void *data"
4813e1db26aSLionel SambucRegister
4823e1db26aSLionel Sambuc.Fa data
4833e1db26aSLionel Sambucto be associated with this EditLine structure.
4843e1db26aSLionel SambucIt can be retrieved with the corresponding
4853e1db26aSLionel Sambuc.Fn el_get
4863e1db26aSLionel Sambuccall.
4873e1db26aSLionel Sambuc.It Dv EL_SETFP , Fa "int fd" , Fa "FILE *fp"
4883e1db26aSLionel SambucSet the current
4893e1db26aSLionel Sambuc.Nm editline
4903e1db26aSLionel Sambucfile pointer for
4913e1db26aSLionel Sambuc.Dq input
4923e1db26aSLionel Sambuc.Fa fd
4933e1db26aSLionel Sambuc=
4943e1db26aSLionel Sambuc.Dv 0 ,
4953e1db26aSLionel Sambuc.Dq output
4963e1db26aSLionel Sambuc.Fa fd
4973e1db26aSLionel Sambuc=
4983e1db26aSLionel Sambuc.Dv 1 ,
4993e1db26aSLionel Sambucor
5003e1db26aSLionel Sambuc.Dq error
5013e1db26aSLionel Sambuc.Fa fd
5023e1db26aSLionel Sambuc=
5033e1db26aSLionel Sambuc.Dv 2
5043e1db26aSLionel Sambucfrom
5053e1db26aSLionel Sambuc.Fa fp .
5063e1db26aSLionel Sambuc.El
5073e1db26aSLionel Sambuc.It Fn el_get
5083e1db26aSLionel SambucGet
5093e1db26aSLionel Sambuc.Nm
5103e1db26aSLionel Sambucparameters.
5113e1db26aSLionel Sambuc.Fa op
5123e1db26aSLionel Sambucdetermines which parameter to retrieve into
5133e1db26aSLionel Sambuc.Fa result .
5143e1db26aSLionel SambucReturns 0 if successful, \-1 otherwise.
5153e1db26aSLionel Sambuc.Pp
5163e1db26aSLionel SambucThe following values for
5173e1db26aSLionel Sambuc.Fa op
5183e1db26aSLionel Sambucare supported, along with actual type of
5193e1db26aSLionel Sambuc.Fa result :
5203e1db26aSLionel Sambuc.Bl -tag -width 4n
5213e1db26aSLionel Sambuc.It Dv EL_PROMPT , Fa "char *(*f)(EditLine *)" , Fa "char *c"
5223e1db26aSLionel SambucReturn a pointer to the function that displays the prompt in
5233e1db26aSLionel Sambuc.Fa f .
5243e1db26aSLionel SambucIf
5253e1db26aSLionel Sambuc.Fa c
5263e1db26aSLionel Sambucis not
5273e1db26aSLionel Sambuc.Dv NULL ,
5283e1db26aSLionel Sambucreturn the start/stop literal prompt character in it.
5293e1db26aSLionel Sambuc.It Dv EL_RPROMPT , Fa "char *(*f)(EditLine *)" , Fa "char *c"
5303e1db26aSLionel SambucReturn a pointer to the function that displays the prompt in
5313e1db26aSLionel Sambuc.Fa f .
5323e1db26aSLionel SambucIf
5333e1db26aSLionel Sambuc.Fa c
5343e1db26aSLionel Sambucis not
5353e1db26aSLionel Sambuc.Dv NULL ,
5363e1db26aSLionel Sambucreturn the start/stop literal prompt character in it.
5373e1db26aSLionel Sambuc.It Dv EL_EDITOR , Fa "const char **"
5383e1db26aSLionel SambucReturn the name of the editor, which will be one of
5393e1db26aSLionel Sambuc.Dq emacs
5403e1db26aSLionel Sambucor
5413e1db26aSLionel Sambuc.Dq vi .
5423e1db26aSLionel Sambuc.It Dv EL_GETTC , Fa "const char *name" , Fa "void *value"
5433e1db26aSLionel SambucReturn non-zero if
5443e1db26aSLionel Sambuc.Fa name
5453e1db26aSLionel Sambucis a valid
5463e1db26aSLionel Sambuc.Xr termcap 5
5473e1db26aSLionel Sambuccapability
5483e1db26aSLionel Sambucand set
5493e1db26aSLionel Sambuc.Fa value
5503e1db26aSLionel Sambucto the current value of that capability.
5513e1db26aSLionel Sambuc.It Dv EL_SIGNAL , Fa "int *"
5523e1db26aSLionel SambucReturn non-zero if
5533e1db26aSLionel Sambuc.Nm
5543e1db26aSLionel Sambuchas installed private signal handlers (see
5553e1db26aSLionel Sambuc.Fn el_get
5563e1db26aSLionel Sambucabove).
5573e1db26aSLionel Sambuc.It Dv EL_EDITMODE , Fa "int *"
5583e1db26aSLionel SambucReturn non-zero if editing is enabled.
5593e1db26aSLionel Sambuc.It Dv EL_GETCFN , Fa "int (**f)(EditLine *, char *)"
5603e1db26aSLionel SambucReturn a pointer to the function that read characters, which is equal to
5613e1db26aSLionel Sambuc.Dq Dv EL_BUILTIN_GETCFN
5623e1db26aSLionel Sambucin the case of the default builtin function.
5633e1db26aSLionel Sambuc.It Dv EL_CLIENTDATA , Fa "void **data"
5643e1db26aSLionel SambucRetrieve
5653e1db26aSLionel Sambuc.Fa data
5663e1db26aSLionel Sambucpreviously registered with the corresponding
5673e1db26aSLionel Sambuc.Fn el_set
5683e1db26aSLionel Sambuccall.
5693e1db26aSLionel Sambuc.It Dv EL_UNBUFFERED , Fa "int"
5703e1db26aSLionel SambucReturn non-zero if unbuffered mode is enabled.
5713e1db26aSLionel Sambuc.It Dv EL_PREP_TERM , Fa "int"
5723e1db26aSLionel SambucSets or clears terminal editing mode.
5733e1db26aSLionel Sambuc.It Dv EL_GETFP , Fa "int fd", Fa "FILE **fp"
5743e1db26aSLionel SambucReturn in
5753e1db26aSLionel Sambuc.Fa fp
5763e1db26aSLionel Sambucthe current
5773e1db26aSLionel Sambuc.Nm editline
5783e1db26aSLionel Sambucfile pointer for
5793e1db26aSLionel Sambuc.Dq input
5803e1db26aSLionel Sambuc.Fa fd
5813e1db26aSLionel Sambuc=
5823e1db26aSLionel Sambuc.Dv 0 ,
5833e1db26aSLionel Sambuc.Dq output
5843e1db26aSLionel Sambuc.Fa fd
5853e1db26aSLionel Sambuc=
5863e1db26aSLionel Sambuc.Dv 1 ,
5873e1db26aSLionel Sambucor
5883e1db26aSLionel Sambuc.Dq error
5893e1db26aSLionel Sambuc.Fa fd
5903e1db26aSLionel Sambuc=
5913e1db26aSLionel Sambuc.Dv 2 .
5923e1db26aSLionel Sambuc.El
5933e1db26aSLionel Sambuc.It Fn el_source
5943e1db26aSLionel SambucInitialise
5953e1db26aSLionel Sambuc.Nm
5963e1db26aSLionel Sambucby reading the contents of
5973e1db26aSLionel Sambuc.Fa file .
5983e1db26aSLionel Sambuc.Fn el_parse
5993e1db26aSLionel Sambucis called for each line in
6003e1db26aSLionel Sambuc.Fa file .
6013e1db26aSLionel SambucIf
6023e1db26aSLionel Sambuc.Fa file
6033e1db26aSLionel Sambucis
6043e1db26aSLionel Sambuc.Dv NULL ,
6053e1db26aSLionel Sambuctry
6063e1db26aSLionel Sambuc.Pa $HOME/.editrc .
6073e1db26aSLionel SambucRefer to
6083e1db26aSLionel Sambuc.Xr editrc 5
6093e1db26aSLionel Sambucfor details on the format of
6103e1db26aSLionel Sambuc.Fa file .
611*0a6a1f1dSLionel Sambuc.Fn el_source
612*0a6a1f1dSLionel Sambucreturns 0 on success and \-1 on error.
6133e1db26aSLionel Sambuc.It Fn el_resize
6143e1db26aSLionel SambucMust be called if the terminal size changes.
6153e1db26aSLionel SambucIf
6163e1db26aSLionel Sambuc.Dv EL_SIGNAL
6173e1db26aSLionel Sambuchas been set with
6183e1db26aSLionel Sambuc.Fn el_set ,
6193e1db26aSLionel Sambucthen this is done automatically.
6203e1db26aSLionel SambucOtherwise, it's the responsibility of the application to call
6213e1db26aSLionel Sambuc.Fn el_resize
6223e1db26aSLionel Sambucon the appropriate occasions.
62384d9c625SLionel Sambuc.It Fn el_cursor
62484d9c625SLionel SambucMove the cursor to the right (if positive) or to the left (if negative)
62584d9c625SLionel Sambuc.Fa count
62684d9c625SLionel Sambuccharacters.
62784d9c625SLionel SambucReturns the resulting offset of the cursor from the beginning of the line.
6283e1db26aSLionel Sambuc.It Fn el_line
6293e1db26aSLionel SambucReturn the editing information for the current line in a
6303e1db26aSLionel Sambuc.Fa LineInfo
6313e1db26aSLionel Sambucstructure, which is defined as follows:
6323e1db26aSLionel Sambuc.Bd -literal
6333e1db26aSLionel Sambuctypedef struct lineinfo {
6343e1db26aSLionel Sambuc    const char *buffer;    /* address of buffer */
6353e1db26aSLionel Sambuc    const char *cursor;    /* address of cursor */
6363e1db26aSLionel Sambuc    const char *lastchar;  /* address of last character */
6373e1db26aSLionel Sambuc} LineInfo;
6383e1db26aSLionel Sambuc.Ed
6393e1db26aSLionel Sambuc.Pp
6403e1db26aSLionel Sambuc.Fa buffer
6413e1db26aSLionel Sambucis not NUL terminated.
6423e1db26aSLionel SambucThis function may be called after
6433e1db26aSLionel Sambuc.Fn el_gets
6443e1db26aSLionel Sambucto obtain the
6453e1db26aSLionel Sambuc.Fa LineInfo
6463e1db26aSLionel Sambucstructure pertaining to line returned by that function,
6473e1db26aSLionel Sambucand from within user defined functions added with
6483e1db26aSLionel Sambuc.Dv EL_ADDFN .
6493e1db26aSLionel Sambuc.It Fn el_insertstr
6503e1db26aSLionel SambucInsert
6513e1db26aSLionel Sambuc.Fa str
6523e1db26aSLionel Sambucinto the line at the cursor.
6533e1db26aSLionel SambucReturns \-1 if
6543e1db26aSLionel Sambuc.Fa str
6553e1db26aSLionel Sambucis empty or won't fit, and 0 otherwise.
6563e1db26aSLionel Sambuc.It Fn el_deletestr
6573e1db26aSLionel SambucDelete
6583e1db26aSLionel Sambuc.Fa count
6593e1db26aSLionel Sambuccharacters before the cursor.
6603e1db26aSLionel Sambuc.El
6613e1db26aSLionel Sambuc.Sh HISTORY LIST FUNCTIONS
6623e1db26aSLionel SambucThe history functions use a common data structure,
6633e1db26aSLionel Sambuc.Fa History ,
6643e1db26aSLionel Sambucwhich is created by
6653e1db26aSLionel Sambuc.Fn history_init
6663e1db26aSLionel Sambucand freed by
6673e1db26aSLionel Sambuc.Fn history_end .
6683e1db26aSLionel Sambuc.Pp
6693e1db26aSLionel SambucThe following functions are available:
6703e1db26aSLionel Sambuc.Bl -tag -width 4n
6713e1db26aSLionel Sambuc.It Fn history_init
6723e1db26aSLionel SambucInitialise the history list, and return a data structure
673*0a6a1f1dSLionel Sambucto be used by all other history list functions, or
674*0a6a1f1dSLionel Sambuc.Dv NULL
675*0a6a1f1dSLionel Sambucon failure.
6763e1db26aSLionel Sambuc.It Fn history_end
6773e1db26aSLionel SambucClean up and finish with
6783e1db26aSLionel Sambuc.Fa h ,
6793e1db26aSLionel Sambucassumed to have been created with
6803e1db26aSLionel Sambuc.Fn history_init .
6813e1db26aSLionel Sambuc.It Fn history
6823e1db26aSLionel SambucPerform operation
6833e1db26aSLionel Sambuc.Fa op
6843e1db26aSLionel Sambucon the history list, with optional arguments as needed by the
6853e1db26aSLionel Sambucoperation.
6863e1db26aSLionel Sambuc.Fa ev
6873e1db26aSLionel Sambucis changed accordingly to operation.
6883e1db26aSLionel SambucThe following values for
6893e1db26aSLionel Sambuc.Fa op
6903e1db26aSLionel Sambucare supported, along with the required argument list:
6913e1db26aSLionel Sambuc.Bl -tag -width 4n
6923e1db26aSLionel Sambuc.It Dv H_SETSIZE , Fa "int size"
6933e1db26aSLionel SambucSet size of history to
6943e1db26aSLionel Sambuc.Fa size
6953e1db26aSLionel Sambucelements.
6963e1db26aSLionel Sambuc.It Dv H_GETSIZE
6973e1db26aSLionel SambucGet number of events currently in history.
6983e1db26aSLionel Sambuc.It Dv H_END
6993e1db26aSLionel SambucCleans up and finishes with
7003e1db26aSLionel Sambuc.Fa h ,
7013e1db26aSLionel Sambucassumed to be created with
7023e1db26aSLionel Sambuc.Fn history_init .
7033e1db26aSLionel Sambuc.It Dv H_CLEAR
7043e1db26aSLionel SambucClear the history.
7053e1db26aSLionel Sambuc.It Dv H_FUNC , Fa "void *ptr" , Fa "history_gfun_t first" , \
7063e1db26aSLionel SambucFa "history_gfun_t next" , Fa "history_gfun_t last" , \
7073e1db26aSLionel SambucFa "history_gfun_t prev" , Fa "history_gfun_t curr" , \
7083e1db26aSLionel SambucFa "history_sfun_t set" , Fa "history_vfun_t clear" , \
7093e1db26aSLionel SambucFa "history_efun_t enter" , Fa "history_efun_t add"
7103e1db26aSLionel SambucDefine functions to perform various history operations.
7113e1db26aSLionel Sambuc.Fa ptr
7123e1db26aSLionel Sambucis the argument given to a function when it's invoked.
7133e1db26aSLionel Sambuc.It Dv H_FIRST
7143e1db26aSLionel SambucReturn the first element in the history.
7153e1db26aSLionel Sambuc.It Dv H_LAST
7163e1db26aSLionel SambucReturn the last element in the history.
7173e1db26aSLionel Sambuc.It Dv H_PREV
7183e1db26aSLionel SambucReturn the previous element in the history.
7193e1db26aSLionel Sambuc.It Dv H_NEXT
7203e1db26aSLionel SambucReturn the next element in the history.
7213e1db26aSLionel Sambuc.It Dv H_CURR
7223e1db26aSLionel SambucReturn the current element in the history.
7233e1db26aSLionel Sambuc.It Dv H_SET
7243e1db26aSLionel SambucSet the cursor to point to the requested element.
7253e1db26aSLionel Sambuc.It Dv H_ADD , Fa "const char *str"
7263e1db26aSLionel SambucAppend
7273e1db26aSLionel Sambuc.Fa str
7283e1db26aSLionel Sambucto the current element of the history, or perform the
7293e1db26aSLionel Sambuc.Dv H_ENTER
7303e1db26aSLionel Sambucoperation with argument
7313e1db26aSLionel Sambuc.Fa str
7323e1db26aSLionel Sambucif there is no current element.
7333e1db26aSLionel Sambuc.It Dv H_APPEND , Fa "const char *str"
7343e1db26aSLionel SambucAppend
7353e1db26aSLionel Sambuc.Fa str
7363e1db26aSLionel Sambucto the last new element of the history.
7373e1db26aSLionel Sambuc.It Dv H_ENTER , Fa "const char *str"
7383e1db26aSLionel SambucAdd
7393e1db26aSLionel Sambuc.Fa str
7403e1db26aSLionel Sambucas a new element to the history, and, if necessary,
7413e1db26aSLionel Sambucremoving the oldest entry to keep the list to the created size.
7423e1db26aSLionel SambucIf
7433e1db26aSLionel Sambuc.Dv H_SETUNIQUE
744*0a6a1f1dSLionel Sambuchas been called with a non-zero argument, the element
7453e1db26aSLionel Sambucwill not be entered into the history if its contents match
7463e1db26aSLionel Sambucthe ones of the current history element.
7473e1db26aSLionel SambucIf the element is entered
7483e1db26aSLionel Sambuc.Fn history
749*0a6a1f1dSLionel Sambucreturns 1; if it is ignored as a duplicate returns 0.
7503e1db26aSLionel SambucFinally
7513e1db26aSLionel Sambuc.Fn history
7523e1db26aSLionel Sambucreturns \-1 if an error occurred.
7533e1db26aSLionel Sambuc.It Dv H_PREV_STR , Fa "const char *str"
7543e1db26aSLionel SambucReturn the closest previous event that starts with
7553e1db26aSLionel Sambuc.Fa str .
7563e1db26aSLionel Sambuc.It Dv H_NEXT_STR , Fa "const char *str"
7573e1db26aSLionel SambucReturn the closest next event that starts with
7583e1db26aSLionel Sambuc.Fa str .
7593e1db26aSLionel Sambuc.It Dv H_PREV_EVENT , Fa "int e"
7603e1db26aSLionel SambucReturn the previous event numbered
7613e1db26aSLionel Sambuc.Fa e .
7623e1db26aSLionel Sambuc.It Dv H_NEXT_EVENT , Fa "int e"
7633e1db26aSLionel SambucReturn the next event numbered
7643e1db26aSLionel Sambuc.Fa e .
7653e1db26aSLionel Sambuc.It Dv H_LOAD , Fa "const char *file"
7663e1db26aSLionel SambucLoad the history list stored in
7673e1db26aSLionel Sambuc.Fa file .
7683e1db26aSLionel Sambuc.It Dv H_SAVE , Fa "const char *file"
7693e1db26aSLionel SambucSave the history list to
7703e1db26aSLionel Sambuc.Fa file .
771*0a6a1f1dSLionel Sambuc.It Dv H_SAVE_FP , Fa "FILE *fp"
772*0a6a1f1dSLionel SambucSave the history list to the opened
773*0a6a1f1dSLionel Sambuc.Ft FILE
774*0a6a1f1dSLionel Sambucpointer
775*0a6a1f1dSLionel Sambuc.Fa fp .
7763e1db26aSLionel Sambuc.It Dv H_SETUNIQUE , Fa "int unique"
7773e1db26aSLionel SambucSet flag that adjacent identical event strings should not be entered
7783e1db26aSLionel Sambucinto the history.
7793e1db26aSLionel Sambuc.It Dv H_GETUNIQUE
7803e1db26aSLionel SambucRetrieve the current setting if adjacent identical elements should
7813e1db26aSLionel Sambucbe entered into the history.
7823e1db26aSLionel Sambuc.It Dv H_DEL , Fa "int e"
7833e1db26aSLionel SambucDelete the event numbered
7843e1db26aSLionel Sambuc.Fa e .
7853e1db26aSLionel SambucThis function is only provided for
7863e1db26aSLionel Sambuc.Xr readline 3
7873e1db26aSLionel Sambuccompatibility.
7883e1db26aSLionel SambucThe caller is responsible for free'ing the string in the returned
7893e1db26aSLionel Sambuc.Fa HistEvent .
7903e1db26aSLionel Sambuc.El
7913e1db26aSLionel Sambuc.Pp
7923e1db26aSLionel Sambuc.Fn history
7933e1db26aSLionel Sambucreturns \*[Gt]= 0 if the operation
7943e1db26aSLionel Sambuc.Fa op
7953e1db26aSLionel Sambucsucceeds.
7963e1db26aSLionel SambucOtherwise, \-1 is returned and
7973e1db26aSLionel Sambuc.Fa ev
7983e1db26aSLionel Sambucis updated to contain more details about the error.
7993e1db26aSLionel Sambuc.El
8003e1db26aSLionel Sambuc.Sh TOKENIZATION FUNCTIONS
8013e1db26aSLionel SambucThe tokenization functions use a common data structure,
8023e1db26aSLionel Sambuc.Fa Tokenizer ,
8033e1db26aSLionel Sambucwhich is created by
8043e1db26aSLionel Sambuc.Fn tok_init
8053e1db26aSLionel Sambucand freed by
8063e1db26aSLionel Sambuc.Fn tok_end .
8073e1db26aSLionel Sambuc.Pp
8083e1db26aSLionel SambucThe following functions are available:
8093e1db26aSLionel Sambuc.Bl -tag -width 4n
8103e1db26aSLionel Sambuc.It Fn tok_init
8113e1db26aSLionel SambucInitialise the tokenizer, and return a data structure
8123e1db26aSLionel Sambucto be used by all other tokenizer functions.
8133e1db26aSLionel Sambuc.Fa IFS
8143e1db26aSLionel Sambuccontains the Input Field Separators, which defaults to
8153e1db26aSLionel Sambuc.Aq space ,
8163e1db26aSLionel Sambuc.Aq tab ,
8173e1db26aSLionel Sambucand
8183e1db26aSLionel Sambuc.Aq newline
8193e1db26aSLionel Sambucif
8203e1db26aSLionel Sambuc.Dv NULL .
8213e1db26aSLionel Sambuc.It Fn tok_end
8223e1db26aSLionel SambucClean up and finish with
8233e1db26aSLionel Sambuc.Fa t ,
8243e1db26aSLionel Sambucassumed to have been created with
8253e1db26aSLionel Sambuc.Fn tok_init .
8263e1db26aSLionel Sambuc.It Fn tok_reset
8273e1db26aSLionel SambucReset the tokenizer state.
8283e1db26aSLionel SambucUse after a line has been successfully tokenized
8293e1db26aSLionel Sambucby
8303e1db26aSLionel Sambuc.Fn tok_line
8313e1db26aSLionel Sambucor
8323e1db26aSLionel Sambuc.Fn tok_str
8333e1db26aSLionel Sambucand before a new line is to be tokenized.
8343e1db26aSLionel Sambuc.It Fn tok_line
8353e1db26aSLionel SambucTokenize
8363e1db26aSLionel Sambuc.Fa li ,
8373e1db26aSLionel SambucIf successful, modify:
8383e1db26aSLionel Sambuc.Fa argv
8393e1db26aSLionel Sambucto contain the words,
8403e1db26aSLionel Sambuc.Fa argc
8413e1db26aSLionel Sambucto contain the number of words,
8423e1db26aSLionel Sambuc.Fa cursorc
8433e1db26aSLionel Sambuc(if not
8443e1db26aSLionel Sambuc.Dv NULL )
8453e1db26aSLionel Sambucto contain the index of the word containing the cursor,
8463e1db26aSLionel Sambucand
8473e1db26aSLionel Sambuc.Fa cursoro
8483e1db26aSLionel Sambuc(if not
8493e1db26aSLionel Sambuc.Dv NULL )
8503e1db26aSLionel Sambucto contain the offset within
8513e1db26aSLionel Sambuc.Fa argv[cursorc]
8523e1db26aSLionel Sambucof the cursor.
8533e1db26aSLionel Sambuc.Pp
8543e1db26aSLionel SambucReturns
8553e1db26aSLionel Sambuc0 if successful,
8563e1db26aSLionel Sambuc\-1 for an internal error,
8573e1db26aSLionel Sambuc1 for an unmatched single quote,
8583e1db26aSLionel Sambuc2 for an unmatched double quote,
8593e1db26aSLionel Sambucand
8603e1db26aSLionel Sambuc3 for a backslash quoted
8613e1db26aSLionel Sambuc.Aq newline .
8623e1db26aSLionel SambucA positive exit code indicates that another line should be read
8633e1db26aSLionel Sambucand tokenization attempted again.
8643e1db26aSLionel Sambuc.
8653e1db26aSLionel Sambuc.It Fn tok_str
8663e1db26aSLionel SambucA simpler form of
8673e1db26aSLionel Sambuc.Fn tok_line ;
8683e1db26aSLionel Sambuc.Fa str
8693e1db26aSLionel Sambucis a NUL terminated string to tokenize.
8703e1db26aSLionel Sambuc.El
8713e1db26aSLionel Sambuc.
8723e1db26aSLionel Sambuc.\"XXX.Sh EXAMPLES
8733e1db26aSLionel Sambuc.\"XXX: provide some examples
8743e1db26aSLionel Sambuc.Sh SEE ALSO
8753e1db26aSLionel Sambuc.Xr sh 1 ,
8763e1db26aSLionel Sambuc.Xr signal 3 ,
8773e1db26aSLionel Sambuc.Xr termcap 3 ,
8783e1db26aSLionel Sambuc.Xr editrc 5 ,
8793e1db26aSLionel Sambuc.Xr termcap 5
8803e1db26aSLionel Sambuc.Sh HISTORY
8813e1db26aSLionel SambucThe
8823e1db26aSLionel Sambuc.Nm
8833e1db26aSLionel Sambuclibrary first appeared in
8843e1db26aSLionel Sambuc.Bx 4.4 .
8853e1db26aSLionel Sambuc.Dv CC_REDISPLAY
8863e1db26aSLionel Sambucappeared in
8873e1db26aSLionel Sambuc.Nx 1.3 .
8883e1db26aSLionel Sambuc.Dv CC_REFRESH_BEEP ,
8893e1db26aSLionel Sambuc.Dv EL_EDITMODE
8903e1db26aSLionel Sambucand the readline emulation appeared in
8913e1db26aSLionel Sambuc.Nx 1.4 .
8923e1db26aSLionel Sambuc.Dv EL_RPROMPT
8933e1db26aSLionel Sambucappeared in
8943e1db26aSLionel Sambuc.Nx 1.5 .
8953e1db26aSLionel Sambuc.Sh AUTHORS
896*0a6a1f1dSLionel Sambuc.An -nosplit
8973e1db26aSLionel SambucThe
8983e1db26aSLionel Sambuc.Nm
899*0a6a1f1dSLionel Sambuclibrary was written by
900*0a6a1f1dSLionel Sambuc.An Christos Zoulas .
901*0a6a1f1dSLionel Sambuc.An Luke Mewburn
902*0a6a1f1dSLionel Sambucwrote this manual and implemented
9033e1db26aSLionel Sambuc.Dv CC_REDISPLAY ,
9043e1db26aSLionel Sambuc.Dv CC_REFRESH_BEEP ,
9053e1db26aSLionel Sambuc.Dv EL_EDITMODE ,
9063e1db26aSLionel Sambucand
9073e1db26aSLionel Sambuc.Dv EL_RPROMPT .
908*0a6a1f1dSLionel Sambuc.An Jaromir Dolecek
909*0a6a1f1dSLionel Sambucimplemented the readline emulation.
910*0a6a1f1dSLionel Sambuc.An Johny Mattsson
911*0a6a1f1dSLionel Sambucimplemented wide-character support.
9123e1db26aSLionel Sambuc.Sh BUGS
9133e1db26aSLionel SambucAt this time, it is the responsibility of the caller to
9143e1db26aSLionel Sambuccheck the result of the
9153e1db26aSLionel Sambuc.Dv EL_EDITMODE
9163e1db26aSLionel Sambucoperation of
9173e1db26aSLionel Sambuc.Fn el_get
9183e1db26aSLionel Sambuc(after an
9193e1db26aSLionel Sambuc.Fn el_source
9203e1db26aSLionel Sambucor
9213e1db26aSLionel Sambuc.Fn el_parse )
9223e1db26aSLionel Sambucto determine if
9233e1db26aSLionel Sambuc.Nm
9243e1db26aSLionel Sambucshould be used for further input.
9253e1db26aSLionel SambucI.e.,
9263e1db26aSLionel Sambuc.Dv EL_EDITMODE
9273e1db26aSLionel Sambucis purely an indication of the result of the most recent
9283e1db26aSLionel Sambuc.Xr editrc 5
9293e1db26aSLionel Sambuc.Ic edit
9303e1db26aSLionel Sambuccommand.
931