From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 28-APR-1989 12:05
To:	MRGATE::"ARISIA::EVERHART"
Subj:	MORE/TPU: File 3 of 3

Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Fri, 28 APR 89 07:43:02 PDT
Received: from ucbvax.Berkeley.EDU by KL.SRI.COM with TCP; Fri, 28 Apr 89 07:17:40 PDT
Received: by ucbvax.Berkeley.EDU (5.61/1.36)
	id AA22910; Fri, 28 Apr 89 07:07:53 -0700
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 28 Apr 89 12:48:10 GMT
From: mailrus!uflorida!haven!umbc3!rostamia@tut.cis.ohio-state.edu  (Rouben Rostamian)
Organization: Univ of Maryland Baltimore County
Subject: MORE/TPU: File 3 of 3
Message-Id: <1961@umbc3.UMBC.EDU>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com


+-+-+-+ Beginning of part 3 +-+-+-+
Xif more$saved_command = "" then more$ring_bell (' No previous command ')
Xelse if more$saved_command = "cr" then more$cr_scroll;
Xelse if more$saved_command = "d" then more$d_scroll;
Xelse if more$saved_command = "u" then more$u_scroll;
Xelse if more$saved_command = "z" then more$z_scroll;
X!else if more$saved_command = "h" then more$give_help;
Xelse if more$saved_command = "N" then more$get_next_file;
Xelse if more$saved_command = "P" then more$get_previous_file;
Xelse if more$saved_command = "G" then more$get_file_by_number;
Xelse if more$saved_command = "L" then more$list_files;
X!else if (more$saved_command = "/") or (more$saved_command = "?") then
X!           more$new_search := FALSE;
X!           more$get_old_string;
X!           more$search_for_string;`032
Xelse if more$saved_command = " " then
X                           more$number := more$saved_number;
X                           more$numeric_mode := TRUE;
X                           more$space_scroll;
Xelse if more$saved_command = "b" then
X                           more$number := more$saved_number;
X                           more$numeric_mode := TRUE;
X                           more$back_scroll;
Xelse if more$saved_command = "f" then
X                           more$number := more$saved_number;
X                           more$numeric_mode := TRUE;
X                           more$forward_scroll;
Xelse if more$saved_command = "g" then
X                           more$number := more$saved_number;
X                           more$numeric_mode := TRUE;
X                           more$goto_line;
Xendif; endif; endif; endif; endif; endif;  endif;`032
Xendif; endif; endif; endif; endif; endif;`032
XENDPROCEDURE;
X
XPROCEDURE more$show_line_number
XLOCAL lines_seen, extra_info;
Xif more$show_long_status_line = TRUE then
X  lines_seen := more$top_line_number + more$main_window_rows - 1;
X  if lines_seen > more$lines_in_buffer then
X    lines_seen := more$lines_in_buffer;
X  endif;
X  extra_info :=
X      fao('   [File !SL/!SL]  !AS   [!SL line!%S of !SL line!%S]',
X                    more$current_file_number, more$total_files,
X                    more$short_file`123more$current_file_number`125
X                    , lines_seen, more$lines_in_buffer);
X  more$numeric_mode := FALSE;
X  more$number := 0;
X  message (more$standard_caption + extra_info);
X  more$show_long_status_line := FALSE;
Xelse
X  message (more$standard_caption);
X  more$show_long_status_line := TRUE;
Xendif;
XENDPROCEDURE;
X
XPROCEDURE more$give_help
X! Displays the contents of the help file MORE$DIR:MORE.HELP
X
XLOCAL this_key, this_buffer, last_buffer;
X
X! Save current buffer
X  this_buffer := current_buffer;
X
X! Check if the Help buffer has already been created.  If not, then create it.
X! ASSUME THAT THE HELP BUFFER IS THE LAST BUFFER CREATED IN MORE.
X  last_buffer := get_info (buffers, "last");
X  if last_buffer <> help_buffer then
X    ! Create a buffer and a window for HELP
X    help_buffer := create_buffer ("Help Buffer");          `032
X    set (no_write, help_buffer);                           `032
X    set (system, help_buffer);                             `032
X    set (EOB_TEXT, help_buffer, "[End of Help Buffer]");   `032
X    position(help_buffer);                                 `032
X    read_file ("more$dir:more.help");                      `032
X  endif;
X`032
X  message ("");                                          `032
X  position(beginning_of(help_buffer));                   `032
X  unmap (main_window);
X  map(main_window, help_buffer);
X  update(main_window);
X  message (
V' Press <Next Screen> or <Prev Screen> for more help, <Return> if done   `032
X    ');
X  loop
X    this_key := read_key;
X    exitif (this_key = RET_KEY) or (this_key = key_name("q"));
X    if this_key = E5 then
X      scroll (current_window, - more$d_scrollamount);
X    else if this_key = E6 then
X      scroll (current_window, more$d_scrollamount);
X    endif; endif;
X  endloop;
X  message ("");
X  unmap(main_window);
X  map (main_window, this_buffer);
X  update(main_window);
X!  more$saved_command := "h";
X  more$numeric_mode := FALSE;
X  more$number := 0;
X  message (more$standard_caption);
XENDPROCEDURE;
X
XPROCEDURE more$get_line_number
X
Xlocal  total_lines, line_no, search_direction, search_increment,
X       line_marker, current_mark, percent, original_position;
X
Xoriginal_position := mark(none);
Xtotal_lines := get_info(current_buffer, 'record_count');
Xposition(search(line_begin,reverse));
Xline_marker := mark(none);   ! mark current position
Xposition(beginning_of(current_buffer));
Xsearch_direction := 1;   ! search forward
Xsearch_increment := total_lines/2;
Xline_no := 1;
Xcurrent_mark := mark(none);
X
Xloop
X  ! Search for the marker  by halving the buffer in each iteration:
X  exitif (search_increment = 0) or (current_mark = line_marker);
X  move_vertical(search_direction*search_increment);
X  line_no := line_no + search_direction*search_increment;
X  current_mark := mark(none);
X  if current_mark > line_marker then
X    search_direction := -1;  ! go backward
X  else ! current_mark < line_marker then
X    search_direction := 1;   ! go forward
X  endif;
X  search_increment := search_increment/2;
Xendloop;
X
Xif current_mark <> line_marker then
X  ! Step in increments of one line at a time:
X  loop
X    move_vertical(search_direction);
X    line_no := line_no + search_direction;
X    current_mark := mark(none);
X    exitif current_mark =  line_marker;
X  endloop;
Xendif;
X
X  RETURN (line_no);
XENDPROCEDURE;
X
X
XPROCEDURE more$ring_bell (line_to_display);
X    set (bell, all, on);
X    if line_to_display = "" then
X      message (more$standard_caption);
X    else
X      message (line_to_display);
X    endif;
X    set (bell, all, off);
X    set (bell, broadcast, on);
XENDPROCEDURE;
X
XPROCEDURE more$standard_caption
XLOCAL percent, caption, lines_seen;
X  lines_seen := more$top_line_number + more$main_window_rows - 1;
X  percent := (((lines_seen * 1000) / more$lines_in_buffer)+5)/10;
X  if percent > 100 then percent := 100; endif;  ! Needed for short files
X  caption :=  fao ('--More--(!SL%) ', percent);
X  return (caption);
XENDPROCEDURE;
X
X
XSAVE('MORE$SECTION.TPU$SECTION');
XQUIT;
$ GOSUB UNPACK_FILE

$ FILE_IS = "MORE_EDIT.COM"
$ CHECKSUM_IS = 1517775387
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X! Command procedure for alternating between EVE and MORE.  This command
X! procedure is called by MORE and should not be run at the user level.
X!`032
X! Parameters:
X!   p1:  File to edit
X!   p2:  "" or "*"  (exit flag)
X!
V! When asked to go to edit mode, MORE creates a subprocess which executes thi
Xs`032
V! file which, in turn, does edit/tpu. After exiting the editor, if p2 is ""`0
X32
V! then contol returns to MORE which then issues a QUIT and end the session. `
X032
V! If p2 is "*" then another MORE session is started which reads in the recent
Xly
X! edited file.`032
X
X$ set noon
X$ esc[0,8] = 27
X$ csi := "''esc'["
X$ cursor_off := "''csi'?25l"
X$ cursor_on := "''csi'?25h"
X$!
X$ on control_y then exit
X$ write sys$output cursor_on
X$ define/user/nolog sys$input sys$command`032
X$ edit/tpu 'p1'
X$ if p2 .eqs. "*" then exit
X$ write sys$output cursor_off
X$ define/user/nolog sys$input sys$command`032
X$ edit/tpu/section=faculty:[rostamian.more]more$section.tpu$section 'p1'
X$ exit
$ GOSUB UNPACK_FILE
$ EXIT
-+-+-+-+-+ End of part 3 +-+-+-+-+-
-- 
Rouben Rostamian
Department of Mathematics                      e-mail:
University of Maryland Baltimore Counnty       Rostamian@umbc2.bitnet
Baltimore, MD 21228                            rostamia@umbc3.umbc.edu

