home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / editors / 1831 < prev    next >
Encoding:
Text File  |  1992-07-28  |  51.3 KB  |  1,129 lines

  1. Newsgroups: comp.editors
  2. Path: sparky!uunet!math.fu-berlin.de!wolff
  3. From: wolff@inf.fu-berlin.de (Thomas Wolff)
  4. Subject: Editor mined (Unix, VMS, MSDOS) - easy, solid, non-8-bit-obstructing (1/4)
  5. Message-ID: <42I54HD@math.fu-berlin.de>
  6. Sender: news@math.fu-berlin.de (Math Department)
  7. Organization: Free University of Berlin, Germany
  8. Date: Tue, 28 Jul 1992 15:02:39 GMT
  9. Lines: 1118
  10.  
  11. #! /bin/sh
  12. : This is a sharchive -- extract the files by running through sh
  13.  
  14. echo ---------------------- extracting mined.txt -----------------
  15. sed 's/^,//' << \EOSED > mined.txt
  16. ,
  17. ,In response to recent requests for a free, simple, and solid editor 
  18. ,(where the problem is: emacs is not simple, most public domain 
  19. ,contributions are not solid, and vi is not an editor), 
  20. ,I wish to contribute my adaptation of mined.
  21. ,
  22. ,Some notes about mined: Its original version is the editor that comes along 
  23. ,with Andrew S. Tanenbaum's freely available operating system minix. 
  24. ,It is small, quick, and easy to use. However, when I found the version one 
  25. ,of my work-mates had adapted to vt100 terminals for use on Sun machines, 
  26. ,it was not solid either nor was it flexible enough to meet my needs.
  27. ,So I spent some effort into mined (enabling arbitrary terminals, windows 
  28. ,with dynamic size changes, full 8 bit compatibility and support, function 
  29. ,keys, etc), improved its user interface, and made it behave safely (removed 
  30. ,many bugs and crash situations).
  31. ,
  32. ,The result has the following basic characteristics:
  33. ,- type in as you'd imagine, no mode switching, logical positioning, i.e. the 
  34. ,  text appears where the cursor is, not at some funny other place like in vi
  35. ,- cursor movement: basic functions available in (Wordmaster-/Wordstar-like) 
  36. ,  graphic control key layout as well as the keyboards cursor movement keys; 
  37. ,  use of a "hop key" for fortifying movement commands, thus making it easy 
  38. ,  to remember twice the amount of basic functions (similar to Wordstar's ^Q)
  39. ,- two key commands (starting with escape) for the less frequent functions
  40. ,- fully functioning with all terminals (using termcap/terminfo); also works 
  41. ,  with curses but that was only built in for a quick port to VMS; curses 
  42. ,  should not be selected in unix versions for two reasons: the output 
  43. ,  behaviour seems to be clumsier than with direct terminal control and 
  44. ,  many unix curses implementations still dare to obstruct the use of 
  45. ,  8-bit character sets
  46. ,- fully functioning in windows which may be resized at any time and the 
  47. ,  editor will react immediately and install a correct screen image; the 
  48. ,  cursor stays at the point of text where it was
  49. ,- multi-file editing
  50. ,- can be positioned on screen with mouse if terminal sends control sequence
  51. ,- no accidental quit without save or overwrite of file not read before without 
  52. ,  prior prompting in any way of exiting/writing
  53. ,- search functions, replacement functions with or without confirmation dialogue
  54. ,- suspend command with automatic file saving
  55. ,- ability to read text from standard input or to write it to standard output
  56. ,- change working directory / change file name commands
  57. ,- cut/copy/paste/write-paste-buffer-to-file commands with appending versions 
  58. ,  and an inter-window paste (actually paste between invocations of mined)
  59. ,- most significant error messages (as a contrast to usual unix commands)
  60. ,- start at specified line number possible; view only mode available
  61. ,- panic handling on external interrupts with attempts to save text
  62. ,- runs on Unix, VMS, and MSDOS. The VMS and MSDOS adaptations are not yet 
  63. ,  perfect. The MSDOS version needs an extended ANSI driver with line insert 
  64. ,  and delete line functions (e.g. NNANSI)
  65. ,
  66. ,This version of mined is from July, 1992.
  67. ,
  68. ,Thomas Wolff
  69. ,Freie Universit:at Berlin
  70. ,Institut f:ur Informatik
  71. ,D-1000 Berlin
  72. ,wolff@inf.fu-berlin.de
  73. ,
  74. EOSED
  75.  
  76. echo ---------------------- extracting mined.help -----------------
  77. sed 's/^,//' << \EOSED > mined.help
  78. ,MINED                EDITOR                MINED
  79. ,
  80. ,
  81. ,NAME
  82. ,    mined - a text editor
  83. ,
  84. ,SYNTAX
  85. ,    mined [ -v ] [ +linenumber ] [ filename ] [ more filenames ... ]
  86. ,
  87. ,
  88. ,DESCRIPTION
  89. ,    An easy-to-use and natural in appearance text editor.
  90. ,    Its original version was designed for Andrew S Tanenbaum's operating 
  91. ,    system Minix.
  92. ,
  93. ,    Startup features:
  94. ,    - with given file name (as usual) or multiple file names
  95. ,    - without given file name
  96. ,    - reading from a pipe (reading text from standard input)
  97. ,    - writing into a pipe (writing edited text to standard output)
  98. ,    Examples:
  99. ,    mined x        - edits the file x
  100. ,    cmd | mined    - edits the output of "cmd", file name for saving 
  101. ,              can be given later
  102. ,    mined x > y    - takes the contents of file x and edits it 
  103. ,              for writing into y
  104. ,    mined | mail nn    - edits a text to be mailed
  105. ,    cmd1 | mined | cmd2 - modifies text in between a pipe from 
  106. ,                program cmd1 (output) to cmd2 (as input)
  107. ,    Startup options:
  108. ,    -v    Mined starts in view only mode. The text cannot be modified.
  109. ,    +number    Mined positions to the given line number.
  110. ,
  111. ,  Basic functionality
  112. ,    Mined is always in insert mode. Commands are single control characters, 
  113. ,    double key commands starting with ESCAPE, and a collection of function 
  114. ,    keys (currently installed for the VT220, SUN, and Iris terminals). 
  115. ,    As a specialty, note the prefixing 'HOP KEY' which stretches the effect 
  116. ,    of some cursor and screen motion commands just as you would expect; this 
  117. ,    provides for more command flexibility without too much key remembering. 
  118. ,    Control key layout in the current version is 'geographically' oriented 
  119. ,    on the left side of the keyboard for the main motion commands, an idea 
  120. ,    probably originating from the 'WordMaster' and 'WordStar' editors. 
  121. ,    On SUN terminals, also the right-hand cursor block is assigned the 
  122. ,    most important movement functions as follows:
  123. ,                        +------+-------+------+
  124. ,                        | LnDn |   ^   | PgUp |
  125. ,                        +------+-------+------+
  126. ,                        |  <-  |  HOP  |  ->  |
  127. ,                        +------+-------+------+
  128. ,                        | LnUp |   v   | PgDn |
  129. ,                        +------+-------+------+
  130. ,
  131. ,    Note that line-feeds (end-of-line character) are treated like any 
  132. ,    ordinary character except that they cannot occur in search strings.
  133. ,    This drawback (not to be able to search / replace lineends naturally) 
  134. ,    seems to be a tradition of line-oriented unix tools and I was not 
  135. ,    willing to spend that much time going into very special parts of mined.
  136. ,
  137. ,    Every care has been taken to prevent loss of the edited text in case 
  138. ,    of save errors or accidental quit commands etc. Also, if a command is 
  139. ,    given to overwrite a file not previously read in, mined prompts for 
  140. ,    confirmation.
  141. ,    In the "write to standard output" mode, only one save to standard output 
  142. ,    can be performed, so there is a problem in the case that more than one 
  143. ,    saving actions occur; the first save (whether by a write, edit, 
  144. ,    or suspend command) of the buffer is written to standard output, 
  145. ,    any subsequent one is treated as usual (with empty file name).
  146. ,
  147. ,    Before regarding the command keys and their functions, 
  148. ,    note the following general remarks:
  149. ,
  150. ,  The HOP function
  151. ,    This function, triggered by any of the HOP keys, fortifies (or modifies) 
  152. ,    functions as follows. To achieve the combined function, first press 
  153. ,    any key that is assigned the HOP function, then any key assigned 
  154. ,    the second function:
  155. ,
  156. ,    HOP - char left            move cursor to start of current line
  157. ,    HOP - char right            move cursor to end of current line
  158. ,    HOP - line up            move cursor to top of screen
  159. ,    HOP - line down            move cursor to bottom of screen
  160. ,    HOP - scroll up            scroll half a screen up
  161. ,    HOP - scroll down            scroll half a screen down
  162. ,    HOP - page up            move to start of file
  163. ,    HOP - page down            move to end of file
  164. ,    HOP - word left            move cursor to previous ";" or "."
  165. ,    HOP - word right            move cursor to next ";" or "."
  166. ,    HOP - set mark            go to mark
  167. ,    HOP - copy/cut            copy or cut, but append to buffer
  168. ,    HOP - save buffer            save buffer, but append to file
  169. ,    HOP - paste buffer            paste "inter-window buffer", 
  170. ,    which is the last saved buffer by any invocation of mined on the 
  171. ,    same machine by the same user.
  172. ,    HOP - edit next file        edit last file
  173. ,    HOP - edit previous file        edit first file
  174. ,    HOP - suspend            suspend without writing file
  175. ,
  176. ,  Typing in 8-bit characters in absence of appropriate keyboard
  177. ,    Some function keys can be used as prefix keys to change the character 
  178. ,    assigned to the following key to a diacritic or special character:
  179. ,    On a SUN terminal, six diacritic prefix keys are provided:
  180. ,    R1 (grave): adds grave accent where applicable: αΦ∞≥∙ └╚╠╥┘
  181. ,    R2 (circumflex): adds circumflex accent where applicable: ΓΩε⌠√ ┬╩╬╘█
  182. ,    R3 (acute): adds acute accent where applicable: ßΘφ≤·² ┴╔═╙┌▌
  183. ,    R4 (diaeresis): adds diaeresis where applicable: Σδ∩÷ⁿ  ─╦╧╓▄
  184. ,    R5 (tilde): adds tilde where applicable: π±⌡ ├╤╒
  185. ,    R6 (angstrom): a╗σ, A╗┼, e╗µ, E╗╞, o╗°, O╗╪
  186. ,    Where these rules do not apply, any of these prefix keys makes the 
  187. ,    following default transformations:
  188. ,    s╗▀, c╗τ, C╗╟, n╗±, N╗╤, d╗≡, D╗╨, p╗■, P╗▐, m╗╡,
  189. ,    l╗ú, L╗ú, /╗ó, $╗ó, Y╗Ñ, X╗ñ, &╗º, #╗╢, !╗í, ?╗┐,
  190. ,    <╗½, >╗╗, x╗╫, :╗≈, +╗▒, 0╗░, 1╗╣, 2╗▓, 3╗│,
  191. ,    *╗╖, .╗╖, ,╗╕, "╗¿, '╗┤, _╗», -╗¡, \╗¼, |╗ª
  192. ,    On a VT100 terminal, the F6-key is assigned the diaeresis 
  193. ,    prefix function (including the default transformations).
  194. ,    If you have an appropriate keyboard, you can of course also type in 
  195. ,    any 8-bit character directly or using the Compose/Combine key.
  196. ,
  197. ,
  198. ,  Summary of mined commands
  199. ,  =========================
  200. ,   Alternative commands or functions keys are listed in further lines 
  201. ,   with an indentation for better orientation.
  202. ,
  203. ,  Cursor and screen motion
  204. ,  ------------------------
  205. ,   ^E            Move cursor 1 line up
  206. ,    up-arrow
  207. ,   ^X            Move cursor 1 line down
  208. ,    down-arrow
  209. ,   ^S ^H        Move cursor 1 character left
  210. ,    left-arrow
  211. ,   ^D            Move cursor 1 character right
  212. ,    right-arrow
  213. ,   ^A            Move backward to start of previous word
  214. ,   ^F            Move forward to start of next word
  215. ,   ^R            Scroll backward 1 page (Top line becomes bottom line)
  216. ,    PrevScreen (vt100)
  217. ,    PgDn (R9, sun)
  218. ,   ^C            Scroll forward 1 page (Bottom line becomes top line)
  219. ,    NextScreen
  220. ,    PgDn (R15, sun)
  221. ,   ^W            Scroll screen backward 1 line
  222. ,    PF2 (vt100)
  223. ,    Home (R7, sun)
  224. ,   ^Z            Scroll screen forward 1 line
  225. ,    PF3 (vt100)
  226. ,    End (R13, sun)
  227. ,   ^Gnn            Move to a line (prompts for line number)
  228. ,   ^Gnn%        Move to position in text determined by percentage
  229. ,    if ^G is not immediately followed by a digit, it works as HOP key 
  230. ,    for the following command if applicable.
  231. ,   ESC ]    ^G ^]    Move to the position previously marked by ^]
  232. ,   ^Q            HOP key
  233. ,    ^G    (if not followed by a digit)
  234. ,    PF1 (vt100)
  235. ,    "5" (R11, sun)
  236. ,
  237. ,   On terminals or windows which can transform mouse button pressings into 
  238. ,   key sequences, direct positioning on the current screen is also available:
  239. ,    (e.g. crttool)
  240. ,   left button        position only
  241. ,   middle button    position and set mark (^] command)
  242. ,   right button        position and copy text (^Y command)
  243. ,
  244. ,  Modifying text
  245. ,  --------------
  246. ,   <printable char>  Insert the character, 
  247. ,   <RET or LF char>  linefeed (newline), 
  248. ,   <TAB char>         or tab at cursor position
  249. ,   ^V <char>         Enter control character (also in prompted input)
  250. ,   ^O             Make new line at current position
  251. ,   <DEL char>         Delete previous character
  252. ,   ^B             Delete next character
  253. ,   ^T             Delete next word
  254. ,   ^^             Delete previous word
  255. ,   ^K             Delete tail of line; if at end of line, delete linefeed
  256. ,
  257. ,  Text block and buffer operations
  258. ,  --------------------------------
  259. ,   ^]            Set mark (to remember the current location)
  260. ,    Select (vt100)
  261. ,    Stop (L1, sun)
  262. ,   ^U            Cut text between and current position; save in buffer
  263. ,    Remove (vt100)
  264. ,    Cut (L10, sun)
  265. ,   ^Y            Copy text between mark and current position into buffer
  266. ,    Do (vt100)
  267. ,    Copy (L6, sun)
  268. ,   ^P            Paste contents of buffer to current position
  269. ,    InsertHere (vt100)
  270. ,    Paste (L8, sun)
  271. ,    Ins (sun)
  272. ,   ESC b        Copy contents of buffer into a file
  273. ,   ESC i        Insert file at current position
  274. ,   ESC p        Print contents of buffer (to default printer)
  275. ,   ESC c        Perform command (prompted for) with buffer as input
  276. ,    For modifications of the "cut", "copy", "paste" and 
  277. ,    "copy buffer to file" commands by the HOP function see above.
  278. ,
  279. ,  Search
  280. ,  ------
  281. ,   ESC /  Find    Search forward (prompt for regular expression)
  282. ,   ESC \    Search backward (prompt for regular expression)
  283. ,   ^N        Search for next occurence (previous expression and direction)
  284. ,    Find (vt100)
  285. ,    Find (L9, sun)
  286. ,   ESC s    (Global) Substitute str1 by str2 (prompts for each string)
  287. ,   ESC r    (Global) Replace str1 by str2 with confirmation prompting
  288. ,   ESC l    (Line) Substitute string1 by string2
  289. ,
  290. ,  Special functions in a search string:
  291. ,    .    matches any character.
  292. ,    ^    (at begin of pattern) restricts match to the begin of a line.
  293. ,    $    (at end of pattern) restricts match to the end of a line.
  294. ,    [<cset>] matches any one of a set of characters;
  295. ,        the set may be given by listing elements,
  296. ,        denoting a range <c1>-<c2>,
  297. ,        or negating the whole set [^<cset>].
  298. ,    \<c>    matches character <c> literally.
  299. ,    <pat>*    where <pat> is any one of the defined patterns,
  300. ,        matches a (zero or more times) repetition of this pattern.
  301. ,  Special function in a replacement string:
  302. ,    &    is replaced by the matched pattern to be replaced.
  303. ,
  304. ,  Miscellaneous
  305. ,  -------------
  306. ,   ESC w    Save (write back) current text to file
  307. ,   ESC e    Edit another file (prompt for save if current text changed)
  308. ,   ESC v    View another file (prompt for save if current text changed)
  309. ,   ESC q    Quit the editor (prompt for save if current text changed)
  310. ,   ESC ESC    Exit the editor (save if current text changed)
  311. ,   ESC +    Edit the next file in the list of file names
  312. ,   ESC -    Edit the previous file in the list of file names
  313. ,   ESC #    Ask for index into the list of file names and edit that file
  314. ,   ESC = count    Repeat a command count times (prompts for count)
  315. ,   ESC count    Repeat a command count times (prompts for rest of count)
  316. ,   ^\        Abort current command (also while prompting or searching)
  317. ,   ESC        Abort current command only if prompting
  318. ,   ESC ?    Print the current status of the file
  319. ,   ESC d    Show working directory / change to another one
  320. ,   ESC n    Change file name associated with edited text (does not 
  321. ,        affect the file previously being edited)
  322. ,   ESC .    Redraw the screen
  323. ,   ESC z    Suspend editor process; first write back file if modified
  324. ,        (no write if HOPped or given empty file name on prompting)
  325. ,   ESC !    Fork off a shell and wait for it to finish
  326. ,   ESC h    Show (this) help file
  327. ,    Help (vt100 / sun)
  328. ,   When entering file names, the leading ~/ notation is accepted.
  329. ,
  330. ,ENVIRONMENT
  331. ,  Concerning some especially stupid terminal drivers
  332. ,    If there is a need to ignore ^S and ^Q keys (in case of stupid keyboard 
  333. ,    drivers which use them, but don't filter them out), the environment 
  334. ,    variable NoCtrlSQ or NoControlSQ must be set.
  335. ,
  336. ,  Help display selection
  337. ,    Mined looks up the environment variable PAGER or uses 'more' for showing 
  338. ,    the help file. The complete command to show it can be changed by setting 
  339. ,    the environment variable MINEDHELP (e.g. to 'less .../mined.help').
  340. ,
  341. ,  Print direction
  342. ,    The environment variable MINEDPRINT may contain a print command to be 
  343. ,    used instead of the default (which is operating system dependant). The 
  344. ,    variable must contain the string %s in the place for the filename.
  345. ,
  346. ,  Line contents indications
  347. ,    Lines which are too long for the screen are usually indicated by a 
  348. ,    '╗' or '>' character. This can be changed by setting the environment 
  349. ,    variable MINEDSHIFT. If this variable contains a second character, 
  350. ,    that one will be used to indicate lines shifted out left off the screen. 
  351. ,    However, moving to and operating on that position will not be changed.
  352. ,
  353. ,    If an environment variable MINEDRET is set, its contents (one character) 
  354. ,    is placed as an indicator at the end of every text line on screen.
  355. ,    If MINEDRET contains another character it is used to fill the rest of 
  356. ,    the screen lines, leaving out the position for the MINEDSHIFT mark, 
  357. ,    which can however be filled with a third character from MINEDRET.
  358. ,    I recommend to set MINEDRET to '½' for people who want to see line ends 
  359. ,    or '╖╖' (or '╖╖╖' or '╖╖½') for people who like Siemens terminals.
  360. ,    Other nice variations are '½░', '½¿', or '╢¼'.
  361. ,    If a third MINEDRET character is used, in some cases of line length the 
  362. ,    appearance at the end of the screen line is a matter of taste.
  363. ,
  364. ,    If visible display of TAB characters is desired, the environment 
  365. ,    variable MINEDTAB can be set (e.g. to '╖').
  366. ,
  367. ,  Buffer file names
  368. ,    For the paste buffer, the inter-window paste buffer, and the panic file, 
  369. ,    environment information as usual on the respective operating system is 
  370. ,    used to build the names. (Unix: TMPDIR, USER; VMS: SYS$SCRATCH, SYS$LOGIN, 
  371. ,    USER; MSDOS: TEMP, TMP)
  372. ,
  373. ,  Terminal type
  374. ,    The Unix terminal type is determined over the environment variable TERM.
  375. ,
  376. ,  Behaviour modification
  377. ,    If the environment variable MINEDMULT exists the exit command (Esc Esc) 
  378. ,    continues with editing the next file (like Esc +).
  379. ,
  380. ,  Highlight mode (MSDOS only)
  381. ,    The ANSI codes for selecting normal and exposed display can be chosen 
  382. ,    with the environment variable MINEDCOL. The two selections are separated 
  383. ,    by a space. Each selection is a semicolon-separated list of the code 
  384. ,    values. The default behaviour corresponds to the setting 
  385. ,    set MINEDCOL=7 27
  386. ,    Example: Green on red text, red on green status: set MINEDCOL=34;42 32;44
  387. ,
  388. ,More special MSDOS notes:
  389. ,    The default colour setting depends on an extended ANSI driver 
  390. ,    (like NNANSI) as does the scroll down function anyway. Unfortunately, 
  391. ,    there is no way to find out the current colour setting nor is there an 
  392. ,    inverse video mode (only a fixed black on white mode) so that it is 
  393. ,    impossible to implement just inverse display for highlighting.
  394. ,
  395. ,    Mined finds out the current screen size on startup. Unfortunately, some 
  396. ,    part of the Turbo-C runtime system sets the screen into text mode, so 
  397. ,    that no editing in the extended size modes (e.g., 44x132 etc) is possible.
  398. ,
  399. ,    PCDOS has this well-hated memory limitation which limits the size of 
  400. ,    editable files to currently ca. 200K. If its maximal size is exceeded 
  401. ,    it ungratefully terminates but saves all your text into the panic-file.
  402. ,    These two restrictions (whole file in memory, no smooth memory overflow 
  403. ,    handling) do not matter in the Unix and VMS versions so they have not 
  404. ,    been taken care of so far; sorry.
  405. ,
  406. ,DIAGNOSTICS
  407. ,    In all cases where it is considered sensible, the appropriate message 
  408. ,    of a system error occurred is displayed (instead of printing numerical 
  409. ,    hieroglyphs or indistinguished commonplace messages as many other 
  410. ,    UNIX commands do).
  411. ,
  412. ,BUGS
  413. ,    When lines are shifted on the display while moving around in a very 
  414. ,    small window, positioning errors and display garbage may occur.
  415. ,
  416. ,    Mined cannot edit a pipe file and hangs if you try to do so. (But it 
  417. ,    can insert or write to a pipe and is interruptable by ^\ then.)
  418. ,    Mined can neither edit nor insert or write to device files such as tty.
  419. ,
  420. ,FILES
  421. ,    /usr/man/catl/mined.l    This help file
  422. ,    /tmp/mined.$$[a-z]        Temporary file for buffer
  423. ,    /tmp/mined.$USER        File for inter-window buffer
  424. EOSED
  425.  
  426. echo ---------------------- extracting mined.hilf -----------------
  427. sed 's/^,//' << \EOSED > mined.hilf
  428. ,
  429. ,    Kurzeinfⁿhrung in die Benutzung des Editors MINED 
  430. ,    und ErlΣuterung der wichtigsten Kommandos
  431. ,
  432. ,
  433. ,    Aufruf
  434. ,
  435. ,    In der Kommandozeile tippe:
  436. ,        mined <Dateiname>
  437. ,    , wobei anstelle von <Dateiname> der Name der vorhandenen oder 
  438. ,    zu erstellenden Datei einzugeben ist.
  439. ,
  440. ,
  441. ,    Einfⁿhrende Beschreibung
  442. ,
  443. ,    Nach Start des Editors wird der (leere oder aus einer Datei 
  444. ,    geladene) Text im internen Buffer des Editors am Bildschirm 
  445. ,    angezeigt. An der Stelle, wo sich der Cursor befindet, kann 
  446. ,    in natⁿrlicher Weise beliebiger Text eingefⁿgt werden und 
  447. ,    mit den Positionierungstasten sowie Control-Tasten kann sich 
  448. ,    ⁿber den Text der gesamten Datei nach Belieben bewegt werden.
  449. ,    Hat die Tastatur eine 9er-Cursorblock, so sollten dessen Tasten 
  450. ,    mit folgenden Funktionen belegt sein:
  451. ,
  452. ,            +------+-------+------+
  453. ,            | LnDn |   ^   | PgUp |
  454. ,            +------+-------+------+
  455. ,            |  <-  |  Hop  |  ->  |
  456. ,            +------+-------+------+
  457. ,            | LnUp |   v   | PgDn |
  458. ,            +------+-------+------+
  459. ,
  460. ,    Mit Hilfe der (mit Richtungs-Pfeilen bezeichneten) Tasten 
  461. ,    des Cursor-Blocks kann sich ⁿber den Text der 
  462. ,    gesamten Datei nach Belieben bewegt werden. Die Tasten 
  463. ,    orientieren sich dabei am Inhalt der Datei (und nicht am 
  464. ,    Bildschirm). Das hei▀t: 
  465. ,    Wenn die Zeile ⁿber den Bildschirmrand hinausgeht und ich 
  466. ,    mich dorthin bewegen will, wird die Anzeige dieser Zeile 
  467. ,    entsprechend verschoben. Bin ich wirklich am Ende der Zeile, 
  468. ,    so geht die 'Pfeil-rechts'-Taste an den Anfang der nΣchsten 
  469. ,    Zeile. Bin ich in der letzten Bildschirmzeile und will nach 
  470. ,    unten, so wird der Bildschirminhalt zu diesem Zweck nach 
  471. ,    oben verschoben und so weiter.
  472. ,
  473. ,    Natⁿrlich kann ich auch mit den Tasten 'PgDn' und 'PgUp' 
  474. ,    seitenweise in der Datei blΣttern.
  475. ,    Praktisch ist das wortweise Weitergehen mit Control-F 
  476. ,    (nΣchstes Wort) oder Control-A (vorheriges Wort).
  477. ,    Au▀erdem kann ich mit den Tasten des Cursor-Blocks, die 
  478. ,    'Home' bzw. 'End' beschrieben sind, den Dateiinhalt am 
  479. ,    Bildschirm nach unten bzw. oben verschieben.
  480. ,
  481. ,    Jetzt zum Editieren: Wenn ich an der Stelle, wo ich gerade bin, 
  482. ,    etwas einfⁿgen m÷chte, dann tippe ich das einfach da hin.
  483. ,
  484. ,    Die M÷glichkeiten zu positionieren, werden auf einfache Weise 
  485. ,    vervielfΣltigt durch die 'VerstΣrkertaste', die jede danach 
  486. ,    betΣtigte Positioniertaste in ihrer Wirkung verstΣrkt. Auf den 
  487. ,    PCs wurde diese Funktion auf die Taste 'Ins' gelegt. Die 
  488. ,    genauen Funktionen in Kombination mit der VerstΣrkertaste 
  489. ,    entnehme bitte der Zusammenfassung der Kommandos weiter unten.
  490. ,    Von Wichtigkeit ist auch das L÷schen von Text: ein Zeichen 
  491. ,    links vom Cursor (meist das zuletzt getippte Zeichen) wird mit 
  492. ,    der Taste 'Del' gel÷scht (auch z.B. wenn es ein Zeilenwechsel 
  493. ,    war). Das ganze nΣchste Wort kann mit Control-T gel÷scht werden. 
  494. ,    Control-K l÷scht alles bis zum Ende der Zeile; wenn ich bereits 
  495. ,    dort bin, l÷scht es jedoch den Zeilenwechsel und fⁿgt somit 
  496. ,    zwei Zeilen zusammen.
  497. ,
  498. ,    Um das Editieren zu beenden und den Editor zu verlassen, 
  499. ,    drⁿcke zweimal die 'Escape'-Taste: Esc Esc . Der (geΣnderte) 
  500. ,    Dateiinhalt wird automatisch in die Datei zurⁿckgeschrieben. 
  501. ,    Will ich nur den Inhalt wegschreiben, danach aber weiter 
  502. ,    editieren, so drⁿcke ich Esc w (w wie write). Schlie▀lich 
  503. ,    kann ich noch mit Esc q (q wie quit) den Editor verlassen, 
  504. ,    ohne den neuen Inhalt wegzuschreiben, werde jedoch nochmal 
  505. ,    gefragt, ob ich das nicht doch lieber m÷chte.
  506. ,
  507. ,    Zum Suchen eines Textstⁿckes ist das Kommando Esc / geeignet. 
  508. ,    Es fragt nach der zu suchenden Zeichenfolge, die mit einem 
  509. ,    Return abzuschlie▀en ist. Will ich dasselbe nochmal suchen, 
  510. ,    so drⁿcke ich einfach Control-N.
  511. ,
  512. ,
  513. ,    Umlaute und Sonderzeichen
  514. ,    werden am SUN-Terminal mit den PrΣfixtasten R1 bis R6 eingegeben 
  515. ,    (R4 fⁿr Umlaut oder ▀); am VT100-Terminal nimm F6.
  516. ,
  517. ,    SonderfΣlle
  518. ,    Ist beim Wegschreiben des editierten Textes kein Dateiname 
  519. ,    bekannt (Mined kann auch ohne Dateiname aufgerufen werden) 
  520. ,    oder liegt fⁿr die bearbeitete Datei keine Schreibberechtigung 
  521. ,    vor, so wird zunΣchst nach einem Dateinamen gefragt.
  522. ,    Gibt es beim Schreiben irgendeinen Fehler, so wird dieser 
  523. ,    mitgeteilt und das Kommando abgebrochen, Mined also nicht beendet.
  524. ,
  525. ,    ▄brigens:
  526. ,    Wird mined von einem Terminal aus benutzt, das die dumme 
  527. ,    Angewohnheit hat, ^S und ^Q als Steuerzeichen zu benutzen, 
  528. ,    so mu▀ unbedingt die Umgebungsvariable  NoControlSQ  gesetzt 
  529. ,    werden, bevor mit mined gearbeitet wird.
  530. ,
  531. ,    Kommandoⁿbersicht (Control- wird mit ^ abgekⁿrzt)
  532. ,
  533. ,      Positionierung
  534. ,    Pfeil nach links    geht ein Zeichen nach links
  535. ,    Pfeil nach rechts    geht ein Zeichen nach rechts
  536. ,    Pfeil nach oben        geht eine Zeile nach oben
  537. ,    Pfeil nach unten    geht eine Zeile nach unten
  538. ,    ^A            geht ein Wort nach links
  539. ,    ^F            geht ein Wort nach rechts
  540. ,    PgUp            geht eine Seite zurⁿck
  541. ,    PdDn            geht eine Seite vor
  542. ,    Home            rollt eine Zeile runter
  543. ,    End            rollt eine Zeile rauf
  544. ,    Hop   Pfeil links    geht an den Anfang der Zeile
  545. ,    Hop   Pfeil rechts    geht an das Ende der Zeile
  546. ,    Hop   Pfeil oben    geht an den Anfang des Bildschirms
  547. ,    Hop   Pfeil unten    geht an das Ende des Bildschirms
  548. ,    Hop   PgUp        geht an den Anfang der Datei
  549. ,    Hop   PgDn        geht an das Ende der Datei
  550. ,    Hop   Home        rollt eine halbe Seite runter
  551. ,    Hop   End        rollt eine halbe Seite rauf
  552. ,    ^G            geht in eine bestimmte Zeile, deren 
  553. ,                Nummer einzugeben ist (auch Hop-Taste)
  554. ,
  555. ,      Einfⁿgen
  556. ,    Zeichen, 
  557. ,    Tab-Taste oder
  558. ,    Zeilenwechsel    fⁿgt dieses Zeichen an der aktuellen Position ein
  559. ,    ^O    fⁿgt einen Zeilenwechsel ein, bleibt jedoch davor stehen
  560. ,    ^P    siehe unten
  561. ,    Esc i    fⁿgt den Inhalt einer Datei an der aktuellen Stelle ein
  562. ,
  563. ,      L÷schen
  564. ,    Del        l÷scht ein Zeichen nach links
  565. ,    ^B        l÷scht ein Zeichen nach rechts
  566. ,    ^T        l÷scht ein Wort nach rechts
  567. ,    ^K        l÷scht bis Zeilenende oder l÷scht dieses alleine
  568. ,
  569. ,      Textabschnitte bearbeiten
  570. ,    ^]        markiert die aktuelle Stelle
  571. ,    ^Y    (copY)    kopiert den Abschnitt zwischen der aktuellen Stelle
  572. ,            und der vorher mit ^] gesetzten Marke in einen Puffer
  573. ,    ^U    (cUt)    entfernt (l÷scht) selbigen Abschnitt, hinterlΣ▀t ihn
  574. ,            jedoch ebenfalls im Puffer
  575. ,    ^P    (Paste)    fⁿgt Inhalt des Puffers an der aktuellen Stelle ein
  576. ,    Esc b        kopiert den Inhalt des Puffers in eine Datei
  577. ,
  578. ,      Suchen
  579. ,    Esc /    sucht vorwΣrts nach einem einzugebenden Ausdruck
  580. ,    Esc \    sucht rⁿckwΣrts nach einem einzugebenden Ausdruck
  581. ,    ^N    wiederholt den letzten Suchvorgang (Richtung und Ausdruck)
  582. ,    Esc s    ersetzt (substituiert) bis zum Dateiende einen Ausdruck
  583. ,        durch einen anderen (beide sind einzugeben)
  584. ,    Esc r   desgleichen mit Nachfrage fⁿr jede Ersetzung
  585. ,
  586. ,      Sonstiges
  587. ,    Esc Esc    schreibt Dateiinhalt in Datei und beendet Mined
  588. ,    Esc w    schreibt nur Dateiinhalt in Datei
  589. ,    Esc q    beendet Mined, eventuell ohne Wegschreiben
  590. ,    Esc e    editiert eine andere Datei
  591. ,    Esc +    editiert nΣchste Datei (bei Aufruf mined Dat1 Dat2 ...)
  592. ,    Esc -    editiert vorige Datei
  593. ,    Esc #    editiert durch Index anzugebende Datei
  594. ,    Esc <Zahl> <Kommando>
  595. ,        wiederholt das <Kommando>  <Zahl>-Mal
  596. ,    ^\    bricht das laufende Kommando ab
  597. ,    Esc ?    zeigt Status der Datei an
  598. ,    Esc .    baut den Bildschirminhalt neu auf
  599. ,    Esc h    zeigt eine Hilfstext-Datei an
  600. EOSED
  601.  
  602. echo ---------------------- extracting mkmined -----------------
  603. sed 's/^,//' << \EOSED > mkmined
  604. ,#! /bin/csh -f
  605. ,# m÷gliche Parameter:
  606. ,#    -O (gro▀ O!) zum Optimieren, wenn neue Gebrauchsversion erzeugt wird
  607. ,#    -DCURSES    , wenn `curses' benutzt werden soll
  608. ,#    -Bstatic    , wenn statisches Binden erzwungen werden soll
  609. ,
  610. ,set newest=newest    # ~wolff/bin/newest
  611. ,if (! $?cc) then
  612. ,   set cc=cc
  613. ,endif
  614. ,
  615. ,set arch=$HOSTTYPE
  616. ,if "$arch" == vax then
  617. ,   set arch=mvax
  618. ,endif
  619. ,set suff=.$arch
  620. ,set opt=($*)
  621. ,
  622. ,set opt=($opt -DTERMIO)
  623. ,
  624. ,foreach param ($*)
  625. ,    switch ($param)
  626. ,    case -O*:
  627. ,        set optimize=$param; echo optimizing; breaksw;
  628. ,    case -DCURSES:
  629. ,        set curses; echo using curses; breaksw;
  630. ,    case -B*:
  631. ,        set bind; echo using bind option; breaksw;
  632. ,    endsw
  633. ,end
  634. ,if $?optimize then
  635. ,   set suff="$suff$optimize"
  636. ,endif
  637. ,
  638. ,if "$arch" == mvax then
  639. ,   set suff=    # the stupid ╡vax C compiler won't accept -c and -o
  640. ,endif
  641. ,if "$suff" == "" then
  642. ,   alias compile 'echo Compiling mined\!*.c: ; $cc $opt -c mined\!*.c'
  643. ,else
  644. ,   alias compile 'echo Compiling mined\!*.c: ; $cc $opt -c mined\!*.c -o mined\!*$suff.o'
  645. ,endif
  646. ,
  647. ,if ! { $newest mined1$suff.o mined1.c mined.h } then
  648. ,   compile 1
  649. ,endif
  650. ,if ! { $newest mined2$suff.o mined2.c mined.h } then
  651. ,   compile 2
  652. ,endif
  653. ,if ! { $newest minedio$suff.o minedio.c mined.h } then
  654. ,   compile io
  655. ,endif
  656. ,if ! { $newest minedmp$suff.o minedmp.c mined.h } then
  657. ,   compile mp
  658. ,endif
  659. ,
  660. ,set OBJ=(mined1$suff.o mined2$suff.o minedio$suff.o minedmp$suff.o)
  661. ,if ( $?bind || ! { $newest mined.$arch $OBJ } || ! -x mined.$arch ) then
  662. ,   echo -n "linking "
  663. ,   if $?curses then
  664. ,      echo "with curses"
  665. ,      $cc $opt $OBJ -lcurses -ltermcap -o mined.$arch
  666. ,   else
  667. ,      echo "without curses"
  668. ,      $cc $opt $OBJ -ltermcap -o mined.$arch
  669. ,   endif
  670. ,   echo -n 'Stripping.. '
  671. ,   strip mined.$arch
  672. ,   echo mkmined done.
  673. ,endif
  674. EOSED
  675.  
  676. echo ---------------------- extracting Makefile -----------------
  677. sed 's/^,//' << \EOSED > Makefile
  678. ,SOURCES = mined1.c mined2.c minedio.c minedmp.c
  679. ,
  680. ,all:    mined
  681. ,
  682. ,mined:
  683. ,    cc -O -DTERMIO $(SOURCES) -ltermcap -o mined
  684. ,    strip mined
  685. ,
  686. ,sgtty:
  687. ,    cc -O -DSGTTY $(SOURCES) -ltermcap -o mined
  688. ,    strip mined
  689. ,
  690. ,cursed:
  691. ,    cc -O -DCURSES $(SOURCES) -lcurses -ltermcap -o mined.cursed
  692. ,    strip mined.cursed
  693. EOSED
  694.  
  695. echo ---------------------- extracting mined.doc -----------------
  696. sed 's/^,//' << \EOSED > mined.doc
  697. ,+=====================================================================+
  698. ,|        Documentation file of the Mined editor.               |
  699. ,+=====================================================================+
  700. ,
  701. , Author: Michiel Huisjes.
  702. ,
  703. , Modified by Achim Mⁿller to run on a Unix machine with VT100-like
  704. , terminals attached and to recognize function key character sequences.
  705. ,
  706. , Modifications and corrections made by Thomas Wolff:
  707. ,    Basic capabilities:
  708. ,    Runs with arbitrary terminals on UNIX (using termcap).
  709. ,    Responds correctly to changes of window size, including
  710. ,        redisplay of status line; keeps position in text.
  711. ,    Accepts and displays an 8 bit character set.
  712. ,    User interface:
  713. ,    Two letter ESCAPE commands are used for less frequent functions.
  714. ,    The concept of a HOP key prefix was introduced which fortifies
  715. ,        any positioning function that follows. This provides more
  716. ,        command flexibility without too much need of key remembering.
  717. ,    Command key layout changed to resemble WordMaster/WordStar.
  718. ,    Improved behaviour:
  719. ,    Stripping off lines too long for the screen implemented
  720. ,        also on status line output. If status line input overflows
  721. ,        the screen and wraps/scrolls, the screen is redisplayed.
  722. ,    Search displays a "wrap around end of file" message for
  723. ,        better orientation.
  724. ,    In case of system errors, the appropriate error message
  725. ,        is fetched and displayed instead of printing
  726. ,        numerical hieroglyphs or indistinguished
  727. ,        commonplace messages (as many UNIX commands do).
  728. ,    Additional features and commands:
  729. ,    A HELP command.
  730. ,    A SUSPEND command with automatic file saving.
  731. ,    A repeat search command.
  732. ,    A replace command with confirmation dialogue.
  733. ,    A change working directory command.
  734. ,    A change file name reference command.
  735. ,    Reading from standard input and writing to standard output.
  736. ,    Starting up at a given line number.
  737. ,    Appending versions of the buffer cut/copy/write commands.
  738. ,    Process-independent version of the paste command, thus enabling
  739. ,        inter-window paste operations.
  740. ,    A view only version of the edit command (not yet very well developed).
  741. ,    Commands to print buffer / to perform command with buffer as input.
  742. ,    Positioning to a percentage within the text.
  743. ,    Accepts control char sequence for absolute positioning (by mouse)
  744. ,    Multi-file edit
  745. ,    External interrupt handling with attempts to save the text
  746. ,    Configurable indicators for line shift left/right, line end, tab.
  747. ,    Improved text security:
  748. ,    Doesn't quit if a file save fails or even if the question for
  749. ,        a filename isn't answered. So you have a chance
  750. ,        to try another filename or something.
  751. ,    Asks whether to overwrite file whenever a file is to be
  752. ,        written to which was not previously read in.
  753. ,    Removed abort_mined since no one wants to kill an editor
  754. ,        unconditionally without attempt to save the text.
  755. ,    Corrections:
  756. ,    Some screen positioning errors and inconsistencies
  757. ,        have been eliminated, for example:
  758. ,    The EF function now really positions to the end of the text, not
  759. ,        to the beginning of the last line,
  760. ,    The HIGH and LOW functions now stay in the current screen column,
  761. ,        as UP and DN do now more consistently.
  762. ,    Input routine detects overflow of input buffer.
  763. ,    Doesn't crash if a file loaded or inserted contains NULL chars.
  764. ,    Scratch file counting and deleting was corrected.
  765. ,    The Readonly flag and status message is now based on the really
  766. ,        effective circumstances (could show wrong state before if
  767. ,        real and effective user id were different).
  768. ,    Several minor modifications, e.g.: XBREAK (the screen column limit)
  769. ,        was increased by 1, since two columns were left blank on
  770. ,        the right screen border.
  771. ,    Missing modification:
  772. ,        The rightmost screen column is currently unused because
  773. ,        linefeed is used as a line positioner. If absolute
  774. ,        positioning would be added for each text line output,
  775. ,        the screen column limit XBREAK could again be increased by 1.
  776. ,
  777. ,
  778. , 1. General remarks.
  779. ,
  780. ,    Mined is a screen editor designed for the minix operating system.
  781. ,    It is meant to be used on files not larger than 50K and to be fast.
  782. ,    When mined starts up, it reads the file into its memory to minimize
  783. ,    disk access. The only time that disk access is needed is when certain
  784. ,    save, write or copy commands are given.
  785. ,
  786. ,    Mined has the style of Emacs or Jove, that means that there are no modes.
  787. ,    Each character has its own entry in an 256 pointer to function array,
  788. ,    which is called when that character is typed. Only ASCII characters are
  789. ,    connected with a function that inserts that character at the current
  790. ,    location in the file. Two exceptions are <linefeed> and <tab> which are
  791. ,    inserted as well. Note that the mapping between commands and functions
  792. ,    called is implicit in the table. Changing the mapping just implies
  793. ,    changing the pointers in this table.
  794. ,
  795. ,    The display consists of SCREENMAX + 1 lines and XMAX + 1 characters. When
  796. ,    a line is larger (or gets larger during editing) than XBREAK characters,
  797. ,    the line is either shifted SHIFT_SIZE characters to the left (which means
  798. ,    that the first SHIFT_SIZE characters are not printed) or the end of the
  799. ,    line is marked with the SHIFT_MARK character and the rest of the line is
  800. ,    not printed.  A line can never exceed MAX_CHARS characters. Mined will
  801. ,    always try to keep the cursor on the same line and same (relative)
  802. ,    x-coordinate if nothing changed. So if you scroll one line up, the cursor
  803. ,    stays on the same line, or when you move one line down, the cursor will
  804. ,    move to the same place on the line as it was on the previous.
  805. ,    Every character on the line is available for editing including the
  806. ,    linefeed at the the of the line. When the linefeed is deleted, the current
  807. ,    line and the next line are joined. The last character of the file (which
  808. ,    is always a linefeed) can never be deleted.
  809. ,    The bottomline (as indicated by YMAX + 1) is used as a status line during
  810. ,    editing. This line is usually blank or contains information mined needs
  811. ,    during editing. This information (or rather questions) is displayed in
  812. ,    reverse video.
  813. ,
  814. ,    The terminal modes are changed completely. All signals like start/stop,
  815. ,    interrupt etc. are unset. The only signal that remains is the quit signal.
  816. ,    The quit signal (^\) is the general abort signal for mined. Typing a ^\
  817. ,    during searching or when mined is asking for filenames, etc. will abort
  818. ,    the function and mined will return to the main loop.
  819. ,    Sending a quit signal during the main loop will abort the session
  820. ,    (after confirmation) and the file is not (!) saved. *removed*
  821. ,    The session will also be aborted when an unrecoverable error occurs, e.g.
  822. ,    when there is no more memory available. If the file has been modified,
  823. ,    mined will ask if the file has to be saved or not.
  824. ,    If there is no more space left on the disk, mined will just give an error
  825. ,    message and continue.
  826. ,
  827. ,    The number of system calls are minimized. This is done to keep the editor
  828. ,    as fast as possible. I/O is done in SCREEN_SIZE reads/writes. Accumulated
  829. ,    output is also flushed at the end of each character typed.
  830. ,
  831. , 2. Regular expressions
  832. ,
  833. ,    Mined has a built in regular expression matcher, which is used for
  834. ,    searching and replace routines. A regular expression consists of a
  835. ,    sequence of:
  836. ,
  837. ,    1. A normal character matching that character.
  838. ,    2. A . matching any character.
  839. ,    3. A ^ matching the begin of a line.
  840. ,    4. A $ (as last character of the pattern) mathing the end of a line.
  841. ,    5. A \<character> matching <character>.
  842. ,    6. A number of characters enclosed in [] pairs matching any of these
  843. ,       characters. A list of characters can be indicated by a '-'. So
  844. ,       [a-z] matches any letter of the alphabet. If the first character
  845. ,       after the '[' is a '^' then the set is negated (matching none of
  846. ,       the characters).
  847. ,       A ']', '^' or '-' can be escaped by putting a '\' in front of it.
  848. ,       Of course this means that a \ must be represented by \\.
  849. ,    7. If one of the expressions as described in 1-6 is followed by a
  850. ,       '*' than that expressions matches a sequence of 0 or more of
  851. ,       that expression.
  852. ,
  853. ,    Parsing of regular expression is done in two phases. In the first phase
  854. ,    the expression is compiled into a more comprehensible form. In the second
  855. ,    phase the actual matching is done. For more details see 3.6.
  856. ,
  857. ,
  858. , 3. Implementation of mined.
  859. ,
  860. ,    3.1 Data structures.
  861. ,
  862. ,    The main data structures are as follows. The whole file is kept in a
  863. ,    double linked list of lines. The LINE structure looks like this:
  864. ,
  865. ,        typedef struct Line {
  866. ,            struct Line * next;
  867. ,            struct Line * prev;
  868. ,            char * text;
  869. ,            unsigned char shift_count;
  870. ,        } LINE;
  871. ,
  872. ,    Each line entry contains a pointer to the next line, a pointer to the
  873. ,    previous line and a pointer to the text of that line. A special field
  874. ,    shift_count contains the number of shifts (in units of SHIFT_SIZE)
  875. ,    that is performed on that line. The total size of the structure is 7
  876. ,    bytes so a file consisting of 1000 empty lines will waste a lot of
  877. ,    memory. A LINE structure is allocated for each line in the file. After
  878. ,    that the number of characters of the line is counted and sufficient
  879. ,    space is allocated to store them (including a linefeed and a '\0').
  880. ,    The resulting address is assigned to the text field in the structure.
  881. ,
  882. ,    A special structure is allocated and its address is assigned to the
  883. ,    variable header as well as the variable tail. The text field of this
  884. ,    structure is set to NIL_PTR. The tail->prev of this structure points
  885. ,    to the last LINE of the file and the header->next to the first LINE.
  886. ,    Other LINE * variables are top_line and bot_line which point to the
  887. ,    first line resp. the last line on the screen.
  888. ,    Two other variables are important as well. First the LINE * cur_line,
  889. ,    which points to the LINE currently in use and the char * cur_text,
  890. ,    which points to the character at which the cursor stands.
  891. ,    Whenever an ASCII character is typed, a new line is build with this
  892. ,    character inserted. Then the old data space (pointed to by
  893. ,    cur_line->text) is freed, data space for the new line is allocated and
  894. ,    assigned to cur_line->text.
  895. ,
  896. ,    Two global variables called x and y represent the x and y coordinates
  897. ,    from the cursor. The global variable nlines contains the number of
  898. ,    lines in the file. Last_y indicates the maximum y coordinate of the
  899. ,    screen (which is usually SCREENMAX).
  900. ,
  901. ,    A few strings must be initialized by hand before compiling mined.
  902. ,    These string are enter_string, which is printed upon entering mined,
  903. ,    rev_video (turn on reverse video), normal_video, rev_scroll (perform a
  904. ,    reverse scroll) and pos_string. The last string should hold the
  905. ,    absolute position string to be printed for cursor motion. The #define
  906. ,    X_PLUS and Y_PLUS should contain the characters to be added to the
  907. ,    coordinates x and y (both starting at 0) to finish cursor positioning.
  908. ,
  909. ,    3.2 Starting up.
  910. ,
  911. ,    Mined can be called with or without argument and the function
  912. ,    load_file() is called with these arguments. load_file() checks
  913. ,    if the file exists if it can be read and if it is writable and
  914. ,    sets the writable flag accordingly. If the file can be read,
  915. ,    load_file() reads a line from the file and stores this line into
  916. ,    a structure by calling install_line() and line_insert() which
  917. ,    installs the line into the double linked list, until the end of the
  918. ,    file is reached.
  919. ,    Lines are read by the function get_line(), which buffers the
  920. ,    reading in blocks of SCREEN_SIZE. Load_file() also initializes the
  921. ,    LINE * variables described above.
  922. ,
  923. ,    3.3 Moving around.
  924. ,
  925. ,    Several commands are implemented for moving through the file.
  926. ,    Moving up (UP), down (DN) left (LF) and right (RT) are done by the
  927. ,    arrow keys. Moving one line below the screen scrolls the screen one
  928. ,    line up. Moving one line above the screen scrolls the screen one line
  929. ,    down. The functions forward_scroll() and reverse_scroll() take care
  930. ,    of that.
  931. ,    Several other move functions exist: move to begin of line (BL), end of
  932. ,    line (EL) top of screen (HIGH), bottom of screen (LOW), top of file
  933. ,    (HO), end of file (EF), scroll one page down (PD), scroll one page up
  934. ,    (PU), scroll one line down (SD), scroll one line up (SU) and move to a
  935. ,    certain line number (GOTO).
  936. ,    Two functions called MN() and MP() each move one word further or
  937. ,    backwards. A word is a number of non-blanks seperated by a space, a
  938. ,    tab or a linefeed.
  939. ,
  940. ,    3.4 Modifying text.
  941. ,
  942. ,    The modifying commands can be separated into two modes. The first
  943. ,    being inserting text, and the other deleting text. Two functions are
  944. ,    created for these purposes: insert() and delete(). Both are capable
  945. ,    of deleting or inserting large amounts of text as well as one
  946. ,    character. Insert() must be given the line and location at which
  947. ,    the text must be inserted. Is doesn't make any difference whether this
  948. ,    text contains linefeeds or not. Delete() must be given a pointer to
  949. ,    the start line, a pointer from where deleting should start on that
  950. ,    line and the same information about the end position. The last
  951. ,    character of the file will never be deleted. Delete() will make the
  952. ,    necessary changes to the screen after deleting, but insert() won't.
  953. ,    The functions for modifying text are: insert one char (S), insert a
  954. ,    file (file_insert(fd)), insert a linefeed and put cursor back to
  955. ,    end of line (LIB), delete character under the cursor (DCC), delete
  956. ,    before cursor (even linefeed) (DPC), delete next word (DNW), delete
  957. ,    previous word (DPW) and delete to end of line (if the cursor is at
  958. ,    a linefeed delete line) (DLN).
  959. ,
  960. ,    3.5 Yanking.
  961. ,
  962. ,    A few utilities are provided for yanking pieces of text. The function
  963. ,    MA() marks the current position in the file. This is done by setting
  964. ,    LINE * mark_line and char * mark_text to the current position. Yanking
  965. ,    of text can be done in two modes. The first mode just copies the text
  966. ,    from the mark to the current position (or visa versa) into a buffer
  967. ,    (YA) and the second also deletes the text (DT). Both functions call
  968. ,    the function set_up() with the delete flag on or off. Set_up()
  969. ,    checks if the marked position is still a valid one (by using
  970. ,    check_mark() and legal()), and then calls the function yank() with
  971. ,    a start and end position in the file. This function copies the text
  972. ,    into a scratch_file as indicated by the variable yank_file. This
  973. ,    scratch_file is made unique by the function scratch_file(). At the end
  974. ,    of copying yank will (if necessary) delete the text. A global flag
  975. ,    called yank_status keeps track of the buffer (or file) status. It is
  976. ,    initialized on NOT_VALID and set to EMPTY (by set_up()) or VALID (by
  977. ,    yank()). Several things can be done with the buffer. It can be
  978. ,    inserted somewhere else in the file (PT) or it can be copied into
  979. ,    another file (WB), which will be prompted for.
  980. ,
  981. ,    3.6 Search and replace routines.
  982. ,
  983. ,    Searching for strings and replacing strings are done by regular
  984. ,    expressions. For any expression the function compile() is called
  985. ,    with as argument the expression to compile. Compile() returns a
  986. ,    pointer to a structure which looks like this:
  987. ,
  988. ,        typedef struct regex {
  989. ,            union {
  990. ,                char * err_mess;
  991. ,                int * expression;
  992. ,            } result;
  993. ,            char status;
  994. ,            char * start_ptr;
  995. ,            char * end_ptr;
  996. ,        } REGEX;
  997. ,
  998. ,    If something went wrong during compiling (e.g. an illegal expression
  999. ,    was given), the function reg_error() is called, which sets the status
  1000. ,    field to REG_ERROR and the err_mess field to the error message. If the
  1001. ,    match must be anchored at the beginning of the line (end of line), the
  1002. ,    status field is set to BEGIN_LINE (END_LINE). If none of these special
  1003. ,    cases are true, the field is set to 0 and the function finished() is
  1004. ,    called. Finished() allocates space to hold the compiled expression
  1005. ,    and copies this expression into the expression field of the union
  1006. ,    (bcopy()). Matching is done by the routines match() and line_check().
  1007. ,    Match() takes as argument the REGEX * program, a pointer to the
  1008. ,    startposition on the current line, and a flag indicating FORWARD or
  1009. ,    REVERSE search. Match() checks out the whole file until a match is
  1010. ,    found. If match is found it returns a pointer to the line in which the
  1011. ,    match was found else it returns a NIL_LINE. Line_check() takes the
  1012. ,    same arguments, but return either MATCH or NO_MATCH.
  1013. ,    During checking, the start_ptr and end_ptr fields of the REGEX
  1014. ,    structure are assigned to the start and end of the match.
  1015. ,    Both functions try to find a match by walking through the line
  1016. ,    character by character. For each possibility, the function
  1017. ,    check_string() is called with as arguments the REGEX * program and the
  1018. ,    string to search in. It starts walking through the expression until
  1019. ,    the end of the expression or the end of the string is reached.
  1020. ,    Whenever a * is encountered, this position of the string is marked,
  1021. ,    the maximum number of matches are performed and the function star()
  1022. ,    is called in order to try to find the longest match possible. Star()
  1023. ,    takes as arguments the REGEX program, the current position of the
  1024. ,    string, the marked position and the current position of the expression
  1025. ,    Star() walks from the current position of the string back to the
  1026. ,    marked position, and calls string_check() in order to find a match.
  1027. ,    It returns MATCH or NO_MATCH, just as string_check() does.
  1028. ,    Searching is now easy. Both search routines (forward (SF) and
  1029. ,    backwards search (SR)) call search() with an apropiate message and a
  1030. ,    flag indicating FORWARD or REVERSE search. Search() will get an
  1031. ,    expression from the user by calling get_expression(). Get_expression()
  1032. ,    returns a pointer to a REGEX structure or NIL_REG upon errors and
  1033. ,    prompts for the expression. If no expression if given, the previous is
  1034. ,    used instead. After that search will call match(), and if a match is
  1035. ,    found, we can move to that place in the file by the functions find_x()
  1036. ,    and find_y() which will find display the match on the screen.
  1037. ,    Replacing can be done in two ways. A global replace (GR) or a line
  1038. ,    replace (LR). Both functions call change() with a message and a flag
  1039. ,    indicating global or line replacement. Change() will prompt for the
  1040. ,    expression and for the replacement. Every & in the replacement pattern
  1041. ,    means substitute the match instead. An & can be escaped by a \. When
  1042. ,    a match is found, the function substitute() will perform the
  1043. ,    substitution.
  1044. ,
  1045. ,    3.6 Miscellaneous commands.
  1046. ,
  1047. ,    A few commands haven't be discussed yet. These are redraw the screen
  1048. ,    (RD) fork a shell (SH), print file status (FS), write file to disc
  1049. ,    (WT), insert a file at current position (IF), leave editor (XT) and
  1050. ,    visit another file (VI). The last two functions will check if the file
  1051. ,    has been modified. If it has, they will ask if you want to save the
  1052. ,    file by calling ask_save().
  1053. ,    The function REPT() will repeat a command n times. It will prompt for
  1054. ,    the number. Aborting the loop can be done by sending the ^\ signal.
  1055. ,
  1056. ,    3.7 Utility functions.
  1057. ,
  1058. ,    Several functions exists for internal use. First allocation routines:
  1059. ,    alloc(bytes) and newline() will return a pointer to free data space
  1060. ,    if the given size. If there is no more memory available, the function
  1061. ,    panic() is called.
  1062. ,    Signal handling: The only signal that can be sent to mined is the
  1063. ,    SIGQUIT signal. This signal, functions as a general abort command.
  1064. ,    Mined will abort if the signal is given during the main loop. The
  1065. ,    function abort_mined() takes care of that.
  1066. ,    Panic() is a function with as argument a error message. It will print
  1067. ,    the message and the error number set by the kernel (errno) and will
  1068. ,    ask if the file must be saved or not. It resets the terminal
  1069. ,    (raw_mode()) and exits.
  1070. ,    String handling routines like copy_string(to, from), length_of(string)
  1071. ,    and build_string(buffer, format, arg1, arg2, ...). The latter takes
  1072. ,    a description of the string out out the format field and puts the
  1073. ,    result in the buffer. (It works like printf (3), but then into a
  1074. ,    string). The functions status_line(string1, string2), error(string1,
  1075. ,    string2), clear_status() and bottom_line() all print information on
  1076. ,    the status line.
  1077. ,    Get_string(message, buffer) reads a string and getchar() reads one
  1078. ,    character from the terminal.
  1079. ,    Num_out((long) number) prints the number into a 11 digit field
  1080. ,    without leading zero's. It returns a pointer to the resulting string.
  1081. ,    File_status() prints all file information on the status line.
  1082. ,    Set_cursor(x, y) prints the string to put the cursor at coordinates
  1083. ,    x and y.
  1084. ,    Output is done by four functions: writeline(fd,string), clear_buffer()
  1085. ,    write_char(fd, c) and flush_buffer(fd). Three defines are provided
  1086. ,    to write on filedescriptor STD_OUT (terminal) which is used normally:
  1087. ,    string_print(string), putchar(c) and flush(). All these functions
  1088. ,    use the global I/O buffer screen and the global index for this array
  1089. ,    called out_count. In this way I/O can be buffered, so that reads or
  1090. ,    writes can be done in blocks of SCREEN_SIZE size.
  1091. ,    The following functions all handle internal line maintenance. The
  1092. ,    function proceed(start_line, count) returns the count'th line after
  1093. ,    start_line.  If count is negative, the count'th line before the
  1094. ,    start_line is returned. If header or tail is encountered then that
  1095. ,    will be returned. Display(x, y, start_line, count) displays count
  1096. ,    lines starting at coordinates [x, y] and beginning at start_line. If
  1097. ,    the header or tail is encountered, empty lines are displayed instead.
  1098. ,    The function reset(head_line, ny) reset top_line, last_y, bot_line,
  1099. ,    cur_line and y-coordinate. This is not a neat way to do the
  1100. ,    maintenance, but it sure saves a lot of code. It is usually used in
  1101. ,    combination with display().
  1102. ,    Put_line(line, offset, clear_line), prints a line (skipping characters
  1103. ,    according to the line->shift_size field) until XBREAK - offset
  1104. ,    characters are printed or a '\n' is encountered. If clear_line is
  1105. ,    TRUE, spaces are printed until XBREAK - offset characters.
  1106. ,    Line_print(line) is a #define from put_line(line, 0, TRUE).
  1107. ,    Moving is done by the functions move_to(x, y), move_addres(address)
  1108. ,    and move(x, adress, y). This function is the most important one in
  1109. ,    mined. New_y must be between 0 and last_y, new_x can be about
  1110. ,    anything, address must be a pointer to an character on the current
  1111. ,    line (or y). Move_to() first adjust the y coordinate together with
  1112. ,    cur_line. If an address is given, it finds the corresponding
  1113. ,    x-coordinate. If an new x-coordinate was given, it will try to locate
  1114. ,    the corresponding character. After that it sets the shift_count field
  1115. ,    of cur_line to an apropiate number according to new_x. The only thing
  1116. ,    left to do now is to assign the new values to cur_line, cur_text, x
  1117. ,    and y.
  1118. ,
  1119. , 4. Summary of commands.
  1120. ,
  1121. ,    See seperate file mined.help .
  1122. ,
  1123. ,+===========================================================================+
  1124. EOSED
  1125.  
  1126. exit 0
  1127.  
  1128.