less, part 1 of 2

Jim Budler jimb at amdcad.UUCP
Thu Sep 19 10:30:48 AEST 1985


I made a few changes to version 40, which I called 40a and 40b.

40a :  Allows a terminal without reverse scroll or insert line
	to use less with the penalty of repainting the screen
	after every upward scroll command. i.e. if you go up one
	page the screen is repainted, but if you go up one line
	it is also repainted.  It still works the same way it 
	did when used with a smarter terminal.

40b :  Used execl() instead of system() to call the editor.  Added
	some signal handling around the fork() call to allow all this
	to work properly if you enter the editor, then stop the editor.

	One bad hack:  I #defined vfork() fork() near the beginning of
	command.c.  I should have done it in the Makefile.
----------------------< cut here >----------------------------------
*** /tmp/,RCSt1011254	Wed Sep 18 15:37:20 1985
--- command.c	Wed Sep 18 13:52:56 1985
***************
*** 3,8
   */
  
  #include "less.h"
  
  extern int erase_char, kill_char;
  extern int pr_type;

--- 3,11 -----
   */
  
  #include "less.h"
+ #include <sys/wait.h>
+ #include <signal.h>
+ #define fork() vfork()
  
  extern int erase_char, kill_char;
  extern int pr_type;
***************
*** 204,209
  	register int n;
  	register int scroll = 10;
  	register int last_mcc = 0;
  
  	mcc = 0;
  

--- 207,213 -----
  	register int n;
  	register int scroll = 10;
  	register int last_mcc = 0;
+ 	int id;
  
  	mcc = 0;
  
***************
*** 509,516
  			clear_eol();
  			flush();
  			raw_mode(0);
! 			sprintf(cmdbuf, "%s %s", editor, current_file);
! 			system(cmdbuf);
  			raw_mode(1);
  			first_cmd = "R";
  			break;

--- 513,531 -----
  			clear_eol();
  			flush();
  			raw_mode(0);
! 			if ( fork() == 0 ) {
! 				execl(editor, editor, current_file, 0 );
! 				write ( 2, "exec failed\n", 12);
! 				_exit(1);
! 			}
! 			signal(SIGINT,SIG_IGN);
! 			signal(SIGQUIT,SIG_IGN);
! #ifdef SIGTSTP
! 			signal(SIGTSTP,SIG_DFL);
! #endif
! 
! 			wait(0);
! 			init_signals();
  			raw_mode(1);
  			first_cmd = "R";
  			break;
*** /tmp/,RCSt1011265	Wed Sep 18 15:38:21 1985
--- prim.c	Thu Sep 12 14:50:24 1985
***************
*** 6,11
  #include "position.h"
  
  public int hit_eof;
  
  extern int quiet;
  extern int top_search;

--- 6,12 -----
  #include "position.h"
  
  public int hit_eof;
+ extern int noaddline;
  
  extern int quiet;
  extern int top_search;
***************
*** 116,124
  		 * Display the line on the screen.
  		 */
  		add_back_pos(pos);
! 		home();
! 		add_line();
! 		put_line();
  	}
  }
  

--- 117,131 -----
  		 * Display the line on the screen.
  		 */
  		add_back_pos(pos);
! 		if ( noaddline == 0 ) {
! 			home();
! 			add_line();
! 			put_line();
! 		}
! 	}
! 	if ( noaddline == 1) {
! 		clear();
! 		repaint();
  	}
  }
  
*** /tmp/,RCSt1011277	Wed Sep 18 15:40:09 1985
--- screen.c	Thu Sep 12 15:17:11 1985
***************
*** 39,44
  static int dumb;
  static int hard;
  
  public int auto_wrap;		/* Terminal does \r\n when write past margin */
  public int ignaw;		/* Terminal ignores \n immediately after wrap */
  public int erase_char, kill_char; /* The user's erase and line-kill chars */

--- 39,45 -----
  static int dumb;
  static int hard;
  
+ 
  public int auto_wrap;		/* Terminal does \r\n when write past margin */
  public int ignaw;		/* Terminal ignores \n immediately after wrap */
  public int noaddline = 0;		/* Terminal doesn't reverse scroll */
***************
*** 41,46
  
  public int auto_wrap;		/* Terminal does \r\n when write past margin */
  public int ignaw;		/* Terminal ignores \n immediately after wrap */
  public int erase_char, kill_char; /* The user's erase and line-kill chars */
  public int sc_width, sc_height;	/* Height & width of screen */
  public int ul_width, ue_width;	/* Printing width of underline sequences */

--- 42,48 -----
  
  public int auto_wrap;		/* Terminal does \r\n when write past margin */
  public int ignaw;		/* Terminal ignores \n immediately after wrap */
+ public int noaddline = 0;		/* Terminal doesn't reverse scroll */
  public int erase_char, kill_char; /* The user's erase and line-kill chars */
  public int sc_width, sc_height;	/* Height & width of screen */
  public int ul_width, ue_width;	/* Printing width of underline sequences */
***************
*** 323,328
  	{
  		cannot("scroll backwards");
  		sc_addline = "";
  	}
  
  	if (dumb || tgetflag("bs"))

--- 325,331 -----
  	{
  		cannot("scroll backwards");
  		sc_addline = "";
+ 		noaddline = 1;
  	}
  
  	if (dumb || tgetflag("bs"))
*** /tmp/,RCSt1011289	Wed Sep 18 15:41:31 1985
--- version.c	Wed Sep 18 14:59:07 1985
***************
*** 69,74
   *	v38: Changed prompting; created prompt.c.	8/19/85   mark
   *	v39: (Not -p) does not initially clear screen.	8/24/85   mark
   *	v40: Added "skipping" indicator in forw().	8/26/85   mark
   *	-----------------------------------------------------------------
   */
  

--- 69,76 -----
   *	v38: Changed prompting; created prompt.c.	8/19/85   mark
   *	v39: (Not -p) does not initially clear screen.	8/24/85   mark
   *	v40: Added "skipping" indicator in forw().	8/26/85   mark
+  *      v40a: Added repaint to reverse scrolling for 'dumb' 9/12/85 jcb
+  *      v40b: Replaced system() with fork() and execl() for editor 9/18/85 jcb
   *	-----------------------------------------------------------------
   */
  
***************
*** 72,75
   *	-----------------------------------------------------------------
   */
  
! char version[] = "@(#) less  version 40";

--- 74,77 -----
   *	-----------------------------------------------------------------
   */
  
! char version[] = "@(#) less  version 40b";
-- 
 Jim Budler
 Advanced Micro Devices, Inc.
 (408) 749-5806
 UUCPnet: {ucbvax,decwrl,ihnp4,allegra,intelca}!amdcad!jimb
 Compuserve:	72415,1200

"... Don't sue me, I'm just the piano player!...."



More information about the Comp.sources.unix mailing list