home *** CD-ROM | disk | FTP | other *** search
/ Programmer's ROM - The Computer Language Library / programmersrom.iso / ada / virterm / vt2user.doc < prev   
Encoding:
Text File  |  1988-05-03  |  124.9 KB  |  2,955 lines

  1.  
  2.  
  3.  
  4.                                            |||||||||||||||||||||||||
  5.                                            |||||||||||||||||||||||||
  6.                                            |||||||||||||||||||||||||
  7.                                            |||||||||||||||||||||||||
  8.                                            |||||||||||||||||||||||||
  9.   
  10.                                                  USER MANUAL
  11.  
  12.                                                    for an
  13.                                             ANSI X3.64 Compatible
  14.                                               Virtual Terminal
  15.                                                     in Ada
  16.  
  17.  
  18.         Prepared for:                      |||||||||||||||||||||||||
  19.                                            |||||||||||||||||||||||||
  20.         NAVAL OCEAN SYSTEMS CENTER (NOSC)  |||||||||||||||||||||||||
  21.         United States Navy                 |||||||||||||||||||||||||
  22.         San Diego, Ca   92152              |||||||||||||||||||||||||
  23.                                            |||||||||||||||||||||||||
  24.         Contract No. N66001-84-R-0030      |||||||||||||||||||||||||
  25.         Item No.  0028                     |||||||||||||||||||||||||
  26.                                            |||||||||||||||||||||||||
  27.                                            |||||||||||||||||||||||||
  28.                                            |||||||||||||||||||||||||
  29.                                            |||||||||||||||||||||||||
  30.                                            |||||||||||||||||||||||||
  31.                                            |||||||||||||||||||||||||
  32.                                            |||||||||||||||||||||||||
  33.                                            |||||||||||||||||||||||||
  34.                                            |||||||||||||||||||||||||
  35.                                            |||||||||||||||||||||||||
  36.                                            |||||||||||||||||||||||||
  37.                                            |||||||||||||||||||||||||
  38.                                            |||||||||||||||||||||||||
  39.                                            |||||||||||||||||||||||||
  40.                                            |||||||||||||||||||||||||
  41.                                            |||||||||||||||||||||||||
  42.                                            |||||||||||||||||||||||||
  43.                                            |||||||||||||||||||||||||
  44.                                            |||||||||||||||||||||||||
  45.           Equipment Group - ACSL           |||||||||||||||||||||||||
  46.           P.O. Box 801, M.S. 8007          |||||||||||||||||||||||||
  47.           McKinney, TX   75069             |||||||||||||||||||||||||
  48.           15-Mar-1985                      |||||||||||||||||||||||||
  49.                                            |||||||||||||||||||||||||
  50.  
  51.                                                TEXAS INSTRUMENTS
  52.                                                   INCORPORATED
  53.  
  54.                                            |||||||||||||||||||||||||
  55.                                            |||||||||||||||||||||||||
  56.                                            |||||||||||||||||||||||||
  57.                                            |||||||||||||||||||||||||
  58.                                            |||||||||||||||||||||||||
  59.  
  60.  
  61.                                    CONTENTS
  62.  
  63.  
  64.  
  65. CHAPTER 1       INTRODUCTION
  66.  
  67.  
  68. CHAPTER 2       SCROLL TERMINAL
  69.  
  70.                 INTRODUCTION . . . . . . . . . . . . . . . . . . . 2-1
  71.                 PROGRAM LEVEL INTERFACES . . . . . . . . . . . . . 2-1
  72.                   Types  . . . . . . . . . . . . . . . . . . . . . 2-3
  73.                   Open . . . . . . . . . . . . . . . . . . . . . . 2-3
  74.                   Close  . . . . . . . . . . . . . . . . . . . . . 2-4
  75.                   Set_position . . . . . . . . . . . . . . . . . . 2-4
  76.                   Position . . . . . . . . . . . . . . . . . . . . 2-5
  77.                   Size . . . . . . . . . . . . . . . . . . . . . . 2-5
  78.                   Set_tab  . . . . . . . . . . . . . . . . . . . . 2-5
  79.                   Clear_tab  . . . . . . . . . . . . . . . . . . . 2-5
  80.                   Tab  . . . . . . . . . . . . . . . . . . . . . . 2-5
  81.                   New_line . . . . . . . . . . . . . . . . . . . . 2-6
  82.                   New_page . . . . . . . . . . . . . . . . . . . . 2-6
  83.                   Put (character)  . . . . . . . . . . . . . . . . 2-6
  84.                   Put (string) . . . . . . . . . . . . . . . . . . 2-6
  85.                   Update_line  . . . . . . . . . . . . . . . . . . 2-6
  86.                   Get  . . . . . . . . . . . . . . . . . . . . . . 2-7
  87.                   Function_count . . . . . . . . . . . . . . . . . 2-8
  88.                   Function_key . . . . . . . . . . . . . . . . . . 2-8
  89.                   Function_key_name  . . . . . . . . . . . . . . . 2-9
  90.                   Exceptions . . . . . . . . . . . . . . . . . .  2-10
  91.  
  92.  
  93. CHAPTER 3       PAGE TERMINAL
  94.  
  95.                 INTRODUCTION . . . . . . . . . . . . . . . . . . . 3-1
  96.                 PROGRAM LEVEL INTERFACES . . . . . . . . . . . . . 3-2
  97.                   Types  . . . . . . . . . . . . . . . . . . . . . 3-4
  98.                   Open . . . . . . . . . . . . . . . . . . . . . . 3-4
  99.                   Close  . . . . . . . . . . . . . . . . . . . . . 3-5
  100.                   Set_position . . . . . . . . . . . . . . . . . . 3-6
  101.                   Position . . . . . . . . . . . . . . . . . . . . 3-6
  102.                   Size . . . . . . . . . . . . . . . . . . . . . . 3-6
  103.                   Delete_character . . . . . . . . . . . . . . . . 3-6
  104.                   Delete_line  . . . . . . . . . . . . . . . . . . 3-7
  105.                   Erase_in_display . . . . . . . . . . . . . . . . 3-7
  106.                   Erase_in_line  . . . . . . . . . . . . . . . . . 3-7
  107.                   Enter_insert_mode  . . . . . . . . . . . . . . . 3-8
  108.                   Exit_insert_mode . . . . . . . . . . . . . . . . 3-8
  109.                   Insert_line  . . . . . . . . . . . . . . . . . . 3-9
  110.                   Select_graphic_rendition . . . . . . . . . . . . 3-9
  111.                   Set_tab  . . . . . . . . . . . . . . . . . . . . 3-9
  112.                   Clear_tab  . . . . . . . . . . . . . . . . . .  3-10
  113.                   Tab  . . . . . . . . . . . . . . . . . . . . .  3-10
  114.                   Put (character/string) . . . . . . . . . . . .  3-10
  115.                   Update_screen  . . . . . . . . . . . . . . . .  3-10
  116.                                                                 Page 2
  117.  
  118.  
  119.                   Update_line  . . . . . . . . . . . . . . . . .  3-11
  120.                   Update_cursor  . . . . . . . . . . . . . . . .  3-11
  121.                   Redraw_screen  . . . . . . . . . . . . . . . .  3-11
  122.                   Get  . . . . . . . . . . . . . . . . . . . . .  3-11
  123.                   Function_count . . . . . . . . . . . . . . . .  3-12
  124.                   Function_key . . . . . . . . . . . . . . . . .  3-13
  125.                   Function_key_name  . . . . . . . . . . . . . .  3-14
  126.                   Bell . . . . . . . . . . . . . . . . . . . . .  3-14
  127.                   Exceptions . . . . . . . . . . . . . . . . . .  3-14
  128.  
  129.  
  130. CHAPTER 4       FORM TERMINAL
  131.  
  132.                 INTRODUCTION . . . . . . . . . . . . . . . . . . . 4-1
  133.                 PROGRAM LEVEL INTERFACES . . . . . . . . . . . . . 4-2
  134.                   Types  . . . . . . . . . . . . . . . . . . . . . 4-3
  135.                   Open . . . . . . . . . . . . . . . . . . . . . . 4-3
  136.                   Close  . . . . . . . . . . . . . . . . . . . . . 4-4
  137.                   Set_position . . . . . . . . . . . . . . . . . . 4-4
  138.                   Position . . . . . . . . . . . . . . . . . . . . 4-5
  139.                   Size . . . . . . . . . . . . . . . . . . . . . . 4-5
  140.                   Define_qualified_area  . . . . . . . . . . . . . 4-5
  141.                   Clear_qualified_area . . . . . . . . . . . . . . 4-6
  142.                   Tab  . . . . . . . . . . . . . . . . . . . . . . 4-6
  143.                   Put (character And String) . . . . . . . . . . . 4-6
  144.                   Get (character And String) . . . . . . . . . . . 4-6
  145.                   Erase_area . . . . . . . . . . . . . . . . . . . 4-7
  146.                   Erase_display  . . . . . . . . . . . . . . . . . 4-7
  147.                   Activate_form  . . . . . . . . . . . . . . . . . 4-7
  148.                   Is_form_updated  . . . . . . . . . . . . . . . . 4-8
  149.                   Termination_key  . . . . . . . . . . . . . . . . 4-8
  150.                   Exceptions . . . . . . . . . . . . . . . . . . . 4-8
  151.  
  152.  
  153. APPENDIX A      THE TERMINAL CAPABILITIES FILE
  154.  
  155.                 INTRODUCTION . . . . . . . . . . . . . . . . . . . A-1
  156.                 CAPABILITIES . . . . . . . . . . . . . . . . . . . A-1
  157.                   Basic Capabilities . . . . . . . . . . . . . . . A-4
  158.                   Cursor Addressing  . . . . . . . . . . . . . . . A-5
  159.                   Area Clears  . . . . . . . . . . . . . . . . . . A-5
  160.                   Insert/Delete Line . . . . . . . . . . . . . . . A-5
  161.                   Insert/Delete Character  . . . . . . . . . . . . A-6
  162.                   Highlighting, Underlining, And Visible Bells . . A-6
  163.                   Function Keys  . . . . . . . . . . . . . . . . . A-6
  164.                   Initialization . . . . . . . . . . . . . . . . . A-6
  165.  
  166.  
  167. APPENDIX B      PROGRAMMER'S NOTES
  168.  
  169.                 COMPILING THE VIRTUAL TERMINAL . . . . . . . . . . B-1
  170.                 REDISPLAY  . . . . . . . . . . . . . . . . . . . . B-2
  171.                 OTHER PACKAGES . . . . . . . . . . . . . . . . . . B-3
  172.                 CHOOSING AN INTERFACE LEVEL  . . . . . . . . . . . B-6
  173.                 EFFICIENCY . . . . . . . . . . . . . . . . . . . . B-7
  174.                                                                 Page 3
  175.  
  176.  
  177.                 SYSTEM DEPENDENCIES  . . . . . . . . . . . . . . . B-7
  178.  
  179.  
  180. APPENDIX C      SAMPLE PROGRAMS
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.                               CHAPTER 1
  194.  
  195.                              INTRODUCTION
  196.  
  197.  
  198.  
  199.       This virtual terminal provides a minimal set of control  functions
  200.       and  procedures  for manipulating asynchronous character-at-a-time
  201.       ascii terminals.  Such terminals include Televideo-970's (which we
  202.       used   for   implementation),   DEC  VT-100's,  DASHER  terminals,
  203.       Visual-50', etc.  It does not support such terminals as  IBM  3278
  204.       and  other block oriented terminals.  A tool or application writer
  205.       can use this package with minimal knowledge of the  terminal  that
  206.       his  program  is  to write to, and achieve device independence and
  207.       program clarity.
  208.  
  209.       Device independence is achieved by using a  capabilities  database
  210.       called  the  Terminal  Capabilities  File  (TCF).   This  terminal
  211.       capabilities database is similar to the UNIX TERMCAP.   Additional
  212.       function  key definitions and their labels have been added and the
  213.       confusing assortment of control  function  definitions  have  been
  214.       removed (for better or worse).
  215.  
  216.       The virtual terminal is 100% written  in  Ada.   99.9%  should  be
  217.       completely  transportable  (it is ANSI standard Ada).  The rest is
  218.       isolated in the package SYSDEP.   This  should  make  it  easy  to
  219.       modify  and  upgrade.   The implementation has been performed on a
  220.       Data General MV10000 in the Ada Development Environment.  Comments
  221.       on this environment can be found in Appendix B and in the document
  222.       titled "A Virtual Terminal in Ada  -  Informal  Technical  Report"
  223.       delivered as part of this contract.
  224.  
  225.       The virtual terminal consists of three seperate packages.  Namely:
  226.  
  227.        *  scroll_terminal
  228.  
  229.        *  page_terminal
  230.  
  231.        *  form_terminal
  232.  
  233.       These packages are described in detail later.
  234.  
  235.       The three packages stand alone when  in  use  by  the  application
  236.       programmer.   That  is,  one  simply  has  to WITH the appropriate
  237.       package and begin using it.  A compilation unit  would  look  like
  238.       this:
  239. INTRODUCTION                                                  Page 1-2
  240.  
  241.  
  242.  
  243.       WITH
  244.           page_terminal;
  245.       PROCEDURE my_main IS
  246.       BEGIN
  247.  
  248.           page_terminal.open;
  249.           ...
  250.           page_terminal.close;
  251.  
  252.       END my_main;
  253.       PRAGMA main;
  254.  
  255.       Some sample programs are given in Appendix C.
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.                                CHAPTER 2
  268.  
  269.                             SCROLL TERMINAL
  270.  
  271.  
  272.  
  273.       2.1  INTRODUCTION
  274.  
  275.       This  package  provides   a   device-independent   scroll-terminal
  276.       interface to a user's program.
  277.  
  278.       A  user's  program  can   WITH   this   package   to   provide   a
  279.       device-independent   terminal   interface   that  is  functionally
  280.       equivalent to a scroll-terminal.  This is  the  simplest  form  of
  281.       terminal that this virtual terminal supports.  This package should
  282.       be chosen for any of the following reasons:
  283.  
  284.       1.  The user's terminal is primitive.  Either it could  be  a  CRT
  285.           with little functionality, or a printing terminal.
  286.  
  287.       2.  The user wants maximum transportability.
  288.  
  289.       3.  The  user  does  not  need  advanced  capabilities   for   the
  290.           application.
  291.  
  292.       4.  The user's appication may run  over  low  speed  communication
  293.           lines, making the page and form mode unacceptable.
  294.  
  295.  
  296.       2.2  PROGRAM LEVEL INTERFACES
  297.  
  298.       The source code for the spec is as follows:
  299.  
  300.       PACKAGE scroll_terminal IS
  301.  
  302.         TYPE function_key_enum IS
  303.           ( up_arrow,       down_arrow,     left_arrow,     right_arrow,
  304.             f1,     f2,     f3,     f4,     f5,     f6,     f7,     f8,
  305.             f9,     f10,    f11,    f12,    f13,    f14,    f15,    f16,
  306.             f17,    f18,    f19,    f20,    f21,    f22,    f23,    f24,
  307.             f25,    f26,    f27,    f28,    f29,    f30,    f31,    f32 );
  308.  
  309.         TYPE function_key_descriptor( length : positive := 32)
  310.                                   IS PRIVATE;
  311.  
  312.         PROCEDURE open (name     : IN string := "none" );
  313. SCROLL TERMINAL                                               Page 2-2
  314.  
  315.  
  316.  
  317.         PROCEDURE close;
  318.  
  319.         PROCEDURE set_position (position : IN     positive);
  320.  
  321.         FUNCTION  position RETURN positive;
  322.  
  323.         FUNCTION  size RETURN positive;
  324.  
  325.         PROCEDURE set_tab;
  326.         PROCEDURE clear_tab;
  327.  
  328.         PROCEDURE tab       (count    : IN     positive := 1);
  329.  
  330.         PROCEDURE new_line  (count    : IN     positive := 1);
  331.  
  332.         PROCEDURE new_page  (count    : IN     positive := 1);
  333.  
  334.         PROCEDURE put (item     : IN     character);
  335.         PROCEDURE put (item     : IN     string);
  336.  
  337.         PROCEDURE update_line;
  338.  
  339.         PROCEDURE get( data : OUT string;
  340.                        last : OUT natural;
  341.                        keys : OUT function_key_descriptor;
  342.                     timeout : IN  duration := duration'last );
  343.  
  344.         FUNCTION function_count(keys : IN function_key_descriptor)
  345.             RETURN natural;
  346.  
  347.         PROCEDURE function_key(keys: IN function_key_descriptor;
  348.                                index : IN positive;
  349.                                key_identifier :    OUT function_key_enum;
  350.                                previous_position :    OUT natural);
  351.  
  352.         PROCEDURE function_key_name
  353.           ( key_identifier : IN     function_key_enum;
  354.             key_name       :    OUT string;
  355.             last           :    OUT natural);
  356.  
  357.         PROCEDURE bell;
  358.  
  359.         uninitialized          : EXCEPTION;
  360.         tcf_error              : EXCEPTION;
  361.         terminal_too_primitive : EXCEPTION;
  362.         unsupported_terminal   : EXCEPTION;
  363.         invalid_function_key   : EXCEPTION;
  364.  
  365.         PRIVATE
  366.  
  367.             TYPE keystroke_record IS
  368.             RECORD
  369.                 key : function_key_enum;
  370.                 position : positive;
  371. SCROLL TERMINAL                                               Page 2-3
  372.  
  373.  
  374.             END RECORD;
  375.  
  376.             TYPE function_key_array IS
  377.                     ARRAY( positive RANGE <> ) OF keystroke_record;
  378.  
  379.             TYPE function_key_descriptor( length : positive := 32 ) IS
  380.             RECORD
  381.                 no_of_keys : natural := 0;
  382.                 keys : function_key_array( 1..length );
  383.             END RECORD;
  384.  
  385.       END scroll_terminal;
  386.  
  387.  
  388.       2.2.1  Types
  389.  
  390.       The following types are defined here:
  391.  
  392.        *  function_key_enum - this enumerates all of the  function  keys
  393.           that  can  be  referenced in the virtual terminal.  Four arrow
  394.           keys and 32  function  keys  are  supported  in  this  virtual
  395.           terminal.  These values can be used to reference function keys
  396.           in the procedures function_key and function_key_name described
  397.           later.
  398.  
  399.        *  function_key_descriptor - a private type used to identify  the
  400.           function keys that were returned from a call on get.
  401.  
  402.  
  403.       2.2.2  Open
  404.  
  405.       Scroll_terminal.open  is  called  to  open  the  scroll  terminal.
  406.       Scroll_terminal.open  must  be  the  first procedure called in the
  407.       virtual terminal package.   A  call  on  any  other  procedure  or
  408.       function   before  calling  open  will  result  in  the  exception
  409.       scroll_terminal.uninitialized being  raised.   The  single  string
  410.       parameter "name" is the name of the terminal if it is known by the
  411.       programmer.  If open is called with no parameter  then  "none"  is
  412.       used  as the default.  In this case the virtual terminal will look
  413.       for a file name "TERM" on your path, open it, and read  the  first
  414.       line.   This string will be used as the terminal name.  The format
  415.       of the string must match exactly (even in case) the terminal  name
  416.       field in the terminal capabilities file.  Please refer to Appendix
  417.       A for a discussion of the TCF.
  418.  
  419.       Due to a bug in the Data General ADE you MUST put a second line in
  420.       the  TERM file.  The contents of the second line are not used.  An
  421.       example TERM file:
  422.  
  423.       tv970
  424.       this line overcomes the END_ERROR problem of the ADE
  425.  
  426.  
  427.       The exceptions that can be raised from a call on open are:
  428. SCROLL TERMINAL                                               Page 2-4
  429.  
  430.  
  431.        *  tcf_error - an error occured when  reading  and/or  processing
  432.           the terminal capabilities file.  Some possible causes are:
  433.  
  434.            -  the TCF file is not on your path.
  435.  
  436.            -  the format of the TCF file is incorrect.
  437.  
  438.            -  the TCF file is opened for  exclusive  access  by  someone
  439.               else.
  440.  
  441.            -  a system error occured.
  442.  
  443.  
  444.        *  unsupported_terminal - this  terminal  is  unsupported.   This
  445.           could be caused by one of the following:
  446.  
  447.            -  There is no TERM file on your path.
  448.  
  449.            -  The TERM file could not be opened.
  450.  
  451.            -  The TCF file had no entry for this terminal.
  452.  
  453.  
  454.  
  455.       2.2.3  Close
  456.  
  457.       Scroll_terminal.close is called to close the scroll terminal.   It
  458.       must  be  the  last  procedure  called.  Any procedure or function
  459.       called after this one will raise the exception unitialized.
  460.  
  461.       If scroll_terminal.close is called  and  the  scroll  terminal  is
  462.       already closed, nothing happens.
  463.  
  464.       2.2.4  Set_position
  465.  
  466.       Scroll_terminal.set_position allows the user's program to move the
  467.       current  position randomly about within the current line.  It does
  468.       not     affect     the     actual     terminal's     line.      If
  469.       scroll_terminal.update_line is called from the user's program then
  470.       set_position will not allow the active position to  move  backward
  471.       past the position that was active at the time that update_line was
  472.       called.  If an attempt is made  to  move  backward  past  the  old
  473.       active  position,  then  the active position will be moved only to
  474.       position corresponding to the old active position.  As an  example
  475.       consider the following:
  476.  
  477.       ...   -- assume the user has opened the scroll_terminal previously
  478.       virtual_terminal.scroll_terminal.put( "My_prompt>" );
  479.       virtual_terminal.scroll_terminal.update_line;
  480.       virtual_terminal.scroll_terminal.set_position( 1 );
  481.  
  482.       The last statement would move  the  active  position  to  position
  483.       number  eleven (the character count of "My_prompt>" plus 1) in the
  484.       current line (immediately after the string "My_prompt>").
  485. SCROLL TERMINAL                                               Page 2-5
  486.  
  487.  
  488.       If the scroll terminal has not been opened previously to this then
  489.       the exception scroll_terminal.uninitialized will be raised.
  490.  
  491.       2.2.5  Position
  492.  
  493.       Scroll_terminal.position returns a value of type positive that  is
  494.       the  current  active position on the scroll terminal's line.  This
  495.       position is the place where further output will be  directed.   It
  496.       should be noted that this does not necessarily correspond to where
  497.       the actual terminal's cursor  is  located  unless  executed  after
  498.       scroll_terminal.update_line   procedure   is   called  and  before
  499.       scroll_terminal.put or scroll_terminal.tab is called again.
  500.  
  501.       If the scroll terminal has not been opened previously to this then
  502.       the exception scroll_terminal.uninitialized will be raised.
  503.  
  504.       2.2.6  Size
  505.  
  506.       Scroll_terminal.size returns a value of type positive which is the
  507.       length  of  the  scroll  terminal's line.  This value is extracted
  508.       from the terminal capabilities file and may or may not reflect the
  509.       actual terminal's line length.
  510.  
  511.       If the scroll terminal has not been opened previously to this then
  512.       the exception scroll_terminal.uninitialized will be raised.
  513.  
  514.       2.2.7  Set_tab
  515.  
  516.       Scroll_terminal.set_tab will set a horizontal tab  at  the  active
  517.       position.   This  tab  will  stay  in  place  even after update or
  518.       new_line have been called.
  519.  
  520.       If the scroll terminal has not been opened previously to this then
  521.       the exception scroll_terminal.uninitialized will be raised.
  522.  
  523.       2.2.8  Clear_tab
  524.  
  525.       Scroll_terminal.clear_tab will remove the tab stop at the location
  526.       of  the  active  position.   This clears the tab completely and it
  527.       will remain gone after an update or new_line has been called.   If
  528.       there was no tab stop set at the active position then no operation
  529.       will be performed.
  530.  
  531.       If the scroll terminal has not been opened previously to this then
  532.       the exception scroll_terminal.uninitialized will be raised.
  533.  
  534.       2.2.9  Tab
  535.  
  536.       Scroll_terminal.tab will move the active position to the specified
  537.       horizontal  tab  stop  counting upward from the next tab stop.  If
  538.       there are no further tab stops on the line then no operation  will
  539.       occur.   If  there  are  no  tab  stops  set  on the line, then no
  540.       operation will occur.
  541.  
  542.       If the scroll terminal has not been opened previously to this then
  543. SCROLL TERMINAL                                               Page 2-6
  544.  
  545.  
  546.       the exception scroll_terminal.uninitialized will be raised.
  547.  
  548.       2.2.10  New_line
  549.  
  550.       Scroll_terminal.new_line will move  the  active  position  to  the
  551.       beginning  of  the  next  line.  This process performs an implicit
  552.       call on update and clears the  internal  buffer.   The  tab  stops
  553.       active on the previous line remain in effect.
  554.  
  555.       If the scroll terminal has not been opened previously to this then
  556.       the exception scroll_terminal.uninitialized will be raised.
  557.  
  558.       2.2.11  New_page
  559.  
  560.       Scroll_terminal.new_page causes a form feed character to be output
  561.       to the terminal.  An implicit call to update is performed then the
  562.       new page operation is performed.
  563.  
  564.       If the scroll terminal has not been opened previously to this then
  565.       the exception scroll_terminal.uninitialized will be raised.
  566.  
  567.       2.2.12  Put (character)
  568.  
  569.       When scroll_terminal.put is called the data  is  placed  into  the
  570.       current  line  at  the  active  position.   The active position is
  571.       advanced past the character that was placed into  the  line.   The
  572.       data  is  lost if the active position moves past the length of the
  573.       line.  Also, the active position is  left  pointing  at  the  last
  574.       character on the line if this occurs.
  575.  
  576.       If the scroll terminal has not been opened previously to this then
  577.       the exception scroll_terminal.uninitialized will be raised.
  578.  
  579.       2.2.13  Put (string)
  580.  
  581.       When scroll_terminal.put is called the data  is  placed  into  the
  582.       current  line  at  the  active  position.   The active position is
  583.       advanced past the last character of the data that was placed  into
  584.       the  line.  The data is lost if the active position moves past the
  585.       length of the line.  Also, the active position is left pointing at
  586.       the last character on the line if this occurs.
  587.  
  588.       If the scroll terminal has not been opened previously to this then
  589.       the exception scroll_terminal.uninitialized will be raised.
  590.  
  591.       2.2.14  Update_line
  592.  
  593.       This procedure is called to force the internal  representation  of
  594.       the line out to the actual terminal display.
  595.  
  596.       It is important to realize that the operations:
  597.  
  598.        *  set_position
  599. SCROLL TERMINAL                                               Page 2-7
  600.  
  601.  
  602.        *  set_tab
  603.  
  604.        *  clear_tab
  605.  
  606.        *  tab
  607.  
  608.        *  put
  609.  
  610.       perform there  operations  on  a  virtual  representation  of  the
  611.       terminal    and    not    directly   on   the   terminal   itself.
  612.       Scroll_terminal.update_line  is  called  to  force  the   internal
  613.       representation   to   the   actual  terminal  display.   Refer  to
  614.       set_position and put for restrictions imposed by update_line.
  615.  
  616.       If the scroll terminal has not been opened previously to this then
  617.       the exception scroll_terminal.uninitialized will be raised.
  618.  
  619.       2.2.15  Get
  620.  
  621.       When scroll_terminal.get is called the keys that the  user  struck
  622.       at  the  actual  terminal  keyboard since the virtual terminal was
  623.       opened,  or  since  the  last  call  to  scroll_terminal.get   are
  624.       returned.
  625.  
  626.       A string parameter named data returns the  string  that  the  user
  627.       typed.   Function/arrow  keys  that were typed are not embedded in
  628.       this string, they are identified seperately.  The last position of
  629.       the  string  is returned in the parameter last of type natural.  A
  630.       timeout can be specified of type duration.  This allows the get to
  631.       eventually  timeout  and  return.  A default for this parameter is
  632.       specified as duration'last which  is  a  system  dependent  value.
  633.       Hopefully  it is large enough to effectively mean infinitely.  The
  634.       function/arrow keys are identified by the paramter keys of private
  635.       limited type function_key_descriptor.
  636.  
  637.       Three cases are important:
  638.  
  639.       1.  get returns with the parameter last equal to zero,  and  there
  640.           were  no function/arrow keys pressed.  This means that no keys
  641.           were typed since the last call on get  or  since  the  virtual
  642.           terminal was called.
  643.  
  644.       2.  get returns with the parameter last equal to zero,  and  there
  645.           were  function/arrow  keys  pressed.   This  means  that  only
  646.           function/arrow keys were pressed since the last call on get or
  647.           since the virtual terminal was initialized.
  648.  
  649.       3.  get returns with the parameter last  not  equal  to  zero  and
  650.           there   were   function/arrow   keys   pressed.    Here   both
  651.           function/arrow keys and regular keys were pressed.
  652.  
  653.       As an example, consider the case where a user  opens  the  virtual
  654.       terminal  then presses three keys.  First an (say) "a" is pressed,
  655.       then a function key (say "F1" on some  terminal),  and  finally  a
  656.       (say) "b" is pressed.  The string parameter data would have length
  657. SCROLL TERMINAL                                               Page 2-8
  658.  
  659.  
  660.       2 and contain the characters "a" and "b" as its values.  The  keys
  661.       parameter  could  then  be  used  to get the function key that was
  662.       pressed ("F1") by making a  call  on  function_count  to  get  the
  663.       number of function keys that were pressed (this would return a 1).
  664.       Then a call on function_key passing in the keys parameter obtained
  665.       from  the  call  on  get  with  the  index set to 1 (the first key
  666.       struck) will return a key_identifier which is  an  enumeration  of
  667.       the   function   key   pressed  (in  this  case  an  f1)  and  the
  668.       previous_position in the string that was returned from the call on
  669.       get (in this case it would return a 2).
  670.  
  671.       On the Data General ADE two items are noted:
  672.  
  673.       1.  the timeout parameter has no effect.
  674.  
  675.       2.  characters are returned one  at  a  time.   DG-AOS/VS  has  no
  676.           facility  for  clearing  the  typeahead  buffer.  This will be
  677.           fixed in later releases of the AOS.
  678.  
  679.  
  680.       2.2.16  Function_count
  681.  
  682.       A value is returned of type natural that identifies the number  of
  683.       function/arrow  keys  that  were  typed  since  the  last  call on
  684.       scroll_terminal.get.  There is a 20 key limit  on  the  number  of
  685.       function/arrow  keys that can be buffered.  If the number returned
  686.       is zero then no function/arrow keys were typed since the last call
  687.       on scroll_terminal.get.
  688.  
  689.       The single input  parameter  keys  is  the  limited  private  type
  690.       returned  from  the  call on scroll_terminal.get.  This identifies
  691.       the specific list of function/arrow keys that will be operated  on
  692.       by this function.
  693.  
  694.       If the scroll terminal has not been opened previously to this then
  695.       the exception scroll_terminal.uninitialized will be raised.
  696.  
  697.       2.2.17  Function_key
  698.  
  699.       As described in the procedure scroll_terminal.get, this  procedure
  700.       returns    a   key_identifier   that   has   a   value   of   type
  701.       function_key_enum  identifying   the   function/arrow   key   that
  702.       corresponds  to  the  index parameter in the list of function keys
  703.       identified by  the  keys  parameter.   This  procedure  is  called
  704.       repeatedly  to  process  the  function/arrow  keys  varying  index
  705.       (usually in ascending numerical order).
  706.  
  707.       The parameters are:
  708.  
  709.        *  keys   -   the   value   of   the   private    limited    type
  710.           function_key_descriptor  that  was  returned  from  a  call on
  711.           scroll_terminal.get.  This is a user  variable.   A  user  may
  712.           have  more  than  one  of  these  variables, and consequently,
  713.           identify more than one list of function/arrow keys.
  714. SCROLL TERMINAL                                               Page 2-9
  715.  
  716.  
  717.        *  index - the number of the function/arrow key in  the  list  of
  718.           function/arrow keys identified by the parameter keys, that the
  719.           user is interested in.
  720.  
  721.        *  key_identifier - returns an enumerated type  which  identifies
  722.           the   function/arrow   key   as   described  in  the  terminal
  723.           capabilities file.
  724.  
  725.        *  previous_position - a position in the string that was returned
  726.           from  a call on scroll_terminal.get.  This position is the one
  727.           immediately before the function/arrow key was pressed.   Three
  728.           cases are important:
  729.  
  730.            -  the function/arrow key was pressed before any of the other
  731.               keys.  In this case previous_position would return a zero.
  732.  
  733.            -  the functon key was the last key pressed.   In  this  case
  734.               the value returned would be the same as last.
  735.  
  736.            -  the function/arrow key was pressed in the  middle  of  the
  737.               string.   In  this  case the character position before the
  738.               function/arrow key would be returned.
  739.  
  740.  
  741.       An example.  Consider the case where a character "a" was  pressed,
  742.       then  function  key  "F9" (as defined in the terminal capabilities
  743.       file), then the key "b".  scroll_terminal.get would return
  744.  
  745.       data  =  "ab"
  746.       last  =  2
  747.       a reference to keys
  748.  
  749.       When  scroll_terminal.function_key  is  called  and   passed   the
  750.       reference  to  keys  and  the index = 1, then key_identifier would
  751.       return f9 and previous_position would return 1.
  752.  
  753.       If the scroll terminal has not been opened previously to this then
  754.       the exception scroll_terminal.uninitialized will be raised.
  755.  
  756.       2.2.18  Function_key_name
  757.  
  758.       This procedure returns a string that is the name of  the  function
  759.       key.  This information is extracted from the terminal capabilities
  760.       database when the virtual terminal is opened and stored in the tcf
  761.       package data structures.
  762.  
  763.       The parameters are:
  764.  
  765.        *  key_identifier - a value of enumerated type  function_key_enum
  766.           which identifies the function key of interest.
  767.  
  768.        *  key_name - a string which is  the  function  key  name  as  it
  769.           appears in the terminal capabilities file (exactly).
  770. SCROLL TERMINAL                                              Page 2-10
  771.  
  772.  
  773.        *  last - a natural number which is the last  character  position
  774.           in the key_name.
  775.  
  776.       This version of the terminal capabilities file limits  the  number
  777.       of function keys to 32 (plus the four arrow keys).
  778.  
  779.       If the scroll terminal has not been opened previously to this then
  780.       the exception scroll_terminal.uninitialized will be raised.
  781.  
  782.       2.2.19  Exceptions
  783.  
  784.       The  following  exceptions  are  defined  in  the  scroll_terminal
  785.       package:
  786.  
  787.        *  uninitialized - raised  when  any  procedure  or  function  is
  788.           called prior to calling scroll_terminal.open (or after calling
  789.           scroll_terminal.close      and      prior      to      calling
  790.           scroll_terminal.open again).
  791.  
  792.        *  tcf_error - raised when an error occured when  reading  and/or
  793.           processing  the  terminal  capabilities  file.   Some possible
  794.           causes are:
  795.  
  796.            -  the TCF file is not on your path.
  797.  
  798.            -  the format of the TCF file is incorrect.
  799.  
  800.            -  the TCF file is opened for  exclusive  access  by  someone
  801.               else.
  802.  
  803.            -  a system error occured.
  804.  
  805.  
  806.        *  terminal_too_primitive - raised when your  terminal  does  not
  807.           have  the  needed  functionality to support this terminal type
  808.           (this  one  should  never   be   raised   in   scroll_terminal
  809.           operations).
  810.  
  811.        *  unsupported_terminal - this  terminal  is  unsupported.   This
  812.           could be caused by one of the following:
  813.  
  814.            -  There is no TERM file on your path.
  815.  
  816.            -  The TERM file could not be opened.
  817.  
  818.            -  The TCF file had no entry for this terminal.
  819.  
  820.  
  821.  
  822.  
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.                                CHAPTER 3
  833.  
  834.                              PAGE TERMINAL
  835.  
  836.  
  837.  
  838.       3.1  INTRODUCTION
  839.  
  840.       This package provides a device-independent page-terminal interface
  841.       to a user's program.
  842.  
  843.       A  user's  program  can  "WITH"  this   package   to   provide   a
  844.       device-independent   terminal   interface   that  is  functionally
  845.       equivalent to a page-terminal.  This is the most advanced form  of
  846.       terminal that this virtual terminal supports.  This package should
  847.       be chosen for any of the following reasons:
  848.  
  849.       1.  The user's terminal has advanced features.   The  terminal  is
  850.           directly  addressable, with erase to end of line, and erase to
  851.           end of screen capabilities.
  852.  
  853.       2.  The  user  wants  advanced  capabilities  and  is  willing  to
  854.           sacrifice some transportability.
  855.  
  856.  
  857.       The screen is addressed as follows (column, row):
  858.  
  859.           (1,1)                             (page_terminal.size.column, 1)
  860.               ____________________________________________________
  861.              |                                                    |
  862.              |                                                    |
  863.              |                                                    |
  864.              |                                                    |
  865.              |                                                    |
  866.              |                                                    |
  867.              |                                                    |
  868.              |                                                    |
  869.              |                                                    |
  870.              |                                                    |
  871.              |                                                    |
  872.              |                                                    |
  873.              | ___________________________________________________|
  874.           (1,page_terminal.size.line)       (page_terminal.size.column,
  875.                                                 page_terminal.size.line  )
  876.  
  877.       where the size is a function call returning an xy_position  record
  878. PAGE TERMINAL                                                 Page 3-2
  879.  
  880.  
  881.       containing  a  line  and column number.  These values are obtained
  882.       from the terminal capabilities file.
  883.  
  884.       3.2  PROGRAM LEVEL INTERFACES
  885.  
  886.       The source code for the spec is as follows:
  887.  
  888.       PACKAGE page_terminal IS
  889.  
  890.         TYPE function_key_enum IS
  891.           ( up_arrow,       down_arrow,     left_arrow,     right_arrow,
  892.             f1,     f2,     f3,     f4,     f5,     f6,     f7,     f8,
  893.             f9,     f10,    f11,    f12,    f13,    f14,    f15,    f16,
  894.             f17,    f18,    f19,    f20,    f21,    f22,    f23,    f24,
  895.             f25,    f26,    f27,    f28,    f29,    f30,    f31,    f32 );
  896.  
  897.         TYPE function_key_descriptor( length : positive := 32)
  898.                                   IS PRIVATE;
  899.  
  900.         TYPE xy_position IS
  901.         RECORD
  902.             line    : positive;
  903.             column  : positive;
  904.         END RECORD;
  905.  
  906.         TYPE select_enumeration IS (from_xy_position_to_end,
  907.                                     from_start_to_xy_position,
  908.                                     all_positions);
  909.  
  910.         TYPE graphic_rendition_enumeration IS
  911.                                    (primary_rendition,
  912.                                     reverse_image,
  913.                                     no_image     );
  914.  
  915.         PROCEDURE open (name : IN string := "none" );
  916.  
  917.         PROCEDURE close;
  918.  
  919.         PROCEDURE set_position (position : IN     xy_position);
  920.  
  921.         FUNCTION  position RETURN xy_position;
  922.  
  923.         FUNCTION  size RETURN xy_position;
  924.  
  925.         PROCEDURE delete_character (count    : IN     positive := 1);
  926.         PROCEDURE delete_line      (count    : IN     positive := 1);
  927.  
  928.         PROCEDURE erase_in_display (selection : select_enumeration);
  929.         PROCEDURE erase_in_line    (selection : select_enumeration);
  930.  
  931.         PROCEDURE enter_insert_mode;
  932.         PROCEDURE exit_insert_mode;
  933.  
  934.         PROCEDURE insert_line      (count     : IN     positive := 1);
  935.  
  936. PAGE TERMINAL                                                 Page 3-3
  937.  
  938.  
  939.         PROCEDURE select_graphic_rendition
  940.                          (selection : IN     graphic_rendition_enumeration);
  941.  
  942.         PROCEDURE set_tab;
  943.         PROCEDURE clear_tab;
  944.  
  945.         PROCEDURE tab       (count    : IN     positive := 1);
  946.  
  947.         PROCEDURE put (item     : IN     character);
  948.         PROCEDURE put (item     : IN     string);
  949.  
  950.         PROCEDURE update_screen
  951.                       ( top_line : IN positive;
  952.                         bottom_line : IN positive );
  953.  
  954.         PROCEDURE update_line( the_line : IN positive );
  955.  
  956.         PROCEDURE update_cursor;
  957.  
  958.         PROCEDURE redraw_screen;
  959.  
  960.         PROCEDURE get( data : OUT string;
  961.                        last : OUT natural;
  962.                        keys : OUT function_key_descriptor;
  963.                     timeout : IN  duration := duration'last );
  964.  
  965.         FUNCTION function_count(keys : IN function_key_descriptor)
  966.             RETURN natural;
  967.  
  968.         PROCEDURE function_key(keys: IN function_key_descriptor;
  969.                                index : IN positive;
  970.                                key_identifier :    OUT function_key_enum;
  971.                                previous_position :    OUT natural);
  972.  
  973.         PROCEDURE function_key_name
  974.           ( key_identifier : IN function_key_enum;
  975.             key_name       :    OUT string;
  976.             last           :    OUT natural);
  977.  
  978.         PROCEDURE bell;
  979.  
  980.         uninitialized          : EXCEPTION;
  981.         tcf_error              : EXCEPTION;
  982.         terminal_too_primitive : EXCEPTION;
  983.         unsupported_terminal   : EXCEPTION;
  984.         invalid_function_key   : EXCEPTION;
  985.  
  986.         PRIVATE
  987.  
  988.             TYPE keystroke_record IS
  989.             RECORD
  990.                 key : function_key_enum;
  991.                 position : positive;
  992.             END RECORD;
  993.  
  994. PAGE TERMINAL                                                 Page 3-4
  995.  
  996.  
  997.             TYPE function_key_array IS
  998.                     ARRAY( positive RANGE <> ) OF keystroke_record;
  999.  
  1000.             TYPE function_key_descriptor( length : positive := 32 ) IS
  1001.             RECORD
  1002.                 no_of_keys : natural := 0;
  1003.                 keys : function_key_array( 1..length );
  1004.             END RECORD;
  1005.  
  1006.       END page_terminal;
  1007.  
  1008.  
  1009.       3.2.1  Types
  1010.  
  1011.       The following types are defined in the page_terminal:
  1012.  
  1013.        *  function_key_enum - an enumerated type  defines  the  4  arrow
  1014.           keys and 32 function keys.
  1015.  
  1016.        *  function_key_descriptor - a limited private type.   This  type
  1017.           is  used  to traverse the function key list whose reference is
  1018.           returned from a call to page_terminal.get  (see  below).   The
  1019.           user must define a variable of this type (or more than one) in
  1020.           order to use the function key procedures and functions.
  1021.  
  1022.        *  xy_position - a record with a  line  component  and  a  column
  1023.           component.   Each  of  these  is  of type positive.  This type
  1024.           identifies a position on the display.
  1025.  
  1026.        *  select_enumeration - an enumerated type  that  identifies  the
  1027.           range that a delete operation will affect.
  1028.  
  1029.        *  graphic_rendition -  an  enumerated  type  that  identifies  a
  1030.           graphic  rendition  (either  primary, reverse, or none) that a
  1031.           single position in the virtual display will have.
  1032.  
  1033.           The   enumerated   type   function_key_enum   identifies   the
  1034.           function/arrow  keys  that  are used in the function/arrow key
  1035.           handling procedures and functions.
  1036.  
  1037.  
  1038.       3.2.2  Open
  1039.  
  1040.       Page_terminal.open  is  called  to   open   the   page   terminal.
  1041.       Page_terminal.open  must  be  the  first  procedure  called in the
  1042.       virtual terminal package.   A  call  on  any  other  procedure  or
  1043.       function   before  calling  open  will  result  in  the  exception
  1044.       page_terminal.uninitialized  being  raised.   The  single   string
  1045.       parameter "name" is the name of the terminal if it is known by the
  1046.       programmer.  If open is called with no parameter  then  "none"  is
  1047.       used  as the default.  In this case the virtual terminal will look
  1048.       for a file name "TERM" on your path, open it, and read  the  first
  1049.       line.   This string will be used as the terminal name.  The format
  1050.       of the string must match exactly (even in case) the terminal  name
  1051.       field in the terminal capabilities file.  Please refer to Appendix
  1052. PAGE TERMINAL                                                 Page 3-5
  1053.  
  1054.  
  1055.       A for a discussion of the TCF.
  1056.  
  1057.       Due to a bug in the Data General ADE you MUST put a second line in
  1058.       the  TERM file.  The contents of the second line are not used.  An
  1059.       example TERM file:
  1060.  
  1061.       tv970
  1062.       this line overcomes the END_ERROR problem of the ADE
  1063.  
  1064.  
  1065.       The exceptions that can be raised from a call on open are:
  1066.  
  1067.        *  tcf_error - an error occured when  reading  and/or  processing
  1068.           the terminal capabilities file.  Some possible causes are:
  1069.  
  1070.            -  the TCF file is not on your path.
  1071.  
  1072.            -  the format of the TCF file is incorrect.
  1073.  
  1074.            -  the TCF file is opened for  exclusive  access  by  someone
  1075.               else.
  1076.  
  1077.            -  a system error occured.
  1078.  
  1079.  
  1080.        *  unsupported_terminal - this  terminal  is  unsupported.   This
  1081.           could be caused by one of the following:
  1082.  
  1083.            -  There is no TERM file on your path.
  1084.  
  1085.            -  The TERM file could not be opened.
  1086.  
  1087.            -  The TCF file had no entry for this terminal.
  1088.  
  1089.  
  1090.        *  terminal_too_primitive - raised if your terminal is considered
  1091.           too  primitive  to  be  a  page  terminal.  Your terminal MUST
  1092.           support:
  1093.  
  1094.            -  erase to end of screen
  1095.  
  1096.            -  erase to end of line
  1097.  
  1098.            -  move the cursor
  1099.  
  1100.  
  1101.  
  1102.       3.2.3  Close
  1103.  
  1104.       Page_terminal.close is called to close the page terminal.  It must
  1105.       be  the  last  procedure called.  Any procedure or function called
  1106.       after this one will raise the exception unitialized.
  1107.  
  1108.       If page_terminal.close is called and the page terminal is  already
  1109.       closed, nothing happens.
  1110. PAGE TERMINAL                                                 Page 3-6
  1111.  
  1112.  
  1113.       3.2.4  Set_position
  1114.  
  1115.       Page_terminal.set_position will move the active  position  in  the
  1116.       virtual  terminal  display  to  the  new  coordinates given in the
  1117.       parameter list.  A call on this  procedure  does  not  affect  the
  1118.       actual  terminal's display, only the virtual representation of the
  1119.       display.
  1120.  
  1121.       This procedure has one parameter, position, which  identifies  the
  1122.       line and column that the active position should be moved to.
  1123.  
  1124.       If the page terminal has not been opened previously to  this  then
  1125.       the exception page_terminal.uninitialized will be raised.
  1126.  
  1127.       3.2.5  Position
  1128.  
  1129.       Page_terminal.position  returns  a  line/column   pair   of   type
  1130.       xy_position  that  identifies where the active position is located
  1131.       in the virtual terminal.  It should be  noted  that  this  is  NOT
  1132.       where the cursor is located on the actual terminal's screen.
  1133.  
  1134.  
  1135.       If the page terminal has not been opened previously to  this  then
  1136.       the exception page_terminal.uninitialized will be raised.
  1137.  
  1138.       3.2.6  Size
  1139.  
  1140.       Page_terminal.size returns the number of  columns  and  number  of
  1141.       lines  contained  in  the  actual  display.   This  information is
  1142.       located in the terminal capabilities  file  and  can  be  set  and
  1143.       altered by the user.
  1144.  
  1145.       If the page terminal has not been opened previously to  this  then
  1146.       the exception page_terminal.uninitialized will be raised.
  1147.  
  1148.       3.2.7  Delete_character
  1149.  
  1150.       Page_terminal.delete_character   will   delete   the   number   of
  1151.       characters  specified  in  the  input  parameter  from the virtual
  1152.       display.  The characters that are deleted  include  the  character
  1153.       that the active position is on and all characters to the right for
  1154.       up to the parameter count.  Characters to the right of the deleted
  1155.       characters that are on the same line are moved to the left to fill
  1156.       the space of the  deleted  characters.   If  more  characters  are
  1157.       specified  than  character  positions  left on the line, then only
  1158.       those characters left on the line will be deleted.
  1159.  
  1160.       The number of characters to be deleted is specified in  the  input
  1161.       parameter count.  Count defaults to one character.
  1162.  
  1163.       If the page terminal has not been opened previously to  this  then
  1164.       the exception page_terminal.uninitialized will be raised.
  1165. PAGE TERMINAL                                                 Page 3-7
  1166.  
  1167.  
  1168.       3.2.8  Delete_line
  1169.  
  1170.       Page_terminal.delete_line  will  delete  the   number   of   lines
  1171.       specified in the input parameter from the virtual display starting
  1172.       at the active position and proceding downward.   A  call  on  this
  1173.       procedure  will  not  affect  the actual display, only the virtual
  1174.       representation  of  the  display.   The  lines  below   the   line
  1175.       containing  the active position will move upward to fill the space
  1176.       deleted.  If the number of lines specified in the input  parameter
  1177.       is  more  than  the  number of lines left on the display then only
  1178.       those lines left on the display will be deleted.   If  the  active
  1179.       position  is  located  in  the  middle of the line, then after the
  1180.       delete the active position will be left at the left margin of  the
  1181.       virtual  display  on the line that moved up to replace the deleted
  1182.       lines.
  1183.  
  1184.       The input parameter count contains the number of lines  that  will
  1185.       be deleted.  The default is 1.
  1186.  
  1187.       If the page terminal has not been opened previously to  this  then
  1188.       the exception page_terminal.uninitialized will be raised.
  1189.  
  1190.       3.2.9  Erase_in_display
  1191.  
  1192.       Page_terminal.erase_in_display is called to  erase  areas  in  the
  1193.       virtual display.  The areas that can be erased are:
  1194.  
  1195.       1.  entire display,
  1196.  
  1197.       2.  from current position to end of display,
  1198.  
  1199.       3.  from beginning of display to active position.
  1200.  
  1201.       Again,  remeber,  this  procedure   only   affects   the   virtual
  1202.       representation  of  the  display  not  the actual display.  If the
  1203.       active position is at the end of the virtual display and a call is
  1204.       made  to erase to end of display, no operation will occur.  If the
  1205.       active position is at the beginning of the display and a  call  is
  1206.       made  to  erase  from  beginning  of  the  display  to  the active
  1207.       position, no operation will occur.
  1208.  
  1209.       The single input parameter selection of type select_enum  is  used
  1210.       to  select  which  of  the three types of erase (listed above) are
  1211.       used.
  1212.  
  1213.       If the page terminal has not been opened previously to  this  then
  1214.       the exception page_terminal.uninitialized will be raised.
  1215.  
  1216.       3.2.10  Erase_in_line
  1217.  
  1218.       Page_terminal.erase_in_line causes areas in  the  line  containing
  1219.       the  active  position to be erased.  This erase operation can take
  1220.       three forms:
  1221. PAGE TERMINAL                                                 Page 3-8
  1222.  
  1223.  
  1224.       1.  erase the entire line,
  1225.  
  1226.       2.  erase from the active position to the end of the line,
  1227.  
  1228.       3.  erase from the beginning of the line to the active position.
  1229.  
  1230.       The erase operation  leaves  the  active  position  where  it  was
  1231.       located  before  the  erase  operation  was  called.  It effective
  1232.       causes the correct amount of blanks to be written to the screen to
  1233.       erase  the  area  requested.   If  the  active  position is at the
  1234.       beginning of  the  line  and  the  area  requested  was  from  the
  1235.       beginning  of  the  line to the active position, then no operation
  1236.       will occur.  If the active position was at the end of the line and
  1237.       the  area requested was from the active position to the end of the
  1238.       line then no operation  will  occur.   If  erase  entire  line  is
  1239.       selected  the cursor will remain where it was before the operation
  1240.       occured and the line will be erased.
  1241.  
  1242.       The single input parameter selection of type select_enum  is  used
  1243.       to  select  which  of  the three types of erase (listed above) are
  1244.       used.
  1245.  
  1246.       If the page terminal has not been opened previously to  this  then
  1247.       the exception page_terminal.uninitialized will be raised.
  1248.  
  1249.       3.2.11  Enter_insert_mode
  1250.  
  1251.       Page_terminal.enter_insert_mode causes characters entered to  push
  1252.       the  characters  that  follow  on  the  line containing the active
  1253.       position to the right.  For example, if a line contains:
  1254.  
  1255.            a b c d
  1256.                | active position located here
  1257.  
  1258.       A call on page_terminal.enter_insert_mode followed by  a  call  on
  1259.       page_terminal.put  (say the string was "test" would cause the line
  1260.       to look like:
  1261.  
  1262.           a b t e s t c d
  1263.                       | active position now here
  1264.  
  1265.       If the inserting of characters pushes characters off  the  end  of
  1266.       the  line,  then those characters pushed off the end are lost.  If
  1267.       insert mode was already in effect then no operation will occur.
  1268.  
  1269.       If the page terminal has not been opened previously to  this  then
  1270.       the exception page_terminal.uninitialized will be raised.
  1271.  
  1272.       3.2.12  Exit_insert_mode
  1273.  
  1274.       Page_terminal.exit_insert_mode is called to exit insert  character
  1275.       mode.   Calls  to  page_terminal.put  will  replace  the  existing
  1276.       characters at the active position on  the  virtual  display  after
  1277.       page_terminal.exit_insert_mode  is  called.  If insert mode is not
  1278.       on (a previous call to page_terminal.enter_insert-mode  was  made)
  1279. PAGE TERMINAL                                                 Page 3-9
  1280.  
  1281.  
  1282.       no operation will occur.
  1283.  
  1284.       If the page terminal has not been opened previously to  this  then
  1285.       the exception page_terminal.uninitialized will be raised.
  1286.  
  1287.       3.2.13  Insert_line
  1288.  
  1289.       Page_terminal.insert_line will insert blank lines onto the virtual
  1290.       display.   The  number  of  blank  lines is specified in the input
  1291.       parameter.  The lines below and including the line containing  the
  1292.       active  position  are pushed downward in the virtual display.  The
  1293.       active position is moved  to  the  beginning  of  the  blank  line
  1294.       corresponding  to  the  line containing the active position before
  1295.       the call on page_terminal.insert_line was made.   Lines  that  are
  1296.       pushed off the end of the virtual display are lost.
  1297.  
  1298.       One input parameter count, of type positive identifies the  number
  1299.       of blank lines that are to be inserted.  The default is one.
  1300.  
  1301.       If the page terminal has not been opened previously to  this  then
  1302.       the exception page_terminal.uninitialized will be raised.
  1303.  
  1304.       3.2.14  Select_graphic_rendition
  1305.  
  1306.       Page_terminal.select_graphic_rendition sets the graphic  rendition
  1307.       to that specified by the input parameter.  The choices are:
  1308.  
  1309.       1.  primary_rendition - display according  to  the  ANSI  standard
  1310.           ASCII codes,
  1311.  
  1312.       2.  reverse_image -  This  can  be  configured  via  the  terminal
  1313.           capabilities file to be anything that the terminal can support
  1314.           and the user desires.  Typically it means black on white (when
  1315.           the default is white on black).
  1316.  
  1317.       3.  no rendition - all following characters will be represented as
  1318.           blanks (have no visible representation on the screen).
  1319.  
  1320.       If the selected rendition is currently in effect no operation will
  1321.       ocurr.
  1322.  
  1323.       The    single    input     parameter     selection     of     type
  1324.       graphic_rendition_enumeration  specified  what  the rendition will
  1325.       be.
  1326.  
  1327.       If the page terminal has not been opened previously to  this  then
  1328.       the exception page_terminal.uninitialized will be raised.
  1329.  
  1330.       3.2.15  Set_tab
  1331.  
  1332.       Page_terminal.set_tab will set a  horizontal  tab  at  the  active
  1333.       position.   This  tab will affect all lines on the virtual display
  1334.       regardless of the line position of the active position.  In  other
  1335.       words, only the column of the active position is used and it spans
  1336.       all lines on the virtual display.  If there is already a tab  stop
  1337. PAGE TERMINAL                                                Page 3-10
  1338.  
  1339.  
  1340.       at the active position's column then no operation will occur.
  1341.  
  1342.       If the page terminal has not been opened previously to  this  then
  1343.       the exception page_terminal.uninitialized will be raised.
  1344.  
  1345.       3.2.16  Clear_tab
  1346.  
  1347.       Page_terminal.clear_tab will clear a horizontal tab at the  active
  1348.       position.  This clear will affect all lines on the virtual display
  1349.       regardless of the line position of the active position.  In  other
  1350.       words, only the column of the active position is used and it spans
  1351.       all lines on the virtual display.  If there is no tab stop at  the
  1352.       active position's column then no operation will occur.
  1353.  
  1354.       3.2.17  Tab
  1355.  
  1356.       Page_terminal.tab moves the active position to a tab stop based on
  1357.       the  input  parameter.  Tabs will be counted from the next tab (to
  1358.       the right) on the same line as the  active  positon  moving  right
  1359.       through  the  line.   If  there  are  no  tab  stops  set, then no
  1360.       operation will occur.  If there are not enough tab  stops  on  the
  1361.       rest of the line to fulfill the requested number to move, then the
  1362.       cursor will be moved to the last tab stop on the line.
  1363.  
  1364.       If the page terminal has not been opened previously to  this  then
  1365.       the exception page_terminal.uninitialized will be raised.
  1366.  
  1367.       3.2.18  Put (character/string)
  1368.  
  1369.       Two versions of page_terminal.put exist:
  1370.  
  1371.       1.  put a string to the virtual display, and,
  1372.  
  1373.       2.  put a character to the display.
  1374.  
  1375.       These work equivalently.  They place characters into  the  virtual
  1376.       display  at  the active position moving the active position to the
  1377.       character following the inserted  string  or  character.   If  the
  1378.       characters  placed  on the display extend past the end of the line
  1379.       then the characters will be lost.  Page_terminal.put  is  affected
  1380.       by      calls      on      page_terminal.enter_insert_mode     and
  1381.       page_terminal.exit_insert_mode.
  1382.  
  1383.       The single input parameter item of type character or string is the
  1384.       character(s)  to  be  placed  onto  the  virtual  display.   These
  1385.       characters should only be printable ASCII characters.  Others will
  1386.       be removed.
  1387.  
  1388.       If the page terminal has not been opened previously to  this  then
  1389.       the exception page_terminal.uninitialized will be raised.
  1390.  
  1391.       3.2.19  Update_screen
  1392.  
  1393.       Page_terminal.update_screen makes the physical  screen  look  like
  1394.       the  internal  representation  of  the  virtual screen.  What this
  1395. PAGE TERMINAL                                                Page 3-11
  1396.  
  1397.  
  1398.       really means is that you can make as many calls on
  1399.  
  1400.        *  put
  1401.  
  1402.        *  insert_line, delete_line
  1403.  
  1404.        *  insert_character, delete_character
  1405.  
  1406.       and  nothing  will  be  seen  on  your  physical  terminal   until
  1407.       update_screen  is  called.   At  that  point a heuristic algortihm
  1408.       determines a minimum distance between  the  virtual  and  physical
  1409.       displays and changes the physical display.
  1410.  
  1411.       You must specify the top and bottom line that the update operation
  1412.       will operate on.
  1413.  
  1414.       If the page terminal has not been opened previously to  this  then
  1415.       the exception page_terminal.uninitialized will be raised.
  1416.  
  1417.       3.2.20  Update_line
  1418.  
  1419.       Same as update_screen but operates on only the given line.
  1420.  
  1421.       3.2.21  Update_cursor
  1422.  
  1423.       Page_terminal.update_cursor is called to make the  cursor  on  the
  1424.       physical display be located at the same position as on the virtual
  1425.       display.  This one is called when you want just to move the cursor
  1426.       around  without incurring the overhead of updating (which would do
  1427.       the same thing at an exorbitant cost).
  1428.  
  1429.       If the page terminal has not been opened previously to  this  then
  1430.       the exception page_terminal.uninitialized will be raised.
  1431.  
  1432.       3.2.22  Redraw_screen
  1433.  
  1434.       Page_terminal.redraw_screen  does  just  that,  it   redraws   the
  1435.       physical  screen  making it look like the virtual screen.  This is
  1436.       called to repaint the screen when something unusual happens,  like
  1437.       a  broadcast  message  from someone, or mail has been received and
  1438.       your screen has been changed.
  1439.  
  1440.       If the page terminal has not been opened previously to  this  then
  1441.       the exception page_terminal.uninitialized will be raised.
  1442.  
  1443.       3.2.23  Get
  1444.  
  1445.       When page_terminal.get is called the keys that the user struck  at
  1446.       the  actual  terminal  keyboard  since  the  virtual  terminal was
  1447.       opened, or since the last call to page_terminal.get are returned.
  1448.  
  1449.       A string parameter named data returns the  string  that  the  user
  1450.       typed.   Function/arrow  keys  that were typed are not embedded in
  1451.       this string, they are identified seperately.  The last position of
  1452.       the  string  is returned in the parameter last of type natural.  A
  1453. PAGE TERMINAL                                                Page 3-12
  1454.  
  1455.  
  1456.       timeout can be specified of type duration.  This allows the get to
  1457.       eventually  timeout  and  return.  A default for this parameter is
  1458.       specified as duration'last which  is  a  system  dependent  value.
  1459.       Hopefully  it is large enough to effectively mean infinitely.  The
  1460.       function/arrow keys are identified by the paramter keys of private
  1461.       limited type function_key_descriptor.
  1462.  
  1463.       Three cases are important:
  1464.  
  1465.       1.  get returns with the parameter last equal to zero,  and  there
  1466.           were  no function/arrow keys pressed.  This means that no keys
  1467.           were typed since the last call on get  or  since  the  virtual
  1468.           terminal was called.
  1469.  
  1470.       2.  get returns with the parameter last equal to zero,  and  there
  1471.           were  function/arrow  keys  pressed.   This  means  that  only
  1472.           function/arrow keys were pressed since the last call on get or
  1473.           since the virtual terminal was initialized.
  1474.  
  1475.       3.  get returns with the parameter last  not  equal  to  zero  and
  1476.           there   were   function/arrow   keys   pressed.    Here   both
  1477.           function/arrow keys and regular keys were pressed.
  1478.  
  1479.       As an example, consider the case where a user  opens  the  virtual
  1480.       terminal  then presses three keys.  First an (say) "a" is pressed,
  1481.       then a function key (say "F1" on some  terminal),  and  finally  a
  1482.       (say) "b" is pressed.  The string parameter data would have length
  1483.       2 and contain the characters "a" and "b" as its values.  The  keys
  1484.       parameter  could  then  be  used  to get the function key that was
  1485.       pressed ("F1") by making a  call  on  function_count  to  get  the
  1486.       number of function keys that were pressed (this would return a 1).
  1487.       Then a call on function_key passing in the keys parameter obtained
  1488.       from  the  call  on  get  with  the  index set to 1 (the first key
  1489.       struck) will return a key_identifier which is  an  enumeration  of
  1490.       the   function   key   pressed  (in  this  case  an  f1)  and  the
  1491.       previous_position in the string that was returned from the call on
  1492.       get (in this case it would return a 2).
  1493.  
  1494.       On the Data General ADE two items are noted:
  1495.  
  1496.       1.  the timeout parameter has no effect.
  1497.  
  1498.       2.  characters are returned one  at  a  time.   DG-AOS/VS  has  no
  1499.           facility  for  clearing  the  typeahead  buffer.  This will be
  1500.           fixed in later releases of the AOS.
  1501.  
  1502.  
  1503.       3.2.24  Function_count
  1504.  
  1505.       A value is returned of type natural that identifies the number  of
  1506.       function/arrow  keys  that  were  typed  since  the  last  call on
  1507.       page_terminal.get.  There is a 20  key  limit  on  the  number  of
  1508.       function/arrow  keys that can be buffered.  If the number returned
  1509.       is zero then no function/arrow keys were typed since the last call
  1510.       on page_terminal.get.
  1511. PAGE TERMINAL                                                Page 3-13
  1512.  
  1513.  
  1514.       The single input  parameter  keys  is  the  limited  private  type
  1515.       returned  from the call on page_terminal.get.  This identifies the
  1516.       specific list of function/arrow keys that will be operated  on  by
  1517.       this function.
  1518.  
  1519.       If the page terminal has not been opened previously to  this  then
  1520.       the exception page_terminal.uninitialized will be raised.
  1521.  
  1522.       3.2.25  Function_key
  1523.  
  1524.       As described in the procedure  page_terminal.get,  this  procedure
  1525.       returns    a   key_identifier   that   has   a   value   of   type
  1526.       function_key_enum  identifying   the   function/arrow   key   that
  1527.       corresponds  to  the  index parameter in the list of function keys
  1528.       identified by  the  keys  parameter.   This  procedure  is  called
  1529.       repeatedly  to  process  the  function/arrow  keys  varying  index
  1530.       (usually in ascending numerical order).
  1531.  
  1532.       The parameters are:
  1533.  
  1534.        *  keys   -   the   value   of   the   private    limited    type
  1535.           function_key_descriptor  that  was  returned  from  a  call on
  1536.           page_terminal.get.  This is a user variable.  A user may  have
  1537.           more  than  one of these variables, and consequently, identify
  1538.           more than one list of function/arrow keys.
  1539.  
  1540.        *  index - the number of the function/arrow key in  the  list  of
  1541.           function/arrow keys identified by the parameter keys, that the
  1542.           user is interested in.
  1543.  
  1544.        *  key_identifier - returns an enumerated type  which  identifies
  1545.           the   function/arrow   key   as   described  in  the  terminal
  1546.           capabilities file.
  1547.  
  1548.        *  previous_position - a position in the string that was returned
  1549.           from  a  call  on page_terminal.get.  This position is the one
  1550.           immediately before the function/arrow key was pressed.   Three
  1551.           cases are important:
  1552.  
  1553.            -  the function/arrow key was pressed before any of the other
  1554.               keys.  In this case previous_position would return a zero.
  1555.  
  1556.            -  the functon key was the last key pressed.   In  this  case
  1557.               the value returned would be the same as last.
  1558.  
  1559.            -  the function/arrow key was pressed in the  middle  of  the
  1560.               string.   In  this  case the character position before the
  1561.               function/arrow key would be returned.
  1562.  
  1563.  
  1564.       An example.  Consider the case where a character "a" was  pressed,
  1565.       then  function  key  "F9" (as defined in the terminal capabilities
  1566.       file), then the key "b".  page_terminal.get would return
  1567.  
  1568.       data  =  "ab"
  1569. PAGE TERMINAL                                                Page 3-14
  1570.  
  1571.  
  1572.       last  =  2
  1573.       a reference to keys
  1574.  
  1575.       When page_terminal.function_key is called and passed the reference
  1576.       to keys and the index = 1, then key_identifier would return f9 and
  1577.       previous_position would return 1.
  1578.  
  1579.       If the page terminal has not been opened previously to  this  then
  1580.       the exception page_terminal.uninitialized will be raised.
  1581.  
  1582.       3.2.26  Function_key_name
  1583.  
  1584.       This procedure returns a string that is the name of  the  function
  1585.       key.  This information is extracted from the terminal capabilities
  1586.       database when the virtual terminal is opened and stored in the tcf
  1587.       package data structures.
  1588.  
  1589.       The parameters are:
  1590.  
  1591.        *  key_identifier - a value of enumerated type  function_key_enum
  1592.           which identifies the function key of interest.
  1593.  
  1594.        *  key_name - a string which is  the  function  key  name  as  it
  1595.           appears in the terminal capabilities file (exactly).
  1596.  
  1597.        *  last - a natural number which is the last  character  position
  1598.           in the key_name.
  1599.  
  1600.       This version of the terminal capabilities file limits  the  number
  1601.       of function keys to 32 (plus the four arrow keys).
  1602.  
  1603.       If the page terminal has not been opened previously to  this  then
  1604.       the exception page_terminal.uninitialized will be raised.
  1605.  
  1606.       3.2.27  Bell
  1607.  
  1608.       Page_terminal.bell sends the  sequence  defined  as  bell  in  the
  1609.       terminal  capabilities file.  This sequence is sent immediately to
  1610.       the physical terminal.  No buffering ocurrs (and it does not  wait
  1611.       for an update_screen or update_line call).
  1612.  
  1613.       If the page terminal has not been opened previously to  this  then
  1614.       the exception page_terminal.uninitialized will be raised.
  1615.  
  1616.       3.2.28  Exceptions
  1617.  
  1618.       The following exceptions are defined in the page_terminal package:
  1619.  
  1620.        *  uninitialized - raised  when  any  procedure  or  function  is
  1621.           called  prior  to calling page_terminal.open (or after calling
  1622.           page_terminal.close and prior  to  calling  page_terminal.open
  1623.           again).
  1624. PAGE TERMINAL                                                Page 3-15
  1625.  
  1626.  
  1627.        *  tcf_error - raised when an error occured when  reading  and/or
  1628.           processing  the  terminal  capabilities  file.   Some possible
  1629.           causes are:
  1630.  
  1631.            -  the TCF file is not on your path.
  1632.  
  1633.            -  the format of the TCF file is incorrect.
  1634.  
  1635.            -  the TCF file is opened for  exclusive  access  by  someone
  1636.               else.
  1637.  
  1638.            -  a system error occured.
  1639.  
  1640.  
  1641.        *  terminal_too_primitive - raised when your  terminal  does  not
  1642.           have  the  needed functionality to support this terminal type.
  1643.           In a page terminal you must have these three capabilities:
  1644.  
  1645.            *  erase to end of line
  1646.  
  1647.            *  erase to end of screen
  1648.  
  1649.            *  move the cursor
  1650.  
  1651.  
  1652.        *  unsupported_terminal - this  terminal  is  unsupported.   This
  1653.           could be caused by one of the following:
  1654.  
  1655.            -  There is no TERM file on your path.
  1656.  
  1657.            -  The TERM file could not be opened.
  1658.  
  1659.            -  The TCF file had no entry for this terminal.
  1660.  
  1661.  
  1662.  
  1663.  
  1664.  
  1665.  
  1666.  
  1667.  
  1668.  
  1669.  
  1670.  
  1671.  
  1672.  
  1673.                                CHAPTER 4
  1674.  
  1675.                              FORM TERMINAL
  1676.  
  1677.  
  1678.  
  1679.       4.1  INTRODUCTION
  1680.  
  1681.       This package provides a device-independent form-terminal interface
  1682.       to a user's program.
  1683.  
  1684.       A  user's  program  can  "WITH"  this   package   to   provide   a
  1685.       device-independent   terminal   interface   that  is  functionally
  1686.       equivalent to a form-terminal.  This is the most advanced form  of
  1687.       terminal that this virtual terminal supports.  This package should
  1688.       be chosen for any of the following reasons:
  1689.  
  1690.       1.  The user's terminal has advanced features.   The  terminal  is
  1691.           directly  addressable, with erase to end of line, and erase to
  1692.           end of screen capabilities.
  1693.  
  1694.       2.  The  user  wants  advanced  capabilities  and  is  willing  to
  1695.           sacrifice some transportability.
  1696.  
  1697.  
  1698.       The screen is addressed as follows:
  1699.  
  1700.           (1,1)                             (1, form_terminal.size.column )
  1701.  
  1702.               ____________________________________________________
  1703.              |                                                    |
  1704.              |                                                    |
  1705.              |                                                    |
  1706.              |                                                    |
  1707.              |                                                    |
  1708.              |                                                    |
  1709.              |                                                    |
  1710.              |                                                    |
  1711.              |                                                    |
  1712.              |                                                    |
  1713.              |                                                    |
  1714.              |                                                    |
  1715.              | ___________________________________________________|
  1716.           (form_terminal.size.line, 1)       (form_terminal.size.line,
  1717.                                                 form_terminal.size.column)
  1718.  
  1719. FORM TERMINAL                                                 Page 4-2
  1720.  
  1721.  
  1722.       where the size is a function call returning an xy_position  record
  1723.       containing  a  line  and column number.  These values are obtained
  1724.       from the terminal capabilities file.
  1725.  
  1726.       4.2  PROGRAM LEVEL INTERFACES
  1727.  
  1728.       The source code for the spec is as follows:
  1729.  
  1730.       PACKAGE form_terminal IS
  1731.  
  1732.         TYPE xy_position IS
  1733.         RECORD
  1734.             line    : positive;
  1735.             column  : positive;
  1736.         END RECORD;
  1737.  
  1738.         TYPE termination_key_range IS RANGE 1..32;
  1739.  
  1740.         TYPE area_intensity  IS (none, normal, high);
  1741.         TYPE area_protection IS (unprotected, protected);
  1742.         TYPE area_input      IS (graphic_characters, numerics );
  1743.  
  1744.         PROCEDURE open (name     : IN string := "none");
  1745.  
  1746.         PROCEDURE close;
  1747.  
  1748.         PROCEDURE set_position (position : IN     xy_position);
  1749.  
  1750.         FUNCTION  position RETURN xy_position;
  1751.  
  1752.         FUNCTION  size RETURN xy_position;
  1753.  
  1754.         PROCEDURE define_qualified_area
  1755.                          (intensity  : IN     area_intensity  := normal;
  1756.                           protection : IN     area_protection := protected;
  1757.                           input      : IN     area_input
  1758.                                                    := graphic_characters );
  1759.  
  1760.         PROCEDURE clear_qualified_area;
  1761.  
  1762.         PROCEDURE tab;
  1763.         PROCEDURE put (item     : IN     character);
  1764.         PROCEDURE put (item     : IN     string);
  1765.  
  1766.         PROCEDURE get (item     :    OUT character);
  1767.         PROCEDURE get (item     :    OUT string);
  1768.  
  1769.         PROCEDURE erase_area;
  1770.         PROCEDURE erase_display;
  1771.         PROCEDURE activate_form;
  1772.  
  1773.         FUNCTION  is_form_updated RETURN boolean;
  1774.         FUNCTION  area_qualifier_requires_space RETURN boolean;
  1775.         FUNCTION  termination_key RETURN termination_key_range;
  1776.  
  1777. FORM TERMINAL                                                 Page 4-3
  1778.  
  1779.  
  1780.  
  1781.         uninitialized          : EXCEPTION;
  1782.         tcf_error              : EXCEPTION;
  1783.         terminal_too_primitive : EXCEPTION;
  1784.         unsupported_terminal   : EXCEPTION;
  1785.         invalid_function_key   : EXCEPTION;
  1786.  
  1787.       END form_terminal;
  1788.  
  1789.  
  1790.       4.2.1  Types
  1791.  
  1792.  
  1793.        *  termination_key_range - indicates the  number  of  a  function
  1794.           keys  available  to use as a terminate key.  The range is 1 to
  1795.           32.  The terminate key is the key that was pressed  to  return
  1796.           control back to the user's program.
  1797.  
  1798.        *  area_intensity  -  indicates  the  intensity  at   which   the
  1799.           characters  in  the  area should be displayed.  NONE indicates
  1800.           that characters  are  not  displayed.   NORMAL  indicates  the
  1801.           default  setting  of  the  terminal at the instant the user is
  1802.           running a form terminal.  HIGH intensity  indicates  something
  1803.           other  than  NORMAL  where  the  characters are visible on the
  1804.           display.
  1805.  
  1806.        *  area_protection - specifies whether the user  can  modify  the
  1807.           contents  of  the area when the form ha s been activated.  The
  1808.           choices are PROTECTED and UNPROTECTED.
  1809.  
  1810.        *  area_input -  specifies  the  valid  characters  that  may  be
  1811.           entered  by  the  user.  GRAPHIC_CHARACTERS indicates that any
  1812.           printable characters may be entered.  The choices are NUMERIC,
  1813.           ALPHABETIC, and GRAPHIC_CHARACTERS.   
  1814.  
  1815.  
  1816.       4.2.2  Open
  1817.  
  1818.       Form_terminal.open  is  called  to   open   the   form   terminal.
  1819.       Form_terminal.open  must  be  the  first  procedure  called in the
  1820.       virtual terminal package.   A  call  on  any  other  procedure  or
  1821.       function   before  calling  open  will  result  in  the  exception
  1822.       form_terminal.uninitialized  being  raised.   The  single   string
  1823.       parameter "name" is the name of the terminal if it is known by the
  1824.       programmer.  If open is called with no parameter  then  "none"  is
  1825.       used  as the default.  In this case the virtual terminal will look
  1826.       for a file name "TERM" on your path, open it, and read  the  first
  1827.       line.   This string will be used as the terminal name.  The format
  1828.       of the string must match exactly (even in case) the terminal  name
  1829.       field in the terminal capabilities file.  Please refer to Appendix
  1830.       A for a discussion of the TCF.
  1831.  
  1832.       Due to a bug in the Data General ADE you MUST put a second line in
  1833.       the  TERM file.  The contents of the second line are not used.  An
  1834.       example TERM file:
  1835. FORM TERMINAL                                                 Page 4-4
  1836.  
  1837.  
  1838.  
  1839.       tv970
  1840.       this line overcomes the END_ERROR problem of the ADE
  1841.  
  1842.  
  1843.       The exceptions that can be raised from a call on open are:
  1844.  
  1845.        *  tcf_error - an error occured when  reading  and/or  processing
  1846.           the terminal capabilities file.  Some possible causes are:
  1847.  
  1848.            -  the TCF file is not on your path.
  1849.  
  1850.            -  the format of the TCF file is incorrect.
  1851.  
  1852.            -  the TCF file is opened for  exclusive  access  by  someone
  1853.               else.
  1854.  
  1855.            -  a system error occured.
  1856.  
  1857.  
  1858.        *  unsupported_terminal - this  terminal  is  unsupported.   This
  1859.           could be caused by one of the following:
  1860.  
  1861.            -  There is no TERM file on your path.
  1862.  
  1863.            -  The TERM file could not be opened.
  1864.  
  1865.            -  The TCF file had no entry for this terminal.
  1866.  
  1867.  
  1868.        *  terminal_too_primitive - raised if your terminal is considered
  1869.           too  primitive  to  be  a  form  terminal.  Your terminal MUST
  1870.           support:
  1871.  
  1872.            -  erase to end of screen
  1873.  
  1874.            -  erase to end of line
  1875.  
  1876.            -  move the cursor
  1877.  
  1878.  
  1879.  
  1880.       4.2.3  Close
  1881.  
  1882.       form_terminal.close is called to close the form terminal.  It must
  1883.       be  the  last  procedure called.  Any procedure or function called
  1884.       after this one will raise the exception unitialized.
  1885.  
  1886.       If form_terminal.close is called and the form terminal is  already
  1887.       closed, nothing happens.
  1888.  
  1889.       4.2.4  Set_position
  1890.  
  1891.       form_terminal.set_position will move the active  position  in  the
  1892.       virtual  terminal  display  to  the  new  coordinates given in the
  1893. FORM TERMINAL                                                 Page 4-5
  1894.  
  1895.  
  1896.       parameter list.  A call on this  procedure  does  not  affect  the
  1897.       actual  terminal's display, only the virtual representation of the
  1898.       display.  if the parameter contains a value that  is  outside  the
  1899.       actual  screen  dimensions  it will be set to the screen dimension
  1900.       which it exceeds.
  1901.  
  1902.       This procedure has one parameter, position, which  identifies  the
  1903.       line and column that the active position should be moved to.
  1904.  
  1905.       If the form terminal has not been opened previously to  this  then
  1906.       the exception form_terminal.uninitialized will be raised.
  1907.  
  1908.       4.2.5  Position
  1909.  
  1910.       form_terminal.position  returns  a  line/column   pair   of   type
  1911.       xy_position  that  identifies where the active position is located
  1912.       in the virtual terminal.  It should be noted that this MAY not  be
  1913.       where the cursor is located on the actual terminal's screen.
  1914.  
  1915.  
  1916.       If the form terminal has not been opened previously to  this  then
  1917.       the exception form_terminal.uninitialized will be raised.
  1918.  
  1919.       4.2.6  Size
  1920.  
  1921.       form_terminal.size returns the number of  columns  and  number  of
  1922.       lines  contained  in  the  actual  display.   This  information is
  1923.       located in the terminal capabilities  file  and  can  be  set  and
  1924.       altered by the user.
  1925.  
  1926.       If the form terminal has not been opened previously to  this  then
  1927.       the exception form_terminal.uninitialized will be raised.
  1928.  
  1929.       4.2.7  Define_qualified_area
  1930.  
  1931.       Form_terminal.define_qualified_area is called to define  qualified
  1932.       areas.   These  qualified  areas are bounded by the next qualified
  1933.       area defined such that the end of a qualified area is indicated by
  1934.       the beginning of the next qualified area.  Each qualified area may
  1935.       have user editing restrictions imposed.  A  virtual  display  that
  1936.       has  no  qualified  area defined by the user program is considered
  1937.       protected and set to blank.
  1938.  
  1939.       The parameters to this procedure are as follows:
  1940.  
  1941.  
  1942.        *  intensity - set the intensity of the qualified  area  (default
  1943.           is normal).
  1944.  
  1945.        *  protection - set the protection of the qualified area (default
  1946.           is protected).
  1947.  
  1948.        *  input - the permissible input characters for the area.
  1949.  
  1950. FORM TERMINAL                                                 Page 4-6
  1951.  
  1952.  
  1953.       4.2.8  Clear_qualified_area
  1954.  
  1955.       Form_terminal.clear_qualified_area removes an area qualifier  from
  1956.       the active position.  The qualified area that precedes this one is
  1957.       extended to encompass the removed area.
  1958.  
  1959.       If the form terminal has not been opened previously to  this  then
  1960.       the     exception     generated    in    the    driver    package,
  1961.       driver.uninitialized,  will  be  propogated  out  to  the  calling
  1962.       program unit.
  1963.  
  1964.       4.2.9  Tab
  1965.  
  1966.       Form_terminal.tab moves the active position the  specified  number
  1967.       of  qualified  areas toward the end of the display.  The resultant
  1968.       active position is the first character position of the  designated
  1969.       qualified area.  If the next qualified area moved to is at the end
  1970.       of a line, the active position is at the first qualified  area  of
  1971.       the  next line.  If the next qualified area moved to is at the end
  1972.       of the form, then the active position is at  the  first  qualified
  1973.       area of the form.
  1974.  
  1975.       If the form terminal has not been opened previously to  this  then
  1976.       the     exception     generated    in    the    driver    package,
  1977.       driver.uninitialized,  will  be  propogated  out  to  the  calling
  1978.       program unit.
  1979.  
  1980.       4.2.10  Put (character And String)
  1981.  
  1982.       There are two types of puts performed by the  form_terminal.   One
  1983.       writes  a  character,  the  other  writes  a string to the virtual
  1984.       display.  Form_terminal.put may write a character to  the  virtual
  1985.       display at the active position.  The column of the active position
  1986.       is incremented by one.  Form_terminal.put may also write a  string
  1987.       to  the virtual display at the active position.  The column of the
  1988.       active position is incremented by length of the  string.   If  the
  1989.       character/string  is  written  in  the  last column of a line, the
  1990.       active position is advanced to the first column of  the  following
  1991.       line.   If  the  character/string is written to the last column of
  1992.       the last line, the active position is moved to the first column of
  1993.       the first line.
  1994.  
  1995.       The one parameter to this procedure is the character/string to  be
  1996.       written to the display.
  1997.  
  1998.       If the form terminal has not been opened previously to  this  then
  1999.       the     exception     generated    in    the    driver    package,
  2000.       driver.uninitialized,  will  be  propogated  out  to  the  calling
  2001.       program unit.
  2002.  
  2003.       4.2.11  Get (character And String)
  2004.  
  2005.       There are two types of reads performed by the form_terminal.   One
  2006.       reads  a  character,  the  other  reads  a  string from the actual
  2007.       display.  Form_terminal.get may read a character from the  virtual
  2008. FORM TERMINAL                                                 Page 4-7
  2009.  
  2010.  
  2011.       display  at  the active position.  The active position is advanced
  2012.       forward one position.  Form_terminal.get may also  read  a  string
  2013.       from  the  virtual  display  at  the  active position.  The active
  2014.       position is advanced forward the length of the string.
  2015.  
  2016.       The only parameter to this procedure is the character/string to be
  2017.       read from the display.
  2018.  
  2019.       If the form terminal has not been opened previously to  this  then
  2020.       the     exception     generated    in    the    driver    package,
  2021.       driver.uninitialized,  will  be  propogated  out  to  the  calling
  2022.       program unit.
  2023.  
  2024.       4.2.12  Erase_area
  2025.  
  2026.       Form_terminal.erase_area clears  the  area  in  which  the  active
  2027.       position is located by replacing the area with blanks.
  2028.  
  2029.       If the form terminal has not been opened previously to  this  then
  2030.       the     exception     generated    in    the    driver    package,
  2031.       driver.uninitialized,  will  be  propogated  out  to  the  calling
  2032.       program unit.
  2033.  
  2034.       4.2.13  Erase_display
  2035.  
  2036.       Form_terminal.erase_display clears the  display  and  removes  all
  2037.       user  program  defined area qualifiers.  The display is then reset
  2038.       to the default form which consists  of  one  qualified  area  (the
  2039.       entire size of the display) which is blank and protected.
  2040.  
  2041.       If the form terminal has not been opened previously to  this  then
  2042.       the     exception     generated    in    the    driver    package,
  2043.       driver.uninitialized,  will  be  propogated  out  to  the  calling
  2044.       program unit.
  2045.  
  2046.       4.2.14  Activate_form
  2047.  
  2048.       Form_terminal.activate_form maps  the  virtual  display  into  the
  2049.       actual           display.            Activate_form           calls
  2050.       redisplay_screen_with_movement  procedure  to  make  the  terminal
  2051.       display  look like the data structures in the vt_contents package.
  2052.       This is called once when activate form is first called.  When  the
  2053.       form  is  activated  the  cursor  is  placed  at the first editing
  2054.       position on the form.  Form editing is performed by the  procedure
  2055.       body  of  activate_form.  The procedure body calls vt_input.get to
  2056.       read the characters from the keyboard into the data structures  of
  2057.       vt_contents.   Redisplay_line_with_movement  is  called after each
  2058.       call of vt_input.get to redisplay the virtual display line to  the
  2059.       actual display line.  Control returns to the user's program when a
  2060.       function key is depressed.  The virtual form  will  exist  in  the
  2061.       data  structures  until  the  virtual  display  is  erased  or the
  2062.       qualified areas are cleared.  The user's program may  then  choose
  2063.       to define another form if desired.
  2064.  
  2065.       If the form terminal has not been opened previously to  this  then
  2066. FORM TERMINAL                                                 Page 4-8
  2067.  
  2068.  
  2069.       the     exception     generated    in    the    driver    package,
  2070.       driver.uninitialized,  will  be  propogated  out  to  the  calling
  2071.       program unit.
  2072.  
  2073.       4.2.15  Is_form_updated
  2074.  
  2075.       Form_terminal.is_form_updated  is  called  by  the  programmer  to
  2076.       determine  if  the  user  modified  the previous form while it was
  2077.       active.  The user can accomplish this by inserting any  data  into
  2078.       the form or deleting any data.
  2079.  
  2080.       If the form terminal has not been opened previously to  this  then
  2081.       the     exception     generated    in    the    driver    package,
  2082.       driver.uninitialized,  will  be  propogated  out  to  the  calling
  2083.       program unit.
  2084.  
  2085.       4.2.16  Termination_key
  2086.  
  2087.       Form_terminal.termination_key returns a value  between  1  and  32
  2088.       indicating  which  function  key  the user struck to exit from the
  2089.       previous form while it was active.
  2090.  
  2091.       If the form terminal has not been opened previously to  this  then
  2092.       the     exception     generated    in    the    driver    package,
  2093.       driver.uninitialized,  will  be  propogated  out  to  the  calling
  2094.       program unit.
  2095.  
  2096.       4.2.17  Exceptions
  2097.  
  2098.       The following exceptions are defined in the page_terminal package:
  2099.  
  2100.        *  uninitialized - raised  when  any  procedure  or  function  is
  2101.           called  prior  to calling page_terminal.open (or after calling
  2102.           page_terminal.close and prior  to  calling  page_terminal.open
  2103.           again).
  2104.  
  2105.        *  tcf_error - raised when an error occured when  reading  and/or
  2106.           processing  the  terminal  capabilities  file.   Some possible
  2107.           causes are:
  2108.  
  2109.            -  the TCF file is not on your path.
  2110.  
  2111.            -  the format of the TCF file is incorrect.
  2112.  
  2113.            -  the TCF file is opened for  exclusive  access  by  someone
  2114.               else.
  2115.  
  2116.            -  a system error occured.
  2117.  
  2118.  
  2119.        *  terminal_too_primitive - raised when your  terminal  does  not
  2120.           have  the  needed functionality to support this terminal type.
  2121.           In a page terminal you must have these three capabilities:
  2122. FORM TERMINAL                                                 Page 4-9
  2123.  
  2124.  
  2125.            *  erase to end of line
  2126.  
  2127.            *  erase to end of screen
  2128.  
  2129.            *  move the cursor
  2130.  
  2131.  
  2132.        *  unsupported_terminal - this  terminal  is  unsupported.   This
  2133.           could be caused by one of the following:
  2134.  
  2135.            -  There is no TERM file on your path.
  2136.  
  2137.            -  The TERM file could not be opened.
  2138.  
  2139.            -  The TCF file had no entry for this terminal.
  2140.  
  2141.  
  2142.  
  2143.  
  2144.  
  2145.  
  2146.  
  2147.  
  2148.  
  2149.  
  2150.  
  2151.  
  2152.  
  2153.                                APPENDIX A
  2154.  
  2155.                      THE TERMINAL CAPABILITIES FILE
  2156.  
  2157.  
  2158.  
  2159.       A.1  INTRODUCTION
  2160.  
  2161.       The Terminal Capabilities File  is  a  variation  of  the  TERMCAP
  2162.       developed in the Berkeley extensions to the UNIX operating system.
  2163.  
  2164.       The TCF is  a  data  base  describing  terminals.   Terminals  are
  2165.       described  in  the  TCF by giving a set of capabilities which they
  2166.       have, and by describing how  operations  are  performed.   Padding
  2167.       requirements and initialization sequences are included in the TCF.
  2168.  
  2169.       Entries in the TCF consist of a number of  ":"  separated  fields.
  2170.       The  first entry for each terminal gives the names which are known
  2171.       for the terminal, separated by "|" characters.  The first name  is
  2172.       always  2  characters long and is used by older UNIX systems which
  2173.       store the terminal type in a 16 bit  word  in  a  systemwide  data
  2174.       base.   The  second name given is the most common abbreviation for
  2175.       the terminal, and the last name given should be a long name  fully
  2176.       identifying  the  terminal.   This  second name is the one that is
  2177.       matched against the VMS logical  name  "TERM".   The  second  name
  2178.       should  contain  no  blanks; the last name may well contain blanks
  2179.       for readability.  This virtual terminal uses the second name as  a
  2180.       match against the  user supplied terminal name.
  2181.  
  2182.  
  2183.       A.2  CAPABILITIES
  2184.  
  2185.  
  2186.            (P) indicates padding may be specified.
  2187.                Padding is an amount of time to be waited after the
  2188.          command is executed.
  2189.  
  2190.            Name   Type          Description
  2191.            al     str           Add new blank line
  2192.            be     str           Bell
  2193.            cd     str           Clear to end of display
  2194.            co     num           Number of columns in a line
  2195.            ce     str           Clear to end of line
  2196.            cm     str           Cursor motion
  2197.            dc     str           Delete character
  2198.            dl     str           Delete line
  2199. THE TERMINAL CAPABILITIES FILE                                Page A-2
  2200.  
  2201.  
  2202.            ei     str           End insert mode
  2203.            im     str           Enter insert character mode
  2204.            is     str           Terminal initialization string
  2205.            k1     str           Sent by terminal function key 1
  2206.            k2     str           Sent by terminal function key 2
  2207.            k3     str           Sent by terminal function key 3
  2208.            k4     str           Sent by terminal function key 4
  2209.            k5     str           Sent by terminal function key 5
  2210.            k6     str           Sent by terminal function key 6
  2211.            k7     str           Sent by terminal function key 7
  2212.            k8     str           Sent by terminal function key 8
  2213.            k9     str           Sent by terminal function key 9
  2214.            l1     str           Label on function key 1
  2215.            l2     str           Label on function key 2
  2216.            l3     str           Label on function key 3
  2217.            l4     str           Label on function key 4
  2218.            l5     str           Label on function key 5
  2219.            l6     str           Label on function key 6
  2220.            l7     str           Label on function key 7
  2221.            l8     str           Label on function key 8
  2222.            l9     str           Label on function key 9
  2223.            kd     str           Sent by terminal down arrow key
  2224.            kl     str           Sent by terminal left arrow key
  2225.            kr     str           Sent by terminal right arrow key
  2226.            ku     str           Sent by terminal up arrow key
  2227.            li     num           Number of lines on screen or page
  2228.            nl     str           Newline character (default \n)
  2229.            se     str           End stand out mode
  2230.            sf     str           Scroll forwards
  2231.            so     str           Begin stand out mode
  2232.            sr     str           Scroll reverse (backwards)
  2233.            su     bool          Scrolls up at bottom of screen
  2234.            wr     bool          Wraps at end of line
  2235.            x0     str           Sent by terminal function key 10
  2236.            x1     str           Sent by terminal function key 11
  2237.            x2     str           Sent by terminal function key 12
  2238.            x3     str           Sent by terminal function key 13
  2239.            x4     str           Sent by terminal function key 14
  2240.            x5     str           Sent by terminal function key 15
  2241.            x6     str           Sent by terminal function key 16
  2242.            x7     str           Sent by terminal function key 17
  2243.            x8     str           Sent by terminal function key 18
  2244.            x9     str           Sent by terminal function key 19
  2245.            g0     str           Sent by terminal function key 20
  2246.            g1     str           Sent by terminal function key 21
  2247.            g2     str           Sent by terminal function key 22
  2248.            g3     str           Sent by terminal function key 23
  2249.            g4     str           Sent by terminal function key 24
  2250.            g5     str           Sent by terminal function key 25
  2251.            g6     str           Sent by terminal function key 26
  2252.            g7     str           Sent by terminal function key 27
  2253.            g8     str           Sent by terminal function key 28
  2254.            g9     str           Sent by terminal function key 29
  2255.            t0     str           Sent by terminal function key 30
  2256.            t1     str           Sent by terminal function key 31
  2257. THE TERMINAL CAPABILITIES FILE                                Page A-3
  2258.  
  2259.  
  2260.            t2     str           Sent by terminal function key 32
  2261.            y0     str           Label on function key 10
  2262.            y1     str           Label on function key 11
  2263.            y2     str           Label on function key 12
  2264.            y3     str           Label on function key 13
  2265.            y4     str           Label on function key 14
  2266.            y5     str           Label on function key 15
  2267.            y6     str           Label on function key 16
  2268.            y7     str           Label on function key 17
  2269.            y8     str           Label on function key 18
  2270.            y9     str           Label on function key 19
  2271.            h0     str           Label on function key 20
  2272.            h1     str           Label on function key 21
  2273.            h2     str           Label on function key 22
  2274.            h3     str           Label on function key 23
  2275.            h4     str           Label on function key 24
  2276.            h5     str           Label on function key 25
  2277.            h6     str           Label on function key 26
  2278.            h7     str           Label on function key 27
  2279.            h8     str           Label on function key 28
  2280.            h9     str           Label on function key 29
  2281.            v0     str           Label on function key 30
  2282.            v1     str           Label on function key 31     
  2283.            v2     str           Label on function key 32     
  2284.            an     str           Ansi terminal
  2285.            vt     str           VT terminal
  2286.            ca     str           Clear all of line
  2287.            cl     str           Clear screen
  2288.            ds     str           De-initialization string
  2289.           
  2290.  
  2291.  
  2292.       The following entry describes the Televideo-970,  among  the  more
  2293.       complex entries in the TCF file as of this writing.
  2294.  
  2295.        t1|tv970|tv-970|televideo 970:\
  2296.           :al=1*\E[1L:am:bs:cd=\E[J:ce=\E[K:cl=\E[2J:cm=\E[%i%2;%2H:co#80:\
  2297.           :dc=\E[1P:dl=1*\E[1M:dn=\E[1B:ei=\E[4l:ho=\E[H:im=\E[4h:li#24:mi:\
  2298.           :nd=\E[1C:as=\E[10m:ae=\E[11m:ms:pt:se=\E[0m:so=\E[7m:up=\E[1A:\
  2299.           :vs=\E[>4h:ve=\E[>4l:kb=^h:ku=\E[A:kd=\E[B:kl=\E[D:kr=\E[C:\
  2300.           :kh=\E[H:kn#8:k1=\EOS:k2=\EOT:k3=\EOU:k4=\EOV:k5=\EOW:l6=blue:\
  2301.           :sr=\EM:is=\E<\E[2J:\
  2302.           :ca=\E[2K:ds=\E[?2l:\
  2303.           :l1=F1:l2=F2:l3=F3:l4=F4:l5=F5:l6=F6:l7=F7:l8=F8:l9=F9:y0=F10:\
  2304.           :y1=F11:y2=F12:y3=F13:y4=F14:y5=F15:y6=F16:\
  2305.           :y7=Shift F1:y8=Shift F2:y9=Shift F3:h0=Shift F4:h1=Shift F5:\
  2306.           :h2=Shift F6:h3=Shift F7:h4=Shift F8:h5=Shift F9:h6=Shift F10:\ 
  2307.           :h7=Shift F11:h8=Shift F12:h9=Shift F13:v0=Shift F14:v1=Shift F15:\ 
  2308.           :v2=Shift F16:an:\
  2309.           :k1=\E?a:k2=\E?b::k3=\E?c:k4=\E?d:k5=\E?e:k6=\E?f:k7=\E?g:k8=\E?h:\
  2310.           :k9=\E?i:x0=\E?j:x1=\E?k:x2=\E?l:x3=\E?m:x4=\E?n:x5=\E?o:x6=\E?p:\
  2311.           :x7=\E?A:x8=\E?B:x9=\E?C:g0=\E?D:g1=\E?E:g2=\E?F:g3=\E?G:g4=\E?H:\
  2312.           :g5=\E?I:g6=\E?J:g7=\E?K:g8=\E?L:g9=\E?M:t0=\E?N:t1=\E?O:t2=\E?P:\
  2313.           :ku=\E[A:kd=\E[B:kr=\E[C:kl=\E[D:
  2314.  
  2315. THE TERMINAL CAPABILITIES FILE                                Page A-4
  2316.  
  2317.  
  2318.  
  2319.       Note that entries may continue onto multiple lines by giving  a  \
  2320.       as  the  last  character  of  a line, and that empty fields may be
  2321.       included for readability (here between the last field  on  a  line
  2322.       and  the  first  field  on  the next).  Capabilities in TCF are of
  2323.       three  types:   Boolean  capabilities  which  indicate  that   the
  2324.       terminal  has some particular feature, numeric capabilities giving
  2325.       the size of the terminal or the size  of  particular  delays,  and
  2326.       string  capabilities,  which  give a sequence which can be used to
  2327.       perform particular terminal operations.
  2328.  
  2329.       All capabilities have two letter codes.  Numeric capabilities  are
  2330.       followed by the character "#" and then the value.  Thus "co" which
  2331.       indicates the number of columns the terminal has gives  the  value
  2332.       "80" for the Televideo-970.
  2333.  
  2334.       String valued capabilities, such as "ce" (clear  to  end  of  line
  2335.       sequence)  are given by the two character code, an "=", and then a
  2336.       string ending at the next following ":".  A delay in  milliseconds
  2337.       may appear after the "=" in such a capability.    The  delay  must
  2338.       be an integer, e.g.  "20".
  2339.  
  2340.       A number of escape sequences are provided  in  the  string  valued
  2341.       capabilities  for  easy encoding of characters there.  A "\E" maps
  2342.       to  an  ESCAPE  character,  "^x"  maps  to  a  control-x  for  any
  2343.       appropriate  x,  and the sequences "\n" "\r" "\t" "\b" "\f" give a
  2344.       newline, return, tab, backspace and formfeed.  Finally, characters
  2345.       may be given as three octal digits after a "\", and the characters
  2346.       "^" and "\" may be given as "\^" and "\\".  If it is necessary  to
  2347.       place a ":" in a capability it must be escaped in octal as "\072".
  2348.  
  2349.       We now outline how to prepare descriptions of terminals.  The most
  2350.       effective  way  to  prepare a terminal description is by imitating
  2351.       the description of a similar terminal in TCF.   Be  aware  that  a
  2352.       very  unusual  terminal  may expose deficiencies in the ability of
  2353.       the TCF file to describe it or bugs in the virtual  terminal.   To
  2354.       easily   test   a  new  terminal  description,  you  can  set  the
  2355.       environment variable TCF to a pathname of a  file  containing  the
  2356.       description  you are working on and the virtual terminal will look
  2357.       there rather than the standard location.
  2358.  
  2359.       A.2.1  Basic Capabilities
  2360.  
  2361.       The number of columns on each line for the terminal  is  given  by
  2362.       the  "co"  numeric capability.  If the terminal is a CRT, then the
  2363.       number of lines on the screen is given by the "li" capability.  If
  2364.       the  terminal  scrolls at the right edge of the screen, use ":wr:"
  2365.       to signal this.  If the terminal scrolls up at the bottom  of  the
  2366.       screen, use ":su:" to signal this.
  2367.  
  2368.       These capabilities suffice to describe  hardcopy  and  "glass-tty"
  2369.       terminals.  Thus the model 33 teletype is described as
  2370.  
  2371.       t3|33|tty33:co#72
  2372.  
  2373. THE TERMINAL CAPABILITIES FILE                                Page A-5
  2374.  
  2375.  
  2376.       while the Lear Siegler ADM-3 is described as
  2377.  
  2378.       cl|adm3|3|lsi:\
  2379.            adm3:wr:li#24:co#80
  2380.  
  2381.  
  2382.       A.2.2  Cursor Addressing
  2383.  
  2384.       Cursor addressing in the terminal is described by  a  "cm"  string
  2385.       capability.   These substitute to encodings of the current line or
  2386.       column  position,  while  other  characters  are  passed   through
  2387.       unchanged.   If the "cm" string is thought of as being a function,
  2388.       then its arguments are the line  and  then  the  column  to  which
  2389.       motion  is  desired,  and  the  "%"  encodings  have the following
  2390.       meanings:
  2391.  
  2392.                 %d   use as many digits as necessary
  2393.                 %2   use 2 digits
  2394.                 %3   use 3 digits
  2395.                 %.   encode binary value into a character (7 bits)
  2396.                 %+x  adds x to value, then %.
  2397.                 %<xy if value < x adds y; then in any case %.
  2398.                 %r   reverses order of line and column, no output
  2399.                 %i   increments line/column (for 1 origin)
  2400.                 %%   gives a single %
  2401.  
  2402.       Consider the HP2645, which, to get to row 3 and column  12,  needs
  2403.       to  be sent "\E&a12c03Y" padded for 6 milliseconds.  Note that the
  2404.       order of the rows and columns is inverted here, and that  the  row
  2405.       and column are printed as two digits.  Thus its "cm" capability is
  2406.       "cm=6\E&%r%2c%2Y".  The Microterm ACT-IV needs the current row and
  2407.       column  sent  preceded  by  a "^T", with the row and column simply
  2408.       encoded in binary, "cm=^T%.%.".
  2409.  
  2410.       A final example is the LSI  ADM-3a,  which  uses  row  and  column
  2411.       offset by a blank character, thus "cm=\E=%+ %+ ".
  2412.  
  2413.       A.2.3  Area Clears
  2414.  
  2415.       If the terminal can clear from the current position to the end  of
  2416.       the  line, leaving the cursor where it is, this should be given as
  2417.       "ce".  If the terminal can clear from the current position to  the
  2418.       end  of  the  display,  then this should be given as "cd".  If the
  2419.       terminal can clear an entire line regardless of cursor location on
  2420.       the line, this should be given as "ca".  If the terminal can clear
  2421.       an entire display then this should be given as "cl".
  2422.  
  2423.       A.2.4  Insert/Delete Line
  2424.  
  2425.       If the terminal can open a new blank line before  the  line  where
  2426.       the  cursor  is,  this  should be given as "al"; this is done only
  2427.       from the first position of a line.  The cursor must then appear on
  2428.       the  newly  blank line.  If the terminal can delete the line which
  2429.       the cursor is on, then this should be given as "dl"; this is  done
  2430.       only from the first position on the line to be deleted.
  2431. THE TERMINAL CAPABILITIES FILE                                Page A-6
  2432.  
  2433.  
  2434.       A.2.5  Insert/Delete Character
  2435.  
  2436.       There are two basic kinds of intelligent terminals with respect to
  2437.       insert/delete character which can be described using the TCF.  The
  2438.       most common insert/delete character  operations  affect  only  the
  2439.       characters on the current line and shift characters off the end of
  2440.       the line rigidly.  Other terminals, such as the  Concept  100  and
  2441.       the Perkin Elmer Owl, make a distinction between typed and untyped
  2442.       blanks on the screen, shifting upon an insert or delete only to an
  2443.       untyped  blank  on  the  screen  which  is  either  eliminated, or
  2444.       expanded to two untyped blanks.  You can find out  which  kind  of
  2445.       terminal  you  have  by  clearing  the screen and then typing text
  2446.       separated by cursor motions.  Type "abc def"  using  local  cursor
  2447.       motions  (not  spaces)  between  the  "abc"  and  the "def".  Then
  2448.       position the cursor before the  "abc"  and  put  the  terminal  in
  2449.       insert  mode.  If typing characters causes the rest of the line to
  2450.       shift rigidly and characters  to  fall  off  the  end,  then  your
  2451.       terminal   does   not   distinguish  between  blanks  and  untyped
  2452.       positions.  If the "abc" shifts over to the "def" which then  move
  2453.       together  around  the end of the current line and onto the next as
  2454.       you insert, you have the second type of  terminal.   If  you  have
  2455.       this  second  type  of  terminal, you will get no support from the
  2456.       virtual terminal.  This may be changed in further versions.
  2457.  
  2458.       Give as "im" the sequence to get into insert character mode.  Give
  2459.       as "ei" the sequence to leave insert mode.
  2460.  
  2461.       A.2.6  Highlighting, Underlining, And Visible Bells
  2462.  
  2463.       If your terminal has sequences to enter  and  exit  standout  mode
  2464.       these  can  be  given as "so" and "se" respectively.  If there are
  2465.       several flavors of standout mode (such as inverse video, blinking,
  2466.       or  underlining  -  half  bright is not considered "standout") the
  2467.       prefered mode is inverse video by itself.
  2468.  
  2469.       If the terminal has a way of flashing the screen  to  indicate  an
  2470.       error quietly (a bell replacement) then this can be given as "be";
  2471.       it must not move the cursor.
  2472.  
  2473.       A.2.7  Function Keys
  2474.  
  2475.       If the terminal has function keys that transmits  codes  when  the
  2476.       keys  are pressed, this information can be given.  Note that it is
  2477.       not possible to handle terminals where the keypad  only  works  in
  2478.       local  (this applies, for example, to the unshifted HP 2621 keys).
  2479.       The codes sent by the left arrow,  right  arrow,  up  arrow,  down
  2480.       arrow,  and  home  keys can be given as "kl", "kr", "ku", and "kd"
  2481.       respectively.  If there are function keys such as "f1", "f2", ...,
  2482.       "f9",  the  codes they send can be given as "k1", "k2", ..., "k9",
  2483.       "x0", "x1", ..., "x6" If these keys have labels, the labels can be
  2484.       given as "l1", ..., "l9", "y0", "y1", ..., "y6".
  2485.  
  2486.       A.2.8  Initialization
  2487.  
  2488.       An  initialization  string  can  be   specified   to   setup   the
  2489. THE TERMINAL CAPABILITIES FILE                                Page A-7
  2490.  
  2491.  
  2492.       characteristics  of  a  terminal.   If  the terminal must have its
  2493.       function keys defined or turn on the keypad mode this can be  done
  2494.       with is.
  2495.  
  2496.       Using the Televideo-970 example again:
  2497.        t1|tv970|tv-970|televideo 970:\
  2498.           :al=1*\E[1L:am:bs:cd=\E[J:ce=\E[K:cl=\E[2J:cm=\E[%i%2;%2H:co#80:\
  2499.           :dc=\E[1P:dl=1*\E[1M:dn=\E[1B:ei=\E[4l:ho=\E[H:im=\E[4h:li#24:mi:\
  2500.           :nd=\E[1C:as=\E[10m:ae=\E[11m:ms:pt:se=\E[0m:so=\E[7m:up=\E[1A:\
  2501.           :vs=\E[>4h:ve=\E[>4l:kb=^h:ku=\E[A:kd=\E[B:kl=\E[D:kr=\E[C:\
  2502.           :kh=\E[H:kn#8:k1=\EOS:k2=\EOT:k3=\EOU:k4=\EOV:k5=\EOW:l6=blue:\
  2503.           :sr=\EM:is=\E<\E[2J:\
  2504.           :ca=\E[2K:ds=\E[?2l:\
  2505.           :l1=F1:l2=F2:l3=F3:l4=F4:l5=F5:l6=F6:l7=F7:l8=F8:l9=F9:y0=F10:\
  2506.           :y1=F11:y2=F12:y3=F13:y4=F14:y5=F15:y6=F16:\
  2507.           :y7=Shift F1:y8=Shift F2:y9=Shift F3:h0=Shift F4:h1=Shift F5:\
  2508.           :h2=Shift F6:h3=Shift F7:h4=Shift F8:h5=Shift F9:h6=Shift F10:\ 
  2509.           :h7=Shift F11:h8=Shift F12:h9=Shift F13:v0=Shift F14:v1=Shift F15:\ 
  2510.           :v2=Shift F16:an:\
  2511.           :k1=\E?a:k2=\E?b::k3=\E?c:k4=\E?d:k5=\E?e:k6=\E?f:k7=\E?g:k8=\E?h:\
  2512.           :k9=\E?i:x0=\E?j:x1=\E?k:x2=\E?l:x3=\E?m:x4=\E?n:x5=\E?o:x6=\E?p:\
  2513.           :x7=\E?A:x8=\E?B:x9=\E?C:g0=\E?D:g1=\E?E:g2=\E?F:g3=\E?G:g4=\E?H:\
  2514.           :g5=\E?I:g6=\E?J:g7=\E?K:g8=\E?L:g9=\E?M:t0=\E?N:t1=\E?O:t2=\E?P:\
  2515.           :ku=\E[A:kd=\E[B:kr=\E[C:kl=\E[D:
  2516.  
  2517.  
  2518.  
  2519.       The initialization string is ":is=\E<\E[2J".  This string will  be
  2520.       sent to the terminal when the virtual terminal is     initialized.
  2521.       The  de-initialization  string,  ds,  sends  a  string  of  escape
  2522.       sequences that changes the terminal upon exiting the program.
  2523.  
  2524.  
  2525.  
  2526.  
  2527.  
  2528.  
  2529.  
  2530.  
  2531.  
  2532.  
  2533.  
  2534.                                APPENDIX B
  2535.  
  2536.                            PROGRAMMER'S NOTES
  2537.  
  2538.  
  2539.  
  2540.       B.1  COMPILING THE VIRTUAL TERMINAL
  2541.  
  2542.       To compile the virtual terminal  (scroll_terminal,  page_terminal,
  2543.       and form_terminal), compile the source in the following order:
  2544.  
  2545.       1.  vtcontent_spec.ada
  2546.  
  2547.       2.  sysdep_spec.ada
  2548.  
  2549.       3.  tcf_spec.ada
  2550.  
  2551.       4.  scroll_spec.ada
  2552.  
  2553.       5.  page_spec.ada
  2554.  
  2555.       6.  form_spec.ada
  2556.  
  2557.       7.  vtinput_spec.ada
  2558.  
  2559.       8.  driver_spec.ada
  2560.  
  2561.       9.  redisplay_spec.ada
  2562.  
  2563.      10.  sysdep_body.ada
  2564.  
  2565.      11.  tcf_body.ada
  2566.  
  2567.      12.  driver_body.ada
  2568.  
  2569.      13.  vtinput_body.ada
  2570.  
  2571.      14.  redisplay_body.ada
  2572.  
  2573.      15.  scroll_body.ada
  2574.  
  2575.      16.  page_body.ada
  2576.  
  2577.      17.  form_body.ada
  2578. PROGRAMMER'S NOTES                                            Page B-2
  2579.  
  2580.  
  2581.      18.  activate_form.ada
  2582.  
  2583.       I suggest you compile with the /debug switch so you can debug your
  2584.       code  and catch any constraint errors coming from the VT code.  If
  2585.       you decide to attempt compilation with /suppress to  remove  error
  2586.       checking,  we  have  found  that vtinput_body.ada will not compile
  2587.       with correct code.
  2588.  
  2589.       B.2  REDISPLAY
  2590.  
  2591.       Our goal was to implement the Gosling redisplay algorithm (the one
  2592.       used  in Unix Emacs).  However, due to the gross inefficiencies of
  2593.       the code generated from the DG  compiler,  we  compromised  on  an
  2594.       incremental  form  of  redisplay.   There is a field in the screen
  2595.       definition (found in the file vtcontent_spec.ada) that  is  called
  2596.       corresponding_line.   This  field  is used to identify the line in
  2597.       the actual_screen (that reflects what is currently on the  screen)
  2598.       that  corresponds  to a particular line in the virtual_screen (the
  2599.       one where all operations occur until update_X (screen or line)  is
  2600.       called.   It  works  OK.  It is definitely faster than the Gosling
  2601.       redisplay.  Things you should keep in mind:
  2602.  
  2603.        *  Use insert and delete line as much as  possible.   These  will
  2604.           work faster if your terminal supports the operations.
  2605.  
  2606.        *  The redisplay is not smart enough to figure  out  combinations
  2607.           of  insert  and delete when you have simply repainted lines on
  2608.           the screen.  That is, if you DO  NOT  use  insert  and  delete
  2609.           line, then the redisplay algorithm won't either.
  2610.  
  2611.        *  Be very careful specifying the top line and bottom line in  an
  2612.           update_screen  call.   You  can  get  into  trouble with these
  2613.           parameters.  We considered removing  them,  but  can  be  much
  2614.           faster with them there.
  2615.  
  2616.        *  If your terminal support ANSI X3.64 sequences then specify the
  2617.           :an boolean field in the TCF.  Your terminal must support
  2618.  
  2619.            *  insert line with a parameter - ESC [ Pn M
  2620.  
  2621.            *  delete line with a parameter - ESC [ Pn L
  2622.  
  2623.            *  Erase in display - ESC [ 0 J, ESC [ 1 J, ESC  [  2  J  (in
  2624.               order:   erase  from active position to end, from start to
  2625.               active position, and all positions).
  2626.  
  2627.            *  Erase in line - ESC [ 0 K, ESC [ 1 K, ESC [ 2 K (in (again
  2628.               in  order:   erase from active position to end, from start
  2629.               to active position, and all positions).
  2630.  
  2631.            *  Select graphic rendition - ESC [ 0 m, ESC [ 7  m  (primary
  2632.               rendition, reverse image).
  2633. PROGRAMMER'S NOTES                                            Page B-3
  2634.  
  2635.  
  2636.            *  Cursor position ESC [ Pl ; Pc H  (where  Pl  is  the  line
  2637.               number  as  an ASCII number sequence, and Pc is the column
  2638.               number).
  2639.  
  2640.           If you can specify this then the parameter modes  will  be  be
  2641.           used  and  this  thing  will  really  fly  when  inserting and
  2642.           deleting lines.
  2643.  
  2644.  
  2645.       B.3  OTHER PACKAGES
  2646.  
  2647.       The structure of this virtual terminal  is  shown  in  the  figure
  2648.       below.
  2649. PROGRAMMER'S NOTES                                            Page B-4
  2650.  
  2651.  
  2652.  
  2653.               ______________            ______________            ______________ 
  2654.              | Scroll mode  |          | Page mode    |          | Form mode    |
  2655.              |______________|          |______________|          |______________|
  2656.              |              |          |              |          |              |
  2657.              |______________|          |______________|          |______________|
  2658.                    |     | |            |  |   |     |             |   |  |    |
  2659.                    |     | \_____ _____ |_ | _ | ___/_____________ | _ | _| __/
  2660.                    |     |       V      |  |   |                   |   |  |    
  2661.                    |     |       |      |  |   |                   |   |  |  
  2662.        ____________v_     \_____ | _    |  |   |                   |   |  |    
  2663.       | vt_content   |           |  \   |  |   |                   |   |  |    
  2664.       |______________|<_________ |_ | _ | _/__ | _________________ | _ | _/
  2665.       |              |           |  |   |      |                   |   |       
  2666.       |______________|           |  |   |      |                   |   |       
  2667.              ^                   |  |   |      |                   |   |       
  2668.        ______|_______            |  |   |      |                   |   |         
  2669.       | redisplay    |           |  |   |      |                   |   |         
  2670.       |______________|<_________ |_ | __/_____ | __________________/   |         
  2671.       |              |           |  |          |                       |         
  2672.       |______________|           |  |          |                       |         
  2673.                   |              |  \__________\________________ ______/      
  2674.                   |         ____/                               V             
  2675.                ___v________v_                            _______v______
  2676.               |    Driver    |___ ______________________|  VT_input    |
  2677.               |______________|   V                      |______________|
  2678.               |              |__ | _________________ ___|              |
  2679.               |______________|   |                  V   |______________|
  2680.                                  |                  |                         
  2681.                        __________v___            ___v__________             
  2682.                       |     TCF      |          |   SYSDEP     |          
  2683.                       |______________|          |______________|               
  2684.                       |              |          |              |               
  2685.                       |______________|          |______________|                
  2686.                         ^                          |    ^                      
  2687.                  _______|__                     ___V____|__       
  2688.                 | TCF file |                   '   ____________  
  2689.                 | ======== |                   |  |  --------  \  
  2690.                 | ======== |                   |  | |        |    
  2691.                 | ======== |                  8 ` | |________|    
  2692.                 | ======== |                  8  `|_____________| 
  2693.                 | ======== |                    8 ______________    
  2694.                 |__________|                     \\========== ==\   
  2695.                                                   \\========== =|   
  2696.                                                       TERMINAL
  2697.  
  2698.       The package definitions are as follows:
  2699.  
  2700.        *  scroll_terminal, page_terminal, form_terminal - these are what
  2701.           the user program uses and are described in this document.
  2702.  
  2703.        *  redisplay - the package containing various redisplay line  and
  2704.           redisplay screen procedures.
  2705. PROGRAMMER'S NOTES                                            Page B-5
  2706.  
  2707.  
  2708.        *  driver - this package is called via driver.interpret to  cause
  2709.           operations  to  occur  on the screen.  The procedure interpret
  2710.           can be sent any string.  Two things may occur with the string.
  2711.  
  2712.            -  the string matches one of the ANSI sequences  that  driver
  2713.               understands.   The  sequence  is transformed into one that
  2714.               the particular terminal that the  user  has  (semantically
  2715.               the same, functionally different).  I.E.  If your terminal
  2716.               is a vt52, to move the position 7,7 the string sent  would
  2717.               need  to be "ESC Y & &".  This information is store in the
  2718.               terminal capabilities file and is read into internal  data
  2719.               structures   by   the  TCF  package  upon  initialization.
  2720.               Driver.interpret will take the sequence "ESC [ 7  ;  7  H"
  2721.               and  translate  it  into  the  sequence "ESC Y & &" before
  2722.               sending it to the terminal display.
  2723.  
  2724.               A single call on driver.interpret will  always  result  in
  2725.               something  being  sent  to the screen immediately.  Do not
  2726.               send partial escape sequences, they will not be understood
  2727.               or translated.
  2728.  
  2729.               The sequences understood are:
  2730.  
  2731.                .  ESC [ Pn P - Delete Character
  2732.  
  2733.                .  ESC [ Pn M - Delete Line
  2734.  
  2735.                .  ESC [ Pn L - Insert Line
  2736.  
  2737.                .  ESC [ 0 J - Erase in display from active pos to end
  2738.  
  2739.                .  ESC [ 1 J - Erase in display from start to active pos
  2740.  
  2741.                .  ESC [ 2 J - Erase in display all positions
  2742.  
  2743.                .  ESC [ 0 K - Erase in line from active pos to end
  2744.  
  2745.                .  ESC [ 1 K - Erase in line from start to active pos
  2746.  
  2747.                .  ESC [ 2 K - Erase in line all positions
  2748.  
  2749.                .  ESC [ 0 m - Select primary rendition
  2750.  
  2751.                .  ESC [ 7 m - Select reverse image rendition
  2752.  
  2753.                .  ESC [ Pl ; Pc H - Cursor position
  2754.  
  2755.                .  ESC [ 4 h - Enter insert mode
  2756.  
  2757.                .  ESC [ 4 l - Exit insert mode
  2758.  
  2759.               Where  -  Pn  is  an  ASCII  representation  of  a  number
  2760.               parameter.  ESC means the escape character.  Pl is like Pn
  2761.               but represents the line  number,  ditto  with  Pc  as  the
  2762.               column number.
  2763. PROGRAMMER'S NOTES                                            Page B-6
  2764.  
  2765.  
  2766.               You may find out if your terminal supports one or more  of
  2767.               these    functions    by    interogating    the   variable
  2768.               driver.supported_functions    which    identifies    those
  2769.               operations that have an entry in the TCF file.
  2770.  
  2771.            -  if the sequence is not one that is understood then  it  is
  2772.               sent  directly  to  the  screen  with  no  translation  or
  2773.               filtering.
  2774.  
  2775.  
  2776.        *  vt_input - gets  characters  from  the  terminal  and  detects
  2777.           function  and arrow keys (this one is extremely inefficient at
  2778.           this  time,  due  to  bugs  in  the   DG   implementation   of
  2779.           unchecked_conversion).
  2780.  
  2781.        *  TCF - reads in the terminal capabilities file and provides the
  2782.           needed data structures containing the information to the other
  2783.           packages.
  2784.  
  2785.        *  SYSDEP - isolates all system dependencies.  This is  described
  2786.           in the next section.
  2787.  
  2788.  
  2789.       B.4  CHOOSING AN INTERFACE LEVEL
  2790.  
  2791.       There are many ways of interfacing  to  the  packages  within  the
  2792.       virtual   terminal.    Depending   on   what  is  desired  (speed,
  2793.       functionality) different choices can  be  made  to  enhance  those
  2794.       desires.
  2795.  
  2796.       This matrix should provide guidance on how to  use  the  different
  2797.       packages  within  the scroll and page mode terminal packages.  The
  2798.       form terminal interfaces are  a  different  beast  and  cannot  be
  2799.       applied to the matrix in a usable way.
  2800.       I desire:                            Interface to package:
  2801.  
  2802.       Direct communication with the        SYSDEP for input
  2803.       terminal, direct communication       SYSDEP for output
  2804.       with the keyboard. No function
  2805.       key identification, No TCF 
  2806.       translation.
  2807.       This is the fastest mode.
  2808.  
  2809.       TCF translation of the output,       SYSDEP for input
  2810.       output immediately, input with       driver for output
  2811.       no function key indentification.
  2812.       This is very fast for input,
  2813.       fairly fast for output.
  2814.  
  2815.       TCF translation of the output,       vt_input for input
  2816.       output immediately, input with       driver for output
  2817.       function key identification.
  2818.       This is fairly fast for output,
  2819.       not so fast for input.
  2820.  
  2821. PROGRAMMER'S NOTES                                            Page B-7
  2822.  
  2823.  
  2824.       TCF translation of the output,       page_terminal, scroll_terminal for
  2825.       output when requested, input         output
  2826.       with no function key translation.    SYSDEP for input
  2827.       fairly fast for output, very fast
  2828.       for input.
  2829.  
  2830.       and so forth...
  2831.  
  2832.  
  2833.       B.5  EFFICIENCY
  2834.  
  2835.       The system as it now stands  is  inefficient.   If  the  /suppress
  2836.       option  is  used  it  can  be  made  somewhat more efficient.  All
  2837.       packages can be recompiled with this switch except vt_input  which
  2838.       cannot.   This  is due to a problem with the code generated by the
  2839.       DG compiler.
  2840.  
  2841.       The vt_input procedure and function calls require a level of  type
  2842.       changing  when calls are made from the page_terminal body into the
  2843.       vt_input package.  This is a  significant  overhead  that  can  be
  2844.       reduced when unchecked conversion is available.
  2845.  
  2846.       The data structures defined in the vt_content  package  are  quite
  2847.       large.   Part of the reason is that the DG generated a 32-bit word
  2848.       for every type of elementary object (even booleans  get  a  32-bit
  2849.       word!).   Arrays  have  a  16-word  overhead associated with every
  2850.       individual one.  Strings are  store  as  32-bit  words  with  each
  2851.       character stored in the upper 8 bits.
  2852.  
  2853.       Some of the interfaces could be made in-line.  We tryed  that  and
  2854.       discovered  a serious problem with the debugger.  So we removed it
  2855.       for development.   Since  it  could  hinder  transportability,  we
  2856.       decided to leave it out.
  2857.  
  2858.       B.6  SYSTEM DEPENDENCIES
  2859.  
  2860.       All system dependencies are isolated in the  package  SYSDEP.   Of
  2861.       course,  coding  work-arounds are technically system dependencies,
  2862.       these are not identified here.
  2863.  
  2864.       An implementation must provide the capabilities  as  described  in
  2865.       the interface spec.  These interfaces are described below.
  2866.  
  2867.        *  open - Open the console for binary I/O, no echo.
  2868.  
  2869.        *  close - Close the console.   Parameters  should  be  reset  to
  2870.           original condition.
  2871.  
  2872.        *  put - Put a string  to  the  terminal.   There  should  be  no
  2873.           translation  of  the  characters.   There can be exceptions to
  2874.           this rule (like CTRL-S and CTRL-Q) and these  exceptions  must
  2875.           be identified in valid_character below.
  2876. PROGRAMMER'S NOTES                                            Page B-8
  2877.  
  2878.  
  2879.        *  get - Get a string from the terminal  keyboard.   This  ocurrs
  2880.           with no echo and no translations.
  2881.  
  2882.        *  tcf_name - Returns the name of the terminal capabilities  file
  2883.           as a string.  You better pass in a string of sufficient length
  2884.           to handle the  name  that  is  returned  or  you  will  get  a
  2885.           constraint error.  80 is a good random number.
  2886.  
  2887.        *  terminal_name - Returns the name of the terminal.   This  name
  2888.           of  a  string  like "tv970".  If the name cannot be determined
  2889.           then last is returned as 0 (zero).  Again, you better make the
  2890.           name parameter big enough to hold the value returned.
  2891.  
  2892.           A DG implementation note:  This procedure  looks  for  a  file
  2893.           called TERM on your searchlist.
  2894.  
  2895.        *  valid_character Returns a boolean  value  identifying  whether
  2896.           the  character  passed  in is safe to used in the environment.
  2897.           Suspicious characters include CTRL-S CTRL-Q CTRL-C CTRL-Y.
  2898.  
  2899.  
  2900.  
  2901.  
  2902.  
  2903.  
  2904.  
  2905.  
  2906.  
  2907.  
  2908.  
  2909.  
  2910.                                APPENDIX C
  2911.  
  2912.                             SAMPLE PROGRAMS
  2913.  
  2914.  
  2915.  
  2916.       The biggest sample program is the interactive/batch form generator
  2917.       that  is  one  of  the  tools developed by Texas Instruments under
  2918.       contract.  This tools should be available in the same location  as
  2919.       this virtual terminal.
  2920.  
  2921.       A code segment that will handle reading  data  from  the  terminal
  2922.       using   the   input   procedures   and   functions   described  in
  2923.       scroll_terminal and page_terminal is as follows:
  2924.       LOOP 
  2925.  
  2926.           page_terminal.get( data, last, keys );
  2927.           number_of_function_keys := page_terminal.function_count( keys );
  2928.  
  2929.           IF last=0  --  only function keys
  2930.           THEN
  2931.               FOR i IN 1..number_of_function_keys
  2932.               LOOP
  2933.                   page_terminal.function_key( keys, i, id, position );
  2934.                   handle_the_function_key( id );
  2935.               END LOOP;
  2936.           ELSE  --  data here too
  2937.               last_position := 1;
  2938.               FOR i IN 1..number_of_function_keys  -- go through the
  2939.                                                    -- function keys
  2940.               LOOP
  2941.                   page_terminal.function_key( keys, i, id, position );
  2942.                   IF position<>0
  2943.                   THEN
  2944.                       handle_the_string( 
  2945.                           data( last_position..position ),
  2946.                           ( position-last_position+1 )     );
  2947.                       last_position := position + 1;
  2948.                   END IF;
  2949.                   handle_the_function_key( id );
  2950.               END LOOP;
  2951.           END IF;
  2952.  
  2953.       END LOOP;
  2954.  
  2955.