[comp.os.vms] new SWING source, part 1 of 5

PORTIA@engvax.scg.hac.COM.UUCP (08/14/87)

$ show default
$ check_sum = 1007251476
$ write sys$output "Creating AAAREADME.GRC"
$ create AAAREADME.GRC
$ DECK/DOLLARS="$*$*EOD*$*$"
[.GRC.ERIC.SWING]

      SWING displays the current directory tree on a CRT screen for 
interactive tree manipulation.  It is able to do the following:

      o  SET DEFAULT by moving from node to node with the arrow keys
         and exiting SWING when the current node is the directory 
         desired.

      o  Rename a subdirectory.

      o  Interactively create a new subdirectory.

      o  Interactively move a subdirectory structure to a new position, 
         with all of its children.

      o  Interactively delete a tree structure - each node blinks and 
         then disappears as it is deleted.  This graphically does what
         the DELTREE type command procedures do.

      o  Create hardcopy of the current directory structure.

      o  Create a "binary save file" so the whole directory doesn't have
         to be searched each time SWING is used.

      o  Perform file-manipulation on the files in the current directory
         with the FILER option.

      o  Execute DCL commands with out leaving the SWING environment.

      The SWING program is written entirely in FORTRAN and replaces a 
lot of worn out command procedures that have been written over the years. 
It allows the user to quickly examine and manipulate a directory 
structure, saving time for the real work at hand.  

      The screen manipulation is handled by the SMG routines and all 
eight directory levels are supported.  The screen is switched between 
80 and 132 columns as the directory tree changes size.  The display 
scrolls up and down for long directory trees and commands are either 
entered by hitting keys or by a pulldown menu at the top of the screen.
There is help while in SWING and a help file is furnished for the VMS 
HELP library as well.  You have to try SWING to believe it.  It is 
proof that computers can be easy to use!

------------------------------------------------------------------------
THE FILES              THEIR USE
------------------------------------------------------------------------
AAAREADME.GRC;1        This file
BUILD.COM;1            Command procedure to compile source
PULLDOWN.CMN;1         Commons for PULLDOWN.FOR
SWING.CMN;1            Commons for SWING.FOR
SWING.EXE;1            SWING executable VMS 4.4
SWING.HLB;1            SWING help library
SWING.HLP;1            SWING help source

------------------------------------------------------------------------
                            INSTALLATION


$ ! Set up a symbol like this in your sylogin.com or login.com
$ !
$ SWING:== $GRC$TOOLS:SWING

$ ! Add the help library to helplib
$ ! This requires privilege
$ !
$ LIBRARY/HELP SYS$HELP:HELPLIB SWING.HLP

$ ! Put the SWING help library in SYS$HELP for interactive help in SWING
$ ! This requires privilege
$ !
$ LIBRARY/HELP/CREATE SYS$HELP:SWING SWING.HLP

NOTE:  GRC$TOOLS is a logical that must be defined in the system logical 
       name table.  The logical GRC$TOOLS is used throughout the GRC 
       tools on this DECUS tape and should point to the disk and 
       directory containing SWING.EXE.

------------------------------------------------------------------------
      COMPLEMENTS, SUGGESTIONS AND COMPLAINTS TO THE FOLLOWING:

                       Eric Andresen
                       General Research Corporation
                       5383 Hollister Avenue
                       Santa Barbara, CA  93111
                       (805)964-7724  Ext. 332

------------------------------------------------------------------------
$*$*EOD*$*$
$ checksum AAAREADME.GRC
$ if checksum$checksum .ne. check_sum then -
$   write sys$output "Checksum failed, file probably corrupted"
$ check_sum = 1902280557
$ write sys$output "Creating SWING.BUL"
$ create SWING.BUL
$ DECK/DOLLARS="$*$*EOD*$*$"
      A new version of SWING has been installed on the system.
      (to use it, type SWING or HELP SWING for help information)

      New Features:

        FILER under the OPTION command - allows you to do individual
              file operations. E.g. Edit, Print, Rename, Delete, Move, etc.

              the logical name SWING$EDIT if defined will be the command
              used to invoke the editor. TPU is the default, if you
              defined TPUSECINI to be USR:EDTPLUS you will be using the
              same TPU.

              the logical name SWING$PRINT, if defined, will be the command
              used to print the file, for example, you can define it
              to be PRINT/QUEUE=TALARIS/FORM=R610P (which can be abbrivated
              to L80 on the system ASL1)

        DCL commands under the OPTION command - allows you to do some
              DCL commands (non-interactively, for example, you can not
              invoke the editor, read mail or use phone, but this can be
              achieved from the SPAWN out of TPU)


        T for top, and B for bottom commands allow you to go to the bottom
              of you directory tree quickly, and back to TOP.

       /START qualifier is added so you can start swing from a subdirectory.

      old info follows,

      SWING displays the current directory tree on a CRT screen for 
interactive tree manipulation.  It is able to do the following:

      o  SET DEFAULT by moving from node to node with the arrow keys
         and exiting SWING when the current node is the directory 
         desired.

      o  Rename a subdirectory.

      o  Interactively create a new subdirectory.

      o  Interactively move a subdirectory structure to a new position, 
         with all of its children.

      o  Interactively delete a tree structure - each node blinks and 
         then disappears as it is deleted.  This graphically does what
         the DELTREE type command procedures do.

      o  Create hardcopy of the current directory structure.

      o  Create a "binary save file" so the whole directory doesn't have
         to be searched each time SWING is used.

      The SWING program is written entirely in FORTRAN and replaces a 
lot of worn out command procedures that have been written over the years. 
It allows the user to quickly examine and manipulate a directory 
structure, saving time for the real work at hand.  

      The screen manipulation is handled by the SMG routines and all 
eight directory levels are supported.  The screen is switched between 
80 and 132 columns as the directory tree changes size.  The display 
scrolls up and down for long directory trees and commands are either 
entered by hitting keys or by a pulldown menu at the top of the screen.
There is help while in SWING and a help file is furnished for the VMS 
HELP library as well.  You have to try SWING to believe it.  It is 
proof that computers can be easy to use!

$*$*EOD*$*$
$ checksum SWING.BUL
$ if checksum$checksum .ne. check_sum then -
$   write sys$output "Checksum failed, file probably corrupted"
$ check_sum = 318771311
$ write sys$output "Creating BUILD.COM"
$ create BUILD.COM
$ DECK/DOLLARS="$*$*EOD*$*$"
$ !	Craig Young			3-AUG-87
$ !
$ !	This command procedure is used to compile and link the parts
$ !	of SWING.  It checks the creation date of the source file
$ !	against that of the current object file and compiles the source
$ !	only if it was created after the last object file.  A similar
$ !	check is done with the link.  In this way, only the subroutines
$ !	that were modified are recompiled.
$ !
$ compile /verify /include=(swing.cmn,pulldown.cmn) /library=swing-
	/nolist/'p1'debug/check -
ADD_NODE,-
ADD_NODE_TO_DISPLAY,-
ADJUST_NODE_POINTERS,-
APPEND_FNODE,-
APPEND_NODE,-
CHANGE_OPTIONS,-
CHANGE_SPEC,-
CHECK_DIRECTORY_MOVE,-
CREATE_DIRECTORY,-
CRT
$ compile /verify /include=(swing.cmn,pulldown.cmn) /library=swing-
	/nolist/'p1'debug/check -
DEFINE_PASTE_BOARD,-
DEFINE_SMG_LAYOUT,-
DELETE_DIRECTORY,-
DELETE_FILE,-
DELETE_FILES,-
DELETE_NODE,-
DIR_TO_FILE,-
DRAW_SCREEN
$ compile /verify /include=(swing.cmn,pulldown.cmn) /library=swing-
	/nolist/'p1'debug/check -
EDIT_FILE,-
EXECUTE_DCL,-
EXIT_SWING,-
FILE_OPTIONS,-
FILE_TO_DIR,-
FIND_NODE,-
FREE_NODE,-
GET_LOCATION,-
HARDCOPY,-
HELP,-
HELP_FILER,-
LOAD_DISPLAY
$ compile /verify/include=(swing.cmn,pulldown.cmn) /library=swing-
	/nolist/'p1'debug/check -
LOAD_FILES,-
LOAD_NODES,-
MODIFY_FILE_PROT,-
MOVE_FILE,-
MOVE_NODE,-
PD_BAR_CHOICE,-
PD_DRAW_BAR,-
PD_GET_CHOICE,-
PD_LIST_CHOICE,-
PD_LOAD_BAR,-
PD_UNDRAW_BAR,-
PRINT_FILE,-
PRINT_MESSAGE
$ compile /verify /include=(swing.cmn,pulldown.cmn) /library=swing-
	/nolist/'p1'debug/check -
PROCESS_COMMAND,-
RECORD_STRUCTURE,-
REDEFINE_SMG_LAYOUT,-
RENAME_DIRECTORY,-
RENAME_FILE,-
RESET_TERMINAL,-
SET_NOTAB,-
SHOW_FILES,-
SM_ALLOW_REPAINT,-
SM_REPAINT_SCREEN
$ compile /verify /include=(swing.cmn,pulldown.cmn) /library=swing-
	/nolist/'p1'debug/check -
TRANSLATE_LOGICAL,-
UPDATE_FILE_WINDOW,-
UPDATE_SCREEN,-
UPDATE_WINDOW1
$ compile /verify /include=(swing.cmn,pulldown.cmn)-
	/nolist/'p1'debug/check -
	/link=(/'p1'debug swing/lib) -
SWING
$ exit
$*$*EOD*$*$
$ checksum BUILD.COM
$ if checksum$checksum .ne. check_sum then -
$   write sys$output "Checksum failed, file probably corrupted"
$ check_sum = 962856556
$ write sys$output "Creating PULLDOWN.CMN"
$ create PULLDOWN.CMN
$ DECK/DOLLARS="$*$*EOD*$*$"
*=======================================================================
*     COMMONS FOR PULLDOWN.FOR
*=======================================================================

C     CONSTRAINTS

      parameter PD_MAX_CHOICES = 10
      parameter PD_MAX_CHOICE_LEN = 20

C     THE PULL DOWN CHOICE STRUCTURE

      structure /pd_choice_type/
         integer number
         character*(PD_MAX_CHOICE_LEN) choice(PD_MAX_CHOICES)
         integer code(PD_MAX_CHOICES)
         integer ptr(PD_MAX_CHOICES)
      end structure

C     PULL DOWN SCREEN INFORMATION

      integer pd_bar_id, pd_num_choices, pd_cell_size

      common /pd_common/ pd_bar_id,      ! BAR DISPLAY ID
     .                   pd_num_choices, ! NUMBER OF POSSIBLE CHOICES
     .                   pd_cell_size    ! LENGTH OF EACH CELL IN THE BAR
$*$*EOD*$*$
$ checksum PULLDOWN.CMN
$ if checksum$checksum .ne. check_sum then -
$   write sys$output "Checksum failed, file probably corrupted"
$ check_sum = 2138404193
$ write sys$output "Creating SWING.CMN"
$ create SWING.CMN
$ DECK/DOLLARS="$*$*EOD*$*$"
*=======================================================================
*     COMMONS FOR SWING.FOR
*=======================================================================

      implicit  none

      include 'pulldown.cmn'

      parameter MAX_LINES = 495  ! Bug in SMG prevents > 496
      parameter MAX_LEVELS = 7
      parameter MAX_NODES = 3500
      parameter MAX_FILES = 500

      integer*4 line
      integer   last_level, last_line(0:MAX_LEVELS)
      integer   last_node(0:MAX_LEVELS)
      integer   node_pointer( 0:MAX_LEVELS, MAX_LINES ), lowest_level
      integer   node_num, num_nodes, num_lines, file_num, num_files

      structure /node_type/
                character*255 spec
                character*12  name
                integer*4     length
                integer*4     level
                integer*4     line  
                integer*4     rend
                integer*4     child
                integer*4     sister
      end structure

      record /node_type/ node(0:MAX_NODES)

      structure /fnode_type/
                character*255 spec
                character*25  name
                integer*4     length
                integer*4     rend
      end structure

      record /fnode_type/ fnode(MAX_FILES)

      common /node_info/ line,
     .                   last_level,
     .                   lowest_level,
     .                   last_line,
     .                   last_node,
     .                   num_lines,
     .                   node_pointer,
     .                   node,
     .                   node_num,
     .                   num_nodes,
     .                   fnode,
     .                   file_num,
     .                   num_files

      integer   window1, window2, window3, board_id, set_term_buf(3)
      integer   width, cur_level, cur_line, bottom_line, top_line
      integer   old_rend, len_disk, len_main, len_root, keyboard
      integer   file_window, top_file_line, bottom_file_line
      integer   DCL_window, proc_created
      integer*2 inbox_channel, outbox_channel
      logical   avo, using_screen, found, update, delete_problem
      logical   use_window1, do_save, swing_file_exists
      character this_terminal*31, disk*31, root*255, main*50

      record /pd_choice_type/ pull_choices

      common /smg_info/  board_id,
     .                   keyboard,
     .                   window1,
     .                   window2,
     .                   window3,
     .                   file_window,
     .                   DCL_window,
     .                   pull_choices,
     .                   this_terminal,
     .                   set_term_buf,
     .                   width,
     .                   avo,
     .                   old_rend,
     .                   disk,
     .                   len_disk,
     .                   root,
     .                   len_root,
     .                   main,
     .                   len_main,
     .                   cur_level,
     .                   cur_line,
     .                   top_line,
     .                   bottom_line,
     .                   top_file_line,
     .                   bottom_file_line,
     .                   using_screen,
     .                   use_window1,
     .                   update,
     .                   found,
     .                   delete_problem,
     .                   do_save,
     .                   swing_file_exists,
     .                   inbox_channel,
     .                   outbox_channel,
     .                   proc_created
$*$*EOD*$*$
$ checksum SWING.CMN
$ if checksum$checksum .ne. check_sum then -
$   write sys$output "Checksum failed, file probably corrupted"
$ check_sum = 1749174224
$ write sys$output "Creating SWING.HLP"
$ create SWING.HLP
$ DECK/DOLLARS="$*$*EOD*$*$"
!=======================================================================
! THIS IS THE HELP LIBRARY FOR SWING
!=======================================================================
!
!   This is the help file for the program SWING
!   To add this to the standard help library on the VAX type:
!   $ LIBRARY/HELP  SYS$HELP:HELPLIB  SWING.HLP
!        
!   Note that the processed version of this file (.HLB)
!   is used by the SWING executable and must be located in SYS$HELP
!
1 SWING
 SWING is a VAX/VMS utility for displaying the graphical representation
 of directory trees on a VT100 or VT200 type terminal.  It can be used to
 move to a directory or subdirectory, as is done with the SET DEFAULT
 command, and it can rename, move and delete subdirectories.  SWING can
 also create hardcopy listings of a directory structure. 

 SWING takes one optional qualifier - START.  This sets the root of the 
 directory tree to any directory that the user desires.  The directory
 is entered with the square brackets as with the SET DEFAULT command.
 START may also be set to CURRENT in which case the default directory
 is the root directory.

 Simply type SWING[/START=directory] at the VMS prompt.

 Limitations:  SWING cannot handle directory trees with more than 3500 
 directories, more than 8 levels deep, or that require more than 500
 lines to display.
2 Moving_around
 Once SWING has drawn a picture of the default directory structure the
 cursor will be positioned at the current directory and it will be
 highlighted.  The arrow keys can be used to move from one subdirectory
 to another.  As you travel around you are "setting default" to that
 directory.  To exit simply type X, E, CONTROL-Z or ENTER and you will
 return to VMS in the new directory location. 
 
 As you move around with the arrow keys notice that the RIGHT, UP and 
 DOWN arrows take you to the first directory available in that direction 
 and that the LEFT arrow takes you to the parent of the current directory.
 Typing B will take you to the bottom of the tree and typing T will take
 you to the top (root directory).

 Other commands can be entered to create, rename and move subdirectories,
 as well as delete entire directory trees and get a hardcopy listing of
 the current directory structure.  To get help on these various commands
 enter the section of help called COMMANDS. 
2 Save_file
 Every time SWING displays a directory tree it gets its information from
 either searching the disk or from a save file called SWING.SAV located
 in the main directory.  If SWING is going to be used on a regular basis
 it is advisable that the structure be saved in such a file.  The SAVE
 command will create a SWING.SAV file and from that point on SWING will
 attempt to keep that file up-to-date.  Having the save file will speed
 up initialization so much that it might be tempting to use SWING for
 "setting default" all of the time. 
 
 If the directory structure is changed in any way by SWING the save file
 will be updated automatically, but if a change has occurred without the
 use of SWING it will be necessary to do a manual SAVE on the new
 directory tree.
 
 NOTE: SWING does purge the save files located in the main directory,
       provided the current process has enough privilege.
2 Commands
 Commands can be entered by either hitting the first letter of the
 commands located on the menu at the top of the screen or by hitting the
 CONTROL-P or DO keys and using the menu bar like a pulldown menu.  The
 pulldown menu is operated by using the arrow keys to go to a selection
 and then hitting the ENTER key to choose that item.  CONTROL-Z will exit
 the pulldown menu without making a choice. Although the pulldown menu is
 cute, hitting the first letter of the commands is by far a faster
 method. 
3 Create
 CREATE prompts the user for the name of a new subdirectory to be created.
 The display will be updated and an actual directory is created. 
3 Rename
 RENAME prompts for a new name to be given to the current directory.  The 
 display may change since the directories are in alphabetical order.
3 Move
 MOVE initiates the move operation by blinking the current subdirectory
 and then the user is asked to move to the a new parent directory.  When
 either RETURN or ENTER is hit the move takes place.  Both the new parent
 and the directory being moved can have other subdirectories attached to
 them as well.  While moving to the new parent directory the operation
 can be canceled by hitting any key besides the arrow keys, ENTER and
 RETURN. 
3 Delete
 DELETE causes the current directory and all subdirectories below it to 
 be deleted automatically.  The user is asked to enter YES before any 
 delete operation takes place and the word YES must be spelled out 
 completely.  The deletion starts at the lowest subdirectory in the tree 
 and works its way back to the current directory.  As files are being 
 deleted from a subdirectory that node will blink on the screen.  If the
 subdirectory is successfully deleted the node name will blank out, so you
 can watch the directory tree being deleted graphically. 

 IMPORTANT: IF A FILE DOES NOT HAVE DELETE ACCESS FOR THE USER, SWING 
            WILL ATTEMPT TO CHANGE THE PROTECTION ON IT SO THAT IT CAN
            DELETE THE FILE (GIVEN THE PRIVILEGE OF THE USER ONLY)

 If a particular subdirectory or file still can't be deleted then the
 deletion process will continue anyway, leaving the protected files. 
 A message will be given stating the problem.
3 Print
 PRINT creates a file for printing that contains a hardcopy version of 
 the directory structure.  One of two file types can be created.  The 
 normal output is for any printer and the LQP input file is for running 
 through the LQP utility on a laser printer for a clean line drawn 
 representation of the directory tree.  The file is called SWING.LIS and 
 it will be placed in the current directory.
3 Save
 SAVE causes a new save file to be created in the main directory.  The 
 save file is for speeding up the initialization of SWING.  See the 
 section called SAVE_FILE on the level of help above this level.
3 Option
 OPTION lists addition facilities available in SWING.  The desired option
 is selected by using the up- and down-arrows to position the cursor over
 the option then pressing RETURN.
4 DCL Command
 This option allows the user to execute any DCL at the prompt.  SWING
 WILL NOT reflect changes made to the directory structure by these
 commands.  This option is non-interactive and should not be used for
 commands that do not return to the DCL prompt after completion.  The
 output is printed in the DCL Command window and reverse scrolling is 
 not possible.

 WARNING: THIS OPTION IS PRONE TO RANDOM BUGS.  THE OUTPUT MAY NOT
 MATCH THE OUTPUT SEEN AT COMMAND LEVEL.  THIS OPTION MAY ALSO CAUSE
 SWING TO HANG.  THIS CAN BE OVERCOME WITH A CTRL-Y BUT THE SUBPRO-
 CESS 'SWING_DCL_PROC' MUST BE STOPPED FOR FURTHER USE OF SWING.
4 Display Directory
 DISPLAY DIRECTORY causes an optional full directory specification to be 
 displayed at the top of the screen.  The directory name will be modified
 each time the user moves to a new directory location.
4 FILER
 This is the file-management portion of the SWING utility.  It can be 
 used to delete, edit, move, print, or rename files in the current 
 directory.

 Limitations: The filer can only handle 500 files.  If a directory
 contains more than 500 files, the first 500 are displayed and the
 rest are not available.
5 Commands
 Commands can be entered by either hitting the first letter of the
 commands located on the menu at the top of the screen or by hitting
 the control-P or DO keys and using the menu bar like a pulldown menu.
 The pulldown menu is operated by using the arrow keys to go to a
 selection and then hitting the ENTER key to choose that item. 
 Control-Z will exit the pulldown menu without making a choice. 
 Although the pulldown menu is cute, hitting the first letter of the
 commands is by far a faster method.
6 Delete
 DELETE causes the current file to be deleted.  The user is asked to
 enter YES before any delete operation takes place and the word YES
 must be spelled out completely.
6 Edit
 EDIT invokes an editor with the current file as input.  The editor
 invoked is that specified in the logical name, SWING$EDIT.  SWING
 looks for translations in the following tables, in the following
 order: LNM$PROCESS, LNM$JOB and LNM$SYSTEM.  If this logical name
 is not defined, the default is TPU.  When the user exits the editor,
 control returns to the filer.  Any new files created by the editor
 will be displayed in the filer window.
6 Move
 MOVE allows the user to move the current file to another directory. 
 The user is asked to move the cursor to the new host directory
 using the arrow keys.  When either RETURN or ENTER is hit the file
 is moved.  The operation may be aborted at any time by hitting any
 key besides the arrow keys, RETURN, or ENTER.
6 Print
 PRINT causes the current file to be sent to the printer defined by
 SWING$PRINT.  SWING looks for translations in the following tables,
 in the following order: LNM$PROCESS, LNM$JOB, and LNM$SYSTEM.  If
 this logical name is not defined, the default is $PRINT.
6 Rename
 RENAME prompts the user for a new name to be given to the current
 file.  The display will reflect the change and keep the files
 listed in alphabetical order.
6 Option
 This command allows for expansion of the filer.  Available options
 are listed in the pulldown menu and a selection is made by using
 the arrow keys to highlight the desired option then hitting RETURN.
7 DCL Command
 This option allows the user to execute any DCL at the prompt.
 SWING WILL NOT reflect changes made to the directory struc-
 ture by these commands.  This option is non-interactive and
 should not be used for commands that do not return to the DCL
 prompt after completion.  The output is printed in the DCL
 Command window and reverse scrolling is not possible.

 WARNING: THIS OPTION IS PRONE TO RANDOM BUGS.  THE OUTPUT MAY
 NOT MATCH THE OUTPUT SEEN AT COMMAND LEVEL.  THIS OPTION MAY
 ALSO CAUSE SWING TO HANG.  THIS CAN BE OVERCOME WITH A CTRL-Y
 BUT THE SUBPROCESS 'SWING_DCL_PROC' MUST BE STOPPED FOR
 FURTHER USE OF SWING.
6 Quit
 QUIT causes the filer to be stored and returns control to SWING.  The keys
 Q, control-Z and ENTER quit the filer.
3 Exit
 EXIT causes the SWING to exit to the currently selected subdirectory or 
 directory.  The keys E, X, CONTROL-Z and ENTER exit SWING.
$*$*EOD*$*$
$ checksum SWING.HLP
$ if checksum$checksum .ne. check_sum then -
$   write sys$output "Checksum failed, file probably corrupted"
$ exit