summaryrefslogtreecommitdiff
path: root/master.c
diff options
context:
space:
mode:
authorNed T. Crigler <crigler@users.sourceforge.net>2004-06-24 01:57:02 +0000
committerNed T. Crigler <crigler@users.sourceforge.net>2004-06-24 01:57:02 +0000
commita5599b4610788c17f5166685612f48c71d7537ac (patch)
tree97826e9812b600d3c4777bd265c932700c63babe /master.c
parent302917ca33d7cdfac786f562986b2c669f64ad49 (diff)
Allow the redraw method to be chosen by the user, and include the old Ctrl L
character method again.
Diffstat (limited to 'master.c')
-rw-r--r--master.c58
1 files changed, 41 insertions, 17 deletions
diff --git a/master.c b/master.c
index 8d31651..612ce2f 100644
--- a/master.c
+++ b/master.c
@@ -238,7 +238,7 @@ client_activity(struct client *p)
struct packet pkt;
/* Read the activity. */
- len = read(p->fd, &pkt, sizeof(pkt));
+ len = read(p->fd, &pkt, sizeof(struct packet));
/* Close the client on an error. */
if (len <= 0)
{
@@ -254,24 +254,9 @@ client_activity(struct client *p)
if (pkt.type == MSG_PUSH)
write(the_pty.fd, pkt.u.buf, pkt.len);
- /* When attaching, we set the window size and force a redraw by sending
- ** the WINCH signal to the program.
- **
- ** XXX: Are there any programs that don't handle the WINCH signal
- ** properly? Full-screen programs should fully redraw themselves, and
- ** line-oriented programs should redraw the prompt, or do nothing.
- */
+ /* Attach or detach from the program. */
else if (pkt.type == MSG_ATTACH)
- {
p->attached = 1;
- if (memcmp(&the_pty.ws, &pkt.u.ws, sizeof(struct winsize)) != 0)
- {
- the_pty.ws = pkt.u.ws;
- ioctl(the_pty.fd, TIOCSWINSZ, &the_pty.ws);
- }
- else
- killpty(&the_pty, SIGWINCH);
- }
else if (pkt.type == MSG_DETACH)
p->attached = 0;
@@ -281,6 +266,41 @@ client_activity(struct client *p)
the_pty.ws = pkt.u.ws;
ioctl(the_pty.fd, TIOCSWINSZ, &the_pty.ws);
}
+
+ /* Force a redraw using a particular method. */
+ else if (pkt.type == MSG_REDRAW)
+ {
+ int method = pkt.len;
+
+ /* If the client didn't specify a particular method, use
+ ** whatever we had on startup. */
+ if (method == REDRAW_UNSPEC)
+ method = redraw_method;
+ if (method == REDRAW_NONE)
+ return;
+
+ /* Set the window size. */
+ the_pty.ws = pkt.u.ws;
+ ioctl(the_pty.fd, TIOCSWINSZ, &the_pty.ws);
+
+ /* Send a ^L character if the terminal is in no-echo and
+ ** character-at-a-time mode. */
+ if (method == REDRAW_CTRL_L)
+ {
+ char c = '\f';
+
+ if (((the_pty.term.c_lflag & (ECHO|ICANON)) == 0) &&
+ (the_pty.term.c_cc[VMIN] == 1))
+ {
+ write(the_pty.fd, &c, 1);
+ }
+ }
+ /* Send a WINCH signal to the program. */
+ else if (method == REDRAW_WINCH)
+ {
+ killpty(&the_pty, SIGWINCH);
+ }
+ }
}
/* The master process - It watches over the pty process and the attached */
@@ -368,6 +388,10 @@ master_main(char **argv)
int s;
pid_t pid;
+ /* Use a default redraw method if one hasn't been specified yet. */
+ if (redraw_method == REDRAW_UNSPEC)
+ redraw_method = REDRAW_CTRL_L;
+
/* Create the unix domain socket. */
s = create_socket(sockname);
if (s < 0)