PageRenderTime 34ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

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