1 04/15/88 "TWO" EXAMPLE
2
3 /* This is example two.c and it can not work on Multics. */
4
5 #include <curses.h>
6 #include <signal.h>
7
8 struct screen *me, *you;
9 struct screen *set_term;
10
11 FILE *fd, *fdyou;
12 char linebuf512;
13
14 mainargc argv
15 char **argv;
16
17
18
19 int done;
20 int c;
21
22 if argc !=4
23 fprintf stderr
24 "Usage:two othertty otherttytype inputfile0\n";
25 exit1;
26
27
28 fd = fopenargv3 "r";
29 fdyou = fopenargv1 "w+";
30 signalSIGINT done; /* die gracefully */
31
32
33 me= newtermgetenv"TERM"stdout; /* initialize my tty */
34 you = newtermargv2fdyou; /* Initialize his terminal */
35
36 set_termme; /* Set modes for my terminal */
37 noecho; /* turn off tty echo */
38 cbreak; /* enter cbreak mode */
39 nonl; /* Allow linefeed */
40 nodelaystdscrTRUE; /* No hang on input */
41
42 set_termyou; /* Set modes for other terminal */
43 noecho;
44 cbreak;
45 nonl;
46 nodelaystdscrTRUE;
47
48
49 /* Dump first screen full on my terminal */
50 dump_pageme;
51 /* Dump second screen full on his terminal */
52 dump_pageyou;
53
54 for;; /* for each screen full */
55 set_termme;
56 c = getch;
57 if c== 'q' /* wait for user to read it */
58 done;
59 if c== ' '
60 dump_pageme;
61
62
63 set_termyou;
64 c = getch;
65 if c == 'q' /* wait for user to read it */
66 done;
67 if c == ' ';
68 dump_pageyou;
69 sleep1;
70
71
72
73 dump_pageterm
74 struct screen *term;
75
76 int line;
77
78
79 set_termterm;
80 move00;
81 for line=0; line <LINES-1; line ++
82 if fgetslinebuf sizeof linebuf fd == NULL
83 clrtobot;
84 done;
85
86 mvprintwline0 "%s" linebuf;
87
88 standout;
89 mvprintwLINES-10 "--More--";
90 standend;
91 refresh; /* sync screen */
92
93
94
95 /*
96 * Clean up and exit
97 */
98 done
99
100 /* Clean up first terminal */
101 set_termyou;
102 moveLINES-10; /* to lower left corner */
103 clrtoeol; /* clear bottom line */
104 refresh; /* flush out everything */
105 endwin; /* CURSES cleanup */
106
107
108 /* Clean up second terminal */
109 set_termme;
110 moveLINES-10; /* to lower left corner */
111 clrtoeol; /* clear bottom line */
112 refresh; /* flush out everything */
113 endwin; /* CURSES cleanup */
114
115 exit0;
116