1 /* screen.c Copyright Michael Temari 08/01/1996 All Rights Reserved */
14 _PROTOTYPE(void gotsig
, (int sig
));
15 _PROTOTYPE(static char *delword
, (WINDOW
*w
));
24 static char line
[80+1];
41 if(initscr() == (WINDOW
*)NULL
) {
42 fprintf(stderr
, "talk: Could not initscr\n");
45 signal(SIGINT
, gotsig
);
46 signal(SIGQUIT
, gotsig
);
47 signal(SIGPIPE
, gotsig
);
48 signal(SIGHUP
, gotsig
);
55 window
[LOCALWIN
].win
= newwin(LINES
/ 2, COLS
, 0, 0);
56 scrollok(window
[LOCALWIN
].win
, TRUE
);
57 wclear(window
[LOCALWIN
].win
);
59 /* divider between windows */
60 dwin
= newwin(1, COLS
, LINES
/ 2, 0);
67 window
[REMOTEWIN
].win
= newwin(LINES
- (LINES
/ 2) - 1, COLS
, LINES
/ 2 + 1, 0);
68 scrollok(window
[REMOTEWIN
].win
, TRUE
);
69 wclear(window
[REMOTEWIN
].win
);
79 w
=window
[LOCALWIN
].win
;
84 wprintw(w
, "[%s]", msg
);
92 void ScreenWho(user
, host
)
97 wmove(dwin
, 0, (COLS
- (1 + strlen(user
) + 1 + strlen(host
) + 1)) / 2);
98 wprintw(dwin
, " %s@%s ", user
, host
);
100 wmove(dwin
, 0, (COLS
- (1 + strlen(user
) + 1)) / 2);
101 wprintw(dwin
, " %s ", user
);
106 void ScreenEdit(lcc
, rcc
)
110 window
[LOCALWIN
].erase
= lcc
[0];
111 window
[LOCALWIN
].kill
= lcc
[1];
112 window
[LOCALWIN
].werase
= lcc
[2];
113 window
[REMOTEWIN
].erase
= rcc
[0];
114 window
[REMOTEWIN
].kill
= rcc
[1];
115 window
[REMOTEWIN
].werase
= rcc
[2];
118 void ScreenPut(data
, len
, win
)
131 /* new line CR, NL */
132 if(ch
== '\r' || ch
== '\n') {
135 /* erase a character, BS, DEL */
136 if(ch
== 0x08 || ch
== 0x7f || ch
== window
[win
].erase
) {
144 /* erase line CTL-U */
145 if(ch
== 0x15 || ch
== window
[win
].kill
) {
152 if(win
== LOCALWIN
) {
155 touchwin(window
[REMOTEWIN
].win
);
156 wrefresh(window
[REMOTEWIN
].win
);
164 /* erase last word CTL-W */
165 if(ch
== 0x17 || ch
== window
[win
].werase
) {
169 if(1 || isprint(ch
)) {
170 if(ch
!= ' ' && c
== (COLS
- 1))
171 wprintw(w
, "\n%s", delword(w
));
179 static char *delword(w
)
192 ch
= mvwinch(w
, r
, c
);