home *** CD-ROM | disk | FTP | other *** search
/ Programmer's ROM - The Computer Language Library / programmersrom.iso / ada / edit / ed.doc < prev    next >
Encoding:
Text File  |  1988-05-03  |  46.8 KB  |  1,585 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.                              ALED - Ada Line Editor
  22.  
  23.                    A Line-Oriented File Editor written in Ada
  24.  
  25.  
  26.                                  by Richard Conn
  27.                                 Texas Instruments
  28.                           Advanced Computer Systems Lab
  29.                               Ada Technology Branch
  30.  
  31.                                 10 December 1984
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.                                 C O N T E N T S 
  71.  
  72.           1. INTRODUCTION...............................................1
  73.  
  74.           2. USING ALED.................................................2
  75.              2.1. PRELIMINARIES.........................................4
  76.                   2.1.1. LINE RANGES....................................4
  77.                   2.1.2. LINE REFERENCES................................5
  78.                   2.1.3. STRINGS and LINES..............................5
  79.                   2.1.4. INPUT LINE EDITOR..............................6
  80.                   2.1.5. ABORTING COMMANDS..............................6
  81.              2.2. COMMANDS..............................................6
  82.              2.3. SAMPLE SESSION........................................9
  83.  
  84.           3. SYNOPSIS and COMMENTS.....................................19
  85.  
  86.              Index.....................................................20
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.                 ALED - A Line-Oriented File Editor Written in Ada
  134.  
  135.  
  136.  
  137.  
  138.                              ALED - Ada Line Editor
  139.  
  140.                    A Line-Oriented File Editor written in Ada
  141.  
  142.  
  143.                                  by Richard Conn
  144.                                 Texas Instruments
  145.                           Advanced Computer Systems Lab
  146.                               Ada Technology Branch
  147.  
  148.                                 10 December 1984
  149.  
  150.  
  151.  
  152.         1. I N T R O D U C T I O N 
  153.  
  154.              ALED  is a relatively simple line-oriented file editor which 
  155.         is  written  in the Ada (trademark,  United States Department  of 
  156.         Defense)  programming language.   It was written to  satisfy  the 
  157.         following needs:
  158.  
  159.                   (1)  to help the author learn the Ada language  by 
  160.             writing  a useful program whose scope (at a few thousand 
  161.             lines) is reasonable
  162.  
  163.                   (2)  to  help  others  wanting  to  learn  Ada  by 
  164.             providing a "living example" of an editor written in Ada 
  165.             (note that this example is by no means perfect and there 
  166.             is room for improvement)
  167.  
  168.                   (3)  to make a transportable  editor,  written  in 
  169.             Ada, available for use on a variety of machines; efforts 
  170.             were  made to use only TEXT_IO for support,  so the code 
  171.             should be transportable between all machines that have a 
  172.             validated Ada compiler
  173.  
  174.  
  175.              This document is divided into two parts:  (1) an overview on 
  176.         the operation of the editor from the user's perspective and (2) a 
  177.         synopsis  of  what was learned during its design and comments  on 
  178.         the design in general.
  179.  
  180.              The  version  of  ALED which has been released  to  the  Ada 
  181.         Repository  is the Engineering Development Model (EDM)  of  ALED.  
  182.         An Advanced Development Model,  which was completed some time ago 
  183.         and  will never be released,  was written to learn the basics  of 
  184.         the  problem and to prove that the problem could be solved.   The 
  185.         EDM  is  a  more  elaborate,   complete,   and  better-documented 
  186.         production of the ADM concept.  A production model of ALED may be 
  187.         released as some future date, but no obligation is assumed on the 
  188.         part of the author to do so.
  189.  
  190.  
  191.  
  192.  
  193.                                         1
  194.  
  195.  
  196.  
  197.  
  198.  
  199.                 ALED - A Line-Oriented File Editor Written in Ada
  200.  
  201.  
  202.  
  203.         2. U S I N G   A L E D 
  204.  
  205.              ALED  was designed and implemented on a Data General MV10000 
  206.         under  the ROLM Ada Development Environment.   It is  invoked  on 
  207.         this system by typing
  208.  
  209.                                     X EDITOR
  210.  
  211.         where  EDITOR.PR is the name of the file containing the object of 
  212.         ALED after compilation and linking.   This invocation results  in 
  213.         the following banner being displayed:
  214.  
  215.                ALED - Ada Line Editor by Richard Conn, Version 1.0
  216.                File Name? 
  217.  
  218.         The  user is expected to enter the name of the file to be  edited 
  219.         at  this time.   A file name must be specified,  and one will  be 
  220.         created  if the file does not exist.   If the indicated text file 
  221.         exists,  its  contents  will be read into  a  doubly-linked  list 
  222.         created  by ALED and made ready for editing.   Input line editing 
  223.         (see the following section on the Input Line Editor) is  allowed, 
  224.         so the user can correct any errors he makes while typing the file 
  225.         name.
  226.  
  227.              After the indicated file is read in or created, ALED prompts 
  228.         the user with
  229.  
  230.                   n>
  231.  
  232.         where  "n"  is 0 if there are no lines in the file (the  file  is 
  233.         empty) or 1 if there are lines in the file.   The number in front 
  234.         of  the ">" character is the number of the current line.   As the 
  235.         user  moves through the file,  this number will be  updated  each 
  236.         time the prompt appears.
  237.  
  238.              Once   this  prompt  appears,   ALED  uses  single-character 
  239.         commands  with command completion and prompting to  interface  to 
  240.         the  user.   In  response  to  any one  of  the  single-character 
  241.         commands  recognized by ALED,  the ALED editor will complete  the 
  242.         text  of  the  command,  prompt the  user  for  input  parameters 
  243.         (allowing him to abort by providing no input in most cases),  and 
  244.         then perform the function of the command.  ALED is interactive in 
  245.         nature, and the learning curve for ALED is quite short.  Built-in 
  246.         summary  documentation  is  provided  by means of  the  H  (Help) 
  247.         command; to illustrate, when the letter "h" is typed (case is not 
  248.         significant  on  letter  commands),   the  following  display  is 
  249.         presented:
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.                                         2
  260.  
  261.  
  262.  
  263.  
  264.  
  265.                 ALED - A Line-Oriented File Editor Written in Ada
  266.  
  267.  
  268.  
  269.             0> help
  270.  
  271.         --- Movement Commands ---  ----- Enter Lines -----
  272.          + Advance N Lines          A Append after <line> 
  273.          - Back Up N Lines          I Insert before <line>
  274.          F Find <string> in <range>                       
  275.          J Jump to <line>          ----- Print Lines -----
  276.          N Find Next <string>       . Print Current Line  
  277.         ----- Delete Command -----  < Print Next Line     
  278.          D Delete lines in <range>  > Print Next Line     
  279.                                     L List over <range>   
  280.         ---- Help and Exits ----                          
  281.          H This Help Text          ---- Substitution ---- 
  282.          Q Quit without Updating    S String Substitute   
  283.          X Exit and Update              over <range>      
  284.  
  285.         ---- File Get/Put ----     -- Miscellaneous --    
  286.          G Get <file> after <line>  ? Print Statistics    
  287.          P Put <file> over <range>                        
  288.  
  289.         <Range>:  %   %,%
  290.         First or Second Entries --
  291.            #-Number, .-Current, C-Current, F-First, L-Last
  292.         Singular Entries --
  293.          A-All, P-Page
  294.             0> 
  295.  
  296.  
  297.                   -- Figure 1: ALED Help Command and Display --
  298.  
  299.              To reiterate, the above display was generated as follows:
  300.  
  301.                   1) the prompt "0>" was printed by ALED
  302.                   2) the user typed the letter "h"
  303.                   3) the characters "elp" were filled in by ALED
  304.                        after the letter "h" (forming the word
  305.                        "help")
  306.                   4) the command summary was printed by ALED
  307.                   5) the prompt "0>" was again printed by ALED,
  308.                        indicating that it is ready for the next
  309.                        command
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.                                         3
  326.  
  327.  
  328.  
  329.  
  330.  
  331.                 ALED - A Line-Oriented File Editor Written in Ada
  332.  
  333.  
  334.  
  335.         2.1. PRELIMINARIES
  336.  
  337.         2.1.1. LINE RANGES
  338.              Several of the ALED commands, such as List and Find, perform 
  339.         their operations over a range of lines.  They prompt the user for 
  340.         this  line  range with the herald "<range>".   Examples  of  this 
  341.         prompt are:
  342.  
  343.                   1) list lines in <range>
  344.                   2) find <string>
  345.                       over <range>
  346.                   3) substitute for old <string>
  347.                       new <string>
  348.                       over <range>
  349.  
  350.              Whenever the range prompt ("<range>") is presented, the user 
  351.         may enter any of the following responses:
  352.  
  353.                   Response       Meaning
  354.                   --------       -------
  355.                   A or a         All Lines
  356.                   P or p         Current Page (next 20 lines)
  357.                   . or C or c    Current Line
  358.                   F or f         First Line
  359.                   L or l         Last Line
  360.  
  361.                   #,#            A pair of line numbers, like "5,8",
  362.                                   or relative line references, like
  363.                                   "-5,+10" for 5 lines before the
  364.                                   current line to 10 lines after the
  365.                                   current line, or any combination,
  366.                                   like "5,+10" for line 5 to 10 lines
  367.                                   after the current line; the only
  368.                                   restriction is that the first number
  369.                                   must evaluate to be less than the
  370.                                   second number
  371.  
  372.                   s,s            A mixture of the symbols for Current
  373.                                   Line, First Line, Last Line, and
  374.                                   a line number or relative line
  375.                                   reference, like ".,L" for current
  376.                                   line to the last line, "1,." for line
  377.                                   1 to the current line, "F,." for first
  378.                                   line to the current line, "-5,." for
  379.                                   five lines before the current line to
  380.                                   the current line, etc.
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.                                         4
  392.  
  393.  
  394.  
  395.  
  396.  
  397.                 ALED - A Line-Oriented File Editor Written in Ada
  398.  
  399.  
  400.  
  401.              Examples:
  402.  
  403.                   list lines in <range> A       <-- all lines
  404.                   list lines in <range> .,L     <-- current to last
  405.                   list lines in <range> 1,5     <-- lines 1 to 5
  406.                   list lines in <range> -5,+6   <-- 5 lines before the
  407.                                                      current line to 6
  408.                                                      lines after the
  409.                                                      current line
  410.                   list lines in <range> P       <-- next 20 lines
  411.                   list lines in <range> F,L     <-- same as All lines
  412.  
  413.  
  414.         2.1.2. LINE REFERENCES
  415.              Some  commands operate only on a specific line,  such as the 
  416.         Append and Insert commands.   The user is to indicate a  specific 
  417.         line, as opposed to a range of lines, in response to the "<line>" 
  418.         herald printed by these commands; for example:
  419.  
  420.                   append after <line>
  421.                   insert before <line>
  422.  
  423.              Any  of the forms indicated above may be used to define this 
  424.         line reference,  and the indicated line becomes the first line of 
  425.         the range.   For instance,  if "A" (all lines) is the response to 
  426.         the  herald,  then line 1 is the indicated line since  all  lines 
  427.         references  line  1  to the last line.   It is usually  safer  to 
  428.         reference only one line in response to the "<line>" herald (like, 
  429.         "5" or ".") rather than to use a range specification.
  430.  
  431.  
  432.         2.1.3. STRINGS and LINES
  433.              Some  commands accept a string or a line as input,  such  as 
  434.         the  Substitute and Insert commands.   In both  cases,  the  text 
  435.         which  is input by the user is simply a group of characters.   No 
  436.         quotes or other delimiters are necessary.   However, AT LEAST ONE 
  437.         CHARACTER MUST BE INPUT.  The response may not simply be a strike 
  438.         at the RETURN key; a space followed by a strike at the RETURN key 
  439.         is the recommended combination.   The reason for this restriction 
  440.         is discussed later.
  441.  
  442.              When  inputting  a group of lines via the Append  or  Insert 
  443.         commands, the lines are prompted for with the herald:
  444.  
  445.                   n:
  446.  
  447.         where  "n" is the number of the line that is about to  be  input.  
  448.         The  user may enter characters as he desires in response to  this 
  449.         prompt,  remembering that blank lines consist of a space followed 
  450.         by the RETURN key.   To terminate input, the user enters a single 
  451.         dot  (".") followed by RETURN.   See the sample session below and 
  452.         experiment with the editor itself for clarification.
  453.  
  454.  
  455.  
  456.  
  457.                                         5
  458.  
  459.  
  460.  
  461.  
  462.  
  463.                 ALED - A Line-Oriented File Editor Written in Ada
  464.  
  465.  
  466.  
  467.         2.1.4. INPUT LINE EDITOR
  468.              The  user has the ability to edit his string or line  inputs 
  469.         as he enters each character.  This is done by striking any one of 
  470.         the  three input line editor command characters.   The  following 
  471.         table  summarizes these characters,  giving their default  values 
  472.         and the functions they perform.
  473.  
  474.         Default
  475.          Value    Function
  476.         -------   --------
  477.            `      Delete previous character
  478.            @      Delete all previous characters and restart input
  479.            ~      Retype the line or string entered so far
  480.  
  481.              These  default values may be changed to some other values by 
  482.         editing the source code and changing three constants.   It may be 
  483.         of  value to replace these defaults with more convenient  values, 
  484.         such  as  the DEL key to delete the  previous  character,  ^U  to 
  485.         delete  all  previous characters,  and ^R to retype the  line  or 
  486.         string.  See Part 2 for an explanation of why these defaults were 
  487.         chosen.
  488.  
  489.         2.1.5. ABORTING COMMANDS
  490.              If the user strikes a command by accident, most commands may 
  491.         be aborted by simply doing the following:
  492.  
  493.                   1)  not  specifying  a range of lines  (enter  a  space 
  494.         followed by a RETURN in response to the <range> herald)
  495.                   2)  not specifying a line (enter a space followed by  a 
  496.         RETURN in response to the <line> herald)
  497.                   3)  not  specifying  a file name for the  Get  and  Put 
  498.         commands (enter a space followed by a RETURN)
  499.  
  500.  
  501.  
  502.  
  503.         2.2. COMMANDS
  504.              The  following presents the various commands of  ALED.   The 
  505.         sample session illustrates their use.
  506.  
  507.              COMMAND:  .
  508.              FUNCTION: Print the current line
  509.              The "." command prints the current line.
  510.  
  511.              COMMAND:  <
  512.              FUNCTION: Back up to the last line and print it
  513.              The "<" command backs up to the last line and prints it.
  514.  
  515.              COMMAND:  >
  516.              FUNCTION: Advance to the next line and print it
  517.              The ">" command advances to the next line and prints it.
  518.  
  519.  
  520.  
  521.  
  522.  
  523.                                         6
  524.  
  525.  
  526.  
  527.  
  528.  
  529.                 ALED - A Line-Oriented File Editor Written in Ada
  530.  
  531.  
  532.              COMMAND:  +
  533.              FUNCTION: Advance n lines from the current line
  534.              The  "+" command moves the user an indicated number of lines 
  535.         forward from his current position.
  536.  
  537.              COMMAND:  -
  538.              FUNCTION: Back up n lines from the current line
  539.              The "-" command moves the user an indicated number of  lines 
  540.         backward from his current position.
  541.  
  542.              COMMAND:  ?
  543.              FUNCTION: Print statistics
  544.              The "?" command prints the name of the file being edited and 
  545.         the number of lines in the edit buffer.
  546.  
  547.              COMMAND:  A
  548.              FUNCTION: Append lines
  549.              The  A  command allows the user to enter a  group  of  lines 
  550.         after the indicated line.  Lines are entered until the user types 
  551.         a line containing a single dot (".") in the first column followed 
  552.         by  a  RETURN.   The Insert command is like  the  Append  command 
  553.         except  that  it inserts lines BEFORE the indicated  line,  where 
  554.         Append appends lines AFTER the indicated line.
  555.  
  556.              COMMAND:  D
  557.              FUNCTION: Delete lines
  558.              The  D command deletes all lines over the indicated range of 
  559.         lines.  There is no recovery from this command.
  560.  
  561.              COMMAND:  F
  562.              FUNCTION: Find the first occurance of a string
  563.              The  F  command searches for the indicated string  over  the 
  564.         indicated  range  of lines.   The first line in the  range  which 
  565.         contains the string is positioned to and the line is printed.
  566.  
  567.              COMMAND:  G
  568.              FUNCTION: Get a File
  569.              The  G  command  loads the indicated file  into  the  editor 
  570.         buffer  after the indicated line.   This command can be  used  to 
  571.         read  in  a  file  to be included in the edit  buffer  for  paste 
  572.         operations,  where  the  Put  command is  the  complementary  cut 
  573.         operation.
  574.  
  575.              COMMAND:  H
  576.              FUNCTION: Print Help Summary
  577.              The  H command prints a summary of the ALED commands to  the 
  578.         user.
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.                                         7
  590.  
  591.  
  592.  
  593.  
  594.  
  595.                 ALED - A Line-Oriented File Editor Written in Ada
  596.  
  597.  
  598.  
  599.              COMMAND:  I
  600.              FUNCTION: Insert lines
  601.              The  I  command allows the user to enter a  group  of  lines 
  602.         before  the  indicated line.   Lines are entered until  the  user 
  603.         types  a  line containing a single dot (".") in the first  column 
  604.         followed  by  a RETURN.   The Append command is like  the  Insert 
  605.         command  except that it appends lines AFTER the  indicated  line, 
  606.         where Insert inserts lines BEFORE the indicated line.
  607.  
  608.              COMMAND:  J
  609.              FUNCTION: Jump to the indicated line
  610.              The J command positions the user at the indicated line.  The 
  611.         line is not printed.
  612.  
  613.              COMMAND:  L
  614.              FUNCTION: List lines over a range
  615.              The  L  command lists all lines over the indicated range  of 
  616.         lines.
  617.  
  618.              COMMAND:  N
  619.              FUNCTION: Find Next occurance of indicated string
  620.              The  N command searches for the indicated string starting at 
  621.         the next line in the file and proceeding to the end of the  file.  
  622.         If  the user inputs a blank line (a space followed by a  RETURN), 
  623.         the  last string referenced by an F or N command is searched  for 
  624.         again.
  625.  
  626.              COMMAND:  P
  627.              FUNCTION: Put a range of lines into a file
  628.              The  P command writes a group of lines from the edit  buffer 
  629.         out  to  a  file on disk.   This may be used  to  create  desired 
  630.         external files or it may be used to cut a section out of the edit 
  631.         buffer and paste it in (via the Get command) elsewhere.
  632.  
  633.              COMMAND:  Q
  634.              FUNCTION: Quit editor and do not update file
  635.              The  Q  command allows the user to exit the  editor  without 
  636.         changing the original file on the disk.
  637.  
  638.              COMMAND:  S
  639.              FUNCTION: Substitute strings
  640.              The  S command substitutes one string for another  over  the 
  641.         indicated range of lines.   All occurrances of the old string are 
  642.         replaced by the new string over this range.
  643.  
  644.              COMMAND:  X
  645.              FUNCTION: Exit the editor and update the file
  646.              The  X command exits the editor and updates the file on  the 
  647.         disk.
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.                                         8
  656.  
  657.  
  658.  
  659.  
  660.  
  661.                 ALED - A Line-Oriented File Editor Written in Ada
  662.  
  663.  
  664.  
  665.         2.3. SAMPLE SESSION
  666.              The  following  is  a sample session which  illustrates  the 
  667.         operation of ALED.  Comments are placed out to the side, prefixed 
  668.         by "<--".
  669.  
  670.  
  671.         ALED - Ada Line Editor by Richard Conn, Version  1.0
  672.         File Name? t.txt         <-- File name is selected
  673.         New File                 <-- File does not already exist
  674.             0 Lines in File
  675.          Type H for Help
  676.             0> help              <-- Help Command
  677.  
  678.         --- Movement Commands ---  ----- Enter Lines -----
  679.          + Advance N Lines          A Append after <line> 
  680.          - Back Up N Lines          I Insert before <line>
  681.          F Find <string> in <range>                       
  682.          J Jump to <line>          ----- Print Lines -----
  683.          N Find Next <string>       . Print Current Line  
  684.         ----- Delete Command -----  < Print Next Line     
  685.          D Delete lines in <range>  > Print Next Line     
  686.                                     L List over <range>   
  687.         ---- Help and Exits ----                          
  688.          H This Help Text          ---- Substitution ---- 
  689.          Q Quit without Updating    S String Substitute   
  690.          X Exit and Update              over <range>      
  691.  
  692.         ---- File Get/Put ----     -- Miscellaneous --    
  693.          G Get <file> after <line>  ? Print Statistics    
  694.          P Put <file> over <range>                        
  695.  
  696.         <Range>:  %   %,%
  697.         First or Second Entries --
  698.            #-Number, .-Current, C-Current, F-First, L-Last
  699.         Singular Entries --
  700.          A-All, P-Page
  701.  
  702.             0> append after <line> .       <-- Append Lines into buffer
  703.         Enter Lines (.<RETURN> to Stop)
  704.             1: This is a test and demonstration of ALED
  705.             2: This is a very short test, but all commands
  706.             3:  should be exercised by it
  707.             4: Note that all commands are single characters;
  708.             5:  the editor fills in the prompt with each
  709.             6:  single character input at the command prompt "n>"
  710.             7: A single dot in a line terminates input
  711.             8: .                           <-- Input is complete
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.                                         9
  722.  
  723.  
  724.  
  725.  
  726.  
  727.                 ALED - A Line-Oriented File Editor Written in Ada
  728.  
  729.  
  730.  
  731.             7> list lines in <range> all   <-- List all lines
  732.             1: This is a test and demonstration of ALED
  733.             2: This is a very short test, but all commands
  734.             3:  should be exercised by it
  735.             4: Note that all commands are single characters;
  736.             5:  the editor fills in the prompt with each
  737.             6:  single character input at the command prompt "n>"
  738.             7: A single dot in a line terminates input
  739.  
  740.             7> list lines in <range> 1,4   <-- List range of lines
  741.             1: This is a test and demonstration of ALED
  742.             2: This is a very short test, but all commands
  743.             3:  should be exercised by it
  744.             4: Note that all commands are single characters;
  745.  
  746.             4> list lines in <range> -1,+2 <-- List range of lines
  747.             3:  should be exercised by it
  748.             4: Note that all commands are single characters;
  749.             5:  the editor fills in the prompt with each
  750.             6:  single character input at the command prompt "n>"
  751.  
  752.             6> list lines in <range> 1     <-- List first line
  753.             1: This is a test and demonstration of ALED
  754.  
  755.             1> list lines in <range> p     <-- List current page
  756.             1: This is a test and demonstration of ALED
  757.             2: This is a very short test, but all commands
  758.             3:  should be exercised by it
  759.             4: Note that all commands are single characters;
  760.             5:  the editor fills in the prompt with each
  761.             6:  single character input at the command prompt "n>"
  762.             7: A single dot in a line terminates input
  763.  
  764.             7> list lines in <range> a     <-- List all lines
  765.             1: This is a test and demonstration of ALED
  766.             2: This is a very short test, but all commands
  767.             3:  should be exercised by it
  768.             4: Note that all commands are single characters;
  769.             5:  the editor fills in the prompt with each
  770.             6:  single character input at the command prompt "n>"
  771.             7: A single dot in a line terminates input
  772.  
  773.             7> y - Error                   <-- Invalid Commands
  774.             7> _ - Error
  775.  
  776.             7> - back up N lines <line count> 3 <-- Backup 3 lines
  777.             4> .                                <-- Print current line
  778.             4: Note that all commands are single characters;
  779.             4> + advance N lines <line count> 1 <-- Advance 1 line
  780.             5> .                                <-- Print current line
  781.             5:  the editor fills in the prompt with each
  782.  
  783.  
  784.  
  785.  
  786.  
  787.                                        10
  788.  
  789.  
  790.  
  791.  
  792.  
  793.                 ALED - A Line-Oriented File Editor Written in Ada
  794.  
  795.  
  796.  
  797.             5> substitute for old <string> test <-- substitute
  798.                 new <string> xx
  799.                 over <range> a
  800.             1: This is a xx and demonstration of ALED     <-- affected
  801.             2: This is a very short xx, but all commands  <--  lines
  802.  
  803.             7> substitute for old <string> xx   <-- change back
  804.                 new <string> test
  805.                 over <range> 2
  806.             2: This is a very short test, but all commands
  807.  
  808.             3> find <string> xx                 <-- look for "xx"
  809.                 over <range> a
  810.             1: This is a xx and demonstration of ALED
  811.  
  812.             1> substitute for old <string> xx   <-- change it
  813.                 new <string> test
  814.                 over <range> .
  815.             1: This is a test and demonstration of ALED
  816.  
  817.             2> find <string> test               <-- look for first
  818.                 over <range> a
  819.             1: This is a test and demonstration of ALED
  820.  
  821.             1> next Occurrance of <string>      <-- look for next
  822.             2: This is a very short test, but all commands
  823.  
  824.             2> list lines in <range> L          <-- look at last line
  825.             7: A single dot in a line terminates input
  826.  
  827.             7> append after <line> L            <-- append lines
  828.         Enter Lines (.<RETURN> to Stop)
  829.             8: This is yet another test
  830.             9: These lines are being appended to the
  831.            10:  end of the file.
  832.            11: I am inserting several instances of
  833.            12:  the word test
  834.            13:  so that there will be something to search for
  835.            14:  in further tests of the Next Occurrance command
  836.            15: .                                <-- end input
  837.  
  838.            14> find <string> test               <-- search for "test"
  839.                 over <range> a
  840.             1: This is a test and demonstration of ALED
  841.  
  842.             1> next Occurrance of <string>      <-- search again
  843.             2: This is a very short test, but all commands
  844.  
  845.             2> next Occurrance of <string>      <-- and again
  846.             8: This is yet another test
  847.  
  848.             8> next Occurrance of <string>      <-- and again
  849.            12:  the word test
  850.  
  851.  
  852.  
  853.                                        11
  854.  
  855.  
  856.  
  857.  
  858.  
  859.                 ALED - A Line-Oriented File Editor Written in Ada
  860.  
  861.  
  862.            12> next Occurrance of <string>      <-- and again
  863.            14:  in further tests of the Next Occurrance command
  864.  
  865.            14> next Occurrance of <string>      <-- and again
  866.            14:  in further tests of the Next Occurrance command
  867.  
  868.            14> substitute for old <string> test <-- change string
  869.                 new <string> xxxxxxx
  870.                 over <range> a
  871.             1: This is a xxxxxxx and demonstration of ALED
  872.             2: This is a very short xxxxxxx, but all commands
  873.             8: This is yet another xxxxxxx
  874.            12:  the word xxxxxxx
  875.            14:  in further xxxxxxxs of the Next Occurrance command
  876.  
  877.            14> substitute for old <string> xxxxxxx   <-- change back
  878.                 new <string> test
  879.                 over <range> a
  880.             1: This is a test and demonstration of ALED
  881.             2: This is a very short test, but all commands
  882.             8: This is yet another test
  883.            12:  the word test
  884.            14:  in further tests of the Next Occurrance command
  885.  
  886.            14> substitute for old <string> test
  887.                 new <string> "test"
  888.                 over <range> 12
  889.            12:  the word "test"
  890.  
  891.            13> jump to <line> 1       <-- Jump command
  892.  
  893.             1> jump to <line> L       <-- Jump to last line
  894.  
  895.            14> jump to <line> 1       <-- Jump to first line
  896.  
  897.             1> list lines in <range> p
  898.             1: This is a test and demonstration of ALED
  899.             2: This is a very short test, but all commands
  900.             3:  should be exercised by it
  901.             4: Note that all commands are single characters;
  902.             5:  the editor fills in the prompt with each
  903.             6:  single character input at the command prompt "n>"
  904.             7: A single dot in a line terminates input
  905.             8: This is yet another test
  906.             9: These lines are being appended to the
  907.            10:  end of the file.
  908.            11: I am inserting several instances of
  909.            12:  the word "test"
  910.            13:  so that there will be something to search for
  911.            14:  in further tests of the Next Occurrance command
  912.  
  913.            14> put <file> q.txt       <-- Write lines out
  914.                 over <range> 11,L     <-- Limit range
  915.            14> get <file> q.txt       <-- Read back in after line 1
  916.                 after <line> 1
  917.  
  918.  
  919.                                        12
  920.  
  921.  
  922.  
  923.  
  924.  
  925.                 ALED - A Line-Oriented File Editor Written in Ada
  926.  
  927.  
  928.             1> list lines in <range> a     <-- look at results
  929.             1: This is a test and demonstration of ALED
  930.             2: I am inserting several instances of
  931.             3:  the word "test"
  932.             4:  so that there will be something to search for
  933.             5:  in further tests of the Next Occurrance command
  934.             6: This is a very short test, but all commands
  935.             7:  should be exercised by it
  936.             8: Note that all commands are single characters;
  937.             9:  the editor fills in the prompt with each
  938.            10:  single character input at the command prompt "n>"
  939.            11: A single dot in a line terminates input
  940.            12: This is yet another test
  941.            13: These lines are being appended to the
  942.            14:  end of the file.
  943.            15: I am inserting several instances of
  944.            16:  the word "test"
  945.            17:  so that there will be something to search for
  946.            18:  in further tests of the Next Occurrance command
  947.  
  948.            18> get <file> q.txt       <-- read lines back in
  949.                 after <line> 7
  950.  
  951.             7> list lines in <range> p     <-- list page of lines
  952.             7:  should be exercised by it
  953.             8: I am inserting several instances of
  954.             9:  the word "test"
  955.            10:  so that there will be something to search for
  956.            11:  in further tests of the Next Occurrance command
  957.            12: Note that all commands are single characters;
  958.            13:  the editor fills in the prompt with each
  959.            14:  single character input at the command prompt "n>"
  960.            15: A single dot in a line terminates input
  961.            16: This is yet another test
  962.            17: These lines are being appended to the
  963.            18:  end of the file.
  964.            19: I am inserting several instances of
  965.            20:  the word "test"
  966.            21:  so that there will be something to search for
  967.            22:  in further tests of the Next Occurrance command
  968.  
  969.            22> insert before <line> 16     <-- insert line
  970.         Enter Lines (.<RETURN> to Stop)
  971.            16: testtesttesttest
  972.            17: .                           <-- end input
  973.  
  974.            17> <                           <-- backup
  975.            16: testtesttesttest
  976.  
  977.            16> <
  978.            15: A single dot in a line terminates input
  979.  
  980.            15> >
  981.            16: testtesttesttest
  982.  
  983.  
  984.  
  985.                                        13
  986.  
  987.  
  988.  
  989.  
  990.  
  991.                 ALED - A Line-Oriented File Editor Written in Ada
  992.  
  993.  
  994.            16> >
  995.            17: This is yet another test
  996.  
  997.            17> <
  998.            16: testtesttesttest
  999.  
  1000.            16> .
  1001.            16: testtesttesttest
  1002.  
  1003.            16> substitute for old <string> test      <-- substitute
  1004.                 new <string> xxxx
  1005.                 over <range> .
  1006.            16: xxxxtesttesttest       <-- observe progress of
  1007.            16: xxxxxxxxtesttest       <-- substitute command
  1008.            16: xxxxxxxxxxxxtest
  1009.            16: xxxxxxxxxxxxxxxx
  1010.  
  1011.            17> <
  1012.            16: xxxxxxxxxxxxxxxx
  1013.  
  1014.            16> substitute for old <string> xxxx      <-- and again
  1015.                 new <string> test
  1016.                 over <range> .
  1017.            16: testxxxxxxxxxxxx
  1018.            16: testtestxxxxxxxx
  1019.            16: testtesttestxxxx
  1020.            16: testtesttesttest
  1021.  
  1022.            17> jump to <line> 1
  1023.  
  1024.             1> ?                      <-- statistics
  1025.                Edit File Name: t.txt
  1026.                   23 Lines in File
  1027.             1> jump to <line> L       <-- verify line count
  1028.  
  1029.            23> jump to <line> 1
  1030.  
  1031.             1> list lines in <range> .
  1032.             1: This is a test and demonstration of ALED
  1033.  
  1034.             1> .
  1035.             1: This is a test and demonstration of ALED
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.                                        14
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.                 ALED - A Line-Oriented File Editor Written in Ada
  1058.  
  1059.  
  1060.  
  1061.             1> list lines in <range> p
  1062.             1: This is a test and demonstration of ALED
  1063.             2: I am inserting several instances of
  1064.             3:  the word "test"
  1065.             4:  so that there will be something to search for
  1066.             5:  in further tests of the Next Occurrance command
  1067.             6: This is a very short test, but all commands
  1068.             7:  should be exercised by it
  1069.             8: I am inserting several instances of
  1070.             9:  the word "test"
  1071.            10:  so that there will be something to search for
  1072.            11:  in further tests of the Next Occurrance command
  1073.            12: Note that all commands are single characters;
  1074.            13:  the editor fills in the prompt with each
  1075.            14:  single character input at the command prompt "n>"
  1076.            15: A single dot in a line terminates input
  1077.            16: testtesttesttest
  1078.            17: This is yet another test
  1079.            18: These lines are being appended to the
  1080.            19:  end of the file.
  1081.            20: I am inserting several instances of
  1082.            21:  the word "test"
  1083.  
  1084.            21> delete lines in <range> 8,11          <-- delete lines
  1085.  
  1086.             8> jump to <line> 1
  1087.  
  1088.             1> list lines in <range> p
  1089.             1: This is a test and demonstration of ALED
  1090.             2: I am inserting several instances of
  1091.             3:  the word "test"
  1092.             4:  so that there will be something to search for
  1093.             5:  in further tests of the Next Occurrance command
  1094.             6: This is a very short test, but all commands
  1095.             7:  should be exercised by it
  1096.             8: Note that all commands are single characters;
  1097.             9:  the editor fills in the prompt with each
  1098.            10:  single character input at the command prompt "n>"
  1099.            11: A single dot in a line terminates input
  1100.            12: testtesttesttest
  1101.            13: This is yet another test
  1102.            14: These lines are being appended to the
  1103.            15:  end of the file.
  1104.            16: I am inserting several instances of
  1105.            17:  the word "test"
  1106.            18:  so that there will be something to search for
  1107.            19:  in further tests of the Next Occurrance command
  1108.  
  1109.            19> delete lines in <range> 2,5      <-- delete more lines
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.                                        15
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.                 ALED - A Line-Oriented File Editor Written in Ada
  1124.  
  1125.  
  1126.  
  1127.             2> list lines in <range> a
  1128.             1: This is a test and demonstration of ALED
  1129.             2: This is a very short test, but all commands
  1130.             3:  should be exercised by it
  1131.             4: Note that all commands are single characters;
  1132.             5:  the editor fills in the prompt with each
  1133.             6:  single character input at the command prompt "n>"
  1134.             7: A single dot in a line terminates input
  1135.             8: testtesttesttest
  1136.             9: This is yet another test
  1137.            10: These lines are being appended to the
  1138.            11:  end of the file.
  1139.            12: I am inserting several instances of
  1140.            13:  the word "test"
  1141.            14:  so that there will be something to search for
  1142.            15:  in further tests of the Next Occurrance command
  1143.  
  1144.            15> Exit and update file (Y/N)? n
  1145.  
  1146.            15> quit without File Update (Y/N)? n
  1147.  
  1148.            15> Exit and update file (Y/N)? y
  1149.  
  1150.         -) type t.txt                                <-- final file
  1151.         This is a test and demonstration of ALED
  1152.         This is a very short test, but all commands
  1153.          should be exercised by it
  1154.         Note that all commands are single characters;
  1155.          the editor fills in the prompt with each
  1156.          single character input at the command prompt "n>"
  1157.         A single dot in a line terminates input
  1158.         testtesttesttest
  1159.         This is yet another test
  1160.         These lines are being appended to the
  1161.          end of the file.
  1162.         I am inserting several instances of
  1163.          the word "test"
  1164.          so that there will be something to search for
  1165.          in further tests of the Next Occurrance command
  1166.         -) type q.txt                                <-- Q.TXT file
  1167.         I am inserting several instances of
  1168.          the word "test"
  1169.          so that there will be something to search for
  1170.          in further tests of the Next Occurrance command
  1171.         -) del q.txt
  1172.         -) x editor
  1173.         ALED - Ada Line Editor by Richard Conn, Version  1.0
  1174.         File Name? t.txt                             <-- reedit file
  1175.            15 Lines in File
  1176.          Type H for Help
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.                                        16
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.                 ALED - A Line-Oriented File Editor Written in Ada
  1190.  
  1191.  
  1192.  
  1193.             1> list lines in <range> a
  1194.             1: This is a test and demonstration of ALED
  1195.             2: This is a very short test, but all commands
  1196.             3:  should be exercised by it
  1197.             4: Note that all commands are single characters;
  1198.             5:  the editor fills in the prompt with each
  1199.             6:  single character input at the command prompt "n>"
  1200.             7: A single dot in a line terminates input
  1201.             8: testtesttesttest
  1202.             9: This is yet another test
  1203.            10: These lines are being appended to the
  1204.            11:  end of the file.
  1205.            12: I am inserting several instances of
  1206.            13:  the word "test"
  1207.            14:  so that there will be something to search for
  1208.            15:  in further tests of the Next Occurrance command
  1209.  
  1210.            15> delete lines in <range> 8
  1211.  
  1212.             8> quit without File Update (Y/N)? y     <-- demo QUIT
  1213.  
  1214.         -) x editor
  1215.         ALED - Ada Line Editor by Richard Conn, Version  1.0
  1216.         File Name? t.txt                        <-- reedit file
  1217.            15 Lines in File
  1218.          Type H for Help
  1219.  
  1220.             1> list lines in <range> a
  1221.             1: This is a test and demonstration of ALED
  1222.             2: This is a very short test, but all commands
  1223.             3:  should be exercised by it
  1224.             4: Note that all commands are single characters;
  1225.             5:  the editor fills in the prompt with each
  1226.             6:  single character input at the command prompt "n>"
  1227.             7: A single dot in a line terminates input
  1228.             8: testtesttesttest
  1229.             9: This is yet another test
  1230.            10: These lines are being appended to the
  1231.            11:  end of the file.
  1232.            12: I am inserting several instances of
  1233.            13:  the word "test"
  1234.            14:  so that there will be something to search for
  1235.            15:  in further tests of the Next Occurrance command
  1236.  
  1237.            15> delete lines in <range> 8        <-- remove line from file
  1238.  
  1239.             8> Exit and update file (Y/N)? y    <-- demo EXIT
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.                                        17
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.                 ALED - A Line-Oriented File Editor Written in Ada
  1256.  
  1257.  
  1258.  
  1259.         -) type t.txt                           <-- show result
  1260.         This is a test and demonstration of ALED
  1261.         This is a very short test, but all commands
  1262.          should be exercised by it
  1263.         Note that all commands are single characters;
  1264.          the editor fills in the prompt with each
  1265.          single character input at the command prompt "n>"
  1266.         A single dot in a line terminates input
  1267.         This is yet another test
  1268.         These lines are being appended to the
  1269.          end of the file.
  1270.         I am inserting several instances of
  1271.          the word "test"
  1272.          so that there will be something to search for
  1273.          in further tests of the Next Occurrance command
  1274.  
  1275.  
  1276.  
  1277.  
  1278.  
  1279.  
  1280.  
  1281.  
  1282.  
  1283.  
  1284.  
  1285.  
  1286.  
  1287.  
  1288.  
  1289.  
  1290.  
  1291.  
  1292.  
  1293.  
  1294.  
  1295.  
  1296.  
  1297.  
  1298.  
  1299.  
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315.                                        18
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.                 ALED - A Line-Oriented File Editor Written in Ada
  1322.  
  1323.  
  1324.  
  1325.         3. S Y N O P S I S   a n d   C O M M E N T S 
  1326.  
  1327.              In  summary,  the  following  items were learned  from  this 
  1328.         experience:
  1329.  
  1330.                   1. Ada is feasible; the editor ran with reasonable 
  1331.                        speed
  1332.  
  1333.                   2. The Ada code was fairly efficient; EDITOR used
  1334.                        only TEXT_IO for support, and, after a 58K
  1335.                        initial overhead, the growth of code was
  1336.                        approximately 9 words/line of code
  1337.  
  1338.                   3. Standardization under TEXT_IO needs some work;
  1339.                        some simple, fundamental items, such as an
  1340.                        input line editor available under GET_LINE,
  1341.                        are missing (this is why I had to write my
  1342.                        own input line editor) and GET does not return
  1343.                        or pass every possible character (the DEL
  1344.                        character does not pass thru the GET routine
  1345.                        in my TEXT_IO package, for instance); do all
  1346.                        GET routines allow single-character input?
  1347.  
  1348.                   4. Generics are useful and work well; software
  1349.                        components libraries will be quite beneficial
  1350.                        in reducing programming overhead once they
  1351.                        have been developed
  1352.  
  1353.                   5. Exceptions are very, very useful; note their
  1354.                        use throughout the code and how they are
  1355.                        fundamental to the design (note the BEGIN/END
  1356.                        in the main loop)
  1357.  
  1358.                   6. Ada code can be written to be quite readable
  1359.                        and maintainable; I feel that I have successfully
  1360.                        done this with ALED (assuming that knowledge
  1361.                        of the generic package in LIST.ADA is known)
  1362.  
  1363.  
  1364.  
  1365.  
  1366.  
  1367.  
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.                                        19
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.                 ALED - A Line-Oriented File Editor Written in Ada
  1388.  
  1389.  
  1390.          I n d e x 
  1391.  
  1392.         +
  1393.         + Command, 7
  1394.  
  1395.         -
  1396.         - Command, 7
  1397.  
  1398.         <
  1399.         < Command, 6
  1400.  
  1401.         >
  1402.         > Command, 6
  1403.  
  1404.         ?
  1405.         ? Command, 7
  1406.  
  1407.         A
  1408.         A Command, 7
  1409.         Aborting Commands, 6
  1410.         Ada, 1
  1411.         Advance Line, 6
  1412.         Advance N Lines, 7
  1413.         Advanced Development Model, 1
  1414.         ALED
  1415.           Aborting Commands, 6
  1416.           ADM, 1
  1417.           Advanced Development Model, 1
  1418.           EDM, 1
  1419.           Engineering Development Model, 1
  1420.           Help Command, 3
  1421.           Input Line Editor, 6
  1422.           Line Input, 5
  1423.           Line Ranges, 4
  1424.           Line References, 5
  1425.           Prompt, 2
  1426.           Purpose, 1
  1427.           String Input, 5
  1428.         Append Lines, 7
  1429.  
  1430.         B
  1431.         Back Up Line, 6
  1432.         Back Up N Lines, 7
  1433.  
  1434.         C
  1435.         Command
  1436.           +, 7
  1437.           -, 7
  1438.           ., 6
  1439.           <, 6
  1440.           >, 6
  1441.           ?, 7
  1442.           A, 7
  1443.           D, 7
  1444.           F, 7
  1445.  
  1446.  
  1447.                                        20
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.                 ALED - A Line-Oriented File Editor Written in Ada
  1454.  
  1455.  
  1456.           G, 7
  1457.           H, 7
  1458.           I, 8
  1459.           J, 8
  1460.           L, 8
  1461.           N, 8
  1462.           P, 8
  1463.           Q, 8
  1464.           S, 8
  1465.           X, 8
  1466.         COMMANDS, 6
  1467.  
  1468.         D
  1469.         D Command, 7
  1470.         Delete Lines, 7
  1471.         Dot Command, 6
  1472.  
  1473.         E
  1474.         Engineering Development Model, 1
  1475.         Exit, 8
  1476.  
  1477.         F
  1478.         F Command, 7
  1479.         File
  1480.           Get, 7
  1481.           Put, 8
  1482.         Find Next String, 8
  1483.         Find String, 7
  1484.  
  1485.         G
  1486.         G Command, 7
  1487.         Get File, 7
  1488.  
  1489.         H
  1490.         H Command, 7
  1491.         Help, 3, 7
  1492.  
  1493.         I
  1494.         I Command, 8
  1495.         Input Line Editor, 6
  1496.         Insert Lines, 8
  1497.         INTRODUCTION, 1
  1498.  
  1499.         J
  1500.         J Command, 8
  1501.         Jump to Line, 8
  1502.  
  1503.         L
  1504.         L Command, 8
  1505.         Line Range Specification, 4
  1506.         Line Reference Specification, 5
  1507.         List Lines, 8
  1508.  
  1509.  
  1510.  
  1511.  
  1512.  
  1513.                                        21
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.                 ALED - A Line-Oriented File Editor Written in Ada
  1520.  
  1521.  
  1522.         N
  1523.         N Command, 8
  1524.         Next String, 8
  1525.  
  1526.         P
  1527.         P Command, 8
  1528.         PRELIMINARIES, 4
  1529.         Print Current Line, 6
  1530.         Print Statistics, 7
  1531.         Put File, 8
  1532.  
  1533.         Q
  1534.         Q Command, 8
  1535.         Quit, 8
  1536.  
  1537.         S
  1538.         S Command, 8
  1539.         SAMPLE SESSION, 9
  1540.         Substitute Strings, 8
  1541.         SYNOPSIS and COMMENTS, 19
  1542.  
  1543.         U
  1544.         USING ALED, 2
  1545.  
  1546.         X
  1547.         X Command, 8
  1548.  
  1549.  
  1550.  
  1551.  
  1552.  
  1553.  
  1554.  
  1555.  
  1556.  
  1557.  
  1558.  
  1559.  
  1560.  
  1561.  
  1562.  
  1563.  
  1564.  
  1565.  
  1566.  
  1567.  
  1568.  
  1569.  
  1570.  
  1571.  
  1572.  
  1573.  
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.                                        22
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.