[net.sources] vc enhancements

afs@bunkerb.UUCP (Andrew F. Seirup) (01/18/85)

   Once I finally got the copy row command (^J) to work, I wondered why there
wasn't a copy column command.  So I added one (^K).  Why ^K?  It's close to
^J (why is it ^J?).  Change it if it makes a difference to you.

   Also, not having used EMACS heavily for several years, and having used vi,
rogue, and hack in the meanwhile, I had difficulty adjusting to the cursor
control commands.  Since h, j, k, and l where unused commands, (you guessed it)
I added them as alternates to ^B, ^N, ^P, and ^F, with the exception that they
won't work to move the entry cursor while entering a long command.  The code
is copied from the originals (as is ^K copied from ^J with the obvious changes).


Andrew Seirup - Bunker Ramo, Trumbull CT - (203)386-2086 
uucp address:  {decvax|ittvax}!bunker!afs


*** sc.c	Fri Jan 18 09:06:13 1985
--- sc.new	Thu Jan 17 16:01:04 1985
***************
*** 269,274
  		    if (curcol > maxcol)
  			curcol = 0;
  		    break;
  		case ctl (l):
  		    FullUpdate++;
  		    break;

--- 269,306 -----
  		    if (curcol > maxcol)
  			curcol = 0;
  		    break;
+ 		case ctl (k):
+ 		    if (curcol >= MAXCOLS - 1 || maxcol >= MAXCOLS - 1) {
+ 			error ("The table can't be any wider");
+ 			break;
+ 		    }
+ 		    modflg++;
+ 		    curcol++;
+ 		    opencol (curcol);
+ 		    for (currow = 0; currow <= maxrow; currow++) {
+ 			register struct ent *p = tbl[currow][curcol - 1];
+ 			if (p) {
+ 			    register struct ent *n;
+ 			    n = lookat (currow, curcol);
+ 			    n -> v = p -> v;
+ 			    n -> flags = p -> flags;
+ 			    n -> expr = copye (p -> expr, 0, 1);
+ 			    n -> label = 0;
+ 			    if (p -> label) {
+ 				n -> label = (char *)
+ 					     malloc (strlen (p -> label) + 1);
+ 				strcpy (n -> label, p -> label);
+ 			    }
+ 			}
+ 		    }
+ 		    for (currow = 0; currow <= maxrow; currow++) {
+ 			register struct ent *p = tbl[currow][curcol];
+ 			if (p && (p -> flags & is_valid) && !p -> expr)
+ 			    break;
+ 		    }
+ 		    if (currow > maxrow)
+ 			currow = 0;
+ 		    break;
  		case ctl (l):
  		    FullUpdate++;
  		    break;
***************
*** 424,429
  			    break;
  			case 'Q':
  			    running = 0;
  			    break;
  			default:
  			    if ((c & 0177) != c)

--- 456,493 -----
  			    break;
  			case 'Q':
  			    running = 0;
+ 			    break;
+ 			case 'h':
+ 			    while (--arg>=0) {
+ 				if (curcol)
+ 				    curcol--;
+ 				else
+ 				    error ("At column zero");
+ 			    }
+ 			    break;
+ 			case 'j':
+ 			    while (--arg>=0) {
+ 				if (currow < MAXROWS - 1)
+ 				    currow++;
+ 				else
+ 				    error ("The table can't be any longer");
+ 			    }
+ 			    break;
+ 			case 'k':
+ 			    while (--arg>=0) {
+ 				if (currow)
+ 				    currow--;
+ 				else
+ 				    error ("At row zero");
+ 			    }
+ 			    break;
+ 			case 'l':
+ 			    while (--arg>=0) {
+ 				if (curcol < MAXCOLS - 1)
+ 				    curcol++;
+ 				else
+ 				    error ("The table can't be any wider");
+ 			    }
  			    break;
  			default:
  			    if ((c & 0177) != c)

haddock@waltz.UUCP (01/28/85)

Andrew,

Many thanks for your use of the `vi' h,j,k, and l cursor motion
keys.   Definitely a blessing for us mortals that tend to shy
away from Emacs.   Alas, I don't believe that your ^K patch is
quite complete.

When you execute the ^K command the width and precision of the
duplicated column do not get carried over to the new (duplicate)
column.  The simple fix is to add the following two lines just
after the opencol() in the ctl(k) case you added [sc.c].

	fwidth[curcol] = fwidth[curcol-1];
	precision[curcol] = precision[curcol-1];

An even simpler modification would have been to change the
conditional in the proper for() loop in opencol() [sc.c].

	    for (i = maxcol - 1; i > cs; i--) {
				   ^-------------- change to >=
		fwidth[i] = fwidth[i-1];
		precision[i] = precision[i-1];
	    }
	    /* fwidth[cs] = DEFWIDTH;
	    precision[i] =  DEFPREC;  */

If done this way the "open column" command, 'c', would
open a column with the width and precision of the column to its
immediate left as opposed to the one the cursor was on when the
command was given.

Comments welcome.   Flames - dowse 'em and be nice instead.
================================================================
			   _____
	-Rusty-		|\/   o \    o
			|   (  -<  O o	   Where's the fish?
			|/\__V__/

ARPA:	Haddock%Waltz%TI-CSL@CSNet-Relay
	Rusty@Maryland (forwarded to CSNet address)
CSNet:	Haddock@TI-CSL
USENET:	{convex!smu, ut-sally, texsun, rice} ! waltz ! haddock
================================================================

Your diff would now look like this:

*** sc.c	Fri Jan 18 09:06:13 1985
--- sc.new	Thu Jan 17 16:01:04 1985
***************
*** 269,274
  		    if (curcol > maxcol)
  			curcol = 0;
  		    break;
  		case ctl (l):
  		    FullUpdate++;
  		    break;

--- 269,306 -----
  		    if (curcol > maxcol)
  			curcol = 0;
  		    break;
+ 		case ctl (k):
+ 		    if (curcol >= MAXCOLS - 1 || maxcol >= MAXCOLS - 1) {
+ 			error ("The table can't be any wider");
+ 			break;
+ 		    }
+ 		    modflg++;
+ 		    curcol++;
+ 		    opencol (curcol);
++			fwidth[curcol] = fwidth[curcol-1];
++			precision[curcol] = precision[curcol-1];
+ 		    for (currow = 0; currow <= maxrow; currow++) {
+ 			register struct ent *p = tbl[currow][curcol - 1];
+ 			if (p) {
+ 			    register struct ent *n;
+ 			    n = lookat (currow, curcol);
+ 			    n -> v = p -> v;
+ 			    n -> flags = p -> flags;
+ 			    n -> expr = copye (p -> expr, 0, 1);
+ 			    n -> label = 0;
+ 			    if (p -> label) {
+ 				n -> label = (char *)
+ 					     malloc (strlen (p -> label) + 1);
+ 				strcpy (n -> label, p -> label);
+ 			    }
+ 			}
+ 		    }
+ 		    for (currow = 0; currow <= maxrow; currow++) {
+ 			register struct ent *p = tbl[currow][curcol];
+ 			if (p && (p -> flags & is_valid) && !p -> expr)
+ 			    break;
+ 		    }
+ 		    if (currow > maxrow)
+ 			currow = 0;
+ 		    break;
  		case ctl (l):
  		    FullUpdate++;
  		    break;
***************