/*Last Modified: 9-MAR-1992 14:51:25.06, By: MARK */
/* manager.c
*
* Part of the Internet Gopher program, copyright (C) 1991
* University of Minnesota Microcomputer Workstation and Networks Center
*/
#include "gopher.h"
#define MENULINE(x) (x)+3
/* If any gophers to display (screen can be blank), count the number
of pages. If there is a remainder greater than zero, add one page */
#define PAGECALC(x,y) (y) ? (x/y) + ((x%y)>0) : 1
#define MIN(x,y) ((x) <= (y) ? (x) : (y))
/*
** Draw the title on the top
*/
Draw_Banner()
{
int ret_status, row, col;
int rend = SMG$M_REVERSE;
int rend_comp = 0;
while (strlen(c) > COLS - 16) {
c = strchr(d, '/');
if (c == NULL) {
c = d;
break; /*** No more slashes ***/
}
d = c+1;
}
if (strlen(c) > COLS-16)
c[COLS-17] = '\0'; /*** Gack, strip off extra cruft **/
strncpy( out_string, "\0", 255 );
if (c != d) {
sprintf( out_string, " ..%s", c+1 );
ret_status = smg$put_chars( &DisplayId, &d_outstring );
}
else {
sprintf( out_string, " %s", c );
ret_status = smg$put_chars( &DisplayId, &d_outstring );
}
}
switch(gophers[iOffset].sFileType)
{
case A_DIRECTORY:
ret_status = smg$put_chars( &DisplayId, &d_slash );
break;
case A_CSO:
ret_status = smg$put_chars( &DisplayId, &d_cso );
break;
case A_TELNET:
ret_status = smg$put_chars( &DisplayId, &d_tel );
break;
case A_INDEX:
ret_status = smg$put_chars( &DisplayId, &d_question );
break;
case A_SOUND:
ret_status = smg$put_chars( &DisplayId, &d_speaker );
/** It's supposed to look like a speaker! **/
break;
case A_FILE:
ret_status = smg$put_chars( &DisplayId, &d_period );
break;
case A_EVENT:
ret_status = smg$put_chars( &DisplayId, &d_pound );
break;
}
}
}
/* scline - Screen line relocator.
* Returns the line resulting from choice */
int
scline(iMaxGophers, iOldGopher, iNewGopher, gophers, MenuTitle)
int iMaxGophers; /* Total number of gophers on all pages */
int iOldGopher; /* Which gopher previously displayed */
int iNewGopher; /* New gopher to be displayed */
GopherStruct *gophers;
char *MenuTitle;
{
int iPageLen, iLastPageLen; /* Length of normal, final pages */
int nMaxPages, nNewPage, nOldPage; /* Natural numbers */
int iOldLine, iNewLine; /* Screen locations */
int ret_status, row, col, rend;
char sPagenum[40];
/*
** This routine draws a numbered menu
** from an array of GopherStructs.
**
** It returns the number that the user selected, or it returns
** zero if the user decided to cancel.
**
*/
int GetMenu(numitems, items, MenuTitle, typedchar, incomingLine)
int numitems;
GopherStruct *items;
char *MenuTitle;
int *typedchar;
int incomingLine;
{
short int ch; /* Input character */
int iItem; /* Display line */
int ret_status, row, col, re