*BSD News Article 11584


Return to BSD News archive

Received: by minnie.vk1xwt.ampr.org with NNTP
	id AA1695 ; Tue, 23 Feb 93 14:54:04 EST
Path: sserve!manuel.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!sun-barr!cs.utexas.edu!news
From: cloyce@cs.utexas.edu (Cloyce D. Spradling)
Newsgroups: comp.os.386bsd.questions
Subject: Re: patch to vi editor (pt.3 -- the look 'n' feel)
Date: 19 Feb 1993 11:58:58 -0600
Organization: CS Dept, University of Texas at Austin
Lines: 237
Message-ID: <loa7v2INN457@dimebox.cs.utexas.edu>
References: <C2nKsx.9Mp@ux1.cso.uiuc.edu> <lo8q52INNgh@dimebox.cs.utexas.edu> <CGD.93Feb18210248@eden.CS.Berkeley.EDU>
NNTP-Posting-Host: dimebox.cs.utexas.edu

Well, while tinkering around inside elvis, trying to find that line killer
bug, I decided to fix a couple of things that I didn't like about how elvis 
looked and acted.  Being a "young 'un", I grew up on vi on Sun 4's.  On those,
when editing multiple files, if you do 'ZZ', and there are more to edit, vi
saves the one you're working on and tells you that there are more.  Elvis
tells you that there are more, but doesn't save it.  This, to me, is a pain
in the butt.  The first patch also removes the static variable 'whenwarned'
because the patched version doesn't need it.  Please let me know if this
causes problems (I'm sure I don't do everything that everybody else does).

The other thing that this patch changes is the way the screen looks in
line-numbering mode -- those annoying '|' are gone from beside the numbers.

I've been running these without problems since mid-December, and it's the
only editor I use, so I think they're pretty tame.  I'm fairly certain that
they work with the ':wq!' fix posted recently (or is it in the patchkit?  I
can't remember).  If not, it should be easy to fix.

Hope someone gets some use out of these!


*** /usr/src/usr.bin/elvis/cmd1.c.orig	Thu Dec 17 09:01:25 1992
--- /usr/src/usr.bin/elvis/cmd1.c	Thu Dec 17 08:39:38 1992
***************
*** 599,612 ****
  	int	bang;
  	char	*extra;
  {
- 	static long	whenwarned;	/* when the user was last warned of extra files */
  	int		oldflag;
  
  	/* if there are more files to edit, then warn user */
! 	if (argno >= 0 && argno + 1 < nargs && whenwarned != changes && (!bang || cmd != CMD_QUIT))
  	{
  		msg("More files to edit -- Use \":n\" to go to next file");
- 		whenwarned = changes;
  		return;
  	}
  
--- 599,616 ----
  	int	bang;
  	char	*extra;
  {
  	int		oldflag;
  
  	/* if there are more files to edit, then warn user */
! 	if (argno >= 0 && argno + 1 < nargs && (!bang || cmd != CMD_QUIT))
  	{
+ 		/* first try to save this file if necessary */
+ 		if (tstflag(file, MODIFIED))
+ 			if (!tmpsave((char *)0, bang))
+ 				msg("Could not save file -- use quit! to abort changes, or w filename");
+ 			else
+ 				clrflag(file, MODIFIED);
  		msg("More files to edit -- Use \":n\" to go to next file");
  		return;
  	}
  
*** /usr/src/usr.bin/elvis/redraw.c.orig	Thu Dec 17 09:01:27 1992
--- /usr/src/usr.bin/elvis/redraw.c	Thu Dec 17 08:13:49 1992
***************
*** 339,345 ****
  	physrow = markline(m) - topline;
  	physcol = i - leftcol;
  	if (*o_number)
! 		physcol += 8;
  
  	return physcol;
  }
--- 339,345 ----
  	physrow = markline(m) - topline;
  	physcol = i - leftcol;
  	if (*o_number)
! 		physcol += 7;
  
  	return physcol;
  }
***************
*** 367,373 ****
  	/* show the line number, if necessary */
  	if (*o_number)
  	{
! 		sprintf(numstr, "%6ld |", lno);
  		qaddstr(numstr);
  	}
  
--- 367,373 ----
  	/* show the line number, if necessary */
  	if (*o_number)
  	{
! 		sprintf(numstr, "%6ld ", lno);
  		qaddstr(numstr);
  	}
  
***************
*** 469,475 ****
  	/* now for the visible characters */
  	limitcol = leftcol + COLS;
  	if (*o_number)
! 		limitcol -= 8;
  	for (; (i = *text) && col < limitcol; text++)
  	{
  #ifndef NO_VISIBLE
--- 469,475 ----
  	/* now for the visible characters */
  	limitcol = leftcol + COLS;
  	if (*o_number)
! 		limitcol -= 7;
  	for (; (i = *text) && col < limitcol; text++)
  	{
  #ifndef NO_VISIBLE
***************
*** 640,646 ****
  			/* move the cursor by calling move() */
  			col = (int)(scan - new);
  			if (*o_number)
! 				col += 8;
  			move((int)(lno - topline), col);
  		}
  	}
--- 640,646 ----
  			/* move the cursor by calling move() */
  			col = (int)(scan - new);
  			if (*o_number)
! 				col += 7;
  			move((int)(lno - topline), col);
  		}
  	}
***************
*** 736,742 ****
  	/* now for the visible characters */
  	limitcol = leftcol + COLS;
  	if (*o_number)
! 		limitcol -= 8;
  	for (; (i = *text) && col < limitcol; text++)
  	{
  		if (i == '\t' && !*o_list)
--- 736,742 ----
  	/* now for the visible characters */
  	limitcol = leftcol + COLS;
  	if (*o_number)
! 		limitcol -= 7;
  	for (; (i = *text) && col < limitcol; text++)
  	{
  		if (i == '\t' && !*o_list)
***************
*** 798,804 ****
  		/* show the line number, if necessary */
  		if (*o_number)
  		{
! 			sprintf(numstr, "%6ld |", lno);
  			qaddstr(numstr);
  		}
  
--- 798,804 ----
  		/* show the line number, if necessary */
  		if (*o_number)
  		{
! 			sprintf(numstr, "%6ld ", lno);
  			qaddstr(numstr);
  		}
  
***************
*** 808,814 ****
  			qaddch(*scan);
  			*build++ = *scan++;
  		}
! 		if (end < new + COLS - (*o_number ? 8 : 0))
  		{
  			clrtoeol();
  			while (build < old + COLS)
--- 808,814 ----
  			qaddch(*scan);
  			*build++ = *scan++;
  		}
! 		if (end < new + COLS - (*o_number ? 7 : 0))
  		{
  			clrtoeol();
  			while (build < old + COLS)
***************
*** 826,832 ****
  	}
  	i = (scan - new);
  	if (*o_number)
! 		i += 8;
  	move((int)(lno - topline), i);
  
  	/* The in-between characters must be changed */
--- 826,832 ----
  	}
  	i = (scan - new);
  	if (*o_number)
! 		i += 7;
  	move((int)(lno - topline), i);
  
  	/* The in-between characters must be changed */
***************
*** 864,870 ****
  				shift[0] = shift[1];
  			}
  			if (*o_number)
! 				shift -= 8;
  			*shift = ' ';
  		}
  		else /* we must overwrite */
--- 864,870 ----
  				shift[0] = shift[1];
  			}
  			if (*o_number)
! 				shift -= 7;
  			*shift = ' ';
  		}
  		else /* we must overwrite */
***************
*** 881,887 ****
  	}
  
  	/* maybe clear to EOL */
! 	end = old + COLS - (*o_number ? 8 : 0);
  	while (build < end && *build == ' ')
  	{
  		build++;
--- 881,887 ----
  	}
  
  	/* maybe clear to EOL */
! 	end = old + COLS - (*o_number ? 7 : 0);
  	while (build < end && *build == ' ')
  	{
  		build++;


------- END OF PATCH -------

-- 
| Cloyce D. Spradling    |           cloyce@{ccwf.cc, cs}.utexas.edu           |
| No matter how you think, you're still only *simulating* logic! |   ENTROPY!  |