annotate motdwin.c @ 3:5a977ccbc7a9 default tip

Empty changelog
author darius
date Sat, 06 Dec 1997 05:41:29 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1 /* $Id: motdwin.c,v 1.1.1.1 1997/12/06 05:41:29 darius Exp $ */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
3 /*** Pop-up motd window code. [BDyess] 11/21/93 ***/
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
4
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
5 #include <stdio.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
6 #include <math.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
7 #include <signal.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
8 #include <sys/types.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
9 #ifdef hpux
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
10 #include <time.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
11 #else /* hpux */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
12 #include <sys/time.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
13 #endif /* hpux */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
14 #include "Wlib.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
15 #include "defs.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
16 #include "struct.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
17 #include "data.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
18 #include "proto.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
19 #ifdef SVR4
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
20 #include <string.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
21 #else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
22 #include <strings.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
23 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
24
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
25 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
26 motdWinEvent(key)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
27 int key;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
28 /* handles keystrokes in the motd window */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
29 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
30 static valuesOn = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
31
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
32 switch (key) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
33 case 'f': /* scroll forward */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
34 if (currpage == NULL) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
35 currpage = motddata;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
36 if (currpage == NULL)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
37 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
38 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
39 if (currpage->next == NULL)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
40 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
41 if (currpage->next)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
42 currpage->next->prev = currpage;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
43 currpage = currpage->next;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
44 showMotd(motdWin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
45 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
46 case 'b': /* Scroll motd backward */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
47 if (currpage == NULL || currpage->prev == NULL)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
48 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
49 currpage = currpage->prev;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
50 showMotd(motdWin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
51 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
52 case ' ': /* unmap window */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
53 showMotdWin();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
54 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
55 case '\t': /* tab: swap between sysdef and motd */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
56 W_ClearWindow(motdWin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
57 if (!valuesOn) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
58 showValues(motdWin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
59 valuesOn = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
60 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
61 showMotd(motdWin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
62 valuesOn = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
63 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
64 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
65 case 'r': /* refresh */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
66 if (valuesOn)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
67 showValues(motdWin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
68 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
69 showMotd(motdWin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
70 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
71 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
72 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
73
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
74 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
75 showMotdWin()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
76 /* handles map/unmap requests */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
77 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
78 if (!motdWin) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
79 motdWin = W_MakeWindow(
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
80 "Motd"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
81 ,-BORDER, -BORDER, WINSIDE, WINSIDE, NULL,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
82 (char *) 0, BORDER, foreColor);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
83 W_MapWindow(motdWin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
84 currpage = motddata;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
85 showMotd(motdWin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
86 } else if (W_IsMapped(motdWin)) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
87 W_UnmapWindow(motdWin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
88 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
89 W_MapWindow(motdWin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
90 currpage = motddata;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
91 showMotd(motdWin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
92 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
93 }