From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX"  7-JUN-1989 03:15
To:	MRGATE::"ARISIA::EVERHART"
Subj:	MAINT -- Full Screen File/Directory Maintenance (Part 2 of 11)

Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Tue,  6 JUN 89 14:31:27 PDT
Received: from ucbvax.Berkeley.EDU by KL.SRI.COM with TCP; Tue, 6 Jun 89 14:21:45 PDT
Received: by ucbvax.Berkeley.EDU (5.61/1.36)
	id AA28409; Tue, 6 Jun 89 14:02:43 -0700
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 6 Jun 89 20:23:48 GMT
From: peirce@gumby.wisc.edu  (Leonard J. Peirce)
Organization: Western Michigan University, Kalamazoo, MI
Subject: MAINT -- Full Screen File/Directory Maintenance (Part 2 of 11)
Message-Id: <737@gumby.cc.wmich.edu>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

+-+-+-+ Beginning of part 2 +-+-+-+
X    */
V/*                                                                       `032
X    */
V/****************************************************************************
X**/
X
X#include "maint.h"`009`009`009/* our very own header file`009      */
X
X#ifdef WMUACC`009`009`009`009/* we have these in a .TLB`009      */
X
X#include itmlst`009`009`009`009/* for item list definition`009      */
X#include utype`009`009`009`009/* unsigned data type header`009      */
X#include clidef`009`009`009`009/* for more CLI$ stuff`009`009      */
X#include string`009`009`009`009/* string function header`009      */
X
X#else`009`009`009`009`009/* look in current directory...`009      */
X`009`009`009`009`009/* ...for everyone else`009`009      */
X#include "itmlst.h"
X#include "utype.h"
X#include "clidef.h"
X
X#endif
X
X#include rms`009`009`009`009/* RMS header; includes all others    */
X#include descrip`009`009`009/* for descriptors`009`009      */
X#include lnmdef`009`009`009`009/* for translating logical names      */
X#include ssdef`009`009`009`009/* SYS$ return code symbolics`009      */
X#include stdio`009`009`009`009/* who knows?`009(NULL maybe?)`009      */
X#include smgdef`009`009`009`009/* SMG$ stuff`009`009`009      */
X#include climsgdef`009`009`009/* for CLI$ routines`009`009      */
X#include ctype`009`009`009`009/* character-type header`009      */
X#include limits`009`009`009`009/* scalar data type limits`009      */
X
V/****************************************************************************
X**/
V/*                                                                       `032
X    */
V/*                             # D E F I N E S                           `032
X    */
V/*                                                                       `032
X    */
V/****************************************************************************
X**/
X
X#define SYSDISK_MAX 256`009`009`009/* max. length of SYS$DISK holder     */
X#define MAX_DIR 15`009`009`009/* max. # of subdirectories to save   */
X
V/****************************************************************************
X**/
V/*                                                                       `032
X    */
V/*          S T R U C T U R E S ,   U N I O N S ,   T Y P E D E F S      `032
X    */
V/*                                                                       `032
X    */
V/****************************************************************************
X**/
X
V/****************************************************************************
X**/
V/*                                                                       `032
X    */
V/*   E X T E R N A L   D E F I N I T I O N S   &   D E C L A R A T I O N S
X    */
V/*                                                                       `032
X    */
V/****************************************************************************
X**/
X
Xextern`009 ULONG`009  LBR$OUTPUT_HELP(),
X`009`009  LIB$FREE_VM(),
X`009`009  LIB$GET_INPUT(),
X`009 `009  LIB$GET_VM(),
X`009`009  LIB$PUT_OUTPUT(),
X`009`009  SMG$CHANGE_PBD_CHARACTERISTICS(),
X`009`009  SMG$CREATE_PASTEBOARD(),
X`009`009  SMG$CREATE_VIRTUAL_DISPLAY(),
X`009`009  SMG$CREATE_VIRTUAL_KEYBOARD(),
X`009`009  SMG$DISABLE_BROADCAST_TRAPPING(),
X`009`009  SMG$ERASE_DISPLAY(),
X`009`009  SMG$GET_BROADCAST_MESSAGE(),
X`009`009  SMG$PASTE_VIRTUAL_DISPLAY(),
X`009`009  SMG$PUT_CHARS(),
X`009`009  SMG$READ_STRING(),
X`009`009  SMG$REPAINT_SCREEN(),
X`009`009  SMG$RING_BELL(),
X`009`009  SMG$SET_BROADCAST_TRAPPING(),
X`009`009  SMG$SET_CURSOR_ABS(),
X`009`009  SMG$SET_OUT_OF_BAND_ASTS(),
X`009`009  SYS$CLOSE(),
X`009`009  SYS$CONNECT(),
X`009`009  SYS$GET(),
X`009`009  SYS$OPEN(),
X`009`009  SYS$PARSE(),
X`009`009  SYS$SETDDIR();
X
Vextern`009 POOL_DEF *new_pool();`009`009/* initialize a new memory pool`009
X      */
X
Vextern`009 char`009  *mystrcpy(),`009`009/* string copy returning pointer`032
X     */
X`009`009  *get_pool_mem(),`009/* get pointer to a memory slot`009      */
X`009`009  *nullptr;`009`009/* pointer to a null string`009      */
X
Xextern`009 ULONG`009  push(),`009`009/* spawn a subprocess`009`009      */
X`009`009  get_string(),`009`009/* prompt and read string from tty    */
X`009`009  edit_acl();`009`009/* edit an ACL for a file`009      */
X
Vextern`009 int`009  strindex(),`009`009/* search for substring of a string
X   */
X`009`009  cat(),`009`009/* concatenate multiple strings`009      */
X`009`009  sleep(),`009`009/* C version of LIB$WAIT()`009      */
X`009`009  strdel();`009`009/* delete characters from a string    */
X
Vextern`009 short`009  get_num_file(),`009/* get number of files in a director
Xy */
X`009`009  expand(),`009`009/* display attributes of a file`009      */
X`009`009  create_text(),`009/* attempt to create text desc. file  */
X`009`009  mark_delete(), `009/* set file to be deleted`009      */
X`009`009  mark_copy_ren(),`009/* set file to be copied/renamed      */
X`009`009  mark_protect(),`009/* set file to be reprotected`009      */
X`009`009  mark_text(),`009`009/* set file's text descriptor`009      */
X`009`009  make_slot(),`009`009/* create a screen slot for a file    */
X`009`009  get_scr_num(),`009/* let user specify new screen number */
X`009`009  prot_val_to_str();`009/* create protection string`009      */
X
Vextern`009 void`009  get_device(),`009`009/* get terminal name for debugging
X    */
X`009`009  info_mess(),`009`009/* write informational message`009      */
X`009`009  curr_dir(),`009`009/* get current directory spec`009      */
X`009`009  init_pool(),`009`009/* initialize memory pool nodes`009      */
X`009`009  reset_pool(),`009`009/* setup pools to reuse memory`009      */
X`009`009  put_pool(),`009`009/* copy a string to the memory pools  */
X`009`009  highlite(),`009`009/* highlight a file slot if necessary */
X`009`009  free_pool(),`009`009/* free memory pools for a directory  */
X `009`009  clear_mess(),`009`009/* clear an information message`009      */
X`009`009  mark_cancel(),`009/* cancel commands for a file entry   */
X`009`009  set_direct(),`009`009/* change to command-line directory   */
X`009`009  tag_file(),`009`009/* "tag" current file on screen`009      */
X`009`009  set_sysdisk(),`009/* set SYS$DISK logical`009`009      */
X`009`009  set_width(),`009`009/* set scr_width variable correctly   */
X`009`009  erase_tag(),`009`009/* erase file tag`009`009      */
X`009`009  xmess(),`009`009/* display messages while eXecuting   */
X`009`009  set_args(),`009`009/* set run-time args and other stuff  */
X`009`009  free_com(),`009`009/* free command structures`009      */
X`009`009  put_text(),`009`009/* put directory text descrip on scr. */
X`009`009  xecute();`009`009/* execute file commands`009      */
X
V/****************************************************************************
X**/
V/*                                                                       `032
X    */
V/*     S T A T I C   D E F I N I T I O N S   &   D E C L A R A T I O N S `032
X    */
V/*                                                                       `032
X    */
V/****************************************************************************
X**/
X
Xstatic`009 ENT_DEF  *baseptr;`009`009/* pointer to base of memory for a    */
X`009`009`009`009`009/* directory; used for sorting`009      */
X
Vstatic`009 char`009  *text_match(),`009/* look for text descriptor record`032
X   */
X`009`009  *text_search();`009/* search directory entries for match */
X
Vstatic`009 long`009  *global_row,`009`009/* pointer to where screen row is
X     */
X`009`009  *global_col;`009`009/* pointer to where screen col is     */
X
Xstatic`009 ULONG`009  paste_id,`009`009/* pasteboard id`009`009      */
X`009`009  disp1_id,`009`009/* directory info virtual display id  */
X`009`009  disp2_id,`009`009/* main virtual display id`009      */
X`009`009  disp3_id,`009`009/* options virtual display id`009      */
X`009`009  disp4_id,`009`009/* select file virtual display id     */
X`009`009  keybd_id,`009`009/* virtual keyboard id`009`009      */
X`009`009  make_ent(),`009`009/* create directory entry`009      */
X`009`009  ctrl_ast(),`009`009/* called for control-C & control-Y   */
X`009`009  put_help(),`009`009/* write to display during help`009      */
X`009`009  get_help();`009`009/* read from display during help      */
X
Vstatic`009 USHORT`009  check_marks();`009/* check for commands in a directory
X  */
X
Xstatic`009 short`009  scr_width,`009`009/* page width`009`009`009      */
X`009`009  def_slot_wid,`009`009/* default slot width`009`009      */
X`009`009  ent_factor,`009`009/* ent. size memory allocation factor */
X`009`009  proc_dir(),`009`009/* process current directory`009      */
X`009`009  mail_note,`009`009/* set if mail notification on screen */
X`009`009  phone_note,`009`009/*  "   " phone     "        "   "    */
X`009`009  state,`009`009/* state variable for put_help()      */
X`009`009  get_text_des(),`009/* read in text descrips for direct.  */
X`009`009  time_cmp(),`009`009/* compare to quadword time values    */
X`009`009  file_select(),`009/* process a Selected file`009      */
X`009`009  file_locate(),`009/* prompt for/locate a file`009      */
X`009`009  file_search();`009/* search directory for file`009      */
X
Vstatic`009 char`009  dir_name[NAM$C_MAXRSS+1], /* current directory`009  `032
X   */
X`009`009  user_dir[NAM$C_MAXRSS+1], /* user's original directory      */
X`009`009  start_spec[SPEC_MAX+1]; /* starting file specification      */
X
Xstatic`009 ARG_DEF  args;`009`009`009/* run-time argument flags`009      */
X
Xstatic`009 NODE_DEF nodes[MAX_NODE_ROW+1][MAX_NODE_COL+1];
X
Vstatic`009 void`009  get_dir_mem(),`009/* allocate memory for directory info
X */
X`009 `009  get_dir(),`009`009/* get information about directory    */
X`009`009  set_nodes(),`009`009/* initialize screen node matrix      */
X`009`009  screen_reset(),`009/* reset cursor/screen info`009      */
X`009`009  get_args(),`009`009/* process command-line arguments     */
X`009`009  set_screen(),`009`009/* set up screen display parameters   */
X`009`009  set_name(),`009`009/* create displayed filename`009      */
X`009`009  put_stat(),`009`009/* write directory statistics line    */
X`009`009  put_spec(),`009`009/* write directory spec/page # info   */
X`009`009  put_pagnum(),`009`009/* write "Page of" stuff in top-right */
X`009     `009  brdcast_ast(),`009/* broadcast message AST routine      */
X`009`009  name_qsort(),`009`009/* quicksort directory by filename    */
X`009`009  date_qsort(),`009`009/* quicksort directory by date`009      */
X`009 `009  make_screen(),`009/* put file info on screen`009      */
X`009`009  initialize(),`009`009/* initial screen & virtual displays  */
X`009`009  get_sysdisk(),`009/* get value of SYS$DISK at startup   */
X`009`009  size_qsort(),`009`009/* quicksort by file size`009      */
X`009`009  swap_entries(),`009/* swap to file entries (for sorting) */
X`009`009  put_options();`009/* write options to display`009      */
X
X#ifdef EXTERNAL_HLB
Xstatic $DESCRIPTOR(helplib_d,"SYS$HELP:MAINT.HLB");
X#else
Xstatic $DESCRIPTOR(helplib_d,"SYS$HELP:HELPLIB.HLB");
X#endif
X/*eject*/        `032
V/****************************************************************************
X**/
V/*                                                                       `032
X    */
V/*                        M A I N   P R O C E S S I N G                  `032
X    */
V/*                                                                       `032
X    */
V/****************************************************************************
X**/
X
Xmain()
X
X`123`009/*** main ***/
X`009`009`009`009`009/********   LOCAL  VARIABLES   ********/
Xstatic`009 ULONG`009  status;`009`009/* return code status holder`009      */
Vstatic`009 short`009  retval;`009`009/* return code from proc_dir()`009  `032
X   */
Vstatic`009 char`009  out_device[DEV_MAX+1], /* output device name`009`009`032
X     */
X`009`009  in_device[DEV_MAX+1],`009/* input device name`009`009      */
X`009`009  sysdisk[SYSDISK_MAX+1], /* for saving SYS$DISK value`009      */
X`009`009  dev_spec[DEV_MAX+1],`009/* device specified on command line   */
X`009`009  dir_spec[DEV_MAX+1];`009/* directory from command line`009      */
Vstatic $DESCRIPTOR(out_d,out_device);`009/* output device descriptor`009 `032
X    */
Vstatic $DESCRIPTOR(inp_d,in_device);`009/* input device descriptor`009      *
X/
X
X
V   get_device(&out_d,&inp_d);`009`009/* set up the I/O device stuff`009  `032
X   */
X
X   /* get the value of SYS$DISK when the program was entered */
X
X   get_sysdisk(sysdisk,SYSDISK_MAX);
X                        `032
X   /* check the command-line arguments and set up 1) the screen width and 2)
X    * the slot width
X    */
X
X   get_args(&helplib_d,&args,&scr_width);
X
X   /* initialize some global factors, such as the ent_factor and default
X    * slot width
X    */
X
X   set_args(&args,&def_slot_wid,&ent_factor,scr_width);
X
X   /* see if a directory was specified on the command line and get the
X    * directory that the user was in when the program was invoked; this
X    * is needed to go back to where the user was when the program was
X    * invoked
X    */
X
X   set_direct(start_spec,dir_spec,dev_spec,user_dir);
X   curr_dir(dir_name);
X
X   /* initialize 1) the pasteboard, 2) all of the virtual displays that will
X    * be needed, and 3) the virtual keyboard for input purposes
X    */
X
X   initialize(&paste_id,&keybd_id,&disp1_id,&disp2_id,&disp3_id,&disp4_id,
X`009      &inp_d,&out_d,&scr_width);
X
X   /* go for it -- process the directories and any thing else that the
X    * user might desire
X    */
X
X   do
X   `123
X
X      retval = proc_dir();
X   `125
X   while(retval == RECALL_PROC);
X
X   if(dev_spec[0])`009`009`009/* if we changed SYS$DISK...`009      */
X      set_sysdisk(sysdisk);`009`009/* ..... set it back`009`009      */
X
X   /* make sure the default directory is reset before exiting...... */
X
X   out_d.dsc$a_pointer = user_dir;
X   out_d.dsc$w_length = (USHORT) strlen(user_dir);
X
X   status = SYS$SETDDIR(&out_d,0,0);
X
X   if(status != RMS$_NORMAL)
X      LIB$STOP(status);
X
X   exit();`009`009`009`009/* NOW we can exit.....`009`009      */
X
X`125`009/*** main ***/
X/*eject*/
V/****************************************************************************
X***
V*****************************************************************************
X***
X
X  Function:`009proc_dir
X
X  Purpose:`009Process the current directory.  This includes allocating memory
X`009`009for storing the information about the files and handling all
X`009`009of the user responses.  This routine is recursive and is called
X`009`009each time the user "selects" a new directory; the current dir-
X`009`009ectory is switched and this routine is called again.  When the
X`009`009user exits a directory, this routine frees up the memory that
X`009`009was allocated for the directory and returns.  The cursor is
X`009`009left pointing to the directory that was just exited.
X
X`009`009This is a *RECURSIVE* function.
X
X  Global variables:
X
X`009Name`009`009`009Examine/Modify/Use/Read/Write
X`009----`009`009`009-----------------------------
X`009paste_id`009`009`009`009X
X`009keybd_id`009`009`009`009X
X`009disp1_id`009`009`009`009X
X`009disp2_id`009`009`009`009X
X`009disp3_id`009`009`009`009X
X`009disp4_id`009`009`009`009X
X`009nodes`009`009`009`009  X     X
X`009scr_width`009`009`009`009X
X`009dir_name`009`009`009  X`009X
X`009args`009`009`009   X`009`009X
X`009phone_note`009`009`009  X`009X
X`009mail_note`009`009`009  X`009X
X`009user_dir`009`009`009`009X
X`009ent_factor`009`009`009`009X
X`009def_slot_wid`009`009`009  X`009X
X`009start_spec`009`009`009`009X
X`009global_row`009`009`009  X
X`009global_col`009`009`009  X
X
X  Return Codes:
X
X`009Code`009`009`009Reason
X`009----`009`009`009------
X   `009  0`009`009`009return normally
X`009RECALL_PROC`009`009return and force this procedure to be recalled
X`009`009`009`009immediately
X`009EMPTY_DIR`009`009the directory entry selected to get us here is
X`009`009`009`009empty
X
V*****************************************************************************
X***
V*****************************************************************************
X**/
X
Xstatic short proc_dir()
X
X`123  `009/*** proc_dir ***/
X`009`009`009`009`009/*********   LOCAL VARIABLES   ********/
Xregister ULONG`009  status;`009`009/* return code status`009`009      */
Xregister short`009  node_col,`009`009/* current node array column`009      */
X`009 `009  node_row;`009`009/* current node array row`009      */
X`009 ENT_DEF  *dirptr,`009`009/* pointer to directory information   */
X`009`009  *entptr;`009`009/* pointer to directory entry`009      */
X`009 POOL_DEF *first_pool,`009`009/* pointer to first memory pool`009      */
X`009`009  *curr_pool;`009`009/* pointer to current memory pool     */
X`009 char`009  *dir_text= NULL; `009/* pointer to directory text descrip  */
X`009 long`009  scr_col,`009`009/* current screen column`009      */
X`009     `009  scr_row,`009`009/* current screen row`009`009      */
X`009`009  dirsize,`009`009/* size of directory info memory      */
X`009`009  pool_length,`009`009/* length for allocating new pools    */
X`009`009  num_block = 0L;`009/* number of blocks in directory      */
X`009 short`009  num_col,`009`009/* number of columns for full screen  */
X`009`009  slot_width,`009`009/* slot width for current directory   */
X`009`009  num_row,`009`009/* number of rows for full screen     */
X`009`009  max_num_file,`009`009/* max. # of files found in directory */
V`009     `009  num_file = 0,`009`009/* number of files in directory`009  `032
X   */
X`009     `009  curr_screen = 1,`009/* current screen of directory`009      */
X`009     `009  num_screen = 0,`009/* number of screens in directory     */
X`009       `009  scr_file,`009`009/* number of files for current screen */
X`009     `009  num_slot,`009`009/* number of slots per screen`009      */
X`009     `009  dir_length,`009`009/* length of current directory string */
X`009 `009  text_flag = 0;`009/* text descrip file processed flag   */
X`009`009`009`009`009/** above vars MUST remain automatic **/
Xstatic`009 char`009  *tptr;`009`009/* temporary character pointer`009      */
Vstatic`009 ULONG`009  rend_set;`009`009/* rendition setting for slots`009`032
X     */
Xstatic`009 long`009  temp_wid,  `009`009/* temporary screen width`009      */
X`009`009  end_col,`009`009/* end column for erasing things      */
X`009`009  mask;`009`009`009/* out-of-band AST flag bit mask      */
Vstatic`009 USHORT`009  term_code;`009`009/* code for keystroke`009`009      *
X/
Xstatic`009 short`009  temp,`009`009`009/* temporary value`009`009      */
X`009`009  temp2,`009`009/* temporary value #2`009`009      */
X`009`009  save_width,`009`009/* temporary slot width holder`009      */
X`009`009  new_screen,`009`009/* new screen when locating files     */
X`009`009  level;`009`009/* what recursion level we are at     */
Vstatic`009 UCHAR `009  mess_flag,`009`009/* set if information mess on screen
X  */
X`009     `009  cursor_flag,`009`009/* set if cursor needs to be set      */
X`009`009  exec_flag;`009`009/* set if we just executed commands   */
Vstatic`009 char`009  slot_buf[BUFSIZ],`009/* for formatting screen slots`009
X      */
X`009`009  help_buf[BUF_MAX+1],`009/* buffer sent to LBR$OUTPUT_HELP     */
X`009`009  response[RESP_MAX+1],`009/* response from screen`009`009      */
X`009`009  in_buf[BUF_MAX+1];`009/* input buffer for various stuff     */
Xstatic`009 struct`009  dsc$descriptor`032
X`009`009  mess_d;`009`009/* screen message descriptor`009      */
Vstatic`009 DIR_SUMM dirmem[MAX_DIR];`009/* summary info for all directories
X   */
Vstatic $DESCRIPTOR(confirm_d,in_buf);`009/* for asking user's confirmation
X     */
Vstatic $DESCRIPTOR(help_line,help_buf);`009/* for LBR$OUTPUT_HELP's sake`009
X      */
Vstatic`009 char`009  auth_str[] =`009`009/* take some credit for this thing
X    */
V`123"Author of MAINT is Leonard J. Peirce at Western Michigan University ACC"
X`125,
X`009`009  version_str[] =`009/* what version number this is`009      */
X`123"MAINT V1.5 (Western Michigan University Academic Computer Center)"`125,
X`009`009  cmd_prompt[] =`009/* prompt for PUSHing command`009      */
X`123"DCL Command: "`125;
X
X
X   phone_note = 0;`009`009`009/* clear these everytime we enter a   */
X   mail_note = 0;`009`009`009/* directory`009`009`009      */
X   cursor_flag = 0;
X   slot_width = def_slot_wid;`009`009/* initialize the slot width`009      */
X
X   /* save the addresses of the screen row and column so that the cursor
X    * can be reset inside of the AST routine that notifies the user in the
X    * event of mail; otherwise, the cursor will just stay at the bottom of
X    * the screen until the user presses a key
X    */
X
X   global_row = &scr_row;
X   global_col = &scr_col;
X
V   dir_length = (short) strlen(dir_name); /* get number of chars in dir name
X  */
X   num_row = MAX_NODE_ROW;`009`009/* set number of rows for now`009      */
V   num_file = get_num_file(start_spec);`009/* get number of files in director
Xy   */
X
X   if(num_file == 0)`009`009`009/* is the directory empty?`009      */
X      return(EMPTY_DIR);`009`009/* yup.........`009`009`009      */
X
X   /* this is the max. number of files we have found in this directory    */
X
X   max_num_file = num_file;
X
V   /* allocate the memory to hold the directory information */           `032
X    `032
X
X   get_dir_mem(&dirptr,&dirsize,num_file);
X
X   /* initialize the memory pools for holding the full filenames of the
X    * files in the directory
X    */
X
X   pool_length = (long) ((num_file + 1) * ent_factor);
X   init_pool(&first_pool,pool_length);
X   curr_pool = first_pool;`009`009/* set current pool pointer`009      */
X                                        `032
X   /* get all of the information about the files in the directory */
X            `032
X   get_dir(dirptr,&args,&num_block,&curr_pool,&num_file,start_spec,
X`009   pool_length,dir_length);
X
X   /* were there any files to get?  there might not be, depending on the
X    * volatility of the directory and file protections
X    */
X
X   if(num_file == 0)
X   `123
X      free_pool(first_pool);`009`009/* free up the memory pools first     */
X
X      /* now free up the memory for the directory information */
X
X      status = LIB$FREE_VM(&dirsize,&dirptr);
X
X      if(status != SS$_NORMAL)
X`009 LIB$STOP(status);
X
X      return(EMPTY_DIR);
X   `125
X
X   if(args.text)
X   `123
X      /* yes, read in the text descriptors */
X
X      text_flag = args.text;`009`009/* set descrip flag for this direct.  */
X
X      if(args.text == DISPLAY_TEXT && !args.text_startup)
X`009 slot_width += TEXT_MAX + 1;`009/* assume we will get text descrips   */
X
X      temp = get_text_des(dirptr,&curr_pool,&dir_text,pool_length,num_file);
X
V      /* check to see if there were any problems getting the text descriptors
X */
X
X      if(temp == BAD_FILE)
X      `123
X`009 info_mess(disp2_id,"Invalid format for text descriptor file",
X`009`009   scr_width);
X`009 mess_flag++;
X`009 text_flag = 0;`009`009`009/* no text descrips for directory     */
V`009 if(args.text == DISPLAY_TEXT)`009/* only update slot_width if needed   *
X/
X`009    slot_width = slot_width - (TEXT_MAX + 1);
X`009 sleep(1);
X      `125
X      else if(temp == CANT_OPEN)
X      `123
X`009 info_mess(disp2_id,"Cannot open text descriptor file",scr_width);
X`009 mess_flag++;
X`009 text_flag = 0;`009`009`009/* no text descrips for directory     */
V`009 if(args.text == DISPLAY_TEXT)`009/* only update slot_width if needed   *
X/
X`009    slot_width = slot_width - (TEXT_MAX + 1);
X`009 sleep(1);
X      `125
X      else if(temp == NO_FILE)
X      `123
X`009 text_flag = 0;`009`009`009/* no text descrips for directory     */
V`009 if(args.text == DISPLAY_TEXT)`009/* update slot_width if it needs it   *
X/
X`009   slot_width = slot_width - (TEXT_MAX + 1);
X      `125
X   `125
X
V   dirmem[level].ptr = dirptr;`009`009/* save a pointer to this memory      *
X/
X   dirmem[level].num_file = num_file;
X
X   /* count this recursion level; when it equals one, it means that we are in
X    * the top-level directory for this session
X    */
X
X   level++;
X
X   /* all of the information about the files in the directory has been
X    * obtained; now initialize the screen parameters, including the screen
X    * nodes and the number of screens for the directory
X    */
X
V   set_screen(&num_screen,&scr_file,num_file,curr_screen,scr_width,slot_width
X,
X`009      &num_col,nodes);
X
X   num_slot = scr_file;`009`009`009/* save number of slots per screen    */
X
X   /* initialize the screen slot node pointers for the screen */
X
X   set_nodes(nodes,&scr_file,num_screen,curr_screen,num_file,slot_width,
X`009     num_col);
X
X   /* write the directory statistics line at the bottom of the display
X    * and the directory spec/page number line at the top of the display
X    */
X
X   put_spec(disp1_id,dir_name,num_screen,scr_width);
X   put_stat(disp3_id,num_block,num_file,scr_width);
X
X   if(args.text)`009`009`009/* write text descrip for directory?  */
X      put_text(disp1_id,dir_text,scr_width);
X
X   /* clear the main virtual display; we do this every time we enter a
X    * directory to make things simple; some directories might have text
X    * descriptors and some might not; this way, we make sure that we have
X    * a clean display to work with, no matter what
X    */
X
X   status = SMG$ERASE_DISPLAY(&disp2_id);
X
X   if(status != SS$_NORMAL)
X      LIB$STOP(status);
X
V   /* put the information about the files for the first screen on the screen
X */
X            `032
X   make_screen(nodes,dirptr,&args,disp2_id,curr_screen,num_file,scr_file,
X`009       num_slot,slot_width,text_flag);
X
X   /* position the cursor to the first file in the directory */
X
X   node_row = 0;`009`009`009/* start in top left of nodes array   */
X   node_col = 0;
V   scr_row = (long) nodes[0][0].row;`009/* start in top left of screen, too
X   */
X   scr_col = (long) nodes[0][0].column;
X
X   /* set the cursor position */
X
X   status = SMG$SET_CURSOR_ABS(&disp2_id,&scr_row,&scr_col);
X
X   if(status != SS$_NORMAL)
X      LIB$STOP(status);
X
X   /* this is the main processing loop for the whole program; each keystroke
X    * is read and appropriate action is taken for each; this is an infinite
X    * loop and the only way out is to break out from the middle and return
X    * to a previous invocation of this function
X    */
X
X   for(;;)   `009`009`009`009/* loop forever.........`009      */
X   `123
X      /* get a keystroke from the keyboard */
X
X      status = SMG$READ_KEYSTROKE(&keybd_id,&term_code,0,0,&disp2_id,0,0);
X
X      if(status != SS$_NORMAL)
X      `123
X`009 /* treat SMG$ read errors like Quits so we can quit gracefully */
X
X`009 term_code = SMG$K_TRM_UPPERCASE_Q;
X      `125
X
X      if(mess_flag)`009`009`009/* was a message on the screen?`009      */
X      `123
X`009 clear_mess(disp2_id,scr_width);  /* clear the message`009`009      */
X`009 mess_flag = 0;`009`009`009/* clear the message flag`009      */
X
X`009 /* reset the cursor to where it should be */
X
X`009 status = SMG$SET_CURSOR_ABS(&disp2_id,&scr_row,&scr_col);
X
X`009 if(status != SS$_NORMAL)
X`009    LIB$STOP(status);
X      `125
X
X      /* now look at the key that was pressed and take appropriate action */
X
X      switch(term_code)
X      `123
X`009 case(SMG$K_TRM_RIGHT):`009`009/**************************************/
X`009 case(SMG$K_TRM_HT):`009`009/*             right-arrow`009      */
X`009 case(SMG$K_TRM_SPACE):`009`009/**************************************/
X`009 case(SMG$K_TRM_GREATER_THAN):
X`009 case(SMG$K_TRM_CTRLL):
X
X`009    /* update the pointer to the screen and then update the position
X`009     * of the physical cursor; we must use temp to get the up_row
X`009     * position and then assign it to node_row because we can't have
X`009     * node_row changing before we use it to get node_col
X`009     */
X
X`009    temp = (short) nodes[node_row][node_col].right_row;
X`009    node_col = (short) nodes[node_row][node_col].right_col;
X`009    node_row = temp;
X`009    scr_row = (long) nodes[node_row][node_col].row;
X`009    scr_col = (long) nodes[node_row][node_col].column;
X
X`009    cursor_flag++;`009`009/* reset the cursor down below`009      */
X
X`009    break;
X
X`009 case(SMG$K_TRM_LEFT):`009`009/**************************************/
X`009 case(SMG$K_TRM_LESS_THAN):`009/*             left-arrow`009      */
X`009 case(SMG$K_TRM_BS):`009`009/**************************************/
X
X`009    /* update the pointer to the screen and then update the position
X`009     * of the physical cursor; we must use temp to get the up_row
X`009     * position and then assign it to node_row because we can't have
X`009     * node_row changing before we use it to get node_col
X`009     */
X
X`009    temp =  (short) nodes[node_row][node_col].left_row;
X`009    node_col = (short) nodes[node_row][node_col].left_col;
X`009    node_row = temp;
X`009    scr_row = (long) nodes[node_row][node_col].row;
X`009    scr_col = (long) nodes[node_row][node_col].column;
X
X`009    cursor_flag++;`009`009/* reset the cursor down below`009      */
X
X`009    break;
X
X`009 case(SMG$K_TRM_DOWN):`009`009/**************************************/
X`009 case(SMG$K_TRM_LF):`009`009/*             down-arrow`009      */
X`009`009`009`009`009/**************************************/
X
X`009    /* update the pointer to the screen and then update the position
X`009     * of the physical cursor; we must use temp to get the up_row
X`009     * position and then assign it to node_row because we can't have
X`009     * node_row changing before we use it to get node_col
X`009     */
X
X`009    temp = (short) nodes[node_row][node_col].down_row;
X`009    node_col = (short) nodes[node_row][node_col].down_col;
X`009    node_row = temp;
X`009    scr_row = (long) nodes[node_row][node_col].row;
X`009    scr_col = (long) nodes[node_row][node_col].column;
X
X`009    cursor_flag++;`009`009/* reset the cursor down below`009      */
X
X`009    break;
X
X`009 case(SMG$K_TRM_UP):`009`009/**************************************/
X`009 case(SMG$K_TRM_CARET):`009`009/*              up-arrow`009      */
X`009 case(SMG$K_TRM_CTRLK):`009`009/**************************************/
X
X`009    /* update the pointer to the screen and then update the position
X`009     * of the physical cursor; we must use temp to get the up_row
X`009     * position and then assign it to node_row because we can't have
X`009     * node_row changing before we use it to get node_col
X`009     */
X
X`009    temp = (short) nodes[node_row][node_col].up_row;
X`009    node_col = (short) nodes[node_row][node_col].up_col;
X`009    node_row = temp;
X`009    scr_row = (long) nodes[node_row][node_col].row;
X`009    scr_col = (long) nodes[node_row][node_col].column;
X
X`009    cursor_flag++;`009`009/* reset the cursor down below`009      */
X
X`009    break;
X
X`009 case(SMG$K_TRM_CR):`009`009/**************************************/
X`009 case(SMG$K_TRM_ENTER):`009`009/*          carriage return`009      */
X`009`009`009`009`009/**************************************/
X
X`009    /* go to left of screen and down one row on the screen */
X
X`009    node_row = nodes[node_row][0].down_row;
X`009    node_col = 0;
X`009    scr_row = nodes[node_row][node_col].row;
X`009    scr_col = nodes[node_row][node_col].column;
X
X`009    cursor_flag++;`009`009/* reset the cursor down below`009      */
X
X`009    break;
X
X`009 case(SMG$K_TRM_EQUAL):`009`009/**************************************/
X`009 case(SMG$K_TRM_NEXT_SCREEN):`009/*            plus-screen`009      */
V`009 case(SMG$K_TRM_ASTERISK + 1):`009/**************************************
X/
X`009 case(SMG$K_TRM_CTRLF):
X
X`009    if(num_screen > 1)`009`009/* more than one screen?`009      */
X`009    `123
X`009       curr_screen++;`009`009/* go to next screen`009`009      */
X`009       if(curr_screen > num_screen)
X`009`009  curr_screen = 1;`009/* oops, I meant the first screen     */
X
X`009       if((curr_screen == 1) `124`124 (curr_screen == num_screen))
X`009       `123
X`009`009  set_nodes(nodes,&scr_file,num_screen,curr_screen,num_file,
X`009`009`009    slot_width,num_col);`032
X`009       `125
X
X`009       /* update the page number in the corner */
X
X`009       put_pagnum(disp1_id,curr_screen,num_screen,scr_width);
X
X`009       /* write the files to the screen */
X
X`009       make_screen(nodes,dirptr,&args,disp2_id,curr_screen,num_file,
X`009`009`009   scr_file,num_slot,slot_width,text_flag);
X
X`009       /* reset screen and node pointers */
X
X`009       node_row = 0;
X`009       node_col = 0;
X`009       scr_row = (long) nodes[0][0].row;
X`009       scr_col = (long) nodes[0][0].column;
X
X`009       /* home the cursor */
X
X`009       cursor_flag++;`009`009/* reset the cursor down below`009      */
X`009    `125
X
X`009    break;
X
X`009 case(SMG$K_TRM_MINUS):`009`009/**************************************/
X`009 case(SMG$K_TRM_UNDERLINE):`009/*            minus-screen`009      */
X`009 case(SMG$K_TRM_PREV_SCREEN):`009/**************************************/
X`009 case(SMG$K_TRM_DASH):
X`009 case(SMG$K_TRM_CTRLB):
X                          `032
X`009    /* reset the screen nodes if we have to */
X
X`009    if(num_screen > 1)
X`009    `123
X`009       curr_screen--;`009`009/* go to previous screen `009      */
V`009       if(curr_screen == 0)`009/* were we on the first screen?`009      *
X/
X`009`009  curr_screen = num_screen; /* oops, go to last screen`009      */
X
X`009       if(curr_screen >= (num_screen-1))
X`009       `123
X`009     `009  set_nodes(nodes,&scr_file,num_screen,curr_screen,num_file,
X`009`009`009    slot_width,num_col);`032
X`009       `125
X
X`009       /* update the page number in the corner */
X
X`009       put_pagnum(disp1_id,curr_screen,num_screen,scr_width);
X
X`009       /* write the files to the screen */
X
X`009       make_screen(nodes,dirptr,&args,disp2_id,curr_screen,num_file,
X`009`009`009   scr_file,num_slot,slot_width,text_flag);
X
X`009       /* reset screen and node pointers */
X
X`009       node_row = 0;
X`009       node_col = 0;                        `032
X`009       scr_row = (long) nodes[0][0].row;
X`009       scr_col = (long) nodes[0][0].column;
X
X`009       /* home the cursor */
X
X`009       cursor_flag++;`009`009/* reset the cursor down below`009      */
X`009    `125
X
X`009    break;
X
X`009 case(SMG$K_TRM_LOWERCASE_L):`009/**************************************/
X`009 case(SMG$K_TRM_UPPERCASE_L):`009/*            Locate-file`009      */
X`009 case(SMG$K_TRM_FIND):`009`009/**************************************/
X
X`009    /* user wants to search for a filename; go for it */
X
X`009    temp = file_locate(dirptr,disp2_id,keybd_id,num_file,scr_width);
X
X`009    if(temp >= 0)
X`009    `123
X`009       /* file was found; recompute the node indexes so that we
X`009`009* can change the cursor on the screen
X`009`009*/
X
X`009       new_screen = (temp / num_slot) + 1;
X
X`009       /* get us to the current screen */
X
X`009       temp2 = temp - ((new_screen - 1) * num_slot);
X`009       node_col = temp2 / num_row;
X`009       node_row = temp % num_row;
X
X`009       /* do we need to go to a new screen?  if so, make the new
X`009`009* one now
X`009`009*/
X
X`009       if(new_screen != curr_screen)
X`009       `123
X`009`009  /* create the new screen by first putting the new page
X`009`009   * number in the upper-right and then rebuilding the
X`009`009   * main display
X`009`009   */
X
X`009       `009  /* do we need to update the screen node pointers? */
X
X`009`009  if((new_screen == num_screen) `124`124
X`009`009     (curr_screen == num_screen))
X`009`009  `123
X`009`009     /* set the nodes */
X                                                     `032
X`009`009     set_nodes(nodes,&scr_file,num_screen,new_screen,
X`009`009`009       num_file,slot_width,num_col);
X`009`009  `125
X
X`009`009  curr_screen = new_screen;
X
X  `009`009  /* put the new page number on the screen */
X
X`009`009  put_pagnum(disp1_id,curr_screen,num_screen,scr_width);
X
X`009`009  /* build the display for the new screen */
X
X`009`009  make_screen(nodes,dirptr,&args,disp2_id,curr_screen,num_file,
X`009`009`009      scr_file,num_slot,slot_width,text_flag);
X`009       `125
X
X`009       /* make the cursor point to the file that was found */
X
X`009       scr_row = nodes[node_row][node_col].row;
X`009       scr_col = nodes[node_row][node_col].column;
X`009    `125
X`009    else if(temp == -1)
X`009    `123
X`009       /* no file found; just put up a message and that's it */
X
X`009       info_mess(disp2_id,"File not found\7",scr_width);
X`009       mess_flag++;
X`009    `125
X
X`009    /* set the cursor where it is supposed to be, whether on the
X`009     * file that was found or the file that it was on when the
X`009     * failed search request was initiated
X`009     */
X
X`009    cursor_flag++;`009`009/* reset the cursor down below`009      */
X
X`009    break;
X
X`009 case(SMG$K_TRM_LOWERCASE_U):`009/**************************************/
X`009 case(SMG$K_TRM_UPPERCASE_U):`009/*              Unmark`009`009      */
X`009`009`009`009  `009/**************************************/
X
X`009    /* first get the entry pointer for the file selected */
X                     `032
X`009    entptr = dirptr + ((curr_screen - 1) * (num_row * num_col)) +
X`009`009     (node_col * num_row) + node_row;
X
X`009    /* now cancel all commands for the file entry and free up the
X`009     * command structure that was allocated for it
X`009     */
X
X`009    mark_cancel(entptr);
X
X`009    /* remake the slot so it can be written */
X
X`009    temp = make_slot(slot_buf,entptr,&args,slot_width,text_flag);
X`009    mess_d.dsc$a_pointer = slot_buf;
X`009    mess_d.dsc$w_length = (USHORT) strlen(slot_buf);
X
X`009    /* now write the file information to the screen in the right spot */
X
X`009    rend_set = SMG$M_NORMAL;
X`009    scr_col++;`009`009`009/* don't write in cursoring spot      */
X
X`009    status = SMG$PUT_CHARS(&disp2_id,&mess_d,&scr_row,&scr_col,0,
X`009`009`009`009   &rend_set,0,0);
X                  `032
X`009    scr_col--;`009`009`009/* reset to where it should be`009      */
X
X`009    if(status != SS$_NORMAL)
X`009       LIB$STOP(status);
X
X`009    /* move to the next logical file on the screen; basically, we are
X`009     * just performing the same stuff we do for a down-arrow
X`009     */
X
X`009    temp = (short) nodes[node_row][node_col].down_row;
X`009    node_col = (short) nodes[node_row][node_col].down_col;
X`009    node_row = temp;
X`009    scr_row = (long) nodes[node_row][node_col].row;
X`009    scr_col = (long) nodes[node_row][node_col].column;
X
X`009    cursor_flag++;`009`009/* reset the cursor, too`009      */
X
X`009    break;
X
X`009 case(SMG$K_TRM_LOWERCASE_S):`009/**************************************/
X`009 case(SMG$K_TRM_UPPERCASE_S):`009/*            Select-file`009      */
X`009 case(SMG$K_TRM_SELECT):`009/**************************************/
X
X`009    /* first get the entry pointer for the file selected */
X                     `032
X`009    entptr = dirptr + ((curr_screen - 1) * (num_row * num_col)) +
X`009`009     (node_col * num_row) + node_row;
X
X`009    /* now see if the file selected was a directory or just a file */
X
X`009    temp = strindex(entptr->filename,".DIR;");
X
X`009    if(temp > 0)
X`009    `123
X`009       /* it was a directory; temporarily lop off everything
X`009`009* after the filename so that we may treat just the filename
X`009`009* as a string
X`009`009*/
X
X`009       entptr->filename[temp] = '\0';
X
X`009       /* find out where we are to put in the period and the
X`009`009* new filename in the directory name
X`009`009*/
X
X`009       tptr = dir_name + (ULONG) dir_length - 1L;
X
X`009       /* now insert the stuff in the right place to create the
X`009`009* NEW and IMPROVED directory name
X`009`009*/
X
X`009       cat(tptr,".",entptr->filename,"]");
X`009       entptr->filename[temp] = '.';`009/* reset the filename`009      */
X`009       exec_flag = 0;`009`009/* must reset to keep things straight */
X
X`009       /* now we have the new directory name; change to this
X`009`009* directory and do a recursive call to ourselves
X`009`009*/
X
X`009       mess_d.dsc$a_pointer = dir_name;
X`009       mess_d.dsc$w_length = (USHORT) strlen(dir_name);
X
X`009       status = SYS$SETDDIR(&mess_d,0,0);
X
X`009       if(status != RMS$_NORMAL)
X`009       `123
X`009`009  /* problems changing to directory; scream at the user
X`009`009   * and get out of here
X`009`009   */
X
X`009`009  info_mess(disp2_id,"Cannot change to selected directory\7",
X`009`009`009    scr_width);
X`009       `009  mess_flag++;`009`009/* set the info message flag`009      */
X
X`009`009  /* reset the cursor */
X
X`009`009  cursor_flag++;`009/* reset the cursor down below`009      */
X
X`009`009  break;
X`009       `125
X
X`009       /* now call ourselves and start over with the new directory */
X
X`009       /***********************************
X`009        *   R E C U R S I V E   C A L L   *
X`009        ***********************************/
X
X`009       do
X`009       `123
X`009`009  temp = proc_dir();
X`009       `125
X`009       while(temp == RECALL_PROC);
X
X`009       global_row = &scr_row;`009/* reset for the current directory    */
X`009       global_col = &scr_col;
X
X`009       /* first reset the directory name the way it was */
X
X`009       tptr = strchr(dir_name,']'); /* find the end of the directory  */
X
X`009       while(*tptr != '.')`009/* find start of last level of name   */
X`009`009  tptr--;
X
X`009       strcpy(tptr,"]");`009/* cut off the last level`009      */
X
X`009       /* change back to the directory that we should be in */
X
X`009       mess_d.dsc$a_pointer = dir_name;
X`009       mess_d.dsc$w_length = (USHORT) strlen(dir_name);
X
X`009       status = SYS$SETDDIR(&mess_d,0,0);
X
X`009       if(status != RMS$_NORMAL)
X`009       `123
X`009`009  /* problems changing to directory; scream at the user
X`009`009   * and get out of here
X`009`009   */
X
X`009`009   info_mess(disp2_id,
X`009`009`009     "Cannot reset directory.....exiting...\7",
X`009`009`009     scr_width);
X`009`009   sleep(2);
X`009`009   LIB$STOP(status);
X`009       `125
X
X `009       if(temp == EMPTY_DIR)`009/* did the user make a good choice?   */
X`009       `123
X`009`009  /* the directory that was selected was empty */
X
X`009`009  info_mess(disp2_id,
X`009`009`009    "Directory is empty........... \7",scr_width);
X`009`009  if(exec_flag)
X`009`009  `123
X`009`009     sleep(2);`009`009/* only pause if we just executed     */
X`009`009     clear_mess(disp2_id,scr_width);
X`009`009  `125
X`009`009  else
X`009`009     mess_flag++;`009/* clear it on next keystroke`009      */
X`009       `125
X
X`009       /* reset some things on the screen since we are actually
X`009`009* returning from a directory
X`009`009*/
X                       `032
X`009       if((args.text) && (!text_flag) && temp != EMPTY_DIR)
X`009       `123
X`009`009  /* when we left this directory to go down, the
X`009`009   * text descriptors were not included (at least not
X`009`009   * not on the screen, anyway); when we were in
X`009`009   * one of the descendant directories, the text
X`009`009   * descriptors were selected; we must read them
X`009`009   * in here; first, update the slot width on the
X`009`009   * assumption that we can get the text descriptors
X`009`009   * for the current directory without any trouble and
X`009`009   * set the flag that signifies that we have text
X`009`009   * descriptors read in for the current directory
X`009`009   */
X
X`009`009  if(args.text == DISPLAY_TEXT)`009/* room to display descrips?  */
X`009`009     slot_width += TEXT_MAX + 1; /* yes, assume we get them   */
X
X`009`009  text_flag = args.text;
X
X`009`009  /* erase the display to make sure we don't have any
X`009`009   * garbage left over if we need to reformat the screen
X`009`009   */
X
X`009`009  status = SMG$ERASE_DISPLAY(&disp2_id);
X
X`009`009  if(status != SS$_NORMAL)
X`009`009     LIB$STOP(status);
X
X`009`009  temp = get_text_des(dirptr,&curr_pool,&dir_text,pool_length,
X`009`009`009`009      num_file);
X
X`009`009  if(temp == BAD_FILE)
X`009`009  `123
X`009`009     info_mess(disp2_id,
X`009`009`009       "Invalid format for text descriptor file\7",
X`009`009`009       scr_width);
X`009`009     mess_flag++;
X`009`009     text_flag = 0;
X`009`009     if(args.text == DISPLAY_TEXT)
X`009`009        slot_width = slot_width - (TEXT_MAX + 1);
X`009`009     sleep(1);
X`009`009  `125
X`009`009  else if(temp == CANT_OPEN)
X`009`009  `123
X`009`009     info_mess(disp2_id,"Cannot open text descriptor file\7",
X`009`009`009       scr_width);
X`009`009     mess_flag++;
X`009`009     text_flag = 0;
X`009`009     if(args.text == DISPLAY_TEXT)
X`009`009        slot_width = slot_width - (TEXT_MAX + 1);
X`009`009     sleep(1);
X`009`009  `125
X`009`009  else if(temp == NO_FILE)
X`009`009  `123
X`009`009     text_flag = 0;
X`009`009     if(args.text == DISPLAY_TEXT)
X`009`009        slot_width = slot_width - (TEXT_MAX + 1);
X`009`009  `125
X`009`009  else if(temp == 0)
X`009`009  `123
X`009`009     /* reset the screen parameters, just in case they need
X`009`009      * to be changed to reflect text descriptors
X`009`009      */
X
X`009`009     set_screen(&num_screen,&scr_file,num_file,curr_screen,
X`009`009`009`009scr_width,slot_width,&num_col,nodes);
X`009`009     num_slot = scr_file;
X`009`009  `125
X               `125
X
X`009       if((temp == EMPTY_DIR && exec_flag) `124`124 temp != EMPTY_DIR)
X`009       `123
X`009`009  /* we just executed commands in a directory so we must
X`009`009   * rebuild stuff
X`009`009   */
X
X`009`009  set_nodes(nodes,&scr_file,num_screen,curr_screen,num_file,
X`009`009`009    slot_width,num_col);
X
X`009`009  /* rewrite all of the stuff local to this directory */
X
X`009`009  put_spec(disp1_id,dir_name,num_screen,scr_width);
X`009`009  put_stat(disp3_id,num_block,num_file,scr_width);
X
X`009`009  if(args.text) `009/* text descriptor to write?`009      */
X`009`009     put_text(disp1_id,dir_text,scr_width);
X
X`009`009  /* this is important; we have to look for the directory
X`009`009   * that we were on when the last Select was done and de-
X`009`009   * termine what page it is on; we might have to change the
X`009`009   * current page and everything just to put the cursor back
X`009`009   * in the right spot
X`009`009   */
X
X`009`009  screen_reset(nodes,dirptr,entptr,&node_row,&node_col,
X`009`009`009       &scr_file,&curr_screen,num_file,num_slot,
X`009`009`009       num_screen,slot_width,num_row,num_col);
X
X`009`009  /* put the new page number on the screen */
X
X`009`009  put_pagnum(disp1_id,curr_screen,num_screen,scr_width);
X
X`009`009  /* create and write the screen again for the current
X`009`009   * directory
X`009`009   */
X
X`009`009  make_screen(nodes,dirptr,&args,disp2_id,curr_screen,
X`009`009`009      num_file,scr_file,num_slot,slot_width,
X`009`009`009      text_flag);
X
X`009`009  exec_flag = 0;`009/* make sure to reset this`009      */
X
X`009`009  /* reset the screen row and column */
X
X`009`009  scr_row = nodes[node_row][node_col].row;
X`009`009  scr_col = nodes[node_row][node_col].column;
X`009       `125
X`009    `125
X`009    else
X`009    `123
X`009       /* this is a file; process it */
X
X`009       if(entptr->size != 0)
X`009       `123
X`009`009  /* the file is not empty; go ahead and try to look at it */
X
X`009`009  temp = file_select(entptr->filename,in_buf,disp4_id,paste_id,
X`009`009`009`009     keybd_id,scr_width);
X`009       `125
X`009       else
X`009          temp = EMPTY_FILE;`009/* file is empty`009`009      */
X
X`009       switch(temp)`009`009/* what happened with the file?`009      */
X`009       `123
X`009`009  case(CANT_OPEN):
X
X`009`009     info_mess(disp2_id,"Cannot open selected file\7",
X`009`009`009       scr_width);
X`009`009     mess_flag++;
X`009`009     break;
X
X`009`009  case(CANT_DISPLAY):
X
X`009`009     info_mess(disp2_id,"Cannot display selected file\7",
X`009`009`009       scr_width);
X`009`009     mess_flag++;
X`009`009     break;
X
X`009`009  case(EMPTY_FILE):
X
X`009`009     info_mess(disp2_id,"Selected file is empty\7",scr_width);
X`009`009     mess_flag++;
X`009`009     break;
X
X`009`009  default:                     `032
X`009`009     break;
X`009       `125
X`009    `125
X
X`009    exec_flag = 0;
X`009    cursor_flag++;`009`009/* reset the cursor down below`009      */
X`009    break;
X                       `032
X`009 case(SMG$K_TRM_LOWERCASE_X):`009/**************************************/
X`009 case(SMG$K_TRM_UPPERCASE_X):`009/*             eXecute`009`009      */
-+-+-+-+-+ End of part 2 +-+-+-+-+-

