From: Edward Wang Date: Wed, 27 Jul 1983 05:02:15 +0000 (-0800) Subject: Function keys passed on to the windows. X-Git-Tag: BSD-4_2-Snapshot-Development~667 X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/commitdiff_plain/3e0824a909d3d273cc7879cbcde841489d4c85f1?hp=f5f43574501f3f31b08dc03d343628adea546929 Function keys passed on to the windows. SCCS-vsn: usr.bin/window/wwinit.c 1.6 SCCS-vsn: usr.bin/window/wwspawn.c 1.6 --- diff --git a/usr/src/usr.bin/window/wwinit.c b/usr/src/usr.bin/window/wwinit.c index 45179cfe36..a7b93fec99 100644 --- a/usr/src/usr.bin/window/wwinit.c +++ b/usr/src/usr.bin/window/wwinit.c @@ -1,5 +1,5 @@ #ifndef lint -static char *sccsid = "@(#)wwinit.c 1.5 83/07/22"; +static char *sccsid = "@(#)wwinit.c 1.6 83/07/26"; #endif #include "ww.h" @@ -12,11 +12,15 @@ struct ww_tty wwnewtty = { 0, 0, 0 }; int _wwdtablesize; +char _wwtermcap[1024]; +char _wwkeys[512]; +static char *kp = _wwkeys; int wwncol, wwnrow; wwinit() { static char done = 0; + int kn; if (done) return 0; @@ -40,5 +44,47 @@ wwinit() return -1; WSetRealCursor = 1; Wscreensize(&wwnrow, &wwncol); + + if (tgetent(_wwtermcap, getenv("TERM")) != 1) + return -1; + addcap("kb"); + addcap("ku"); + addcap("kd"); + addcap("kl"); + addcap("kr"); + addcap("kh"); + if ((kn = tgetnum("kn")) >= 0) { + char cap[5]; + int i; + + sprintf(kp, "kn#%d:", kn); + for (; *kp; kp++) + ; + for (i = 1; i <= kn; i++) { + sprintf(cap, "k%d", i); + addcap(cap); + cap[0] = 'l'; + addcap(cap); + } + } return 0; } + +addcap(cap) +register char *cap; +{ + static char tbuf[512]; + static char *tp = tbuf; + register char *str; + char *tgetstr(); + + if ((str = tgetstr(cap, &tp)) != 0) { + while (*kp++ = *cap++) + ; + kp[-1] = '='; + while (*kp++ = *str++) + ; + kp[-1] = ':'; + *kp = 0; + } +} diff --git a/usr/src/usr.bin/window/wwspawn.c b/usr/src/usr.bin/window/wwspawn.c index 0056b2c31b..916be00d67 100644 --- a/usr/src/usr.bin/window/wwspawn.c +++ b/usr/src/usr.bin/window/wwspawn.c @@ -1,10 +1,11 @@ #ifndef lint -static char *sccsid = "@(#)wwspawn.c 1.5 83/07/22"; +static char *sccsid = "@(#)wwspawn.c 1.6 83/07/26"; #endif #include "ww.h" extern int _wwdtablesize; +extern char _wwtermcap[]; wwfork(wp) register struct ww *wp; @@ -31,8 +32,9 @@ register struct ww *wp; :co#%d:dc=\\EN:dl=\\EM:do=\\EB:ei=\\EO:ho=\\EH:li#%d:im=\\E@:mi:\ :nd=\\EC:ta=^I:pt:up=\\EA:" static char *env[100]; -static char buf[sizeof TERMCAP + 10]; +static char buf[1024]; extern char **environ; +extern char _wwkeys[]; wwenviron(wp) register struct ww *wp; @@ -64,5 +66,6 @@ register struct ww *wp; termcap = q++; *q = 0; *termcap = sprintf(buf, TERMCAP, wp->ww_i.ncol, wp->ww_i.nrow); + strcat(buf, _wwkeys); environ = env; }