Deleted Added
sdiff udiff text old ( 141851 ) new ( 148834 )
full compact
1.\" $NetBSD: editline.3,v 1.20 2000/02/28 17:41:05 chopps Exp $
2.\"
3.\" Copyright (c) 1997-1999 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This file was contributed to The NetBSD Foundation by Luke Mewburn.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright

--- 16 unchanged lines hidden (view full) ---

28.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34.\" POSSIBILITY OF SUCH DAMAGE.
35.\"
36.\" $FreeBSD: head/lib/libedit/editline.3 141851 2005-02-13 23:45:54Z ru $
37.\"
38.Dd November 12, 1999
39.Os
40.Dt EDITLINE 3
41.Sh NAME
42.Nm editline ,
43.Nm el_init ,
44.Nm el_end ,
45.Nm el_reset ,
46.Nm el_gets ,
47.Nm el_getc ,
48.Nm el_push ,
49.Nm el_parse ,
50.Nm el_set ,
51.Nm el_source ,
52.Nm el_resize ,
53.Nm el_line ,
54.Nm el_insertstr ,
55.Nm el_deletestr ,
56.Nm history_init ,
57.Nm history_end ,
58.Nm history
59.Nd line editor and history functions
60.Sh LIBRARY
61.Lb libedit
62.Sh SYNOPSIS
63.In histedit.h
64.Ft EditLine *
65.Fn el_init "const char *prog" "FILE *fin" "FILE *fout" "FILE *ferr"
66.Ft void
67.Fn el_end "EditLine *e"
68.Ft void
69.Fn el_reset "EditLine *e"
70.Ft const char *
71.Fn el_gets "EditLine *e" "int *count"
72.Ft int
73.Fn el_getc "EditLine *e" "char *ch"
74.Ft void
75.Fn el_push "EditLine *e" "const char *str"
76.Ft int
77.Fn el_parse "EditLine *e" "int argc" "char *argv[]"
78.Ft int
79.Fn el_set "EditLine *e" "int op" "..."
80.Ft int
81.Fn el_get "EditLine *e" "int op" "void *result"
82.Ft int
83.Fn el_source "EditLine *e" "const char *file"
84.Ft void
85.Fn el_resize "EditLine *e"

--- 4 unchanged lines hidden (view full) ---

90.Ft void
91.Fn el_deletestr "EditLine *e" "int count"
92.Ft History *
93.Fn history_init
94.Ft void
95.Fn history_end "History *h"
96.Ft int
97.Fn history "History *h" "HistEvent *ev" "int op" "..."
98.Sh DESCRIPTION
99The
100.Nm
101library provides generic line editing and history functions,
102similar to those found in
103.Xr sh 1 .
104.Pp
105These functions are available in the
106.Nm libedit
107library (which needs the
108.Nm libtermcap
109library).

--- 39 unchanged lines hidden (view full) ---

149is modified to contain the number of characters read.
150Returns the line read if successful, or
151.Dv NULL
152if no characters were read or if an error occurred.
153.It Fn el_getc
154Read a character from the tty.
155.Fa ch
156is modified to contain the character read.
157Returns the number of characters read if successful, -1 otherwise.
158.It Fn el_push
159Pushes
160.Fa str
161back onto the input stream.
162This is used by the macro expansion mechanism.
163Refer to the description of
164.Ic bind
165.Fl s

--- 5 unchanged lines hidden (view full) ---

171.Fa argv
172array (which is
173.Fa argc
174elements in size)
175to execute builtin
176.Nm
177commands.
178If the command is prefixed with
179.Dq prog:
180then
181.Fn el_parse
182will only execute the command if
183.Dq prog
184matches the
185.Fa prog
186argument supplied to
187.Fn el_init .
188The return value is
189-1 if the command is unknown,
1900 if there was no error or
191.Dq prog
192did not match, or
1931 if the command returned an error.
194Refer to
195.Xr editrc 5
196for more information.
197.It Fn el_set

--- 102 unchanged lines hidden (view full) ---

300.Ic telltc
301builtin command.
302Refer to
303.Xr editrc 5
304for more information.
305.It Dv EL_ADDFN , Xo
306.Fa "const char *name" ,
307.Fa "const char *help" ,
308.Fa "unsigned char (*func)(EditLine *e, int ch)
309.Xc
310Add a user defined function,
311.Fn func ,
312referred to as
313.Fa name
314which is invoked when a key which is bound to
315.Fa name
316is entered.

--- 48 unchanged lines hidden (view full) ---

365Note that this is only an indication, and does not
366affect the operation of
367.Nm .
368At this time, it is the caller's responsibility to
369check this
370(using
371.Fn el_get )
372to determine if editing should be enabled or not.
373.El
374.It Fn el_get
375Get
376.Nm
377parameters.
378.Fa op
379determines which parameter to retrieve into
380.Fa result .
381.Pp
382The following values for
383.Fa op
384are supported, along with actual type of
385.Fa result :
386.Bl -tag -width 4n
387.It Dv EL_PROMPT , Fa "char *(*f)(EditLine *)"
388Return a pointer to the function that displays the prompt.

--- 7 unchanged lines hidden (view full) ---

396.It Dv EL_SIGNAL , Fa "int *"
397Return non-zero if
398.Nm
399has installed private signal handlers (see
400.Fn el_get
401above).
402.It Dv EL_EDITMODE, Fa "int *"
403Return non-zero if editing is enabled.
404.El
405.It Fn el_source
406Initialise
407.Nm
408by reading the contents of
409.Fa file .
410.Fn el_parse
411is called for each line in

--- 26 unchanged lines hidden (view full) ---

438structure, which is defined as follows:
439.Bd -literal
440typedef struct lineinfo {
441 const char *buffer; /* address of buffer */
442 const char *cursor; /* address of cursor */
443 const char *lastchar; /* address of last character */
444} LineInfo;
445.Ed
446.It Fn el_insertstr
447Insert
448.Fa str
449into the line at the cursor.
450Returns -1 if
451.Fa str
452is empty or will not fit, and 0 otherwise.
453.It Fn el_deletestr
454Delete
455.Fa num
456characters before the cursor.
457.El
458.Sh HISTORY LIST FUNCTIONS

--- 63 unchanged lines hidden (view full) ---

522Return the next element in the history.
523.It Dv H_CURR
524Return the current element in the history.
525.It Dv H_SET
526Set the cursor to point to the requested element.
527.It Dv H_ADD , Fa "const char *str"
528Append
529.Fa str
530to the current element of the history, or create an element with
531.It Dv H_APPEND , Fa "const char *str"
532Append
533.Fa str
534to the last new element of the history.
535.It Dv H_ENTER , Fa "const char *str"
536Add
537.Fa str
538as a new element to the history, and, if necessary,
539removing the oldest entry to keep the list to the created size.
540.It Dv H_PREV_STR , Fa "const char *str"
541Return the closest previous event that starts with
542.Fa str .
543.It Dv H_NEXT_STR , Fa "const char *str"
544Return the closest next event that starts with
545.Fa str .
546.It Dv H_PREV_EVENT , Fa "int e"
547Return the previous event numbered
548.Fa e .
549.It Dv H_NEXT_EVENT , Fa "int e"
550Return the next event numbered
551.Fa e .
552.It Dv H_LOAD , Fa "const char *file"
553Load the history list stored in
554.Fa file .
555.It Dv H_SAVE , Fa "const char *file"
556Save the history list to
557.Fa file .
558.El
559.Pp
560The
561.Fn history
562function returns 0 if the operation
563.Fa op
564succeeds.
565Otherwise, \-1 is returned and
566.Fa ev
567is updated to contain more details about the error.
568.El
569.\"XXX.Sh EXAMPLES
570.\"XXX: provide some examples
571.Sh SEE ALSO
572.Xr sh 1 ,
573.Xr signal 3 ,
574.Xr termcap 3 ,
575.Xr editrc 5
576.Sh HISTORY

--- 21 unchanged lines hidden (view full) ---

598.An Luke Mewburn
599wrote this manual and implemented
600.Dv CC_REDISPLAY ,
601.Dv CC_REFRESH_BEEP ,
602.Dv EL_EDITMODE ,
603and
604.Dv EL_RPROMPT .
605.Sh BUGS
606The tokenization functions are not publically defined in
607.In histedit.h .
608.Pp
609At this time, it is the responsibility of the caller to
610check the result of the
611.Dv EL_EDITMODE
612operation of
613.Fn el_get
614(after an
615.Fn el_source
616or
617.Fn el_parse )
618to determine if
619.Nm
620should be used for further input.
621I.e.,
622.Dv EL_EDITMODE
623is purely an indication of the result of the most recent
624.Xr editrc 5
625.Ic edit
626command.