editline.3 (5466B)
1 .\" $Revision: 1.1 $ 2 .TH EDITLINE 3 3 .SH NAME 4 editline \- command-line editing library with history 5 .SH SYNOPSIS 6 .nf 7 .B "char *" 8 .B "readline(prompt)" 9 .B " char *prompt;" 10 11 .B "void" 12 .B "add_history(line)" 13 .B " char *line;" 14 .fi 15 .SH DESCRIPTION 16 .I Editline 17 is a library that provides an line-editing interface with text recall. 18 It is intended to be compatible with the 19 .I readline 20 library provided by the Free Software Foundation, but much smaller. 21 The bulk of this manual page describes the user interface. 22 .PP 23 The 24 .I readline 25 routine returns a line of text with the trailing newline removed. 26 The data is returned in a buffer allocated with 27 .IR malloc (3), 28 so the space should be released with 29 .IR free (3) 30 when the calling program is done with it. 31 Before accepting input from the user, the specified 32 .I prompt 33 is displayed on the terminal. 34 .PP 35 The 36 .I add_history 37 routine makes a copy of the specified 38 .I line 39 and adds it to the internal history list. 40 .SS "User Interface" 41 A program that uses this library provides a simple emacs-like editing 42 interface to its users. 43 A line may be edited before it is sent to the calling program by typing either 44 control characters or escape sequences. 45 A control character, shown as a caret followed by a letter, is typed by 46 holding down the ``control'' key while the letter is typed. 47 For example, ``^A'' is a control-A. 48 An escape sequence is entered by typing the ``escape'' key followed by one or 49 more characters. 50 The escape key is abbreviated as ``ESC''. 51 Note that unlike control keys, case matters in escape sequences; ``ESC\ F'' 52 is not the same as ``ESC\ f''. 53 .PP 54 An editing command may be typed anywhere on the line, not just at the 55 beginning. 56 In addition, a return may also be typed anywhere on the line, not just at 57 the end. 58 .PP 59 Most editing commands may be given a repeat count, 60 .IR n , 61 where 62 .I n 63 is a number. 64 To enter a repeat count, type the escape key, the number, and then 65 the command to execute. 66 For example, ``ESC\ 4\ ^f'' moves forward four characters. 67 If a command may be given a repeat count then the text ``[n]'' is given at the 68 end of its description. 69 .PP 70 The following control characters are accepted: 71 .RS 72 .nf 73 .ta \w'ESC DEL 'u 74 ^A Move to the beginning of the line 75 ^B Move left (backwards) [n] 76 ^D Delete character [n] 77 ^E Move to end of line 78 ^F Move right (forwards) [n] 79 ^G Ring the bell 80 ^H Delete character before cursor (backspace key) [n] 81 ^I Complete filename (tab key); see below 82 ^J Done with line (return key) 83 ^K Kill to end of line (or column [n]) 84 ^L Redisplay line 85 ^M Done with line (alternate return key) 86 ^N Get next line from history [n] 87 ^P Get previous line from history [n] 88 ^R Search backward (forward if [n]) through history for text; 89 \& prefixing the string with a caret (^) forces it to 90 \& match only at the beginning of a history line 91 ^T Transpose characters 92 ^V Insert next character, even if it is an edit command 93 ^W Wipe to the mark 94 ^X^X Exchange current location and mark 95 ^Y Yank back last killed text 96 ^[ Start an escape sequence (escape key) 97 ^]c Move forward to next character ``c'' 98 ^? Delete character before cursor (delete key) [n] 99 .fi 100 .RE 101 .PP 102 The following escape sequences are provided. 103 .RS 104 .nf 105 .ta \w'ESC DEL 'u 106 ESC\ ^H Delete previous word (backspace key) [n] 107 ESC\ DEL Delete previous word (delete key) [n] 108 ESC\ ESC Show possible completions; see below 109 ESC\ SP Set the mark (space key); see ^X^X and ^Y above 110 ESC\ . Get the last (or [n]'th) word from previous line 111 ESC\ ? Show possible completions; see below 112 ESC\ < Move to start of history 113 ESC\ > Move to end of history 114 ESC\ b Move backward a word [n] 115 ESC\ d Delete word under cursor [n] 116 ESC\ f Move forward a word [n] 117 ESC\ l Make word lowercase [n] 118 ESC\ m Toggle if 8bit chars display as themselves or with 119 \& an ``M\-'' prefix 120 ESC\ u Make word uppercase [n] 121 ESC\ y Yank back last killed text 122 ESC\ w Make area up to mark yankable 123 ESC\ nn Set repeat count to the number nn 124 ESC\ C Read from environment variable ``_C_'', where C is 125 \& an uppercase letter 126 .fi 127 .RE 128 .PP 129 The 130 .I editline 131 library has a small macro facility. 132 If you type the escape key followed by an uppercase letter, 133 .IR C , 134 then the contents of the environment variable 135 .I _C_ 136 are read in as if you had typed them at the keyboard. 137 For example, if the variable 138 .I _L_ 139 contains the following: 140 .RS 141 ^A^Kecho '^V^[[H^V^[[2J'^M 142 .RE 143 Then typing ``ESC L'' will move to the beginning of the line, kill the 144 entire line, enter the echo command needed to clear the terminal (if your 145 terminal is like a VT-100), and send the line back to the shell. 146 .PP 147 The 148 .I editline 149 library also does filename completion. 150 Suppose the root directory has the following files in it: 151 .RS 152 .nf 153 .ta \w'core 'u 154 bin vmunix 155 core vmunix.old 156 .fi 157 .RE 158 If you type ``rm\ /v'' and then the tab key. 159 .I Editline 160 will then finish off as much of the name as possible by adding ``munix''. 161 Because the name is not unique, it will then beep. 162 If you type the escape key followed by either a question mark or another 163 escape, it will display the two choices. 164 If you then type a period and a tab, the library will finish off the filename 165 for you: 166 .RS 167 .nf 168 .RI "rm /v[TAB]" munix ".[TAB]" old 169 .fi 170 .RE 171 The tab key is shown by ``[TAB]'' and the automatically-entered text 172 is shown in italics. 173 .SH "BUGS AND LIMITATIONS" 174 Cannot handle lines more than 80 columns. 175 .SH AUTHORS 176 Simmule R. Turner <uunet.uu.net!capitol!sysgo!simmy> 177 and Rich $alz <rsalz@osf.org>. 178 Original manual page by DaviD W. Sanderson <dws@ssec.wisc.edu>.