Subject: 9term mark patch

From: [email-masked] (Steve_Kilbane)
Date: Fri, 7 Apr 1995 04:49:42 -0400

This is a patch for 9term 1.6.3. It adds another toggled option to menu button 2,
with the values "mark" and "select". The former records the current position of
selected text, while the latter selects all text between the saved position and
the current selection, inclusive.

Enjoy,

steve

diff -c orig/9term.c hacked/9term.c
*** orig/9term.c	Fri Apr  7 08:39:32 1995
--- hacked/9term.c	Fri Apr  7 08:42:08 1995
***************
*** 25,36 ****
  int		waterquantum;
  int		beepmask;
  int		ninewm;
  
! static char	*items[] = { "cut", "paste", "snarf", "send", "scroll", 0 };
  static Menu	edit = {items};
  enum {	mCUT,
  	mPASTE,
  	mSNARF,
  	mSEND,
  	mSCROLL
  };
--- 25,39 ----
  int		waterquantum;
  int		beepmask;
  int		ninewm;
+ static long	mark0, mark1;
+ static int	markset;
  
! static char	*items[] = { "cut", "paste", "snarf", "mark", "send", "scroll", 0 };
  static Menu	edit = {items};
  enum {	mCUT,
  	mPASTE,
  	mSNARF,
+ 	mMARK,
  	mSEND,
  	mSCROLL
  };
***************
*** 398,403 ****
--- 401,407 ----
  	static Rune nl[] = { '\n', 0 };
  
  	specialchars(slave_fd);
+ 	edit.item[mMARK] = markset?"select":"mark";
  	edit.item[mSCROLL] = text->scrolling?"noscroll":"scroll";
  	switch (menuhit(2, m, &edit))
  	{
***************
*** 415,420 ****
--- 419,440 ----
  		if (text->snarfed) {
  			textdelete(text, text->p0, text->p1);
  			inputrune(text, text->snarfed, text->snarflen);
+ 		}
+ 		break;
+ 	case mMARK:			/* save point, or select to point */
+ 		if (markset) {
+ 			ulong m0, m1;
+ 
+ 			m0 = (mark0 < text->p0)? mark0 : text->p0;
+ 			m1 = (mark1 > text->p1)? mark1 : text->p1;
+ 			markset = 0;
+ 			if (m0 < text->base || text->end < m0)
+ 				textset(text, _backnl(text, m0, 3));
+ 			texthighlight(text,m0,m1, F & ~D);
+ 		} else {
+ 			mark0 = text->p0;
+ 			mark1 = text->p1;
+ 			markset = 1;
  		}
  		break;
  	case mSEND: