1 04/15/88 "SHOW" EXAMPLE
2
3 /* SHOW. This program takes a filename
4 * as input and displays it on the screen,
5 */ similar to the more command.
6
7 #include <curses.h>
8 #include <signal.h>
9
10 char sysline50='0';
11 int segno=0;
12
13 mainargc argv
14 int argc;
15 char *argv;
16
17 FILE *fd;
18 char linebufBUFSIZ;
19 int line;
20 void done;
21
22
23 if argc != 2
24
25 fprintf stderr"Usage: %s file-name\n" argv0;
26 exit1;
27
28 if fd=fopenargv1 "r" == NULL
29
30 perrorargv1;
31 exit2;
32
33
34 signalSIGINT done;
35
36
37 initscr;
38 noecho;
39 cbreak;
40 nonl;
41 idlokstdscr TRUE;
42
43 while 1
44
45 move 00;
46 for line=0; line<LINES-1; line++
47
48 if fgets linebuf sizeof linebuf fd == NULL
49
50 clrtobot;
51 standout;
52 mvaddstr230"EOF reached";
53 standend;
54
55 else
56
57 move line0;
58
59
60 clrtoeol;
61 printw"%s" linebuf;
62
63
64
65 move 230;
66 void refresh;
67
68 if getch == 'q'
69 done;
70
71
72
73 void done
74
75
76
77 moveLINES-1 0;
78 erase;
79 refresh;
80 endwin;
81 exit0;
82
83
84