adam@npois.UUCP (Adam V. Reed) (05/21/85)
/* wenv.c */ /* This program can be used, via $ eval `wenv`, to update the environment variables after starting a new window or changing the size of an old one. It is most useful in connection with aliases such as the following in in $ENV (= $HOME/.kshrc): more='(eval `/u/adam/lib/wenv<$TTY`; /usr/bin/more -n$MLINES)' \ vi='eval `/u/adam/lib/wenv`; /usr/bin/vi' \ view='eval `/u/adam/lib/wenv`; /usr/bin/view' \ If you don't have ksh, you can do the equivalent (less efficiently) with scripts. */ #include <stdio.h> #include <sys/font.h> #include <sys/window.h> char s0[] = "MLINES="; char s1[] = " LINES="; char s2[] = " COLS="; char s3[] = " COLUMNS="; char s4[] = " TERMCAP=':al=\\E[1L:am:bs:cd=\\E[0J:ce=\\E[0K:cl=\\E[2J\\E[H:cm=\\E[%i%2;%2H:dc=\\E[1P:dl=\\E[1M:do=\\E[B:ei=:ho=\\E[H:ic=\\E[1@:im=:kb=\\\10:kd=\\E[B:kl=\\E[D:kr=\\E[C:ku=\\E[A:k1=\\EOc:k2=\\EOd:k3=\\EOe:k4=\\EOf:k5=\\EOg:k6=\\EOh:k7=\\EOi:k8=\\EOj:nd=\\E[C:se= ^H\\E[m:so=\\E[1;2;7m:ue=\\E[m:up=\\E[A:us=\\E[4m:EE=\\E[m:BO=\\E[0;7m:CV=\\E[=C:CI=\\E[=1C:KM=/usr/lib/ua/kmap.s4:li#"; char s5[] = ":co#"; char s6[] = ":' \n"; main() { struct uwdata thiswindow; extern int errno; int cols, lines; if (ioctl(0,WIOCGETD,&thiswindow) != -1) { cols = thiswindow.uw_width / thiswindow.uw_hs ; lines = thiswindow.uw_height / thiswindow.uw_vs ; (void)printf("%s%d%s%d%s%d%s%d%s%d%s%d%s",s0,lines-2, s1,lines,s2,cols,s3,cols,s4,lines,s5,cols,s6); } else (void)printf("TERMCAP=/etc/termcap \n"); exit(errno); }