cmd/9term: A hack because I'm constantly getting confused about ^C vs fn+delete

Since Google (and a lot of the outside) is so engrained with using
^C as interrupt, I'd like to be able to use it in 9term if I've
stty'd my intr to ^C. Without this, hitting ^C still works but if
the program behind the window isn't reading from /dev/cons, it won't
take effect till after I hit a newline which is often very confusing.

I know this is a hack since it only works if I stty intr ^C but that
seems the only other character that gets used anyways.

Change-Id: I0597e63b2d7628f5668c648e6dba6f281e4b27fd
Reviewed-on: https://plan9port-review.googlesource.com/2742
Reviewed-by: Russ Cox <rsc@swtch.com>
diff --git a/src/cmd/9term/9term.c b/src/cmd/9term/9term.c
index 5cf46de..192a9bc 100644
--- a/src/cmd/9term/9term.c
+++ b/src/cmd/9term/9term.c
@@ -448,6 +448,11 @@
 	write(rcfd, rubout, 1);
 }
 
+int
+intrc() {
+	return getintr(sfd);
+}
+
 /*
  * Process in-band messages about window title changes.
  * The messages are of the form:
diff --git a/src/cmd/9term/fns.h b/src/cmd/9term/fns.h
index a0ae686..196f418 100644
--- a/src/cmd/9term/fns.h
+++ b/src/cmd/9term/fns.h
@@ -31,6 +31,7 @@
 int	goodrect(Rectangle);
 int	rawon(void);
 void	winterrupt(Window*);
+int	intrc();
 
 #define	runemalloc(n)		malloc((n)*sizeof(Rune))
 #define	runerealloc(a, n)	realloc(a, (n)*sizeof(Rune))
diff --git a/src/cmd/9term/wind.c b/src/cmd/9term/wind.c
index b03f15f..7dc2044 100644
--- a/src/cmd/9term/wind.c
+++ b/src/cmd/9term/wind.c
@@ -705,6 +705,11 @@
 		wcut(w);
 	}
 	switch(r){
+	case 0x03:		/* maybe send interrupt */
+		/* since ^C is so commonly used as interrupt, special case it */
+		if (intrc() != 0x03)
+			break;
+		/* fall through */
 	case 0x7F:		/* send interrupt */
 		w->qh = w->nr;
 		wshow(w, w->qh);