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