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

Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Tue,  6 JUN 89 14:30:57 PDT
Received: from ucbvax.Berkeley.EDU by KL.SRI.COM with TCP; Tue, 6 Jun 89 14:21:25 PDT
Received: by ucbvax.Berkeley.EDU (5.61/1.36)
	id AA28448; Tue, 6 Jun 89 14:03:17 -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:24:54 GMT
From: peirce@gumby.wisc.edu  (Leonard J. Peirce)
Organization: Western Michigan University, Kalamazoo, MI
Subject: MAINT -- Full Screen File/Directory Maintenance (Part 3 of 11)
Message-Id: <738@gumby.cc.wmich.edu>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

+-+-+-+ Beginning of part 3 +-+-+-+
X`009 case(SMG$K_TRM_DO):`009`009/**************************************/
X
X`009    if(args.confirm)`009`009/* should we ask to make sure?`009      */
X`009    `123
X`009       /* the user wants to be asked if they REALLY want to execute
X`009`009* the commands for the directory
X`009`009*/
X
X`009       info_mess(disp2_id,"REALLY eXecute commands? [N] ",scr_width);
X
X`009       /* get a keystroke from the keyboard */
X
X`009       status = SMG$READ_KEYSTROKE(&keybd_id,&term_code,0,0,&disp2_id,
X`009`009`009`009`009   0,0);
X
X`009       if(status == SMG$_EOF)
X`009`009  SYS$EXIT();`009`009/* just get out right now`009      */
X
X`009       if(status != SS$_NORMAL)
X`009`009  LIB$STOP(status);`009/* error if we get here.....`009      */
X
X`009       /* now look at what the keystroke is; if it is not Y or y,
X`009`009* then we DO NOT execute the commands for the directory
X`009        */
X
X`009       if((term_code != SMG$K_TRM_UPPERCASE_Y) &&
X`009`009  (term_code != SMG$K_TRM_LOWERCASE_Y))
X`009       `123
X`009`009  /* clear out the prompt message first and then set the
X`009`009   * flag to reset the cursor
X`009`009   */
X
X`009`009  clear_mess(disp2_id,scr_width);
X`009`009  cursor_flag++;`009/* reset the cursor`009`009      */
X`009`009  break;`009`009/* nope, don't do anything yet.....   */
X`009       `125
X`009    `125
X
X`009    /* execute the file commands for all of the files in the current
X`009     * directory; informational messages will appear for each action
X`009     * for each file
X`009     */
X
X`009    xecute(dirptr,&args,in_buf,dir_text,disp2_id,num_file,scr_width);
X`009    exec_flag++;`009`009/* set flag saying we just executed   */
X
X`009    /* just fall through here and do what we would normally do for
X`009     * a REBUILD command; no sense in putting the code in two places,
X`009     * now is there?
X`009     */
X
X`009 case(SMG$K_TRM_CTRLR):`009`009/**************************************/
X`009`009`009`009`009/*`009 rebuild the directory`009      */
X`009`009`009`009`009/**************************************/
X
X`009    /* tell the user we are doing something so they don't worry */
X
X`009    xmess(disp2_id,"Rebuilding directory information......");
X
X`009    /* decrement the recursion level before returning */
X
X`009    --level;
X
X`009    /* free up the memory pools first */
X
X`009    free_pool(first_pool);
X
X`009    /* now free up the memory for the directory information */
X
X`009    status = LIB$FREE_VM(&dirsize,&dirptr);
X
X`009    if(status != SS$_NORMAL)
X`009       LIB$STOP(status);
X
X`009    return(RECALL_PROC);`009/* force proc_dir() to be recalled    */
X`009    break;
X
X`009 case(SMG$K_TRM_LOWERCASE_H):`009/**************************************/
X`009 case(SMG$K_TRM_UPPERCASE_H):`009/*               Help`009`009      */
X`009 case(SMG$K_TRM_HELP):`009`009/**************************************/
X
X`009    state = 0;`009`009`009/* reset help internal static var     */
V`009    strcpy(help_buf,"MAINT ");`009/* initialize the help line buffer    *
X/
X
X`009    /* first ask for a topic to be sent to help */
X
X`009    status = get_string(keybd_id,disp2_id,RESP_MAX,response,
X`009`009`009`009"HELP Topic? ",scr_width);
X
X`009    if(status == SS$_NORMAL)
X`009    `123
X`009       if(response[0] != '\0')
X`009`009  strcat(help_buf,response);
X
X`009       status = SMG$PASTE_VIRTUAL_DISPLAY(&disp4_id,&paste_id,
X`009`009`009`009`009`009  &WORK_BASE_ROW,
X`009`009`009`009`009`009  &WORK_BASE_COL,0);
X
X`009       if(status != SS$_NORMAL)
X`009       `123
X`009`009  info_mess(disp2_id,"Error in on-line help\7",scr_width);
X`009`009  mess_flag++;
X`009`009  cursor_flag++;
X`009`009  break;
X`009       `125
X
X`009       /* start the help session */
X
X`009       help_line.dsc$w_length = (USHORT) strlen(help_buf);
X
X`009       status = LBR$OUTPUT_HELP(put_help,0,&help_line,&helplib_d,0,
X`009`009`009`009`009get_help);
X
X`009       if(status != SS$_NORMAL && status != RMS$_EOF)
X`009       `123
X`009`009  info_mess(disp2_id,"Error in on-line help\7",scr_width);
X`009`009  mess_flag++;
X`009`009  cursor_flag++;
X`009       `125
X
X`009       /* pop the work virtual display off the screen */
X
X`009       status = SMG$UNPASTE_VIRTUAL_DISPLAY(&disp4_id,&paste_id);
X
X`009       if(status != SS$_NORMAL)
X`009`009  LIB$STOP(status);
X
X`009       /* clear out the work virtual display before continuing */
X
X `009       SMG$ERASE_DISPLAY(&disp4_id);
X`009    `125
X`009    else if(status == SMG$_EOF)
X`009    `123
X`009       /* just repaint the screen here; the control-Z messes up the
X`009`009* screen sometimes
X
X`009       status = SMG$REPAINT_SCREEN(&paste_id);
X
X`009       if(status != SS$_NORMAL)
X`009`009  LIB$STOP(status);
X`009`009*/
X
X`009       clear_mess(disp2_id,scr_width);
X`009    `125
X
X`009    cursor_flag++;
X`009    break;
X
X`009 case(SMG$K_TRM_LOWERCASE_D):`009/**************************************/
X`009 case(SMG$K_TRM_UPPERCASE_D):`009/*              Delete`009`009      */
X`009 case(SMG$K_TRM_REMOVE):`009/**************************************/
X
X`009    /* first get the entry pointer for the file indicated */
X
X`009    entptr = dirptr + ((curr_screen - 1) * (num_row * num_col)) +
X`009`009     (node_col * num_row) + node_row;
X
X`009    mark_delete(entptr); `009/* mark file for deletion`009      */
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`009    slot_buf[slot_width] = '\0';
X
X`009    /* now write the file information to the screen in the right spot */
X
X`009    if(temp == 0)
X`009       rend_set = SMG$M_NORMAL;
X`009    else
X`009       rend_set = SMG$M_BOLD;
X
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
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`009    break;
X
X`009 case(SMG$K_TRM_LOWERCASE_P):`009/**************************************/
X`009 case(SMG$K_TRM_UPPERCASE_P):`009/*              Protect`009`009      */
X`009`009`009`009`009/**************************************/
X
X`009    /* first get the entry pointer for the file indicated */
X
X`009    entptr = dirptr + ((curr_screen - 1) * (num_row * num_col)) +
X`009`009     (node_col * num_row) + node_row;
X
X`009    /* tag the file on the screen */
X
X`009    tag_file(scr_row,scr_col,disp2_id);
X
X`009    /* get the new filename and mark the file to be renamed */
X
X`009    temp = mark_protect(entptr,disp2_id,keybd_id,scr_width);
X
X`009    if(temp != 0)`009`009/* wot happen?`009`009`009      */
X`009    `123
X`009       info_mess(disp2_id,"Invalid protection string\7",scr_width);
X`009       mess_flag++;
X`009    `125
X`009    else
X`009    `123
X`009       /* highlite the file slot */
X
X`009       highlite(disp2_id,slot_buf,entptr,&args,scr_row,scr_col+1,
X`009`009`009slot_width,text_flag);
X`009    `125
X
X`009    /* erase the file tag */
X
X`009    erase_tag(scr_row,scr_col,disp2_id);
X
X`009    /* reset the cursor to where it should be */
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_F):`009/**************************************/
X`009 case(SMG$K_TRM_UPPERCASE_F):`009/*              Finish`009`009      */
X`009`009`009`009`009/**************************************/
X
X
X`009    if(level == 1)`009`009/* are we at the top?`009`009      */
X`009    `123
X`009       /* beep and continue, ignoring the Finish command */
X
X`009       SMG$RING_BELL(&disp2_id,0);
X`009       break;`009`009`009/* yes, we can't go up any more       */
X`009    `125
X
X`009    /* check for marked files first; if some are marked, ask the user
X`009     * if Finishing is the right thing to do
X`009     */
X
X`009    if(check_marks(dirptr,num_file) == TRUE)
X`009    `123
X`009       info_mess(disp2_id,
X`009`009`009 "Some files are marked.  Finish anyway? [N] ",
X`009`009`009 scr_width);
X
X`009       /* get a keystroke from the keyboard */
X
X`009       status = SMG$READ_KEYSTROKE(&keybd_id,&term_code,0,0,&disp2_id,
X`009`009`009`009`009   0,0);
X
X`009       if(status == SMG$_EOF)
X`009`009  SYS$EXIT();`009`009/* just get out right now`009      */
X
X`009       if(status != SS$_NORMAL)
X`009`009  LIB$STOP(status);`009/* error if we get here.....`009      */
X
X`009       clear_mess(disp2_id,scr_width);
X`009       cursor_flag++;`009`009/* reset cursor`009`009`009      */
X
X`009       if(term_code != SMG$K_TRM_LOWERCASE_Y &&`032
X  `009`009  term_code != SMG$K_TRM_UPPERCASE_Y)
X`009`009  break;
X`009    `125
X
X`009    /* the user is finished with the current directory; free up the
X`009     * memory that was allocated for the directory and just return;
X`009     * whether we return to the mainline or to a previous call to
X  `009     * proc_dir() is no matter to us at this point
X`009     */
X
X`009    level--;`009`009`009/* decrement recursion level counter  */
X
X`009    /* free up the memory pools first */
X
X`009    free_pool(first_pool);
X
X`009    /* free up the memory for any command structures that might
X`009     * have been allocated
X`009     */
X
X`009    free_comm(dirptr,num_file);
X
X`009    /* now free up the memory for the directory information */
X
X`009    status = LIB$FREE_VM(&dirsize,&dirptr);
X
X`009    if(status != SS$_NORMAL)
X`009       LIB$STOP(status);
X
X`009    /* erase the main virtual display */
X
X`009    status = SMG$ERASE_DISPLAY(&disp2_id);
X
X`009    if(status != SS$_NORMAL)
X`009       LIB$STOP(status);
X
X`009    return(0);`009`009`009/* go back to where we were called    */
X
X`009    break;
X
X`009 case(SMG$K_TRM_LOWERCASE_E):`009/**************************************/
X`009 case(SMG$K_TRM_UPPERCASE_E):`009/*              Expand`009`009      */
X`009`009`009`009`009/**************************************/
X
X`009    /* first get the entry pointer for the file indicated */
X
X`009    entptr = dirptr + ((curr_screen - 1) * (num_row * num_col)) +
X`009`009     (node_col * num_row) + node_row;
X
X`009    /* display all of the information about the file on the screen */
X
X`009    temp = expand(entptr,&args,disp4_id,paste_id,keybd_id,scr_width);
X
X`009    if(temp != 0)
X`009    `123
X`009       info_mess(disp2_id,"Cannot expand on file\7",scr_width);
X`009       mess_flag++;
X`009    `125
X
X`009    cursor_flag++;`009`009/* reset the cursor`009`009      */
X
X`009    break;
X
X`009 case(SMG$K_TRM_LOWERCASE_R):`009/**************************************/
X`009 case(SMG$K_TRM_UPPERCASE_R):`009/*              Rename`009`009      */
X`009`009`009`009`009/**************************************/
X
X`009    /* first get the entry pointer for the file indicated */
X
X`009    entptr = dirptr + ((curr_screen - 1) * (num_row * num_col)) +
X`009`009     (node_col * num_row) + node_row;
X
X`009    /* tag the file on the screen */
X
X`009    tag_file(scr_row,scr_col,disp2_id);
X
X`009    /* get the new filename and mark the file to be renamed */
X
X`009    temp = mark_copy_ren(entptr,&curr_pool,disp2_id,keybd_id,
X`009`009`009`009 pool_length,scr_width,RENAME);
X
X`009    if(temp != 0)`009`009/* wot happen?`009`009`009      */
X`009    `123
X`009       info_mess(disp2_id,"Error in trying to rename file\7",scr_width);
X`009       mess_flag++;
X`009    `125
X`009    else
X`009    `123
X`009       /* highlite the file slot */
X
X`009       highlite(disp2_id,slot_buf,entptr,&args,scr_row,scr_col+1,
X`009`009`009slot_width,text_flag);
X`009    `125
X
X`009    /* erase the file tag */
X
X`009    erase_tag(scr_row,scr_col,disp2_id);
X
X`009    /* reset the cursor to where it should be */
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_C):`009/**************************************/
X`009 case(SMG$K_TRM_UPPERCASE_C):`009/*               Copy `009`009      */
X`009`009`009`009`009/**************************************/
X
X `009    /* first get the entry pointer for the file indicated */
X
X`009    entptr = dirptr + ((curr_screen - 1) * (num_row * num_col)) +
X`009`009     (node_col * num_row) + node_row;
X`032
X`009    /* tag the file on the screen */
X
X`009    tag_file(scr_row,scr_col,disp2_id);
X
X`009    /* get the new filename and mark the file to be copied */
X
X`009    temp = mark_copy_ren(entptr,&curr_pool,disp2_id,keybd_id,
X`009`009`009`009 pool_length,scr_width,COPY);
X
X`009    if(temp != 0)`009`009/* wot happen?`009`009`009      */
X`009    `123
X`009       info_mess(disp2_id,"Error in trying to copy file\7",scr_width);
X`009       mess_flag++;
X`009    `125
X`009    else
X`009    `123
X`009       /* highlite the file slot */
X
X`009       highlite(disp2_id,slot_buf,entptr,&args,scr_row,scr_col+1,
X`009`009`009slot_width,text_flag);
X`009    `125
X
X`009    /* erase the file tag */
X
X`009    erase_tag(scr_row,scr_col,disp2_id);
X
X`009    /* reset the cursor to where it should be */
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_T):`009/**************************************/
X`009 case(SMG$K_TRM_UPPERCASE_T):`009/*               Text`009`009      */
X`009`009`009`009`009/**************************************/
X
X `009    /* first save what file the cursor was pointing to */
X
X`009    entptr = dirptr + ((curr_screen - 1) * (num_row * num_col)) +
X`009`009     (node_col * num_row) + node_row;
X`032
X`009    save_width = slot_width;
X
X`009    if(!text_flag)
X`009    `123
X`009       /* were text descriptors already turned on? */
X
X`009       if(!args.text)
X`009       `123
X`009`009  /* now see what we need to set the text global run-time
X`009`009   * flag to (whether we should display text descriptors
X`009`009   * or not)
X`009`009   */
X
X`009`009  if((slot_width + TEXT_MAX + 1) <= scr_width)
X`009`009  `123
X`009`009     /* Good news!  The text descriptors will fit on the
X`009`009      * screen; update the current slot width but leave the
X`009`009      * global slot width alone
X`009`009      */                                `032
X
X`009`009     slot_width = slot_width + TEXT_MAX + 1;
X`009`009     args.text = DISPLAY_TEXT;
X`009`009  `125
X`009`009  else
X`009`009  `123
X`009`009     /* no, the text descriptors will not fit on the screen;
X`009`009      * but we want them read in from now on anyway
X`009`009      */
X
X`009`009     args.text = SLOT_OVF;
X`009`009  `125
X`009       `125
X
X`009       /* text descriptors have NOT been read in for the current dir-
X`009`009* ectory; first we must see if the text descriptor file exists;
X`009`009* if it is there, we will use it; if not, we will ask if they
X`009`009* want to create one
X`009`009*/
X
X`009       text_flag = args.text;
X
X`009       temp = get_text_des(dirptr,&curr_pool,&dir_text,pool_length,
X`009`009`009`009   num_file);
X
X`009       if(temp == NO_FILE)
X`009       `123
X`009`009  /* the text descriptor file does not exist; ask the user if
X`009`009   * it should be created
X`009`009   */
X
X`009       `009  temp = create_text(keybd_id,disp2_id,scr_width);
X`009       `125
X
X`009       switch(temp)`009`009/* what happened with the file?`009      */
X`009       `123
X`009`009  case(NEW_FILE):`009/* new text descriptor file?`009      */
X
X`009`009     /* ask the user if the commands should be executed
X`009`009      * before rebuilding things
X`009`009      */
X
X`009`009     info_mess(disp2_id,
X`009`009`009     "Commands will be wiped out.  eXecute them? [y] ",
X`009`009`009`009scr_width);
X
X`009`009     /* read the keystroke */
X
X`009`009     status = SMG$READ_KEYSTROKE(&keybd_id,&term_code,0,0,
X`009`009`009`009`009`009 &disp2_id,0,0);
X
X`009`009     if(status != SS$_NORMAL)
X`009`009        LIB$STOP(status);
X
X`009`009     clear_mess(disp2_id,scr_width);
X
X`009`009     if((term_code != SMG$K_TRM_LOWERCASE_N) &&
X`009`009        (term_code != SMG$K_TRM_UPPERCASE_N))
X`009`009     `123
X`009`009`009/* execute the stuff first */
X
X`009`009`009/* make sure we don't try to create a text descriptor
X`009`009`009 * file before eXecuting the commands
X`009`009`009 */                                `032
X
X`009`009`009xecute(dirptr,&args,in_buf,dir_text,disp2_id,num_file);
X`009`009     `125
X
X`009`009     /* free up the memory pools first */
X
X`009`009     free_pool(first_pool);
X
X`009`009     /* now free up the memory for the directory info */
X
X`009`009     status = LIB$FREE_VM(&dirsize,&dirptr);
X
X`009`009     if(status != SS$_NORMAL)
X`009`009        LIB$STOP(status);
X
X`009`009     --level;`009`009/* don't count this level anymore     */
X
X`009`009     /* return here and force the routine to be called
X`009`009      * again; this makes the function epilogue (don't
X`009`009      * you just love those programming language terms)
X`009`009      * do all of the work by allocating and initializing
X`009`009      * all of the automatic variables; this is a neat
X`009`009      * way to take advantage of the recursive structure
X`009`009      * we have set up for ourselves because all of the
X`009`009      * code to reinitialize a directory does not have
X`009`009      * to be duplicated
X`009`009      */
X
X`009`009     return(RECALL_PROC);
X
X`009`009  case(0):`009`009/* text descriptors read in ok?`009      */
X
X`009`009     /* the text descriptors were read in ok; now rebuild the
X`009`009      * nodes for the directory and remake the screen
X`009`009      */
X
X`009`009     text_flag = args.text;
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     set_nodes(nodes,&scr_file,num_screen,curr_screen,num_file,
X`009`009`009       slot_width,num_col);
X`009`009     put_spec(disp1_id,dir_name,num_screen,scr_width);
X`009`009     put_text(disp1_id,dir_text,scr_width);
X
X`009`009     /* we have to look for the file that was being point to
X`009`009      * when the Text command was done and determine what page
X`009`009      * it is on; we might have to change the current page and
X`009`009      * everything just to put the cursor back in the right spot
X`009`009      */
X
X`009`009     screen_reset(nodes,dirptr,entptr,&node_row,&node_col,
X`009`009`009`009  &scr_file,&curr_screen,num_file,num_slot,
X`009`009`009`009  num_screen,slot_width,num_row,num_col);
X
X`009`009     /* put the page number on the screen again, just in case
X`009`009      * it might have changed
X`009`009      */
X
X`009`009     put_pagnum(disp1_id,curr_screen,num_screen,scr_width);
X
X`009`009     /* clear the screen to make sure we don't have any
X`009`009      * any garbage left over when we put the text des-
X`009`009      * criptors on 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`009LIB$STOP(status);
X
X`009`009     /* remake the virtual display now that it is clear */
X
X`009`009     make_screen(nodes,dirptr,&args,disp2_id,curr_screen,
X`009`009`009`009 num_file,scr_file,num_slot,slot_width,
X`009`009`009`009 text_flag);
X
X`009`009     /* reset the screen cursor values */
X
X`009`009     scr_row = nodes[node_row][node_col].row;
X`009`009     scr_col = nodes[node_row][node_col].column;
X
X`009`009     /* make the sure pool length is set properly */
X
X`009`009     pool_length = (long) ((num_file + 1) * ent_factor);
X`009`009     cursor_flag++;`009/* reset the cursor`009`009      */
X`009`009     break;
X
X`009`009  case(BAD_FILE):
X
X`009`009     /* bad format for text descriptor file */
X
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
X`009`009     /* reset the slot width */
X
X`009`009     slot_width = save_width;
X`009`009     text_flag = 0;
X`009`009     mess_flag++;
X`009`009     break;
X
X`009`009  case(CANT_OPEN):
X
X`009`009     info_mess(disp2_id,"Cannot open text descriptor file\7",
X`009`009`009       scr_width);
X
X`009`009     /* reset the slot width */
X
X`009`009     slot_width = save_width;
X`009`009     text_flag = 0;
X`009`009     mess_flag++;
X`009`009     break;
X
X`009`009  case(DONT_CREATE):
X
X`009`009     /* reset the slot width */
X
X`009`009     slot_width = save_width;
X`009`009     text_flag = 0;
X`009`009     break;
X
X`009`009  default:
X
X`009`009     /* reset the slot width */
X
X`009`009     slot_width = save_width;
X`009`009     text_flag = 0;
X`009`009     break;
X`009       `125
X`009    `125
X`009    else
X`009    `123
X`009       /* the text descriptors have already been read in; get the
X`009`009* text descriptor for the selected file and store it in a
X`009`009* memory pool
X`009`009*/
X
X`009       /* first get the entry pointer for the file indicated */
X
X`009       entptr = dirptr + ((curr_screen - 1) * (num_row * num_col)) +
X`009`009`009(node_col * num_row) + node_row;
X
X`009       /* we only allow text descriptors to be specified for the
X`009`009* highest version of a file; the version numbers are not
X`009`009* stored in the text descriptor file itself so they really
X`009`009* don't matter; we just make sure that there is only one text
X`009`009* descriptor per filename right here to make things easier on
X`009`009* ourselves later
X`009`009*/
X
X`009       if(entptr != dirptr)
X`009       `123
X`009`009  /* this is NOT the first file in the directory, so we have
X`009`009   * to look at the previous filename in the directory to make
X`009`009   * sure that the one selected by the user is the highest
X`009`009   * version
X`009`009   */
X
X`009`009  temp = (short) strindex(entptr->filename,";");
X
X`009`009  if(strncmp(entptr->filename,(entptr-1)->filename,temp) == 0)
X`009`009  `123
X`009`009     /* we have a match; thus, we can't allow a text descriptor
X`009`009      * on this file
X`009`009      */
X
X`009`009     SMG$RING_BELL(&disp2_id,0);
X`009`009     break;`009`009/* get out of the switch statement    */
X`009`009  `125
X`009       `125
X
X`009       /* tag the file on the screen */
X
X`009       tag_file(scr_row,scr_col,disp2_id);
X
X`009       /* get the text descriptor and mark the file */
X
X`009       temp = mark_text(entptr,&curr_pool,disp2_id,keybd_id,pool_length,
X`009`009`009`009scr_width);
X
X`009       if(temp != 0)`009`009/* did everything go ok?`009      */
X`009       `123
X`009`009  info_mess(disp2_id,"Invalid text descriptor\7",scr_width);
X`009`009  mess_flag++;
X`009       `125
X`009       else
X`009       `123
X`009`009  /* highlite the file slot */
X
X`009`009  highlite(disp2_id,slot_buf,entptr,&args,scr_row,scr_col+1,
X`009`009`009   slot_width,text_flag);
X`009       `125
X
X`009       /* erase the file tag */
X
X`009       erase_tag(scr_row,scr_col,disp2_id);
X`009    `125
X
X`009    cursor_flag++;`009`009/* reset the cursor down below`009      */
X`009    break;
X
X`009 case(SMG$K_TRM_LOWERCASE_Q):`009/**************************************/
X`009 case(SMG$K_TRM_UPPERCASE_Q):`009/*               Quit`009`009      */
X`009 `009`009`009`009/**************************************/
X
X`009    /* check for marked files first; if some are marked, ask the user
X`009     * if Quitting is the right thing to do
X`009     */
X
X`009    for(temp = 0,status = FALSE; temp < level && status == FALSE;
X`009`009temp++)
X`009       status = check_marks(dirmem[temp].ptr,dirmem[temp].num_file);
X
X`009    if(status == TRUE)
X`009    `123
X`009       info_mess(disp2_id,
X`009`009`009 "Some files are marked.  Quit anyway? [N] ",
X`009`009`009 scr_width);
X
X`009       /* get a keystroke from the keyboard */
X
X`009       status = SMG$READ_KEYSTROKE(&keybd_id,&term_code,0,0,&disp2_id,
X`009`009`009`009`009   0,0);
X
X`009       if(status == SMG$_EOF)
X`009`009  SYS$EXIT();`009`009/* just get out right now`009      */
X
X`009       if(status != SS$_NORMAL)
X`009`009  LIB$STOP(status);`009/* error if we get here.....`009      */
X
X`009       clear_mess(disp2_id,scr_width);
X`009       cursor_flag++;`009`009/* reset cursor`009`009`009      */
X
X`009       if(term_code != SMG$K_TRM_LOWERCASE_Y &&`032
X  `009`009  term_code != SMG$K_TRM_UPPERCASE_Y)
X`009`009  break;
X
X`009    `125
X
X`009    status = SMG$DISABLE_BROADCAST_TRAPPING(&paste_id);
X            `032
X`009    if(status != SS$_NORMAL)
X`009       LIB$STOP(status);
X
X`009    /* change the default directory to where we should be now */
X
X`009    mess_d.dsc$a_pointer = user_dir;
X`009    mess_d.dsc$w_length = (USHORT) strlen(user_dir);
X
X`009    status = SYS$SETDDIR(&mess_d,0,0);
X
X`009    if(status != RMS$_NORMAL)
X`009       LIB$STOP(status);
X
X`009    exit();`009`009`009/* now we can exit`009`009      */
X
X`009    break;
X                                   `032
X`009 case(SMG$K_TRM_EXCLAMATION_POINT):
V  `009 case(SMG$K_TRM_DOLLAR_SIGN):`009/*************************************
X*/
X`009`009`009`009`009/*           DCL escape`009`009      */
X`009 `009`009`009`009/**************************************/
X
X`009    /* the user wants to suspend MAINT and execute just one command;
X`009     * prompt them for it and then just fall through and pretend we
X`009     * are doing a real `094Push command; the response string being
X`009     * non-NULL will cause the push() routine to execute LIB$SPAWN
X`009     * with a command string specified; a real `094Push command will
X`009     * have a NULL response string which cause a LIB$SPAWN to be
X`009     * called without a command to be executed
X`009     */
X
X`009    status = get_string(keybd_id,disp2_id,
X`009`009`009        scr_width-sizeof(cmd_prompt),response,
X`009`009`009        cmd_prompt,scr_width);
X
X`009    if(status == SMG$_EOF)
X`009    `123
X`009       cursor_flag++;`009`009/* reset the cursor`009`009      */
X`009       clear_mess(disp2_id,scr_width);
X`009       break;
X`009    `125
X`009    else if(status != SS$_NORMAL)
X`009    `123
X`009       info_mess(disp2_id,"Cannot read from display\7",scr_width);
X`009       mess_flag++;`009`009/* .... and clear it out later`009      */
X`009       cursor_flag++;`009`009/* reset the cursor down below`009      */
X`009       break;
X`009    `125
X
X`009    /* just fall through */
X
X`009 case(SMG$K_TRM_CTRLP):`009`009/**************************************/
X`009 case(SMG$K_TRM_INSERT_HERE):`009/*              `094Push`009`009      */
X`009 `009`009`009`009/**************************************/
X
X`009    /* first we have to disable BROADCAST_TRAPPING because LIB$SPAWN
X`009     * has fits if we don't
X`009     */
X
X`009    status = SMG$DISABLE_BROADCAST_TRAPPING(&paste_id);
X
X`009    if(status != SS$_NORMAL)
X`009       LIB$STOP(status);
X
X`009    /* shut off the trapping of control-C's and control-Y's so that
X`009     * they will worked in the spawned process
X`009     */
X
X`009    mask = 0L;
X`009    status = SMG$SET_OUT_OF_BAND_ASTS(&paste_id,&mask,ctrl_ast,0);
X
X`009    if(status != SS$_NORMAL)
X`009       LIB$STOP(status);
X
X`009    /* clear out a place to tell the user how to get back here */
X
X`009    temp_wid = (long) scr_width; /* get a long value for scr_width    */
X
X`009    status = SMG$ERASE_DISPLAY(&disp3_id,&2L,&1L,&2L,&temp_wid);
X
X`009    if(status != SS$_NORMAL)
X`009       LIB$STOP(status);
X
X`009    /* tell the user how to get back after they are done messing
X`009     * around...
X`009     */
X
X`009    if(!response[0])
X`009       printf("Type \"log\" to return to MAINT\n");
X
X`009    if(push(response) != SS$_NORMAL) /* push to a subprocess and wait */
X`009    `123
X`009       /* problems creating the subprocess; tell the user and
X`009`009* get out of here
X`009`009*/
X
X`009       info_mess(disp2_id,"Cannot create subprocess\7",scr_width);
X`009       mess_flag = 1;`009`009/* set the info mess flag`009      */
X`009       break;
X`009    `125
X
X`009    cursor_flag++;`009`009/* reset the cursor down below`009      */
X
X`009    if(response[0])
X`009    `123
X`009       /* ask for a return if returning from just a single command;
X`009`009* this pauses the screen just in case the user forgot to
X`009`009*/
X
X`009       printf("\nPress RETURN to return to MAINT: ");
X`009       getchar();
X`009    `125
X
X`009    /* now that we are back, turn on BROADCAST_TRAPPING again */
X
X`009    status = SMG$SET_BROADCAST_TRAPPING(&paste_id,brdcast_ast,0);
X
X`009    if(status != SS$_NORMAL)
X`009       LIB$STOP(status);
X
X`009    /* turn on the trapping of control-C's and control-Y's again */
X
V`009    mask = (1 << 0x3) `124 (1 <<0x19); /* trap control-C and control-Y
X   */
X`009    status = SMG$SET_OUT_OF_BAND_ASTS(&paste_id,&mask,ctrl_ast,0);
X
X`009    if(status != SS$_NORMAL)
X`009       LIB$STOP(status);
X
X`009    /* rewrite the options line because we trashed it on the way out */
X
X`009    put_options(disp3_id,scr_width);
X
X`009    /* repaint the screen so that things are the same as before */
X
X`009    status = SMG$REPAINT_SCREEN(&paste_id);
X
X`009    if(status != SS$_NORMAL)
X`009       LIB$STOP(status);
X
X`009    /* write the directory statistics line to clear out any messages
X`009     * from the AST routine that might be hanging around
X`009     */
X
X`009    put_stat(disp3_id,num_block,num_file,scr_width);
X
X`009    response[0] = '\0';`009`009/* clear this for next time through   */
X`009    break;
X
X`009 case(SMG$K_TRM_CTRLW):`009`009/**************************************/
X`009`009`009`009`009/*           repaint screen`009      */
X`009`009`009`009`009/**************************************/
X
V`009    if(mail_note `124`124 phone_note) /* need to clear a broadcast messag
Xe? */
X`009    `123
X`009       mail_note = 0;`009`009/* clear the notification flags`009      */
X`009       phone_note = 0;
X`009       put_stat(disp3_id,num_block,num_file,scr_width);
X`009    `125
X
X`009    status = SMG$REPAINT_SCREEN(&paste_id);
X
X`009    if(status != SS$_NORMAL)
X`009       LIB$STOP(status);
X
X`009    break;
X
X
X`009 case(SMG$K_TRM_LOWERCASE_G):`009/**************************************/
X`009 case(SMG$K_TRM_UPPERCASE_G):`009/*                Goto`009`009      */
X`009`009`009`009`009/**************************************/
X
X`009    /* ask for a new screen number */
X
X`009    temp = get_scr_num(disp2_id,keybd_id,curr_screen,num_screen,
X`009`009`009       scr_width);
X
V`009    if(temp == BAD_SCREEN_NO)`009/* was it a bad screen number?`009  `032
X   */
X`009    `123
X`009       info_mess(disp2_id,"\07Invalid page number",scr_width);
X`009       mess_flag++;
X`009    `125
X`009    else
X`009    `123
X`009       /* was the page number specified different from the
X`009`009* current one?  If not, don't do anything
X`009`009*/
X
X`009       if(curr_screen != temp)
X`009       `123
X`009`009  /* the page number specified was valid; set up the new page */
X
X`009`009  curr_screen = temp;`009/* store the new current screen`009      */
X
X`009`009  /* update the screen nodes array */
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  /* update the page number in the corner */
X
X`009`009  put_pagnum(disp1_id,curr_screen,num_screen,scr_width);
X
X`009`009  /* remake the screen to reflect the new screen specified */
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
X`009`009  /* reset the screen and node pointers */
X
X`009`009  node_row = 0;
X`009`009  node_col = 0;
X`009`009  scr_row = (long) nodes[0][0].row;
X`009`009  scr_col = (long) nodes[0][0].column;
X`009       `125
X`009    `125
X
X`009    cursor_flag++;`009`009/* set the cursor`009`009      */
X
X`009    break;
X
X`009 case(SMG$K_TRM_LOWERCASE_A):`009/**************************************/
X`009 case(SMG$K_TRM_UPPERCASE_A):`009/*               ACL`009`009      */
X`009`009`009`009`009/**************************************/
X
X`009    /* user wants to edit the ACL for the specified object; first
X`009     * get the entry pointer for the file indicated
X`009     */
X
X`009    entptr = dirptr + ((curr_screen - 1) * (num_row * num_col)) +
X`009`009     (node_col * num_row) + node_row;
X
X`009    status = edit_acl(entptr->filename);
X
X`009    if(status != TPU$_NORMAL)
X`009    `123
X`009       info_mess(disp2_id,"Error editing ACL\7",scr_width);
X`009       mess_flag++;`009`009/* .... and clear it out later`009      */
X`009       cursor_flag++;`009`009/* reset the cursor down below`009      */
X`009    `125
X
X`009    /* we need to repaint the screen after exiting the ACL editor */
X
X`009    status = SMG$REPAINT_SCREEN(&paste_id);
X
X`009    if(status != SS$_NORMAL)
X`009       LIB$STOP(status);
X
X`009    break;
X
X`009 case(SMG$K_TRM_LOWERCASE_W):`009/**************************************/
X`009 case(SMG$K_TRM_UPPERCASE_W):`009/*               Who`009`009      */
X`009     `009`009`009`009/**************************************/
X
X`009    /* tell the user who write this monstrosity..... */
X
X`009    info_mess(disp2_id,auth_str,scr_width);
X`009    mess_flag++;
X`009    cursor_flag++;
X`009    break;
X
X`009 case(SMG$K_TRM_LOWERCASE_V):`009/**************************************/
X`009 case(SMG$K_TRM_UPPERCASE_V):`009/*               Version              */
X`009     `009`009`009`009/**************************************/
X
X`009    /* tell the user what version this is.... */
X
X`009    info_mess(disp2_id,version_str,scr_width);
X`009    mess_flag++;
X`009    cursor_flag++;
X`009    break;
X
X`009 case(0):`009`009`009/**************************************/
X      `009`009`009`009`009/*        something weird  :-C`009      */
X`009`009`009`009`009/**************************************/
X`009    break;
X
X`009 default:`009`009`009/**************************************/
X`009`009`009`009`009/*            all others`009      */
X`009     `009`009`009`009/**************************************/
X`009    /* scream at the user */
X
X`009    status = SMG$RING_BELL(&disp2_id,0);
X`009    break;
X
X      `125 /* switch(term_code) */
X
X      /* do we need to set the position of the cursor? */
X
X      if(cursor_flag)
X      `123
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
X`009 cursor_flag = 0;`009`009/* clear the cursor set flag`009      */
X      `125
X
X   `125 /* for(;;) */`009`009`009/* end of main processing loop`009      */
X
X`125`009/*** proc_dir ***/
X/*eject*/
V/****************************************************************************
X***
V*****************************************************************************
X***
X
X  Function:`009initialize
X
X  Purpose:`009This routine initilalizes all of the SMG stuff that will be
X`009`009needed later.  This includes the pasteboard, virtual keyboard,
X`009`009and all of the virtual displays.
X
X`009`009This routines also sets the pasteboard to 132-column mode if
X`009`009it was specified on the command line with the /WIDE argument.
X
X  Global variables:
X
X`009Name`009`009`009Examine/Modify/Use/Read/Write
X`009----`009`009`009-----------------------------
X`009none
X
X  Return Codes:
X
X`009Code`009`009`009Reason
X`009----`009`009`009------
X`009none
X
X  Termination Codes:
X
X`009Code`009`009`009Reason
X`009----`009`009`009------
X`009status`009`009`009return code from various System Service calls `032
X
V*****************************************************************************
X***
V*****************************************************************************
X**/
X
Xstatic void initialize(paste_id,keybd_id,disp1_id,disp2_id,disp3_id,disp4_id,
X`009`009       inp_d,out_d,scr_width)
X`009`009`009`009`009/*******   FORMAL  PARAMETERS   *******/
X`009 ULONG`009  *paste_id,`009`009/* pasteboard id`009`009      */
X`009`009  *keybd_id,`009`009/* virtual keyboard 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     */
Xstruct`009 dsc$descriptor_s
X`009`009  *inp_d,`009`009/* input device`009`009`009      */
X`009`009  *out_d;`009`009/* output device`009`009      */
X`009 short`009  *scr_width;`009`009/* width of terminal screen`009      */
X                                       `032
X`123`009/*** initialize ***/
X`009`009`009`009`009/********   LOCAL  VARIABLES   ********/
Xregister ULONG`009  status;`009`009/* return code status`009`009      */
Vstatic`009 ULONG`009  rows,`009`009`009/* number of rows in pasteboard`009
X      */
X`009`009  columns,`009`009/* number of columns in pasteboard    */
X`009`009  video_attr,`009`009/* virtual display video attributes   */
X`009`009  rend_set,`009`009/* display rendition setting`009      */
X`009`009  rend_comp,`009`009/* display rendition complement`009      */
X`009`009  mask,`009`009`009/* AST-trap mask longword`009      */
X`009`009  mode;`009`009`009/* control mode options`009`009      */
Vstatic`009 long`009  start_row,`009`009/* start row for CHANGE_RENDITION `032
X   */
X`009`009  start_col,`009`009/* start col for CHANGE_RENDITION     */
X`009`009  num_row,`009`009/* temporary number of rows`009      */
X`009`009  num_col;`009`009/* temporary number of columns`009      */
X
X
X   /* create the pasteboard first */
X
X   status = SMG$CREATE_PASTEBOARD(paste_id,out_d,&rows,&columns,0);
X
X   if(status != SS$_NORMAL)
X      LIB$STOP(status);
X
X   if(*scr_width == 132)`009`009/* wide-mode specified?`009`009      */
X   `123
X      /* wants to be cute with wide mode, eh....?  we'll try but we aren't
X       * guaranteeing anything; it's up to the user to make sure that their
X       * terminal can handle it
X       */
X
V      status = SMG$CHANGE_PBD_CHARACTERISTICS(paste_id,&132,&columns,&24,&row
Xs);
X
X      if(status != SS$_NORMAL)
X`009 LIB$STOP(status);
X
X      if(columns != 132)
X`009 *scr_width = 80;`009`009/* reset screen width`009`009      */
X   `125
X
X   /* create the directory info line virtual display; this will be at the
V    * top of the screen and will contain 1) the name of the current directory
X,
X    * and 2) the page number of the current page of the directory along with
X    * the number of pages in the directory; the second line is reserved for
X    * the text descriptor for the directory
X    */
X
X   video_attr = SMG$M_NORMAL;`009`009/* normal video for this one`009      */
X   num_row = DIR_INFO_ROWS;`009`009/* set number of rows and colums      */
X   num_col = columns;
X
X   status = SMG$CREATE_VIRTUAL_DISPLAY(&num_row,&num_col,disp1_id,0,
X`009`009`009`009       &video_attr,0);
X
X   if(status != SS$_NORMAL)
X      LIB$STOP(status);
X
X   /* create the main virtual display which will eventually contain the in-
X    * formation about the files in the directory; normal video attributes
X    * for this display
X    */
X
X   num_row = MAIN_ROWS;`009`009`009/* set number of rows and columns     */
X   num_col = columns;
X
X   status = SMG$CREATE_VIRTUAL_DISPLAY(&num_row,&num_col,disp2_id,0,0,0);
X
X   if(status != SS$_NORMAL)
X      LIB$STOP(status);
X
X   /* create the workhorse virtual display; this display will be used for
X    * a number of different tasks, including Selecting a file and Xpanding
X    * a file
X    */
X
X   num_row = WORK_ROWS;`009`009`009/* set number of rows and columns     */
X   num_col = columns;
X
X   status = SMG$CREATE_VIRTUAL_DISPLAY(&num_row,&num_col,disp4_id,0,0,0);
X
X   if(status != SS$_NORMAL)
X      LIB$STOP(status);
X
X   /* now create the options virtual display; this will be at the bottom
X    * of the screen and will contain the directory statistics line that
X    * will have the number of files and blocks for the directory as well
X    * as a list of the options available to the user
X    */
X
X   num_row = OPT_INFO_ROWS;`009`009/* set number of rows and colums      */
X   num_col = columns;
X   video_attr = SMG$M_NORMAL;
X
V   status = SMG$CREATE_VIRTUAL_DISPLAY(&num_row,&num_col,disp3_id,0,&video_at
Xtr,
X`009`009`009`009       0);
X
X   if(status != SS$_NORMAL)
X      LIB$STOP(status);
X
X   /* put in the options line for the bottom display */
X
X   put_options(*disp3_id,*scr_width);
X
X   /* create the keyboard for the I/O device */
X  `032
X   status = SMG$CREATE_VIRTUAL_KEYBOARD(keybd_id,inp_d,0,0,0);
X
X   if(status != SS$_NORMAL)
X      LIB$STOP(status);
X
X   /* now paste the three main virtual displays to the pasteboard */
X
X   status = SMG$PASTE_VIRTUAL_DISPLAY(disp1_id,paste_id,&DIR_INFO_BASE_ROW,
X`009`009`009`009      &DIR_INFO_BASE_COL,0);
X
X   if(status != SS$_NORMAL)
X      LIB$STOP(status);
X
X   status = SMG$PASTE_VIRTUAL_DISPLAY(disp2_id,paste_id,&MAIN_BASE_ROW,
X`009`009`009`009      &MAIN_BASE_COL,0);
X
X   if(status != SS$_NORMAL)
X      LIB$STOP(status);
X
X   status = SMG$PASTE_VIRTUAL_DISPLAY(disp3_id,paste_id,&OPT_INFO_BASE_ROW,
X`009`009`009`009      &OPT_INFO_BASE_COL,0);
X
X   if(status != SS$_NORMAL)
X      LIB$STOP(status);
X
X   /* make sure 1) the screen is cleared when we exit, and 2) minimal update
X    * is enabled
X    */
X
X   mode = SMG$M_CLEAR_SCREEN `124 SMG$M_MINUPD;
X   status = SMG$CONTROL_MODE(paste_id,&mode,0);
X
X   if(status != SS$_NORMAL)
X      LIB$STOP(status);
X
V   /* trap control-C's and control-Y's so that when they are detected, will c
Xall
X    * a routine so that the program can continue as if nothing has happened
X    */
X
V   mask = (1 << 0x3) `124 (1 <<0x19);`009/* trap control-C and control-Y`009
X      */
X   status = SMG$SET_OUT_OF_BAND_ASTS(paste_id,&mask,ctrl_ast,0);
X
X   if(status != SS$_NORMAL)
X      LIB$STOP(status);
X
X   /* trap broadcast messages during execution; upon exit, this is turned
X    * off so that any broadcast messages that arrived during the run of the
X    * program are sent to the terminal
X    */
X
X   status = SMG$SET_BROADCAST_TRAPPING(paste_id,brdcast_ast,0);
X
X   if(status != SS$_NORMAL)
X      LIB$STOP(status);
X
X   return;
X
X`125`009/*** initialize ***/
X/*eject*/
V/****************************************************************************
X***
V*****************************************************************************
X***
X
X  Function:`009set_screen
X
X  Purpose:`009Compute values for parameters that relate to the screen,
X`009`009including number of columns, number of files, and the number
X`009`009of screens needed for the directory.
X
X  Global variables:
X
X`009Name`009`009`009Examine/Modify/Use/Read/Write
X`009----`009`009`009-----------------------------
X`009none
X
X  Return Codes:
X
X`009Code`009`009`009Reason
X`009----`009`009`009------
X`009none
X
X  Termination Codes:
X
X`009Code`009`009`009Reason
X`009----`009`009`009------
X`009none
X
V*****************************************************************************
X***
V*****************************************************************************
X**/
X
Xstatic void set_screen(num_screen,scr_file,num_file,curr_screen,scr_width,
X`009`009       slot_width,num_col,nodes)
X`009`009`009`009`009/*******   FORMAL  PARAMETERS   *******/
X`009 short`009  *num_screen,`009`009/* number of screens in directory     */
X`009`009  *scr_file,`009`009/* number of file slots per screen    */
X`009 `009  num_file,`009`009/* number of files in directory`009      */
X`009`009  curr_screen,`009`009/* current screen`009`009      */
X`009`009  scr_width,`009`009/* width of screen`009`009      */
X`009`009  slot_width,`009`009/* width of file slot`009`009      */
X`009`009  *num_col;`009`009/* number of columns for full screen  */
Xregister NODE_DEF nodes[][MAX_NODE_COL+1];
X
X`123`009/*** set_screen ***/
X
X
X   /* compute the number of files per row of the screen */
X
X   *num_col = scr_width/(slot_width + 1);
X
X   /* now compute how many file slots will fit on a screen */
X
X   *scr_file = *num_col * MAX_NODE_ROW;
X
X   /* compute how many screens will be needed for this directory */
X
X   *num_screen = num_file/(*scr_file);
X
X   if((num_file % (*scr_file)) != 0)
X      *num_screen += 1;
X
X   return;
X            `032
X`125`009/*** set_screen ***/
X/*eject*/
V/****************************************************************************
X***
V*****************************************************************************
X***
X
X  Function:`009set_nodes
X
X  Purpose:`009Initialize the screen slot node pointers for the current
X`009`009directory.
X
X  Global variables:
X
X`009Name`009`009`009Examine/Modify/Use/Read/Write
X`009----`009`009`009-----------------------------
X`009none
X
X  Return Codes:
X
X`009Code`009`009`009Reason
X`009----`009`009`009------
X`009none
X
X  Termination Codes:
X
X`009Code`009`009`009Reason
X`009----`009`009`009------
X`009none
X
V*****************************************************************************
X***
V*****************************************************************************
X**/
X
Vstatic void set_nodes(nodes,scr_file,num_screen,curr_screen,num_file,slot_wid
Xth,
X`009`009      num_col)
X`009`009`009`009`009/*******   FORMAL  PARAMETERS   *******/
Xregister NODE_DEF nodes[][MAX_NODE_COL+1]; /* screen node matrix`009      */
X`009 short`009  *scr_file,`009`009/* number of files on current screen  */
X`009 `009  num_screen,`009`009/* number of screens for directory    */
X`009`009  curr_screen,`009`009/* current screen`009`009      */
X`009`009  num_file,`009`009/* number of files in directory`009      */
X`009`009  slot_width,`009`009/* number of characters for file slot */
X`009`009  num_col;`009`009/* number of columns per screen`009      */
X
X`123`009/*** set_nodes ***/
X`009`009`009`009`009/********   LOCAL  VARIABLES   ********/
Xregister NODE_DEF *tptr;`009`009/* temporary node pointer`009      */
Xregister int`009  i,`009`009`009/* loop and array index`009`009      */
X     `009`009  j;`009`009`009/* ditto....`009`009`009      */
Vregister short`009  file_count;`009`009/* number of files processed`009  `032
X   */
Xstatic`009 short`009  left_val,`009`009/* left pointer for node`009      */
X`009`009  up_val,`009`009/* up pointer for node`009`009      */
X`009`009  column_val,`009`009/* current column value`009`009      */
X`009`009  row_val,`009`009/* current row value`009`009      */
X`009`009  num_row,`009`009/* number of rows for this screen     */
X`009`009  full_row,`009`009/* number of full rows for screen     */
X`009`009  full_col;`009`009/* number of full columns`009      */
X
X
X   if(curr_screen == num_screen)`009/* if this is the last page`009      */
X   `123
X      /* recompute the number of columns; it might be different because
X       * this is the last page of the directory
X       */
X
X      /* compute how many files will be on this screen of the directory */
X
X      *scr_file = num_file - (num_col * MAX_NODE_ROW * (curr_screen - 1));
X
X      /* now compute how many columns are needed for the last screen */
X
X      num_col = *scr_file / MAX_NODE_ROW;
X      if((*scr_file % MAX_NODE_ROW) != 0)
X`009 num_col++;
X   `125
X   else
X   `123
X      /* compute how many files will be on this screen of the directory */
X
X      *scr_file = num_col * MAX_NODE_ROW;
X   `125
X
V   if(*scr_file < MAX_NODE_ROW)`009`009/* determine number of rows`009      *
X/
X      num_row = *scr_file;
X   else
X      num_row = MAX_NODE_ROW;
X
X   left_val = num_col - 1;`009`009/* set left and right pointers`009      */
X   j = 0;`009`009`009`009/* start with the first column`009      */
X   column_val = 1;`009`009`009/* cursor on screen starts @ (1,1)    */
X   file_count = 0;
V   full_col = *scr_file / MAX_NODE_ROW; /* calculate number of full columns
X   */
X
X   if(full_col == 0)`009`009`009/* must have at least one full column */
X      full_col = 1;
X
X   full_row = *scr_file - (full_col * num_row);
X   if(full_row == 0)
-+-+-+-+-+ End of part 3 +-+-+-+-+-

