|
|
1.1 root 1: #include "parms.h"
2: #include "structs.h"
3:
4: #ifdef RCSIDENT
5: static char rcsid[] = "$Header: index.c,v 1.7.0.2 85/09/09 18:32:22 notes Rel $";
6: #endif RCSIDENT
7:
8: /*
9: * INPUT KEY PROCESSING FOR INDEX PHASE
10: *
11: * Process all keystrokes while the index page is on the screen.
12: * invokes director options also (if user qualified)
13: * Returns: >=0 read note with that number ( 0 is policy)
14: * -1 reprint the index page
15: * -2 leave notefiles, update sequencer time
16: * -3 leave notefile, dont update sequencer
17: * -4 Universal leave notefiles
18: * (-2 and -3 leave single notefile, -4 leaves
19: * entire package, aborting rest of notefiles.
20: *
21: * Original Coding: Rob Kolstad Winter 1980
22: * modifications: Ray Essick December 1981
23: */
24:
25: indx (io, firstdis, lastdis, respnum)
26: struct io_f *io;
27: int *firstdis,
28: *lastdis,
29: *respnum;
30: {
31: struct io_f io2; /* for nested notefiles */
32: char nfname[WDLEN + 1]; /* for nested nfs */
33: int num; /* note number */
34: int i;
35: int c;
36: int znote,
37: zresp; /* for asearch */
38:
39: *respnum = 0; /* init response */
40: while (1)
41: {
42: at (-1, 1);
43: #ifdef PROMPT
44: printf (PROMPT); /* issue a prompt */
45: #endif
46: c = gchar ();
47: printf ("\10 \10"); /* erase the key */
48: switch (c) /* what to do? */
49: {
50: case '?':
51: case 'h':
52: help (INDXHLP); /* put the help on screen */
53: return (-1); /* back and display the index */
54:
55: case 'r': /* replot the index page */
56: case '\f': /* everyone else uses ^L, might as well */
57: return (-1);
58:
59: case 'W': /* this too shall write a note */
60: case 'w': /* write a note */
61: return addnote (io, NULL, "Edit Note text:", "Note Title: ", NULL, EDIT);
62: /* do it */
63:
64: case 'B': /* bitch, bitch, bitch */
65: if (init (&io2, GRIPES) < 0) /* no gripe file */
66: {
67: at (0, 1);
68: printf ("Gripe file not available");
69: }
70: else
71: {
72: addnote (&io2, NULL, "Edit Gripe text:", "Gripe Header: ", NULL, EDIT);
73: /* let him put the note in */
74: finish (&io2); /* close up the gripe file */
75: }
76: return (-1); /* replot */
77:
78: case '-': /* back up a little */
79: case '\b': /* add backspace also */
80: *firstdis -= Nindex - 1;
81: return (-1);
82:
83: case '=': /* back up a lot */
84: *firstdis = 1;
85: return (-1);
86:
87: case '+':
88: case '\r':
89: case '\n':
90: case ' ':
91: if (*lastdis < io -> descr.d_nnote)
92: {
93: *firstdis = *lastdis;
94: return (-1);
95: }
96: break; /* keep doing what we were */
97:
98: case '*': /* skip to last page */
99: if (*lastdis < io -> descr.d_nnote)
100: {
101: *firstdis = io -> descr.d_nnote - Nindex + 1;
102: return (-1);
103: }
104: break; /* already at end */
105:
106: case 'q':
107: #ifdef K_KEY
108: case 'k': /* can use right hand */
109: #endif K_KEY
110: return QUITSEQ;
111:
112: case '\04': /* ^D */
113: return QUITFAST; /* total exit */
114:
115: case 'z': /* ^D w/sequencer update */
116: return QUITUPD; /* total exit w/update */
117:
118: case 'Q': /* exit without update of sequencer */
119: #ifdef K_KEY
120: case 'K': /* so can use just right hand */
121: #endif K_KEY
122: return QUITNOSEQ;
123:
124: case 'N': /* go to an archive */
125: sprintf (nfname, "%s/%s", ARCHDIR, io -> nf);/* build dest */
126: goto donest; /* share common code */
127:
128:
129:
130: case 'n': /* nest notesfiles - a stack */
131: at (-1, 10);
132: printf ("New notesfile: ");
133: printf (" \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
134: if (gline (nfname, WDLEN) == 1)
135: return (-1); /* forget it, replot */
136: donest: /* used by N */
137: closenf (io); /* save fids */
138: if ((i = control (nfname, NOSEQ)) == -1)/* do the other */
139: sleep (1); /* some error there */
140: if (opennf (io, 0) < 0)
141: {
142: at (0, 1);
143: printf ("Couldn't reopen notesfile %s", io -> fullname);
144: fflush (stdout);
145: sleep (2);
146: return QUITNOSEQ; /* don't update */
147: }
148: if (i == QUITFAST) /* he in a hurry? */
149: return QUITFAST; /* oblige him */
150: return (-1); /* redisplay index */
151:
152: case 'p': /* to read note 0 */
153: if (io -> descr.d_plcy)
154: return 0;
155: else
156: {
157: at (0, PROMPTMSGX);
158: printf ("There is no policy note");
159: continue; /* grab another key */
160: }
161:
162:
163:
164: case 'd': /* to director options */
165: if (allow (io, DRCTOK))
166: return direct (io); /* perform those babies */
167: else
168: {
169: at (0, PROMPTMSGX);
170: printf (" Anonymous: %s Networked: %s",
171: (io -> descr.d_stat & ANONOK) ? "YES" : "NO",
172: (io -> descr.d_stat & NETWRKD) ? "YES" : "NO");
173: continue;
174: }
175:
176: case 'x':
177: case 'X':
178: i = tsearch (io, *lastdis, c == 'x'); /* assume lies before here */
179: if (i > 0)
180: return i; /* return that one */
181: continue; /* otherwise get another key */
182:
183: case 'a':
184: case 'A': /* author search from current spot */
185: znote = *lastdis;
186: zresp = 0; /* start at the correct place */
187: i = asearch (io, &znote, &zresp, (c == 'a'));
188: /* look */
189: if (i > 0)
190: {
191: *respnum = zresp; /* return correct value */
192: return znote; /* and such */
193: }
194: continue; /* get another command */
195:
196: case '1':
197: case '2':
198: case '3':
199: case '4':
200: case '5':
201: case '6':
202: case '7':
203: case '8':
204: case '9':
205: at (-1, 1);
206: printf ("Read note > ");
207: if ((num = getnum (c)) == 0)
208: {
209: at (-1, 3);
210: printf (" ");
211: continue;
212: }
213:
214: return num;
215:
216: case 'j':
217: case 'J': /* goto first unread article */
218: return (nxtnote (io, 0, &io -> stime));
219:
220: case 'l': /* leave if no new */
221: case 'L':
222: if ((i = nxtnote (io, 0, &io -> stime)) < 0)
223: return QUITSEQ; /* nope, leave */
224: else
225: return (i); /* go there */
226:
227: case 'o': /* modify sequencer time */
228: gdate (&io -> stime); /* let him hack on the time */
229: continue; /* and go back */
230:
231: case 'O': /* set it for today's notes */
232: gettime (&io -> stime); /* grab current date */
233: io -> stime.w_hours = 0; /* beginning of day */
234: io -> stime.w_mins = 0;
235: io -> stime.w_gmttime = 0; /* use formatted */
236: at (0, PROMPTMSGX); /* tell him what we did */
237: printf ("Set to read notes since: ");
238: prdate (&io -> stime);
239: continue; /* and get the next command */
240:
241:
242: case '!':
243: gshell (); /* give him a shell in right directory */
244: return (-1);
245:
246: default:
247: at (0, 5);
248: printf ("\07 type ? for help, q to quit ");
249: continue;
250: }
251:
252:
253: /* end main index page code */
254: }
255: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.