[net.sources] HELP file modification to "month" program

bauer@eta.UUCP (Jeff Bauer) (10/20/86)

Got tired of squinting at the cheat_sheet, so modified that nice "month"
calendar routine posted earlier to read a HELP file via the "?" key.

After unpacking the below shell archive via sh, apply the user.c.diff
mods to user.c and re-make.  You will have to install the HELP file in
the directory specified via the HELPFILE constant in help.c, or modify it
to your own tastes.

Apologies to the original author and descendant modifiers when appropriate.

#---------- CUT HERE --------- CUT HERE ---------- CUT HERE -------- OUCH !
#!/bin/sh
#
# This is a shell archive.
#
# Files generated - Makefile		(modified from original; added help.c)
#                   user.c.diff     (mods needed for HELP support)
#                   help.c          (new module that displays HELP file)
#                   month.hf        (HELP file - old cheat_sheet cleaned up)
#
echo -x - Makefile
cat > Makefile << END-OF-FILE
MONTH_OBJS = display.o lunar.o month.o psched.o schedule.o time.o user.o help.o

CC = cc
# define BSDFLG if target system is Berkeley 4.2
BSDFLG = -DBSD
CFLAGS = -O -c $(BSDFLG)
LIBS = -lm -lcurses $(LIB2)
# undefine LIB2 if target system is Pyramid SystemV Universe
# Note: some systems may require termlib instead of termcap
LIB2 = -ltermcap


month: $(MONTH_OBJS)
	$(CC) $(MONTH_OBJS) $(LIBS) -o month

display.o: display.c month.h
	$(CC) $(CFLAGS) display.c

lunar.o: lunar.c 
	$(CC) $(CFLAGS) lunar.c

help.o: help.c 
	$(CC) $(CFLAGS) help.c

month.o: month.c month.h
	$(CC) $(CFLAGS) month.c

psched.o: psched.c month.h
	$(CC) $(CFLAGS) psched.c

schedule.o: schedule.c month.h
	$(CC) $(CFLAGS) schedule.c

time.o: time.c month.h
	$(CC) $(CFLAGS) time.c

user.o: user.c month.h
	$(CC) $(CFLAGS) user.c
END-OF-FILE
echo -x - user.c.diff
cat > user.c.diff << END-OF-FILE
169,174d168
<         case 'B':
<             psched();
<             break;
< 		case '?':
< 			help();
< 			break;
176,179d169
< 			standout();
< 			mvaddstr(23,60," Press ? for HELP");
< 			standend();
< 			refresh();
181a172,174
>                case 'B':
>                        psched();
>                        break;
356c349
< 		addstr(" -MORE-");
---
> 		addstr(" -more-");
END-OF-FILE
echo -x - help.c
cat > help.c << END-OF-FILE
#include <curses.h>

#define LINES		24
#define WIDTH		80
#define BUFSIZE     LINES * WIDTH	/* one screenful of help */

#define HELPFILE "/usr/local/month.hf"

extern FILE *fopen();
extern int fread();

help()
{
	static FILE *helpf = NULL;
	static char buffer[BUFSIZE];

	clear();
	standout();
	mvaddstr(0,25," Keys and their Functions");
	standend();
	if (helpf == NULL) {
		helpf = fopen(HELPFILE,"r");
		if (helpf == NULL) mvaddstr(12,30,"HELP file unavailable!");
		else {
			fread(&buffer, BUFSIZE, 1, helpf);
			mvaddstr(1,0,buffer);
		}
	}
	else {
		mvaddstr(1,0,buffer);
	}
	standout();
	mvaddstr(23,18," Press any key to return to your calendar.");
	standend();
	refresh();
	get_char();
	clear();
	print_screen();
}
END-OF-FILE
echo -x - month.hf
cat > month.hf << END-OF-FILE
h, l, k, j       - move cursor left, right, up, down
<CR> and <LF>    - select items/commands/scroll-areas
0-9              - direct entry of date or marker numbers
/  - directly type in complete date (i.e. 5/6/86) | <ESC> - abort function
<SPACE>/<BACKSPACE> - scroll hours/minutes forward/backward
m, d - and y     - move into the months, days, years areas
n or +, p or '-' - go to the next or previous month, day, or year
M - mark the currently displayed date  | G - go to a previously marked date
;                - go to last visited date outside of currently displayed month
T                - go to today's actual date (initial date displayed)
O                - display schedule grid for currently displayed day
A                - show days in current month that have items scheduled
S                - scan the events for the currently displayed day
                        + +   In the scan   + +
  n : go to next event      p : go to previous event    d : delete this event
  e : edit this event       q : quit the scan           <ESC>: same as 'q'
E                - scan every stored event
P                - post an event (see man page)
L                - print picture of moon for 11:00 PM of current day
Q                - quit, store any event changes
^L, ^R           - redraw screen (including this page)
^C, ^\           - quit, ignore any event changes
END-OF-FILE
exit 0
#---------- CUT HERE --------- CUT HERE ---------- CUT HERE -------- OUCH !
-- 
---------------------------------------------------------------------------
Jeff Bauer              UUCP: {ihnp4!rosevax, caip!meccts}!eta!bauer
ETA Systems, Inc.       USPS: ETA03J, 1450 Energy Park Dr, St Paul, MN  55108
The New Force in Supercomputers