shansen@Navajo.ARPA (10/23/85)
About a month ago Corey Satten at Fluke submitted several little and useful programs for the Unix PC. The one that I really like is the "bvi" command which fires 'vi' up but gives it a full 80x24 boarderless window (a new window) instead of the 76x18 biggest Unix window that can be had. I now use "bvi" all the time. There are a couple of improvements that I have made to the original program. The new code follows in shar format. The changes are: 1. Makes sure that you are starting from a window incase you are dialed in or on the aux tty line. If not, just start vi. 2. Use execvp() to find 'vi' instead of execve which requires the full path of the program. In spite of the modifications to the environment, execve() is not needed. Admittedly, there is probably going to be just the 'vi' in "/usr/bin/vi", but I hate ever having to modify/recompile for any reason (much less just because I moved a program to another location. 3. (This is the main addition - the real reason for resubmitting this command). It seems that in opening a new window, the edit characters are not passed on. They get reset to the defaults (KILL '@', ERASE '#'....) Before the new window is opened, 'bvi' now gets the current edit characters, and in the new window sets in those old characters. Michael Eldredge dredge@su-fuji.arpa hplabs!glacier!shasta!"dredge@fuji" --------------cut-here------------------------cut-here--------------------- : ' SHAR format, remove everything above this line and give this to ' : ' sh (not csh) ' echo x - bvi.c echo '-rw-rw---- 1 dredge 2055 Oct 23 10:29 bvi.c (as sent)' sed 's/^X//' > bvi.c <<'_BAZZL_' X/* X * BVI -- On an AT&T Unix-PC, run vi in a new 24x80 borderless window. X * X * This program will open a borderless (80 column) window on top of all X * your other windows and run vi in it. When vi exits, the window X * will be removed, revealing the window in which you typed bvi unchanged. X * X * Usage: bvi args-to-vi X * X * Author: Corey Satten, fluke!corey Sept 1985 X * Mod #1: Michael Eldredge, shasta!fuji!skippy!dredge Sep 85 X * Check to see if we are in a window to start with before opening X * a new one. This incase dialed in or on aux tty line. X * Instead of execve() that needs the absolute path for 'vi', use X * execvp() which will search through PATH - the modifications of X * the env will indeed be passed along without the help of execve(). X * Mod #2: Michael Eldredge, shasta!fuji!skippy!dredge Oct 85 X * Make sure that the terminal editing characters are passed along X * to the new editor. X * X * This software is hereby officially introduced into the public domain. X */ X X#include <termio.h> X Xmain(ac,av,ep) X int ac; X char *av[], *ep[]; X { X int fd, i; X struct termio t ; X int bad = 0 ; X char *termcap; X char *ttyname() ; X X /* Only open a new window if this is a window to start with */ X if (isatty(0) && strncmp("/dev/w", ttyname(0), 6)==0 ) { X /* First get old edit characters to reset in new window */ X if (ioctl(0, TCGETA, &t) < 0) { X perror("getting tty chars") ; X bad = 1 ; X } X X fd = open("/dev/window",2); X if (fd < 0) { X perror("opening window") ; X goto exec_it ; /* Yes, a goto! What's it's Wirth? */ X } X X close(0); dup(fd); X close(1); dup(fd); X close(2); dup(fd); X 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 X for (i=0; ep[i]; ++i) { X if (!strncmp(ep[i],"TERMCAP=",8)) { X ep[i] = "TERMCAP=/etc/termcap"; X } X if (!strncmp(ep[i],"TERM=",5)) { X ep[i] = "TERM=s4"; X } X } X } X X /* Now exec vi..... */ X exec_it: X av[0] = "vi"; X execvp("vi", av); /* Let the exec() find the file with PATH */ X } _BAZZL_ ls -l bvi.c