]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - lib/libedit/editline.3
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / lib / libedit / editline.3
1 .\"     $NetBSD: editline.3,v 1.70 2009/07/05 21:55:24 perry Exp $
2 .\"
3 .\" Copyright (c) 1997-2003 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
12 .\"    notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\"    notice, this list of conditions and the following disclaimer in the
15 .\"    documentation and/or other materials provided with the distribution.
16 .\"
17 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 .\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 .\" POSSIBILITY OF SUCH DAMAGE.
28 .\"
29 .\" $FreeBSD$
30 .\"
31 .Dd July 5, 2009
32 .Dt EDITLINE 3
33 .Os
34 .Sh NAME
35 .Nm editline ,
36 .Nm el_init ,
37 .Nm el_end ,
38 .Nm el_reset ,
39 .Nm el_gets ,
40 .Nm el_getc ,
41 .Nm el_push ,
42 .Nm el_parse ,
43 .Nm el_set ,
44 .Nm el_get ,
45 .Nm el_source ,
46 .Nm el_resize ,
47 .Nm el_line ,
48 .Nm el_insertstr ,
49 .Nm el_deletestr ,
50 .Nm history_init ,
51 .Nm history_end ,
52 .Nm history ,
53 .Nm tok_init ,
54 .Nm tok_end ,
55 .Nm tok_reset ,
56 .Nm tok_line ,
57 .Nm tok_str
58 .Nd line editor, history and tokenization functions
59 .Sh LIBRARY
60 .Lb libedit
61 .Sh SYNOPSIS
62 .In histedit.h
63 .Ft EditLine *
64 .Fn el_init "const char *prog" "FILE *fin" "FILE *fout" "FILE *ferr"
65 .Ft void
66 .Fn el_end "EditLine *e"
67 .Ft void
68 .Fn el_reset "EditLine *e"
69 .Ft const char *
70 .Fn el_gets "EditLine *e" "int *count"
71 .Ft int
72 .Fn el_getc "EditLine *e" "char *ch"
73 .Ft void
74 .Fn el_push "EditLine *e" "char *str"
75 .Ft int
76 .Fn el_parse "EditLine *e" "int argc" "const char *argv[]"
77 .Ft int
78 .Fn el_set "EditLine *e" "int op" "..."
79 .Ft int
80 .Fn el_get "EditLine *e" "int op" "..."
81 .Ft int
82 .Fn el_source "EditLine *e" "const char *file"
83 .Ft void
84 .Fn el_resize "EditLine *e"
85 .Ft const LineInfo *
86 .Fn el_line "EditLine *e"
87 .Ft int
88 .Fn el_insertstr "EditLine *e" "const char *str"
89 .Ft void
90 .Fn el_deletestr "EditLine *e" "int count"
91 .Ft History *
92 .Fn history_init
93 .Ft void
94 .Fn history_end "History *h"
95 .Ft int
96 .Fn history "History *h" "HistEvent *ev" "int op" "..."
97 .Ft Tokenizer *
98 .Fn tok_init "const char *IFS"
99 .Ft void
100 .Fn tok_end "Tokenizer *t"
101 .Ft void
102 .Fn tok_reset "Tokenizer *t"
103 .Ft int
104 .Fo tok_line
105 .Fa "Tokenizer *t" "const LineInfo *li" "int *argc" "const char **argv[]"
106 .Fa "int *cursorc" "int *cursoro"
107 .Fc
108 .Ft int
109 .Fn tok_str "Tokenizer *t" "const char *str" "int *argc" "const char **argv[]"
110 .Sh DESCRIPTION
111 The
112 .Nm
113 library provides generic line editing, history and tokenization functions,
114 similar to those found in
115 .Xr sh 1 .
116 .Pp
117 These functions are available in the
118 .Nm libedit
119 library (which needs the
120 .Nm libtermcap
121 library).
122 Programs should be linked with
123 .Fl ledit ltermcap .
124 .Sh LINE EDITING FUNCTIONS
125 The line editing functions use a common data structure,
126 .Fa EditLine ,
127 which is created by
128 .Fn el_init
129 and freed by
130 .Fn el_end .
131 .Pp
132 The following functions are available:
133 .Bl -tag -width 4n
134 .It Fn el_init
135 Initialise the line editor, and return a data structure
136 to be used by all other line editing functions.
137 .Fa prog
138 is the name of the invoking program, used when reading the
139 .Xr editrc 5
140 file to determine which settings to use.
141 .Fa fin ,
142 .Fa fout
143 and
144 .Fa ferr
145 are the input, output, and error streams (respectively) to use.
146 In this documentation, references to
147 .Dq the tty
148 are actually to this input/output stream combination.
149 .It Fn el_end
150 Clean up and finish with
151 .Fa e ,
152 assumed to have been created with
153 .Fn el_init .
154 .It Fn el_reset
155 Reset the tty and the parser.
156 This should be called after an error which may have upset the tty's
157 state.
158 .It Fn el_gets
159 Read a line from the tty.
160 .Fa count
161 is modified to contain the number of characters read.
162 Returns the line read if successful, or
163 .Dv NULL
164 if no characters were read or if an error occurred.
165 If an error occurred,
166 .Fa count
167 is set to \-1 and
168 .Dv errno
169 contains the error code that caused it.
170 The return value may not remain valid across calls to
171 .Fn el_gets
172 and must be copied if the data is to be retained.
173 .It Fn el_getc
174 Read a character from the tty.
175 .Fa ch
176 is modified to contain the character read.
177 Returns the number of characters read if successful, \-1 otherwise.
178 .It Fn el_push
179 Pushes
180 .Fa str
181 back onto the input stream.
182 This is used by the macro expansion mechanism.
183 Refer to the description of
184 .Ic bind
185 .Fl s
186 in
187 .Xr editrc 5
188 for more information.
189 .It Fn el_parse
190 Parses the
191 .Fa argv
192 array (which is
193 .Fa argc
194 elements in size)
195 to execute builtin
196 .Nm
197 commands.
198 If the command is prefixed with
199 .Dq prog:
200 then
201 .Fn el_parse
202 will only execute the command if
203 .Dq prog
204 matches the
205 .Fa prog
206 argument supplied to
207 .Fn el_init .
208 The return value is
209 \-1 if the command is unknown,
210 0 if there was no error or
211 .Dq prog
212 did not match, or
213 1 if the command returned an error.
214 Refer to
215 .Xr editrc 5
216 for more information.
217 .It Fn el_set
218 Set
219 .Nm
220 parameters.
221 .Fa op
222 determines which parameter to set, and each operation has its
223 own parameter list.
224 .Pp
225 The following values for
226 .Fa op
227 are supported, along with the required argument list:
228 .Bl -tag -width 4n
229 .It Dv EL_PROMPT , Fa "char *(*f)(EditLine *)"
230 Define prompt printing function as
231 .Fa f ,
232 which is to return a string that contains the prompt.
233 .It Dv EL_PROMPT_ESC , Fa "char *(*f)(EditLine *)" , Fa "char c"
234 Same as
235 .Dv EL_PROMPT ,
236 but the
237 .Fa c
238 argument indicates the start/stop literal prompt character.
239 .Pp
240 If a start/stop literal character is found in the prompt, the
241 character itself
242 is not printed, but characters after it are printed directly to the
243 terminal without affecting the state of the current line.
244 A subsequent second start/stop literal character ends this behavior.
245 This is typically used to embed literal escape sequences that change the
246 color/style of the terminal in the prompt.
247 .Dv 0
248 unsets it.
249 .It Dv EL_REFRESH
250 Re-display the current line on the next terminal line.
251 .It Dv EL_RPROMPT , Fa "char *(*f)(EditLine *)"
252 Define right side prompt printing function as
253 .Fa f ,
254 which is to return a string that contains the prompt.
255 .It Dv EL_RPROMPT_ESC , Fa "char *(*f)(EditLine *)" , Fa "char c"
256 Define the right prompt printing function but with a literal escape character.
257 .It Dv EL_TERMINAL , Fa "const char *type"
258 Define terminal type of the tty to be
259 .Fa type ,
260 or to
261 .Ev TERM
262 if
263 .Fa type
264 is
265 .Dv NULL .
266 .It Dv EL_EDITOR , Fa "const char *mode"
267 Set editing mode to
268 .Fa mode ,
269 which must be one of
270 .Dq emacs
271 or
272 .Dq vi .
273 .It Dv EL_SIGNAL , Fa "int flag"
274 If
275 .Fa flag
276 is non-zero,
277 .Nm
278 will install its own signal handler for the following signals when
279 reading command input:
280 .Dv SIGCONT ,
281 .Dv SIGHUP ,
282 .Dv SIGINT ,
283 .Dv SIGQUIT ,
284 .Dv SIGSTOP ,
285 .Dv SIGTERM ,
286 .Dv SIGTSTP ,
287 and
288 .Dv SIGWINCH .
289 Otherwise, the current signal handlers will be used.
290 .It Dv EL_BIND , Fa "const char *" , Fa "..." , Dv NULL
291 Perform the
292 .Ic bind
293 builtin command.
294 Refer to
295 .Xr editrc 5
296 for more information.
297 .It Dv EL_ECHOTC , Fa "const char *" , Fa "..." , Dv NULL
298 Perform the
299 .Ic echotc
300 builtin command.
301 Refer to
302 .Xr editrc 5
303 for more information.
304 .It Dv EL_SETTC , Fa "const char *" , Fa "..." , Dv NULL
305 Perform the
306 .Ic settc
307 builtin command.
308 Refer to
309 .Xr editrc 5
310 for more information.
311 .It Dv EL_SETTY , Fa "const char *" , Fa "..." , Dv NULL
312 Perform the
313 .Ic setty
314 builtin command.
315 Refer to
316 .Xr editrc 5
317 for more information.
318 .It Dv EL_TELLTC , Fa "const char *" , Fa "..." , Dv NULL
319 Perform the
320 .Ic telltc
321 builtin command.
322 Refer to
323 .Xr editrc 5
324 for more information.
325 .It Dv EL_ADDFN , Fa "const char *name" , Fa "const char *help" , \
326 Fa "unsigned char (*func)(EditLine *e, int ch)"
327 Add a user defined function,
328 .Fn func ,
329 referred to as
330 .Fa name
331 which is invoked when a key which is bound to
332 .Fa name
333 is entered.
334 .Fa help
335 is a description of
336 .Fa name .
337 At invocation time,
338 .Fa ch
339 is the key which caused the invocation.
340 The return value of
341 .Fn func
342 should be one of:
343 .Bl -tag -width "CC_REDISPLAY"
344 .It Dv CC_NORM
345 Add a normal character.
346 .It Dv CC_NEWLINE
347 End of line was entered.
348 .It Dv CC_EOF
349 EOF was entered.
350 .It Dv CC_ARGHACK
351 Expecting further command input as arguments, do nothing visually.
352 .It Dv CC_REFRESH
353 Refresh display.
354 .It Dv CC_REFRESH_BEEP
355 Refresh display, and beep.
356 .It Dv CC_CURSOR
357 Cursor moved, so update and perform
358 .Dv CC_REFRESH .
359 .It Dv CC_REDISPLAY
360 Redisplay entire input line.
361 This is useful if a key binding outputs extra information.
362 .It Dv CC_ERROR
363 An error occurred.
364 Beep, and flush tty.
365 .It Dv CC_FATAL
366 Fatal error, reset tty to known state.
367 .El
368 .It Dv EL_HIST , Fa "History *(*func)(History *, int op, ...)" , \
369 Fa "const char *ptr"
370 Defines which history function to use, which is usually
371 .Fn history .
372 .Fa ptr
373 should be the value returned by
374 .Fn history_init .
375 .It Dv EL_EDITMODE , Fa "int flag"
376 If
377 .Fa flag
378 is non-zero,
379 editing is enabled (the default).
380 Note that this is only an indication, and does not
381 affect the operation of
382 .Nm .
383 At this time, it is the caller's responsibility to
384 check this
385 (using
386 .Fn el_get )
387 to determine if editing should be enabled or not.
388 .It Dv EL_GETCFN , Fa "int (*f)(EditLine *, char *c)"
389 Define the character reading function as
390 .Fa f ,
391 which is to return the number of characters read and store them in
392 .Fa c .
393 This function is called internally by
394 .Fn el_gets
395 and
396 .Fn el_getc .
397 The builtin function can be set or restored with the special function
398 name
399 .Dv EL_BUILTIN_GETCFN .
400 .It Dv EL_CLIENTDATA , Fa "void *data"
401 Register
402 .Fa data
403 to be associated with this EditLine structure.
404 It can be retrieved with the corresponding
405 .Fn el_get
406 call.
407 .It Dv EL_SETFP , Fa "int fd" , Fa "FILE *fp"
408 Set the current
409 .Nm editline
410 file pointer for
411 .Dq input
412 .Fa fd
413 =
414 .Dv 0 ,
415 .Dq output
416 .Fa fd
417 =
418 .Dv 1 ,
419 or
420 .Dq error
421 .Fa fd
422 =
423 .Dv 2
424 from
425 .Fa fp .
426 .El
427 .It Fn el_get
428 Get
429 .Nm
430 parameters.
431 .Fa op
432 determines which parameter to retrieve into
433 .Fa result .
434 Returns 0 if successful, \-1 otherwise.
435 .Pp
436 The following values for
437 .Fa op
438 are supported, along with actual type of
439 .Fa result :
440 .Bl -tag -width 4n
441 .It Dv EL_PROMPT , Fa "char *(*f)(EditLine *)" , Fa "char *c"
442 Return a pointer to the function that displays the prompt in
443 .Fa f .
444 If
445 .Fa c
446 is not
447 .Dv NULL ,
448 return the start/stop literal prompt character in it.
449 .It Dv EL_RPROMPT , Fa "char *(*f)(EditLine *)" , Fa "char *c"
450 Return a pointer to the function that displays the prompt in
451 .Fa f .
452 If
453 .Fa c
454 is not
455 .Dv NULL ,
456 return the start/stop literal prompt character in it.
457 .It Dv EL_EDITOR , Fa "const char *"
458 Return the name of the editor, which will be one of
459 .Dq emacs
460 or
461 .Dq vi .
462 .It Dv EL_GETTC , Fa "const char *name" , Fa "void *value"
463 Return non-zero if
464 .Fa name
465 is a valid
466 .Xr termcap 5
467 capability
468 and set
469 .Fa value
470 to the current value of that capability.
471 .It Dv EL_SIGNAL , Fa "int *"
472 Return non-zero if
473 .Nm
474 has installed private signal handlers (see
475 .Fn el_get
476 above).
477 .It Dv EL_EDITMODE , Fa "int *"
478 Return non-zero if editing is enabled.
479 .It Dv EL_GETCFN , Fa "int (**f)(EditLine *, char *)"
480 Return a pointer to the function that read characters, which is equal to
481 .Dv EL_BUILTIN_GETCFN
482 in the case of the default builtin function.
483 .It Dv EL_CLIENTDATA , Fa "void **data"
484 Retrieve
485 .Fa data
486 previously registered with the corresponding
487 .Fn el_set
488 call.
489 .It Dv EL_UNBUFFERED , Fa "int"
490 Sets or clears unbuffered mode.
491 In this mode,
492 .Fn el_gets
493 will return immediately after processing a single character.
494 .It Dv EL_PREP_TERM , Fa "int"
495 Sets or clears terminal editing mode.
496 .It Dv EL_GETFP , Fa "int fd", Fa "FILE **fp"
497 Return in
498 .Fa fp
499 the current
500 .Nm editline
501 file pointer for
502 .Dq input
503 .Fa fd
504 =
505 .Dv 0 ,
506 .Dq output
507 .Fa fd
508 =
509 .Dv 1 ,
510 or
511 .Dq error
512 .Fa fd
513 =
514 .Dv 2 .
515 .El
516 .It Fn el_source
517 Initialise
518 .Nm
519 by reading the contents of
520 .Fa file .
521 .Fn el_parse
522 is called for each line in
523 .Fa file .
524 If
525 .Fa file
526 is
527 .Dv NULL ,
528 try
529 .Pa $PWD/.editrc
530 then
531 .Pa $HOME/.editrc .
532 Refer to
533 .Xr editrc 5
534 for details on the format of
535 .Fa file .
536 .It Fn el_resize
537 Must be called if the terminal size changes.
538 If
539 .Dv EL_SIGNAL
540 has been set with
541 .Fn el_set ,
542 then this is done automatically.
543 Otherwise, it is the responsibility of the application to call
544 .Fn el_resize
545 on the appropriate occasions.
546 .It Fn el_line
547 Return the editing information for the current line in a
548 .Fa LineInfo
549 structure, which is defined as follows:
550 .Bd -literal
551 typedef struct lineinfo {
552     const char *buffer;    /* address of buffer */
553     const char *cursor;    /* address of cursor */
554     const char *lastchar;  /* address of last character */
555 } LineInfo;
556 .Ed
557 .Pp
558 .Fa buffer
559 is not NUL terminated.
560 This function may be called after
561 .Fn el_gets
562 to obtain the
563 .Fa LineInfo
564 structure pertaining to line returned by that function,
565 and from within user defined functions added with
566 .Dv EL_ADDFN .
567 .It Fn el_insertstr
568 Insert
569 .Fa str
570 into the line at the cursor.
571 Returns \-1 if
572 .Fa str
573 is empty or will not fit, and 0 otherwise.
574 .It Fn el_deletestr
575 Delete
576 .Fa count
577 characters before the cursor.
578 .El
579 .Sh HISTORY LIST FUNCTIONS
580 The history functions use a common data structure,
581 .Fa History ,
582 which is created by
583 .Fn history_init
584 and freed by
585 .Fn history_end .
586 .Pp
587 The following functions are available:
588 .Bl -tag -width 4n
589 .It Fn history_init
590 Initialise the history list, and return a data structure
591 to be used by all other history list functions.
592 .It Fn history_end
593 Clean up and finish with
594 .Fa h ,
595 assumed to have been created with
596 .Fn history_init .
597 .It Fn history
598 Perform operation
599 .Fa op
600 on the history list, with optional arguments as needed by the
601 operation.
602 .Fa ev
603 is changed accordingly to operation.
604 The following values for
605 .Fa op
606 are supported, along with the required argument list:
607 .Bl -tag -width 4n
608 .It Dv H_SETSIZE , Fa "int size"
609 Set size of history to
610 .Fa size
611 elements.
612 .It Dv H_GETSIZE
613 Get number of events currently in history.
614 .It Dv H_END
615 Cleans up and finishes with
616 .Fa h ,
617 assumed to be created with
618 .Fn history_init .
619 .It Dv H_CLEAR
620 Clear the history.
621 .It Dv H_FUNC , Fa "void *ptr" , Fa "history_gfun_t first" , \
622 Fa "history_gfun_t next" , Fa "history_gfun_t last" , \
623 Fa "history_gfun_t prev" , Fa "history_gfun_t curr" , \
624 Fa "history_sfun_t set" , Fa "history_vfun_t clear" , \
625 Fa "history_efun_t enter" , Fa "history_efun_t add"
626 Define functions to perform various history operations.
627 .Fa ptr
628 is the argument given to a function when it is invoked.
629 .It Dv H_FIRST
630 Return the first element in the history.
631 .It Dv H_LAST
632 Return the last element in the history.
633 .It Dv H_PREV
634 Return the previous element in the history.
635 .It Dv H_NEXT
636 Return the next element in the history.
637 .It Dv H_CURR
638 Return the current element in the history.
639 .It Dv H_SET
640 Set the cursor to point to the requested element.
641 .It Dv H_ADD , Fa "const char *str"
642 Append
643 .Fa str
644 to the current element of the history, or perform the
645 .Dv H_ENTER
646 operation with argument
647 .Fa str
648 if there is no current element.
649 .It Dv H_APPEND , Fa "const char *str"
650 Append
651 .Fa str
652 to the last new element of the history.
653 .It Dv H_ENTER , Fa "const char *str"
654 Add
655 .Fa str
656 as a new element to the history, and, if necessary,
657 removing the oldest entry to keep the list to the created size.
658 If
659 .Dv H_SETUNIQUE
660 was has been called with a non-zero arguments, the element
661 will not be entered into the history if its contents match
662 the ones of the current history element.
663 If the element is entered
664 .Fn history
665 returns 1, if it is ignored as a duplicate returns 0.
666 Finally
667 .Fn history
668 returns \-1 if an error occurred.
669 .It Dv H_PREV_STR , Fa "const char *str"
670 Return the closest previous event that starts with
671 .Fa str .
672 .It Dv H_NEXT_STR , Fa "const char *str"
673 Return the closest next event that starts with
674 .Fa str .
675 .It Dv H_PREV_EVENT , Fa "int e"
676 Return the previous event numbered
677 .Fa e .
678 .It Dv H_NEXT_EVENT , Fa "int e"
679 Return the next event numbered
680 .Fa e .
681 .It Dv H_LOAD , Fa "const char *file"
682 Load the history list stored in
683 .Fa file .
684 .It Dv H_SAVE , Fa "const char *file"
685 Save the history list to
686 .Fa file .
687 .It Dv H_SETUNIQUE , Fa "int unique"
688 Set flag that adjacent identical event strings should not be entered
689 into the history.
690 .It Dv H_GETUNIQUE
691 Retrieve the current setting if adjacent identical elements should
692 be entered into the history.
693 .It Dv H_DEL , Fa "int e"
694 Delete the event numbered
695 .Fa e .
696 This function is only provided for
697 .Xr readline 3
698 compatibility.
699 The caller is responsible for free'ing the string in the returned
700 .Fa HistEvent .
701 .El
702 .Pp
703 The
704 .Fn history
705 function returns \*[Ge] 0 if the operation
706 .Fa op
707 succeeds.
708 Otherwise, \-1 is returned and
709 .Fa ev
710 is updated to contain more details about the error.
711 .El
712 .Sh TOKENIZATION FUNCTIONS
713 The tokenization functions use a common data structure,
714 .Fa Tokenizer ,
715 which is created by
716 .Fn tok_init
717 and freed by
718 .Fn tok_end .
719 .Pp
720 The following functions are available:
721 .Bl -tag -width 4n
722 .It Fn tok_init
723 Initialise the tokenizer, and return a data structure
724 to be used by all other tokenizer functions.
725 .Fa IFS
726 contains the Input Field Separators, which defaults to
727 .Aq space ,
728 .Aq tab ,
729 and
730 .Aq newline
731 if
732 .Dv NULL .
733 .It Fn tok_end
734 Clean up and finish with
735 .Fa t ,
736 assumed to have been created with
737 .Fn tok_init .
738 .It Fn tok_reset
739 Reset the tokenizer state.
740 Use after a line has been successfully tokenized
741 by
742 .Fn tok_line
743 or
744 .Fn tok_str
745 and before a new line is to be tokenized.
746 .It Fn tok_line
747 Tokenize
748 .Fa li ,
749 if successful, modify
750 .Fa argv
751 to contain the words,
752 .Fa argc
753 to contain the number of words,
754 .Fa cursorc
755 (if not
756 .Dv NULL )
757 to contain the index of the word containing the cursor,
758 and
759 .Fa cursoro
760 (if not
761 .Dv NULL )
762 to contain the offset within
763 .Fa argv[cursorc]
764 of the cursor.
765 .Pp
766 Returns
767 0 if successful,
768 \-1 for an internal error,
769 1 for an unmatched single quote,
770 2 for an unmatched double quote,
771 and
772 3 for a backslash quoted
773 .Aq newline .
774 A positive exit code indicates that another line should be read
775 and tokenization attempted again.
776 .It Fn tok_str
777 A simpler form of
778 .Fn tok_line ;
779 .Fa str
780 is a NUL terminated string to tokenize.
781 .El
782 .\"XXX.Sh EXAMPLES
783 .\"XXX: provide some examples
784 .Sh SEE ALSO
785 .Xr sh 1 ,
786 .Xr signal 3 ,
787 .Xr termcap 3 ,
788 .Xr editrc 5 ,
789 .Xr termcap 5
790 .Sh HISTORY
791 The
792 .Nm
793 library first appeared in
794 .Bx 4.4 .
795 .Dv CC_REDISPLAY
796 appeared in
797 .Nx 1.3 .
798 .Dv CC_REFRESH_BEEP
799 and
800 .Dv EL_EDITMODE
801 appeared in
802 .Nx 1.4 .
803 .Dv EL_RPROMPT
804 appeared in
805 .Nx 1.5 .
806 .Sh AUTHORS
807 .An -nosplit
808 The
809 .Nm
810 library was written by
811 .An Christos Zoulas .
812 .An Luke Mewburn
813 wrote this manual and implemented
814 .Dv CC_REDISPLAY ,
815 .Dv CC_REFRESH_BEEP ,
816 .Dv EL_EDITMODE ,
817 and
818 .Dv EL_RPROMPT .
819 .Sh BUGS
820 At this time, it is the responsibility of the caller to
821 check the result of the
822 .Dv EL_EDITMODE
823 operation of
824 .Fn el_get
825 (after an
826 .Fn el_source
827 or
828 .Fn el_parse )
829 to determine if
830 .Nm
831 should be used for further input.
832 I.e.,
833 .Dv EL_EDITMODE
834 is purely an indication of the result of the most recent
835 .Xr editrc 5
836 .Ic edit
837 command.