richard@islenet.UUCP (Richard Foulk) (08/20/87)
# Since quite a number of people seem to be in need of this package # I though it would be a good idea to post it. # # It's pretty small anyway. # : to unbundle, "sh" this file -- DO NOT use csh : SHAR archive format. Archive created Thu Aug 20 03:23:49 PM echo x - windy.README sed 's/^X//' > windy.README <<'+FUNKY+STUFF+' Xwindy, a tool for inspecting and manipulating window parameters. XSee the article 'window' in Section 7 of the 7300 System V Administrator's Xmanual, and see the file /usr/include/sys/window.h X XBrief theory. Each window has these parameters: X(the ones marked RO are not alterable by a user) X XNAME ARG TYPE MEANING X Xuw_x -x 16 bits x coord of upper left corner, in pixels Xuw_y -y 16 bits y coord of upper left corner, in pixels Xuw_width -w 16 bits width of window, in pixels Xuw_height -h 16 bits height of window, in pixels Xuw_uflags -f 16 bits word of bits. see X /usr/include/sys/window.h X You can alter bits 4ff. Xuw_hs 8 bits[RO] ? Xuw_vs 8 bits[RO] ? Xuw_baseline 8 bits[RO] ? Xuw_cx 16 bits[RO] ? Xuw_cy 16 bits[RO] ? X XPROMPT -p char string 'prompt' line XCMD -c char string 'command' line XLABEL -l char string label on top of window border XUSER -n char string name of window as reported W icon. XSLK1 -1 char string first line of F-key labels XSLK2 -2 char string second line of F-key labels X XThe 29-line screen is divied up like this: X XLine 1: status line XLines 2-25: window lines XLine 26: the prompt line XLine 27: the line a user types in XLine 28: the top line of special function key labels XLine 29: the bottom line of ditto. X XOK. the program windy can be used to X 1) report these things or X 2) alter them. X XExamples of use: (see the column labeles ARGS above) X1. To get a report about current window, do this: X windy -r X X2. To alter current window name: X windy -n "My New Name" X X3. To alter size of current window: X windy -w 400 -h 100 X X4. To make current window borderless & of maximal size: X windy X X5. To make a new borderless maximal window with 'vi file' running Xin it: X windy vi file X X6. To do the above and call the new window "Vi Hotshot": X windy -n "Vi Hotshot" vi file X X XIn general, there are 2 forms: X X windy -r X windy [window-args] [command-args] X XAs we saw, windy -r just reports on current window. In the second case, Xif no command-args are given, the window-args apply to the current window. XIf command-args are given, a new window is created and the window-args Xapply to it, and the indicated command is run in the new window. XAn empty window-args list means borderless & maximal size. X XValid window args are listed in ARGS column of table above. The only Xzinger is this: the -f arg must be specified in hex, the other numerical Xargs in decimal. X XNEW STUFF 5 Dec 85 X=== ===== = === == X XTwo new flags: -b -K X X-b applies only to windy invocations that create a new window, viz, those Xthat specify command-args. It puts the command in the new window in Xthe background, so that if you return to the window manager and select Xyour shell, the shell will not wait for the windy command to finish. X XTry "windy -b directu" and click on the corner W and select the shell, Xcontrast with "windy directu" followed by ditto: much better the -b way. X XNOTE: there is a command 'resume' which is a shelly way of selecting Xwindows for the mouse shy. X X-K is used to put RVideo mode on the SLK labels. You invoke windy with Xan argument list like: X X windy -1 "special key label, row 1" -2 "special key label, row 2" \ X -K " rrrrrrrr rrrrrrr rrrrrrrr rrrrrrrr rrrrrrrr " X Xand whereever an 'r' occurs in the K-arg, the corresponding slk label Xnoodle will be in reverse video. The other entries will be blank. X X +FUNKY+STUFF+ echo '-rw-rw-rw- 1 richard users 3359 Aug 20 15:21 windy.README (as sent)' chmod u=rw,g=rw,o=rw windy.README ls -l windy.README echo x - Makefile sed 's/^X//' > Makefile <<'+FUNKY+STUFF+' X Xinclude $(MAKEINC)/Makepre.h X X XOBJ=windy.o X X Xall: $(OBJ) X $(LD) $(LDFLAGS) $(SHAREDLIB) $(OBJ) $(LIBM) -o windy X X Xinclude $(MAKEINC)/Makepost.h X X X +FUNKY+STUFF+ echo '-rw-rw-rw- 1 richard users 150 Aug 20 15:21 Makefile (as sent)' chmod u=rw,g=rw,o=rw Makefile ls -l Makefile echo x - windy.c sed 's/^X//' > windy.c <<'+FUNKY+STUFF+' X#include <termio.h> X#include <sys/window.h> X#include <stdio.h> X X#define NA 0xffff X Xstruct uwdata xuw = { X NA, NA, NA, NA, NA}; Xstruct utdata xut[WTXTNUM]; Xint bflag = 0; Xint Kflag = 0; Xchar blot[81]; Xchar *ttyname(); X Xmain(ac,av) Xint ac; Xchar **av; X{ X int nflag = 0; X char avname[81]; X extern char *optarg; X extern int optind; X int i, c; X X while((c = getopt(ac, av, "brp:c:l:u:1:2:n:f:h:w:x:y:K:")) != EOF) { X switch(c) { X case 'r': X report(ttyname(0)); X exit(0); X break; X case 'b': X bflag++; X break; X case 'h': X xuw.uw_height = atoi(optarg); X break; X case 'w': X xuw.uw_width = atoi(optarg); X break; X case 'x': X xuw.uw_x = atoi(optarg); X break; X case 'y': X xuw.uw_y = atoi(optarg); X break; X case 'f': X xuw.uw_uflags = htoi(optarg); X xuw.uw_uflags &= ~NOSETUFLAGS; X break; X case 'p': X utset(WTXTPROMPT, optarg); X break; X case 'c': X utset(WTXTCMD, optarg); X break; X case 'l': X utset(WTXTLABEL, optarg); X break; X case 'n': X case 'u': X nflag = 1; X utset(WTXTUSER, optarg); X break; X case '1': X utset(WTXTSLK1, optarg); X break; X case '2': X utset(WTXTSLK2, optarg); X break; X case '?': X fprintf(stderr, "usage: windy [window-args] [command-args]\n"); X fprintf(stderr, "or windy -r\n"); X exit(2); X case 'K': X strncpy(blot, optarg, 80); X Kflag ++; X } X } X /* X * if gave command args, put it in a new window X * if gave window args, or no args at all, change window params X */ X if(optind == 1) { X xuw.uw_x = 0; X xuw.uw_y = 12; X xuw.uw_width = 720; X xuw.uw_height = 288; X xuw.uw_uflags = 0x1; X } X if(optind < ac) { X newwind(); X avname[0] = 0; X for(i=optind; i<ac; i++) { X strncat(avname, av[i], 80); X strncat(avname, " ", 80); X } X if(!nflag) X utset(WTXTUSER, avname); X } X fixwind(); X if(optind < ac) { X int pid; X X if(bflag) { X pid = fork(); X if(pid > 0) X exit(1); X else if(pid == 0) { X setpgrp(); X ioctl(0, WIOCPGRP); X } X } X av += optind; X execvp(av[0], av); X perror(av[0]); X exit(1); X } X exit(0); X} Xutset(n, s) Xchar *s; X{ X xut[n].ut_num = 1; X strncpy(xut[n].ut_text, s, WTXTLEN); X} Xnewwind() { X char name[10]; X extern char **environ; X struct termio t; X int bad = 0, i, fd; X X if (!isatty(0)) return; X if(strncmp("/dev/w", ttyname(0), 6)!=0 ) return; X X if (ioctl(0, TCGETA, &t) < 0) { X perror("getting tty chars"); X bad = 1; X } X fd = open("/dev/window",2); X if (fd < 0) { X perror("opening window"); X return; X } X if(bflag) { X ioctl(fd, WIOCSELECT); X sprintf(name, "[w%d]\n", ioctl(fd, WIOCGCURR)); X write(0, name, strlen(name)); X } X X close(0); X dup(fd); X close(1); X dup(fd); X close(2); X dup(fd); X close(fd); X /* Set in the previous edit characters to the new window */ X if (!bad && ioctl(0, TCSETAF, &t) < 0) X perror("setting tty chars"); X for (i=0; environ[i]; ++i) { X if (!strncmp(environ[i],"TERMCAP=",8)) { X environ[i] = "TERMCAP=/etc/termcap"; X } X if (!strncmp(environ[i],"TERM=",5)) { X environ[i] = "TERM=s4"; X } X } X} Xfixwind() { X struct uwdata uw; X int i; X X if(Kflag) { X xut[WTXTSLK1].ut_num = WTXTSLK1; X xut[WTXTSLK2].ut_num = WTXTSLK2; X keyfix(xut[WTXTSLK1].ut_text); X keyfix(xut[WTXTSLK2].ut_text); X } X for(i=0; i<WTXTNUM; i++) { X if(xut[i].ut_num) { X xut[i].ut_num = i; X ioctl(0, WIOCSETTEXT, &xut[i]); X } X } X ioctl(0, WIOCGETD, &uw); X if(xuw.uw_x != NA) uw.uw_x = xuw.uw_x; X if(xuw.uw_y != NA) uw.uw_y = xuw.uw_y; X if(xuw.uw_width != NA) uw.uw_width = xuw.uw_width; X if(xuw.uw_height != NA) uw.uw_height = xuw.uw_height; X if(xuw.uw_uflags != NA) uw.uw_uflags = xuw.uw_uflags; X ioctl(0, WIOCSETD, &uw); X} Xkeyfix(s) Xchar *s; X{ X int c, i; X X for(i=0; i<80; i++) { X c = s[i] & 0177; X if(c == 0) c = ' '; X switch(blot[i]) { X case ' ': X case 0: X c = ' '; X break; X case 'r': X case 'R': X c |= 0200; X break; X } X s[i] = c; X } X} Xchar *utname[] = { X "Prompt line", X "Command line", X "Label", X "User", X "SLK1", X "SLK2", X}; Xreport(s) Xchar *s; X{ X struct uwdata uw; X struct utdata ut; X int i; X X printf("%s: ", s); X ioctl(0, WIOCGETD, &uw); X uwshow(&uw, (char *)0); X X for(i=0; i<WTXTNUM; i++) { X ut.ut_num = i; X ioctl(0, WIOCGETTEXT, &ut); X if(ut.ut_text[0]) { X printf("%s=<%.81s>\n", utname[i], ut.ut_text); X } X } X} Xuwshow(p, s) Xstruct uwdata *p; Xchar *s; X{ X printf("(x,y)=(%d,%d) ", p->uw_x, p->uw_y); X printf("(width,height)=(%d,%d) ", p->uw_width, p->uw_height); X printf("flags=%x\n ", p->uw_uflags); X printf("(hs,vs)=(%d, %d)[RO] ", p->uw_hs, p->uw_vs); X printf("baseline=%d[RO] ", p->uw_baseline); X printf("(cx,cy)=(%d, %d)[RO]\n", p->uw_cx, p->uw_cy); X} Xhtoi(s) Xchar *s; X{ X int x = NA; X X sscanf(s, "%x", &x); X return x; X} +FUNKY+STUFF+ echo '-rw-rw-rw- 1 richard users 4593 Aug 20 15:21 windy.c (as sent)' chmod u=rw,g=rw,o=rw windy.c ls -l windy.c exit 0 -- Richard Foulk ...{dual,vortex,ihnp4}!islenet!richard Honolulu, Hawaii