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

Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Fri, 28 APR 89 07:43:45 PDT
Received: from ucbvax.Berkeley.EDU by KL.SRI.COM with TCP; Fri, 28 Apr 89 07:33:08 PDT
Received: by ucbvax.Berkeley.EDU (5.61/1.36)
	id AA22903; Fri, 28 Apr 89 07:07:41 -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:47:11 GMT
From: mailrus!uflorida!haven!umbc3!rostamia@tut.cis.ohio-state.edu  (Rouben Rostamian)
Organization: Univ of Maryland Baltimore County
Subject: MORE/TPU: File 2 of 3
Message-Id: <1960@umbc3.UMBC.EDU>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com


+-+-+-+ Beginning of part 2 +-+-+-+
X                                       more$get_old_string;
X                                       more$search_for_string;
X                 else if ch = "p" then more$search_mode := reverse;`032
X                                       more$search_promot := "?";`032
X                                       more$new_search := FALSE;
X                                       more$get_old_string;
X                                       more$search_for_string;
X                 else if ch = "/" then more$search_mode := forward;`032
X                                       more$search_prompt := "/";`032
X                                       more$search;
X                 else if ch = "?" then more$search_mode := reverse;`032
X                                       more$search_prompt := "?";`032
X                                       more$search;
X                 else if ch = "v" then more$edit_file_recursive;
X                 else if ch = "V" then more$edit_file_nonrecursive;
X                 else if ch = "N" then more$get_next_file;
X                 else if ch = "P" then more$get_previous_file;
X                 else if ch = "G" then more$get_file_by_number;
X                 else if ch = "L" then more$list_files;
X                 else more$numeric_mode := FALSE;
X                      more$number := 0; more$ring_bell ("");
V                 endif; endif; endif; endif; endif; endif; endif; endif; endi
Xf;
V                 endif; endif; endif; endif; endif; endif; endif; endif; endi
Xf;
X                 endif; endif; endif; endif;
X  ENDCASE;
X  if not ( (more$saved_command = "N") or`032
X           (more$saved_command = "P") or`032
X           (more$saved_command = "G") or`032
X           (ch = "=") ) then`032
X    more$show_long_status_line := TRUE;`032
X  endif;
X
X  if (ch = "/") or (ch = "?") or (ch = "n") or (ch = "p") then
X    more$numeric_mode := FALSE;
X    more$number := 0;
X    more$searching := TRUE;
X  else`032
X    if (ch = "." ) and (more$searching = TRUE) then
X       more$searching := TRUE
X    else
X       more$searching := FALSE;
X    endif;
X  endif;
X
XENDLOOP;
Xmessage(""); ! to erase message buffer
XENDPROCEDURE;
X
XPROCEDURE more$get_next_file
X  if more$current_file_number = more$total_files then
X    more$ring_bell (more$standard_caption + '    No next file ');     `032
X  else
X    message ('');
X    unmap (main_window);
X    more$current_file_number := more$current_file_number + 1;
X    main_buffer := more$buffer`123more$current_file_number`125;
X    more$lines_in_buffer := get_info (main_buffer, 'RECORD_COUNT');
X    more$top_line_number := 1;
X    more$saved_position := beginning_of (current_buffer);
X    map ( main_window, main_buffer);
X    position(beginning_of(main_buffer));
X    more$show_long_status_line := TRUE;
X    more$show_line_number;
X    update(main_window);
X  endif;
X  more$saved_command := "N";
X  more$numeric_mode := FALSE;
X  more$number := 0;
XENDPROCEDURE;
X
XPROCEDURE more$get_previous_file
X  if more$current_file_number = 1 then
X    more$ring_bell (more$standard_caption + '    No previous file ');
X  else
X    message ('');
X    unmap (main_window);
X    more$current_file_number := more$current_file_number - 1;
X    main_buffer := more$buffer`123more$current_file_number`125;
X    more$lines_in_buffer := get_info (main_buffer, 'RECORD_COUNT');
X    more$top_line_number := 1;
X    more$saved_position := beginning_of (current_buffer);
X    map ( main_window, main_buffer);
X    position(beginning_of(main_buffer));
X    more$show_long_status_line := TRUE;
X    more$show_line_number;
X    update(main_window);
X  endif;
X  more$saved_command := "P";
X  more$numeric_mode := FALSE;
X  more$number := 0;
XENDPROCEDURE;
X
XPROCEDURE more$get_file_by_number
X  if more$numeric_mode = FALSE then
X    more$ring_bell (' No file number specified ');
X  else
X    if more$number = 0 then
X      more$ring_bell (' Zero is not a file number ');
X    else
X      if more$number > more$total_files then
X        if more$total_files = 1 then
X          more$ring_bell (' No other files present ');
X        else
X          more$ring_bell (
V                fao(' There are only !SL files present ', more$total_files) )
X;
X        endif;
X      else
X        message ('');
X        unmap (main_window);
X        more$current_file_number := more$number;
X        main_buffer := more$buffer`123more$current_file_number`125;
X        more$lines_in_buffer := get_info (main_buffer, 'RECORD_COUNT');
X        more$top_line_number := 1;
X        more$saved_position := beginning_of (current_buffer);
X        map ( main_window, main_buffer);
X        position(beginning_of(main_buffer));
X        more$show_long_status_line := TRUE;
X        more$show_line_number;
X        update(main_window);
X      endif;
X    endif;
X  endif;
X  more$saved_command := "G";
X  more$numeric_mode := FALSE;
X  more$number := 0;
XENDPROCEDURE;
X
XPROCEDURE more$list_files
XLOCAL this_buffer, this_key;
X  message ('');
X  this_buffer := current_buffer;
X  unmap (main_window);
X  map ( main_window, list_buffer);
X  update (main_window);
X  message (
X    ' Press <Next Screen> or <Prev Screen> to scroll, <Return> if done ');
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 (current_window);
X  map ( main_window, this_buffer);
X  update (main_window);
X  more$saved_command := "L";
X  more$number := 0;
X  more$numeric_mode := FALSE;
X  message (more$standard_caption);
XENDPROCEDURE;
X
XPROCEDURE more$edit_file_recursive
X! Will start a new MORE after edit ends
X  message ("Preparing to edit.  Please wait...");
V  spawn("@more$dir:more_edit " + more$file`123more$current_file_number`125, o
Xn);
X  QUIT;
XENDPROCEDURE;
X
XPROCEDURE more$edit_file_nonrecursive
X! Will return here and will quit MORE after edit ends
X  message ("Preparing to edit.  Please wait...");
V  spawn("@more$dir:more_edit " + more$file`123more$current_file_number`125+ "
X *", on);
X  QUIT;
XENDPROCEDURE;
X
X
XPROCEDURE more$goto_line
XLOCAL this_row, additional_caption, beyond_end, beyond_top;
X
X  beyond_end := FALSE;
X  beyond_top := FALSE;
X
X  if more$numeric_mode = FALSE  then
X    more$number := more$lines_in_buffer;  ! Default action
X  else if more$number > more$lines_in_buffer then
X    more$saved_number := more$number;
X    more$number := more$lines_in_buffer;
X    beyond_end := TRUE;
X  else if more$number = 0 then
X    more$saved_number := 0;
X    more$number := 1;
X    beyond_top := TRUE;
X  endif; endif; endif;
X
X  message ("");   ! clear message window;
X
X  position (beginning_of (current_buffer));
X  move_vertical (more$number - 1);
X  update (current_window);
X
X  this_row := CURRENT_ROW;
X  if this_row <> 1 then
X    move_vertical ( - (this_row - 1) );
X  endif;
X  update (current_window);
X
X  more$top_line_number := more$get_line_number;
X  if beyond_end then
X    additional_caption :=
X              fao ('        File has only !SL line!%S.  (Now at the end.) ',
X                                                    more$lines_in_buffer);
X    more$ring_bell ( more$standard_caption + additional_caption);
X  else if beyond_top then
X    additional_caption :=
X         '        Can''t go to line zero.   (Now at the top.) ';
X    more$ring_bell ( more$standard_caption + additional_caption);
X  else
X    message (more$standard_caption);
X    more$saved_number := more$number;
X  endif; endif;
X
X  more$number := 0;
X  more$numeric_mode := false;
X  more$saved_command := "g";
X
XENDPROCEDURE;
X
XPROCEDURE more$goto_previous_mark
X  position (more$saved_position);
X  position (search (line_begin, reverse));
V  if mark (none) <> beginning_of (current_buffer) then move_vertical(-1) endi
Xf;
V  if mark (none) <> beginning_of (current_buffer) then move_vertical(-1) endi
Xf;
X  update (main_window);
X  more$top_line_number := more$get_line_number;
X  message (more$standard_caption);
XENDPROCEDURE;
X
XPROCEDURE more$search`032
X  more$pre_search_position := mark (none);
X  more$no_prev_string := FALSE;
X  more$string_to_find := read_line (more$search_prompt);
X  if more$string_to_find = "" then
X    more$new_search := FALSE;   ! Continuing the old search
X    more$get_old_string
X  endif;
X
X  if more$no_prev_string = TRUE then
X    return;
X  endif;
X
X  more$new_search := TRUE;   ! Starting a new search
X  more$saved_string := more$string_to_find;
X  more$search_for_string;
X
XENDPROCEDURE;
X
XPROCEDURE more$get_old_string
Xif more$saved_string = "" then
X  more$ring_bell (more$standard_caption + '   Nothing to find ');
X  more$no_prev_string := TRUE;
X  return;
Xendif;
X
Xmore$string_to_find := more$saved_string;
X
Xif (more$new_search = FALSE) and (more$searching = TRUE) then
X  position (more$saved_position);`032
Xendif;
X
Xif more$search_mode = FORWARD then
X  move_horizontal (1)
Xelse
X  move_horizontal (-1)
Xendif;
XENDPROCEDURE;
X
XPROCEDURE more$how_to_search
X! Search "exact" if the target is a mix of upper- and lower-case letters.
X! Otherwise, search "no_exact".
XLOCAL lowercase_target;
X    lowercase_target := more$string_to_find;
X    change_case ( lowercase_target, lower);
X    if lowercase_target = more$string_to_find then
X      RETURN (no_exact);
X    else
X      RETURN (exact);
X    endif;
XENDPROCEDURE;
X
X`032
XPROCEDURE more$search_for_string
XLOCAL found_range, last_char, display_range, here;
X
XON_ERROR         ! Trap "String not found error messages
XENDON_ERROR;
X
Xfound_range :=`032
X          search (more$string_to_find, more$search_mode, more$how_to_search);
X  if found_range = 0 then
X    message ('');
X    more$ring_bell (' String not found ');
X    position (more$pre_search_position);
X  else
X    position (end_of(found_range));
X    last_char := mark(none);
X    position (beginning_of(found_range));
X    more$saved_position := mark(none);
X    display_range := create_range ( more$saved_position, last_char, reverse);
X    move_vertical(-2);
X    move_horizontal (-current_offset);
X    update(main_window);
X    more$top_line_number := more$get_line_number;
X    message (more$standard_caption);
X  endif;
XENDPROCEDURE;
X
X
XPROCEDURE more$cr_scroll
XLOCAL lines_scrolled, lines_requested;
X  if more$numeric_mode = TRUE then
X    more$cr_scrollamount := more$number;
X    more$numeric_mode := false;
X    more$number := 0;
X  endif;
X  message ('');
X  lines_requested := more$cr_scrollamount;
X  lines_scrolled := scroll(main_window, lines_requested);
X  more$top_line_number := more$top_line_number + lines_scrolled;
X  if lines_scrolled <> lines_requested then more$ring_bell (""); endif;
X  more$saved_command := "cr";
X  message (more$standard_caption);
XENDPROCEDURE;
X
XPROCEDURE more$d_scroll
XLOCAL lines_scrolled, lines_requested;
X  if more$numeric_mode = TRUE then
X    more$d_scrollamount := more$number;
X    more$numeric_mode := false;
X    more$number := 0;
X  endif;
X  lines_requested := more$d_scrollamount;
X  message ("");
X  lines_scrolled := scroll(main_window, lines_requested);
X  more$top_line_number := more$top_line_number + lines_scrolled;
X  if lines_scrolled <> lines_requested then more$ring_bell (""); endif;
X  more$saved_command := "d";
X  message (more$standard_caption);
XENDPROCEDURE;
X
XPROCEDURE more$u_scroll
XLOCAL lines_scrolled, lines_requested;
X  if more$numeric_mode = TRUE then
X    more$d_scrollamount := more$number;
X    more$numeric_mode := false;
X    more$number := 0;
X  endif;
X  lines_requested := - more$d_scrollamount;
X  message ("");
X  lines_scrolled := scroll(main_window, lines_requested);
X  more$top_line_number := more$top_line_number + lines_scrolled;
X  if lines_scrolled <> lines_requested then more$ring_bell (""); endif;
X  more$saved_command := "u";
X  message (more$standard_caption);
XENDPROCEDURE;
X
XPROCEDURE more$space_scroll
XLOCAL lines_scrolled, lines_requested;
X  if more$numeric_mode = TRUE then
X    lines_requested := more$number;
X    more$saved_number := more$number;
X    more$numeric_mode := false;
X    more$number := 0;
X  else
X    lines_requested := more$pagesize;
X    more$saved_number := more$pagesize;
X  endif;
X  message ("");
X  lines_scrolled := scroll(main_window, lines_requested);
X  more$top_line_number := more$top_line_number + lines_scrolled;
X  if lines_scrolled <> lines_requested then more$ring_bell (""); endif;
X  more$saved_command := " ";
X  message (more$standard_caption);
XENDPROCEDURE;
X
XPROCEDURE more$z_scroll
XLOCAL lines_scrolled, lines_requested;
X  if more$numeric_mode = TRUE then
X    more$pagesize := more$number;
X    more$numeric_mode := false;
X    more$number := 0;
X    more$d_scrollamount := more$pagesize / 2;
X    more$saved_number := more$pagesize;
X  endif;
X  lines_requested := more$pagesize;
X  message ("");
X  lines_scrolled := scroll(main_window, lines_requested);
X  more$top_line_number := more$top_line_number + lines_scrolled;
X  if lines_scrolled <> lines_requested then more$ring_bell (""); endif;
X  more$saved_command := " ";
X  message (more$standard_caption);
XENDPROCEDURE;
X
XPROCEDURE more$back_scroll
XLOCAL lines_scrolled, lines_requested, pages_requested;
X  if more$numeric_mode = TRUE then
X    pages_requested := more$number;
X    more$saved_number := more$number;
X    more$numeric_mode := false;
X    more$number := 0;
X  else
X    pages_requested := 1;
X    more$saved_number := 1;
X  endif;
X  lines_requested := - pages_requested * more$pagesize;
X  message( fao('...back !SL page!%S ', pages_requested));
X  set (scrolling, main_window, off, 0, more$main_window_rows, 0);
X  lines_scrolled := scroll(main_window, lines_requested);
X  set (scrolling, main_window, on, 0, more$main_window_rows, 0);
X  more$top_line_number := more$top_line_number + lines_scrolled;
X  if lines_scrolled <> lines_requested then more$ring_bell (""); endif;
X  more$saved_command := "b";
X  message (more$standard_caption);
XENDPROCEDURE;
X
XPROCEDURE more$forward_scroll
XLOCAL lines_scrolled, lines_requested;
X  if more$numeric_mode = TRUE then
X    lines_requested :=  (1 + more$number) * more$pagesize;
X    more$saved_number := more$number;
X    more$numeric_mode := false;
X    more$number := 0;
X  else
X    lines_requested := 2 * more$pagesize;
X    more$saved_number := 1;
X  endif;
X  message( fao('...skipping !SL lines ', lines_requested - more$pagesize));
X  set (scrolling, main_window, off, 0, more$main_window_rows, 0);
X  lines_scrolled := scroll(main_window, lines_requested);
X  set (scrolling, main_window, on, 0, more$main_window_rows, 0);
X  more$top_line_number := more$top_line_number + lines_scrolled;
X  if lines_scrolled <> lines_requested then more$ring_bell (""); endif;
X  more$saved_command := "f";
X  message (more$standard_caption);
XENDPROCEDURE;
X
XPROCEDURE more$repeat_command
Xmessage ('');
-+-+-+-+-+ End of part 2 +-+-+-+-+-
-- 
Rouben Rostamian
Department of Mathematics                      e-mail:
University of Maryland Baltimore Counnty       Rostamian@umbc2.bitnet
Baltimore, MD 21228                            rostamia@umbc3.umbc.edu

