! LSE$EVE_EDIT.TPU ! !************************************************************************* ! * ! © Copyright 2005 Hewlett-Packard Development Company, L.P. * ! * ! Confidential computer software. Valid license from HP required for * ! possession, use or copying. Consistent with FAR 12.211 and 12.212, * ! Commercial Computer Software, Computer Software Documentation, and * ! Technical Data for Commercial Items are licensed to the U.S. * ! Government under vendor's standard commercial license. * ! * !************************************************************************* ! !++ ! FACILITY: ! VAX Language-Sensitive Editor ! ! ABSTRACT: ! This file contains superceded EVE procedures that are located in the ! file EVE$EDIT.TPU. ! ! ENVIRONMENT: ! VAX/VMS ! ! CREATION DATE: 21-DEC-1989 ! ! MODIFIED BY: ! ! X3.1-1 DAS 21-Dec-89 First pass. ! X3.1-2 DAS 06-Apr-90 Stop superceding of EVE_TOP. The correct procedure ! to call is now LSE_TOP. ! X3.2 WC3 01-Oct-90 Use get_info( lse$search, 'lse$auto_reverse' ) ! instead of lse$$x_search_all ! X3.2-1 NMC 09-Oct-90 Supercede eve_move_by_line for overview lines in lse ! X3.2-2 DAS 23-Oct-90 Changed LSE_TOP to LSE$TOP ! X3.2-3 NMC 23-Oct-90 Add error message to eve_move_by_line at eob and bob ! X3.2-4 AVH 29-Nov-90 Changed LSE$$WIDGET_REPLACE to ! LSE$$SUBSTITUTE_DIALOG ! X3.2-5 GJJ 27-Feb-91 Applied TPU 3.0 FT3 name conversions for widget ! resource names and callback reasons; updated ! the copyright notice. ! X4.0-1 WC3 11-Jul-91 Replace use of eve$display_choices ! w/lse$prompt_list_buffer ! X4.0-2 WC3 31-Jul-91 Use lse$prompt_boolean for reverse direction stuff ! X4.0-3 DAS 27-Oct-91 Added LOCAL MARK_FLAG ! X4.0-4 DAS 14-Nov-91 Empty module init ! X4.0-5 SHE 25-Aug-92 Use lse$$$get_repeat_count instead of directly ! reference eve$x_repeat_count. ! X4.3-1 RKB 26-Oct-94 Add calls to the following builtins in ! eve$$replace_loop ! - LSE$$START_SUBSTITUTE ! _ LSE$$END_SUBSTITUTE ! - LSE$$ADD_SUBSTITUTE_ENTRY ! X4.3-2 RKB 23-Jan-95 Add call to save inserted text !- procedure lse$eve_edit_module_ident return "4.7-3"; endprocedure; ! EVE$EDIT.TPU Page 4 procedure eve_move_by_page ! Move to next page break local saved_mark, ! Marker where we started saved_scrolls, ! Boolean set if saved_scroll_xxx valid saved_scroll_top, ! Original value of scroll_top saved_scroll_bottom, ! Original value of scroll_bottom saved_scroll_amount, ! Original value of scroll_amount window_length, ! For finding bottom of scroll region current_repeat_count; on_error [TPU$_CONTROLC]: if saved_scrolls then set (SCROLLING, current_window, ON, saved_scroll_top, saved_scroll_bottom, saved_scroll_amount); update (current_window); endif; eve$learn_abort; abort; [TPU$_STRNOTFOUND]: if current_window = eve$prompt_window then eve$learn_abort; return (FALSE); endif; if current_direction = FORWARD then position (end_of (current_buffer)); if mark (NONE) <> saved_mark then eve$message (EVE$_NONEXTPAGE); endif; else ! ! ### LSE CHANGE ! position (beginning_of (current_buffer)); ! lse$top; ! ! ### end of LSE change ! if mark (NONE) <> saved_mark then eve$message (EVE$_NOPREVPAGE); endif; endif; [OTHERWISE]: if saved_scrolls then set (SCROLLING, current_window, ON, saved_scroll_top, saved_scroll_bottom, saved_scroll_amount); update (current_window); endif; endon_error; if not eve$declare_intention (eve$k_action_reposition) then return (FALSE); endif; saved_mark := mark (FREE_CURSOR); ! prevent padding position (TEXT); ! snap cursor to prevent padding position (search (PAGE_BREAK, current_direction, EXACT)); ! want error if none if (( mark (NONE) = saved_mark ) or ( NOT (lse$is_visible) )) then ! ! LSE change, search visible page break ! loop if current_direction = FORWARD then move_horizontal(1); else move_horizontal(-1); endif; position (search (PAGE_BREAK, current_direction, EXACT)); ! want error if none exitif lse$is_visible; endloop; ! ! end of change ! endif; current_repeat_count := lse$$$get_repeat_count; ! Only position the cursor on the last repeat count if current_repeat_count <= 1 then ! save old scrolling region saved_scroll_amount := get_info (current_window, "scroll_amount"); saved_scroll_bottom := get_info (current_window, "scroll_bottom"); saved_scroll_top := get_info (current_window, "scroll_top"); saved_scrolls := TRUE; ! for error handler window_length := get_info (current_window, "visible_bottom") - get_info (current_window, "visible_top"); ! find # of lines from bottom to place cursor window_length := window_length - saved_scroll_top; ! quickly force cursor to top of screen set (SCROLLING, current_window, ON, saved_scroll_top, window_length, 0); update (current_window); ! be sure to show it ! reset old scrolling region set (SCROLLING, current_window, ON, saved_scroll_top, saved_scroll_bottom, saved_scroll_amount); endif; return (TRUE); endprocedure; ! EVE$EDIT.TPU Page 9 procedure eve_line ! Go to line number in buffer (line_parameter, ! Line number to move to - input procedure_parameter) ! Procedure in which to move to line number ! Go to start of a certain line in the current buffer, or optionally to ! the line in a certain procedure local the_line, ! Local copy of line_parameter the_name, ! Local (and normalized) copy of 2nd arg saved_mark, ! Marker for current cursor position saved_window, ! Current window last_line, ! Number of lines in buffer, including eob_text procedure_pattern, ! Pattern that matchs the PROCEDURE and w/s search_pattern, ! Pattern that matches the procedure statement search_range, ! Range returned by search temp_mark, ! Beginning of a possible procedure start_mark, ! Start of the procedure end_mark, ! End of the procedure procedure_range, ! The name part of the procedure statement this_name; ! String version of procedure_range on_error [TPU$_CONTROLC]: eve$$restore_position (saved_window, saved_mark); eve$learn_abort; abort; [TPU$_ENDOFBUF]: [OTHERWISE]: eve$message (EVE$_CANTMOVE, 0, the_line); eve$$restore_position (saved_window, saved_mark); eve$learn_abort; return (FALSE); endon_error; if not eve$declare_intention (eve$k_action_reposition) then return (FALSE); endif; if not (eve$prompt_number (line_parameter, the_line, message_text (EVE$_LINENO, 1), message_text (EVE$_NOLINNO, 0))) then eve$learn_abort; return (FALSE); endif; if the_line <= 0 then eve$message (EVE$_CANTMOVE, 0, the_line); eve$learn_abort; return (FALSE); endif; last_line := get_info (current_buffer, "record_count"); ! do NOT include eob_text if last_line = 0 then eve$message (EVE$_BUFEMPTY); eve$learn_abort; return (FALSE); endif; saved_mark := mark (FREE_CURSOR); saved_window := current_window; position (TEXT); ! snap the cursor the_name := procedure_parameter; edit (the_name, UPPER, TRIM, COMPRESS); if the_name = "" then if the_line > last_line then position (end_of (current_buffer)); eve$message (EVE$_BUFHASONLY, 0, last_line); eve$learn_abort; return (FALSE); else position (beginning_of (current_buffer)); ! ! ### LSE CHANGE ! position (the_line); ! ! ! If the first record is an oveview, then ! position to the first visible record ! if lse$is_overview(mark(none)) then lse$move_by_source(1); endif; lse$move_by_source (the_line - 1); ! already at line 1 ! ! ### END OF LSE CHANG ! return (TRUE); endif; else eve$message (EVE$_FINDINGPROC, 0, the_name); erase (eve$choice_buffer); procedure_pattern := ANCHOR + "procedure" + span (eve$kt_whitespace); search_pattern := LINE_BEGIN + "procedure" + span (eve$kt_whitespace) + the_name; position (beginning_of (current_buffer)); loop search_range := search_quietly (search_pattern, FORWARD); exitif search_range = 0; position (beginning_of (search_range)); temp_mark := mark (FREE_CURSOR); ! Get entire name of this procedure position (end_of (search_quietly (procedure_pattern, FORWARD))); move_horizontal (1); procedure_range := search_quietly (eve$pattern_procname, FORWARD); ! Find corresponding endprocedure search_range := search_quietly (eve$pattern_endprocedure, FORWARD); if search_range <> 0 then start_mark := temp_mark; position (end_of (search_range)); move_horizontal (1); end_mark := mark (FREE_CURSOR); this_name := substr (procedure_range, 1, length (procedure_range)); change_case (this_name, UPPER); if this_name = the_name then erase (eve$choice_buffer); eve$add_choice (this_name); exitif 1; else eve$add_choice (this_name); endif; endif; position (LINE_END); move_horizontal (1); endloop; case get_info (eve$choice_buffer, "record_count") from 0 to 1 [0]: eve$message (EVE$_PROCNOTFOUND, 0, the_name); eve$$restore_position (saved_window, saved_mark); eve$learn_abort; return (FALSE); [1]: ! ! ### LSE CHANGE ! position (get_info (start_mark, "record_number") + the_line - 1); ! position (start_mark); lse$move_by_source (the_line - 1); ! ! ### END OF LSE CHANGE ! if mark (FREE_CURSOR) > end_mark then eve$message (EVE$_LESSLINES, 0, this_name, the_line); position (end_mark); position (LINE_BEGIN); endif; [OUTRANGE]: ! ! ### LSE CHANGE eve$message( EVE$_AMBPROC, 0, the_name ); POSITION( BEGINNING_OF( eve$choice_buffer ) ); lse$prompt_list_buffer( eve$choice_buffer, lse$command_window ); POSITION( saved_window ); POSITION( saved_mark ); eve_line( line_parameter, GET_INFO( eve$choice_buffer, 'line' ) ); ! eve$display_choices (message_text (EVE$_AMBPROC, 0, the_name), !** How do we get the synonym for the key that was defined to this command? ! "line " + str (the_line) + " ", ! procedure_parameter); ! ! ### END OF LSE CHANGE eve$learn_abort; return (FALSE); endcase; endif; eve$position_in_middle (mark (FREE_CURSOR)); return (TRUE); endprocedure; ! EVE$EDIT.TPU Page 11 ! Parameters ! total_lines = total lines in buffer, output ! the_line = the line we're on, and low limit for binary search, output ! eob_flag = true if at eob, output ! percent = percent of way through buffer, output procedure eve$what_line (total_lines, ! WHAT LINE subprocedure low_line, percent, eob_flag) local saved_mark, ! marker - current position text_mark, ! marker - after snapping to text this_line_position, ! marker - position at start of this_line high_line, ! integer - high line limit for binary search low_position, ! marker - beginning of low line this_line, ! integer - line number of current guess mark_flag; on_error [TPU$_CONTROLC]: eve$$restore_position (saved_mark); ! restore free cursor position eve$learn_abort; abort; [OTHERWISE]: eve$$restore_position (saved_mark); endon_error; ! Initialization saved_mark := mark (FREE_CURSOR); position (line_begin); text_mark := mark (NONE); if text_mark = end_of (current_buffer) then if text_mark = beginning_of (current_buffer) then eve$message (EVE$_BUFEMPTY); position (saved_mark); ! no learn_abort here return (FALSE); else eob_flag := TRUE; endif; endif; position (beginning_of (current_buffer)); total_lines := 0; mark_flag := FALSE; loop exitif mark(FREE_CURSOR) = end_of (current_buffer); if NOT lse$is_overview(mark(none)) then total_lines := total_lines + 1; if mark_flag then low_line := total_lines; mark_flag := FALSE; endif; endif; if mark(FREE_CURSOR) = text_mark then if lse$is_overview(mark(none)) then mark_flag := TRUE; else low_line := total_lines; endif; endif; move_vertical(1); endloop; ! TPU will truncate numbers on division; make it round instead percent := (((low_line * 1000) / total_lines) + 5) / 10; position (saved_mark); return (TRUE); endprocedure; ! EVE$EDIT.TPU Page 41 procedure eve_move_by_line ! Move to start of line ! Move to start of line if current direction is reverse; ! else move to end of line. If this would be a no-op, go ! to the start of the previous line or the end of the next line. ! ! Note that at the end of the command prompt in reverse, the cursor moves ! to the end of the previous line, not to the end of the prompt in the ! previous line - because the post command filter always leaves the cursor at ! the end of a command line if you've moved up or down in the command buffer. local cursor_is_free, ! True if cursor beyond end of current line saved_mark; on_error [TPU$_CONTROLC]: eve$$restore_position (saved_mark); eve$learn_abort; abort; [TPU$_BEGOFBUF, TPU$_ENDOFBUF]: message(error_text); eve$$restore_position (saved_mark); [OTHERWISE]: eve$$restore_position (saved_mark); endon_error; if not eve$declare_intention (eve$k_action_short_move) then return (FALSE); endif; cursor_is_free := not (get_info (current_buffer, "bound")); saved_mark := mark (FREE_CURSOR); position (TEXT); ! snap cursor to text if current_direction = REVERSE then ! In prompting window, go to previous line if within prompt if eve$in_prompting_window then if eve$in_prompt then ! ! ### LSE changes ### ! ! move_vertical (-1); ! lse$move_vertical(-1); ! ### End LSE changes ### ! endif; ! NOTE: the command post filter always moves to the end of a new line ! in the command window. position (LINE_BEGIN); else ! not command if not cursor_is_free then if current_offset = 0 then ! ! ### LSE changes ### ! ! move_vertical (-1); ! lse$move_vertical(-1); ! ### End LSE changes ### ! endif; endif; position (LINE_BEGIN); endif; else if cursor_is_free then position (saved_mark); if get_info (current_window, "beyond_eol") then position (LINE_END); ! Prevent padding. ! ! ### LSE changes ### ! ! move_horizontal (1); ! Faster than move_vertical, & move_vert ! ! doesn't always go to eol if lse$move_horizontal(1); ! ### End LSE changes ### ! endif; else ! EDT-style column_move_vertical is ON if mark (NONE) <> end_of (current_buffer) then if current_character = "" ! on eol then ! ! ### LSE changes ### ! ! move_horizontal (1); ! Faster than move_vertical + move_vert ! lse$move_horizontal(1); ! ### End LSE changes ### ! endif; ! doesn't always to to eol else ! ! ### LSE changes ### ! lse$move_horizontal(1); ! Force error message at end of buffer ! ! ### End LSE changes ### ! endif; endif; position (LINE_END); ! gotta do this for all cases endif; return (TRUE); endprocedure; ! eve_move_by_line ! EVE$EDIT.TPU Page 43 procedure eve_move_down ! Move down one row (free and bound cursor) ! Move down one row, staying in the same column. Scroll if necessary. on_error [OTHERWISE]: endon_error; ! scroll the VT100 choice window if it's mapped if eve$$x_state_array {eve$$k_ambiguous_parse} then if (current_window = eve$command_window) and eve$on_a_pre_lk201 then eve$move_by_screen (1); return (TRUE); endif; endif; if not eve$declare_intention (eve$k_action_down_right) then return (FALSE); endif; if eve$x_bound_cursor then ! ! ### LSE changed ### ! !move_vertical (1); ! command post filter cleans up after this move_vertical ! lse$move_vertical(1); ! else case cursor_vertical (1) from - 1 to 0 [-1]: cursor_vertical (-1); if scroll (current_window, 1) = 0 then eve$learn_abort; return FALSE; endif; [0]: if scroll (current_window, 1) = 0 then eve$learn_abort; return FALSE; endif; endcase; endif; return (TRUE); endprocedure; ! EVE$EDIT.TPU Page 43 procedure eve_move_left ! Move left one column (free and bound cursor) ! Move left one column. Do not wrap at edge of the screen. on_error [OTHERWISE]: endon_error; if not eve$declare_intention (eve$k_action_up_left) then return (FALSE); endif; if eve$x_bound_cursor then ! ! ### LSE changed #### ! ! move_horizontal (-1); ! lse$move_horizontal(-1); ! else if cursor_horizontal (-1) = 0 then eve$learn_abort; return FALSE; endif; endif; return (TRUE); endprocedure; ! eve_move_left ! EVE$EDIT.TPU Page 44 procedure eve_move_right ! Move right one column (free and bound cursor) ! Move right one column. Do not wrap at edge of the screen. on_error [OTHERWISE]: endon_error; if eve$in_prompting_window then if current_character = "" then return (TRUE); endif; endif; if not eve$declare_intention (eve$k_action_down_right) then return (FALSE); endif; if eve$x_bound_cursor then ! ! ### LSE change ### ! ! move_horizontal (1); ! lse$move_horizontal(1); ! else if cursor_horizontal (1) = 0 then eve$learn_abort; return (FALSE); endif; endif; return (TRUE); endprocedure; ! eve_move_right ! EVE$EDIT.TPU Page 45 procedure eve_move_up ! Move up one row (free and bound cursor) ! Move up one row, staying in the same column. Scroll if necessary. on_error [OTHERWISE]: endon_error; ! scroll the VT100 choice window if it's mapped if eve$$x_state_array {eve$$k_ambiguous_parse} then if (current_window = eve$command_window) and eve$on_a_pre_lk201 then eve$move_by_screen (-1); return (TRUE); endif; endif; if not eve$declare_intention (eve$k_action_up_left) then return (FALSE); endif; if eve$x_bound_cursor then ! ! ### LSE changed #### ! ! move_vertical (-1); ! lse$move_vertical(-1); ! else case cursor_vertical (-1) [-1]: cursor_vertical (1); if scroll (current_window, -1) = 0 then eve$learn_abort; return FALSE; endif; [0]: if scroll (current_window, -1) = 0 then eve$learn_abort; return FALSE; endif; endcase; endif; return (TRUE); endprocedure; ! eve_move_up ! EVE$EDIT.TPU Page 26 procedure eve$start_of_word ! Go to start of word and return distance moved ! Go to the beginning of a word. Return amount moved, or 0 if at ! start of line. local temp_length, ! Distance moved temp_char, ! Character to check original_mark; ! Original mark on_error [OTHERWISE]: endon_error; position (TEXT); ! snap cursor to text if current_offset = 0 then return (0); endif; !+ ! The following code is all new for LSE !- original_mark := mark (none); lse$$goto_word (reverse); return (length (create_range (original_mark, mark(none), none))); endprocedure; ! EVE$EDIT.TPU Page 27 procedure eve$end_of_word ! Find distance to end of word & move there LOCAL saved_mark, ! Current location original_mark; ! Original mark on_error [TPU$_CONTROLC]: eve$$restore_position (saved_mark); ! restore free cursor position eve$learn_abort; abort; [TPU$_NOEOBSTR]: eve$$restore_position (saved_mark); return (FALSE); [OTHERWISE]: eve$$restore_position (saved_mark); endon_error; !+ ! LSE changed here and remove all rest of EVE's code ! because LSE uses builtin lse$$goto_word !- saved_mark := mark (NONE); if saved_mark = end_of (current_buffer) then position (saved_mark); eve$learn_abort; return (FALSE); endif; original_mark := mark (none); lse$$goto_word(FORWARD); return (length (create_range (original_mark, mark(none), none))); endprocedure; ! EVE$EDIT.TPU Page 16 ! ! LSE added arguement remove_flag 1 : remove found range ! ! procedure eve$$replace_init(;remove_flag) ! Replace subprocedure local how_exact, status; on_error [OTHERWISE]: endon_error; eve$$x_replace_all := FALSE; ! Dialog box ALL button eve$$x_replace_array {eve$$k_replace_saved_mark} := mark (FREE_CURSOR); position (TEXT); ! snap cursor to prevent padding eve$$x_replace_array {eve$$k_replace_this_buffer} := current_buffer; !!!!!! eve$$x_replace_array {eve$$k_replace_asking} := TRUE; eve$$x_replace_array {eve$$k_replace_saved_mode} := get_info ( eve$$x_replace_array { eve$$k_replace_this_buffer }, "mode"); set (INSERT, eve$$x_replace_array {eve$$k_replace_this_buffer}); eve$$x_replace_array {eve$$k_switched_pivot_point} := FALSE; ! here's where we'll look in other_direction eve$$x_replace_array {eve$$k_pivot_point} := mark (FREE_CURSOR); eve$$x_replace_array {eve$$k_replace_saved_direction} := current_direction; if eve$$x_replace_array {eve$$k_replace_saved_direction} = FORWARD then eve$$x_replace_array {eve$$k_other_direction} := REVERSE; else eve$$x_replace_array {eve$$k_other_direction} := FORWARD; endif; ! Set up case of targets ! !eve$$x_replace_array {eve$$k_lowercase_target} := ! eve$$x_replace_array ! {eve$$k_replace_target}; !if get_info (eve$$x_replace_array {eve$$k_lowercase_target}, "type") = STRING !then ! change_case (eve$$x_replace_array {eve$$k_lowercase_target}, LOWER); !endif; ! !eve$$x_replace_array {eve$$k_replace_search_exact} := eve$x_find_exact; !if not eve$$x_state_array {eve$$k_find_case_exact} !then ! if (eve$$x_replace_array {eve$$k_lowercase_target} = ! eve$$x_replace_array {eve$$k_replace_target}) ! then ! eve$$x_replace_array {eve$$k_replace_search_exact} := ! eve$x_find_no_exact ! ; ! endif; !endif; !eve$$x_replace_array {eve$$k_lowercase_replacement} := ! eve$$x_replace_array ! {eve$$k_replacement}; !change_case (eve$$x_replace_array {eve$$k_lowercase_replacement}, LOWER); ! !if (eve$$x_replace_array {eve$$k_lowercase_target} = ! eve$$x_replace_array {eve$$k_replace_target}) ! and (eve$$x_replace_array {eve$$k_lowercase_replacement} = ! eve$$x_replace_array {eve$$k_replacement}) !then ! eve$$x_replace_array {eve$$k_replace_how_exact} := eve$x_find_no_exact; ! eve$$x_replace_array {eve$$k_uppercase_target} := ! eve$$x_replace_array ! {eve$$k_replace_target}; ! if get_info (eve$$x_replace_array {eve$$k_uppercase_target}, "type") = ! STRING ! then ! change_case (eve$$x_replace_array {eve$$k_uppercase_target}, UPPER); ! endif; ! eve$$x_replace_array {eve$$k_capital_target} := ! eve$$x_replace_array ! {eve$$k_replace_target}; ! if get_info (eve$$x_replace_array {eve$$k_capital_target}, "type") = STRING ! then ! eve$capitalize_string (eve$$x_replace_array {eve$$k_capital_target}); ! endif; ! eve$$x_replace_array {eve$$k_uppercase_replacement} := ! eve$$x_replace_array ! {eve$$k_replacement}; ! change_case (eve$$x_replace_array {eve$$k_uppercase_replacement}, UPPER); ! eve$$x_replace_array {eve$$k_capital_replacement} := ! eve$$x_replace_array ! {eve$$k_replacement}; ! eve$capitalize_string (eve$$x_replace_array {eve$$k_capital_replacement}); !else ! eve$$x_replace_array {eve$$k_replace_how_exact} := eve$x_find_exact; !endif; ! ! eve$$find searches for eve$x_target !---------------------------------------------------------------------- ! LSE's SUBSTITUTE/PATTERN for wildcard search status := eve$get_find_target(lse$$search_string,how_exact, lse$$x_search_type); if NOT status then return (FALSE); endif; eve$$x_replace_array {eve$$k_replace_search_exact} := how_exact; eve$$x_replace_array {eve$$k_replace_how_exact} := lse$$x_search_how_exact; eve$$x_replace_array {eve$$k_replace_target} := eve$x_target; !---- end of LSE's case_matching ! eve$x_target := eve$$x_replace_array {eve$$k_replace_target}; eve$$x_replace_array {eve$$k_found_forward} := FALSE; eve$$x_replace_array {eve$$k_found_reverse} := FALSE; if remove_flag = tpu$k_unspecified then eve$$remove_found_range; ! remove range so current position is searched else if remove_flag = 1 then eve$$remove_found_range; endif; endif; return (TRUE); endprocedure; ! EVE$EDIT.TPU Page 13 procedure eve_replace ! EVE Replace (target_arg, ! Old string - input replacement_arg; ! New string - input the_action ) ! the action ! Search and replace procedure. Case-sensitivity of search is ! same as for the find command. If case-insensitive, replacements ! are done to match case of current occurrence. ! ! Replace strings in current direction first. When no more are found, ! then temporarily reverse direction, and search from the original ! position (the pivot_point). Two type of actions result: ! ! 1. None found in other direction: return to the location of the ! last one found, and look for any more in the buffer. Exit if ! no more are found. If any are found, ! we start alternately traversing the buffer from beginning to end or ! end to beginning (actually between the first and last found strings ! in the buffer), swapping the pivot_point with each traversal. ! This allows replacing a string with a superset ! of itself (FOO with FOOBAR) multiple times. ! ! 2. One or more are found in other direction: replace in the other ! direction. Then return to pivot point, and look in opposite ! direction. Exit if none found, or continue replacing in one direction ! from the pivot point, and returning to the pivot point to look in the ! opposite direction. ! ! Once the entire buffer has been traversed, then default ! to a NO answer when asking to change direction again. ! ! Syntax: ! REPLACE old_string new_string ! on_error [OTHERWISE]: endon_error; if not eve$test_if_modifiable (current_buffer) then eve$learn_abort; return (FALSE); endif; if not eve$declare_intention (eve$k_action_modify) then return (FALSE); endif; if get_info (eve$$x_replace_array, "type") = ARRAY then delete (eve$$x_replace_array); endif; eve$$x_replace_array := create_array (eve$$k_replace_array_length, eve$$k_state_array_indexes); eve$$x_replace_array {TYPE} := eve$$k_replace_context; eve$$x_replace_array {eve$$k_replace_occurrences} := 0; if the_action <> tpu$k_unspecified then return (eve$$replace1 (target_arg,replacement_arg,1,the_action)); else return (eve$$replace1 (target_arg, replacement_arg,1)); endif; endprocedure; ! EVE$EDIT.TPU Page 15 procedure eve$$replace1 ! Replace subprocedure (target_arg, replacement_arg; ignore_null_replacement, ! Boolean = 1 if replacement_arg can be "" the_action) local get_replacement, action_length, the_widget, temp_array, status; on_error [TPU$_CONTROLC]: eve$message (EVE$_REPLCTRLC, 0, eve$$x_replace_array {eve$$k_replace_occurrences}); eve$$replace_error_handler; eve$learn_abort; abort; [OTHERWISE]: eve$$replace_error_handler; endon_error; eve$$x_replace_array {eve$$k_replace_target} := target_arg; eve$$x_replace_array {eve$$k_replacement} := replacement_arg; ! get the args if (target_arg = "") then if (eve$$x_state_array {eve$$k_command_line_flag} = eve$k_invoked_by_menu) and (eve$$x_state_array {eve$$k_dialog_box}) then %if eve$x_option_decwindows %then if eve$x_decwindows_active then lse$$substitute_dialog; endif; %endif return (eve$k_async_prompting); else if not (eve$prompt_string (target_arg, eve$$x_replace_array {eve$$k_replace_target}, message_text (EVE$_OLDPROMPT, 1), message_text (EVE$_NOREPLSTR, 0))) then eve$learn_abort; return (FALSE); endif; endif; endif; eve$$x_replace_array {eve$$k_replacement} := replacement_arg; if eve$$x_replace_array {eve$$k_replacement} = "" then if ignore_null_replacement <> tpu$k_unspecified then if ignore_null_replacement <> 1 then get_replacement := TRUE; endif; else get_replacement := TRUE; endif; endif; if get_replacement then eve$$x_replace_array {eve$$k_replacement} := replacement_arg; if eve$$x_replace_array {eve$$k_replacement} = "" then eve$$x_replace_array {eve$$k_replacement} := eve$prompt_line (message_text (EVE$_NEWPROMPT, 1), eve$$x_prompt_terminators ); if eve$$x_replace_array {eve$$k_replacement} = 0 then eve$learn_abort; return (FALSE); endif; endif; endif; status := eve$$replace_init; ! ! LSE added the following code, this is to mark return position and ! turn off screen update if replace action is "all" ! eve$$x_replace_array {eve$$k_replace_asking} := TRUE; if (NOT status) and (get_info (lse$search, 'lse$pattern') = lse$os_tpu) and (lse$$x_search_type = 2) then ! Behaviour only changed for a TPU style pattern replacement eve$$replace_error_handler; return (FALSE); endif; if the_action <> tpu$k_unspecified then eve$$x_replace_array {eve$$k_replace_action} := the_action; action_length := length (eve$$x_replace_array {eve$$k_replace_action}); if (eve$$x_replace_array {eve$$k_replace_action} = substr (eve$x_all, 1, action_length)) and (action_length > 0) then eve$$x_replace_array {eve$$k_replace_asking} := FALSE; ! ! LSE remove EVE$_REPALL message ! !eve$message (EVE$_REPLALL, 0, ! eve$$x_replace_array {eve$$k_replace_target}); ! eve$$x_replace_array {eve$$k_replace_saved_mark} := mark (FREE_CURSOR );! return here when done set (SCREEN_UPDATE, OFF); endif; endif; ! ! end of LSE's addition ! %if eve$x_option_decwindows %then if eve$x_decwindows_active and (eve$$x_state_array {eve$$k_command_line_flag} = eve$k_invoked_by_menu) then ! !----------------------------------------------------------------------- ! LSE V3.0 CHANGE ( removed 'ALL' toggle button ) ! ! the_widget := get_info (WIDGET, "widget_id", lse$x_replace_dialog, ! "REPLACE_DIALOG.REPLACE_ALL"); ! temp_array := create_array; ! temp_array {eve$x_resource_array {eve$k_nvalue}} := ""; ! status := get_info (the_widget, "widget_info", temp_array); ! if temp_array {eve$x_resource_array {eve$k_nvalue}} ! then ! !+ ! LSE SET TO FALSE !- ! eve$$x_replace_all := TRUE; ! prevent REPLACE EACH dialog box ! return (eve$$replace_loop (1, eve$x_all)); ! REPLACE /ALL ! else ! ! ! LSE V3.0 CHANGE !----------------------------------------------------------------------- if the_action <> tpu$k_unspecified then return (eve$$replace_loop (1, the_action)); else return( eve$$replace_loop (1)); endif; ! ! endif; else ! ! LSE additional action from command line ! if the_action <> tpu$k_unspecified then return (eve$$replace_loop (1, the_action)); ! REPLACE /ALL else return (eve$$replace_loop (1)); endif; endif; %else if the_action <> tpu$k_unspecified !!! eve$x_all then return (eve$$replace_loop (1, the_action)); ! REPLACE /ALL else return (eve$$replace_loop (1)); endif; %endif endprocedure; ! EVE$EDIT.TPU Page 16 procedure eve$$replace_loop ! Main replace loop (find_flag; ! find_flag = 1 if ok to find replace_action) ! replace_action = "yes", "no", "quit", "last", "all" ! Main REPLACE loop local first_pass, status; on_error [TPU$_CONTROLC]: ! let it ripple up to where message is output eve$learn_abort; abort; [OTHERWISE]: eve$$replace_error_handler; endon_error; ! Search for target first_pass := TRUE; ! LSE add following code ! always restore original direction and mode eve$$x_replace_array {eve$$k_replace_saved_direction} := eve$x_old_find_direction; set (eve$$x_replace_array {eve$$k_replace_saved_direction}, eve$$x_replace_array {eve$$k_replace_this_buffer}); if eve$$x_replace_array {eve$$k_replace_saved_direction} = FORWARD then eve$$x_replace_array {eve$$k_other_direction} := REVERSE; else eve$$x_replace_array {eve$$k_other_direction} := FORWARD; endif; ! ! Save any text that has been inserted between last command and this one ! lse$$save_inserted_text; ! ! Start storing substitute commands for UNDO ! if (get_info (lse$search, 'lse$pattern') = lse$os_tpu) and (lse$$x_search_type = 2) then ! Behaviour only changed for a TPU style pattern replacement lse$$start_substitute (''); else lse$$start_substitute (eve$$x_replace_array {eve$$k_replacement}); endif; ! ---- loop ! ! LSE change ! eve$$x_replace_array {eve$$k_repeat_find_range} := 0; eve$$x_replace_array {eve$$k_erasing_pivot_point} := FALSE; ! use find_flag only in first pass if (find_flag and first_pass) or (not first_pass) then eve$$x_this_direction := current_direction; !+ ! LSE changed, uses lse$$x_search_type !- eve$$x_replace_array {eve$$k_replace_range} := ! find and position to it eve$find_target (eve$$x_replace_array { eve$$k_replace_search_exact }, lse$$x_search_type, 1); if eve$$x_replace_array {eve$$k_replace_range} = 0 then status := eve$$replace_search_fail; if status = eve$k_warning then ! no more occurrences eve$$replace_clean_up; ! ! End adding of substitute commands for UNDO ! lse$$end_substitute(); ! return (status); endif; if status = eve$k_async_prompting then ! more occurrences, dialog box prompt ! ! End adding of substitute commands for UNDO ! lse$$end_substitute(); ! return (status); endif; endif; endif; exitif eve$$x_replace_array {eve$$k_replace_range} = 0; ! ! LSE V3.0 CHANGE ! ! if first_pass then ! use optional arg only in first pass status := eve$$replace_action (replace_action); else if (eve$$x_state_array {eve$$k_command_line_flag} = eve$k_invoked_by_menu) and (eve$$x_state_array {eve$$k_dialog_box}) and eve$x_decwindows_active then status := eve$$replace_action (replace_action); else status := eve$$replace_action; endif; endif; ! ! end of LSE V3.0 CHANGE ! if status = eve$k_async_prompting then ! ! End adding of substitute commands for UNDO ! lse$$end_substitute(); ! return (status); endif; exitif status = FALSE; first_pass := FALSE; !+ ! LSE V3.0 CHANGED HERE ! if (eve$$x_state_array {eve$$k_command_line_flag} = eve$k_invoked_by_menu) and (eve$$x_state_array {eve$$k_dialog_box}) and eve$x_decwindows_active and (replace_action <> eve$x_all) then exitif 1; endif; !- endloop; ! ! End adding of substitute commands for UNDO ! lse$$end_substitute(); ! eve$$replace_clean_up; return (TRUE); endprocedure; ! EVE$EDIT.TPU Page 17 procedure eve$$replace_search_fail ! Did not find another occurrence in current direction, look in other direction local find_reply, saved_direction, change_direction_key, the_value, the_prompt, ! status, yesno, last_found; on_error [TPU$_CONTROLC]: ! let it ripple up to where message is output eve$learn_abort; abort; [OTHERWISE]: eve$$replace_error_handler; endon_error; ! ! ### LSE change (1) : Don't abort learn sequence if SUBSTITUTE/ALL has ! replaced at least one string successfully. ! ! if eve$$x_replace_array {eve$$k_replace_occurrences} = 0 then if learn_abort ! Don't look in opposite direction if in LEARN SEQUENCE then if not eve$$x_replace_array {eve$$k_replace_asking} then ! reposition if 'all' position (eve$$x_replace_array {eve$$k_replace_saved_mark}); endif; ! always restore original direction and mode set (eve$$x_replace_array {eve$$k_replace_saved_direction}, eve$$x_replace_array {eve$$k_replace_this_buffer}); set (eve$$x_replace_array {eve$$k_replace_saved_mode}, eve$$x_replace_array {eve$$k_replace_this_buffer}); set (SCREEN_UPDATE, ON); ! ! ### LSE CHANGE (2); ! ! LSE removes all EVE messages ! ! eve$message (EVE$_FINDFAIL); ! eve$message (EVE$_REPLCOUNT, 0, ! eve$$x_replace_array {eve$$k_replace_occurrences}); ! eve$message (EVE$_LEARNABORTBIG); ! ! ### END OF LSE CHANGE (2) ! return (FALSE); endif; ! ! ### LSE change (1) ! endif; ! ! ### LSE change ! ! Did not find another occurrence in current direction - give up. ! ! if not (get_info( lse$search, 'lse$auto_reverse' )) then return (FALSE); endif; ! ! ### end of LSE change ! ! remember last found string in case user doesn't want to go to next one eve$$x_replace_array {eve$$k_replace_here} := mark (FREE_CURSOR); ! Search in other direction from pivot point. last_found := mark (FREE_CURSOR); ! (maybe = pivot_point) position (eve$$x_replace_array {eve$$k_pivot_point}); ! ! ### LSE add to save current direction ! saved_direction := current_direction; ! set (eve$$x_replace_array {eve$$k_other_direction}, eve$$x_replace_array {eve$$k_replace_this_buffer}); eve$$x_this_direction := current_direction; eve$$x_replace_array {eve$$k_replace_range} := eve$find_target (eve$$x_replace_array {eve$$k_replace_search_exact}, lse$$x_search_type, 0); ! LSE CHANGE 1 to lse$$x_search_type if (eve$$x_replace_array {eve$$k_replace_range} = 0) then !+ ! Couldn't find one on other side of pivot_point; so ! go to last one found, and search in other direction. !- position (last_found); eve$$x_replace_array {eve$$k_pivot_point} := mark (FREE_CURSOR); eve$$x_replace_array {eve$$k_switched_pivot_point} := TRUE; ! see if ANY other occurrences still exist eve$$x_this_direction := current_direction; eve$$x_replace_array {eve$$k_repeat_find_range} := eve$find_target (eve$$x_replace_array { eve$$k_replace_search_exact }, lse$$x_search_type, 0); ! LSE CHANGE 1 to lse$$x_search_type if (eve$$x_replace_array {eve$$k_repeat_find_range} = 0) then ! no more occurrences return (FALSE); endif; endif; if not eve$$x_replace_array {eve$$k_replace_asking} then ! We're in 'all' loop: during prompts, return to location that's ! showing on screen so the screen doesn't change (eve$prompt_line ! doesn't use read_lines -> must turn on update) eve$$x_replace_array {eve$$k_replace_temp_mark} := mark (FREE_CURSOR); position (eve$$x_replace_array {eve$$k_replace_saved_mark}); set (SCREEN_UPDATE, ON); endif; if (eve$$x_replace_array {eve$$k_repeat_find_range} <> 0) or ((eve$$x_replace_array {eve$$k_replace_range} <> 0) and eve$$x_replace_array {eve$$k_switched_pivot_point}) or ((eve$$x_replace_array {eve$$k_replace_range} <> 0) and eve$$x_replace_array {eve$$k_found_forward} and eve$$x_replace_array {eve$$k_found_reverse}) then !+ ! Ask if ok to replace again in another pass thru the buffer. !- %if eve$x_option_decwindows %then if eve$x_decwindows_active and (eve$$x_state_array {eve$$k_command_line_flag} = eve$k_invoked_by_menu) then if eve$$x_replace_array {eve$$k_other_direction} = FORWARD then the_prompt := message_text (EVE$_REPLACEFWDAGIN2, 1); else the_prompt := message_text (EVE$_REPLACEREVAGIN2, 1); endif; else %endif if eve$$x_replace_array {eve$$k_other_direction} = FORWARD then the_prompt := message_text (EVE$_REPLACEFWDAGAIN, 1); else the_prompt := message_text (EVE$_REPLACEREVAGAIN, 1); endif; %if eve$x_option_decwindows %then endif; %endif else %if eve$x_option_decwindows %then if eve$x_decwindows_active and (eve$$x_state_array {eve$$k_command_line_flag} = eve$k_invoked_by_menu) then if eve$$x_replace_array {eve$$k_other_direction} = FORWARD then the_prompt := message_text (EVE$_REPLACEFWDAGIN2, 1); else the_prompt := message_text (EVE$_REPLACEREVAGIN2, 1); endif; else %endif if eve$$x_replace_array {eve$$k_other_direction} = FORWARD then the_prompt := message_text (EVE$_REPLACEFWD, 1); else the_prompt := message_text (EVE$_REPLACEREV, 1); endif; %if eve$x_option_decwindows %then endif; %endif endif; if (eve$$x_state_array {eve$$k_command_line_flag} = eve$k_invoked_by_menu) and (eve$$x_state_array {eve$$k_dialog_box}) ! user hasn't disabled dialogs then ! set up for re-entry after dialog box dismissal if (eve$$x_replace_array {eve$$k_replace_range} = 0) and (eve$$x_replace_array {eve$$k_repeat_find_range} <> 0) then eve$$x_replace_array {eve$$k_replace_range} := ! new replace range eve$$x_replace_array { eve$$k_repeat_find_range }; endif; ! ! LSE Change here ! If 'all', we position at the last replacement.... ! if not eve$$x_replace_array {eve$$k_replace_asking} then ! reposition if 'all' position (eve$$x_replace_array {eve$$k_replace_here}); else position (eve$$x_replace_array {eve$$k_replace_saved_mark}); endif; %if eve$x_option_decwindows %then if eve$x_decwindows_active then ! ! ### LSE change ### ! ! In LSE V3.0, we removed eve$x_replace_go_each_dialog and ! lse$x_find_each_dialog. We use a generic dialog box for ! prompting yes/no. ! if current_direction = FORWARD then ! found in other direction, go there? the_prompt := message_text (EVE$_FOUNDFORWARD, 1); else the_prompt := message_text (EVE$_FOUNDREVERSE, 1); endif; ! ! Turn on screen updater. ! set (SCREEN_UPDATE, ON); lse$prompt_boolean_decw (tpu$k_unspecified, yesno, the_prompt, "", "", FALSE); if yesno then if index(lse$$subs_qual_string, "ALL") > 0 then set (SCREEN_UPDATE, OFF); eve$$widget_find_each_yes (1, 1,(current_direction = FORWARD)); else eve$$widget_find_each_yes (0, 1,(current_direction = FORWARD)); endif; endif; ! ! ### LSE changed here: ! always restore original direction ! set (saved_direction,eve$$x_replace_array {eve$$k_replace_this_buffer}); set (SCREEN_UPDATE, ON); ! ### end of LSE change ! endif; ! ! ### end of V3.0 CHANGE ### ! ! %endif return (eve$k_async_prompting); else ! LSE change, use lse$prompt_boolean ! IF NOT lse$prompt_boolean( , find_reply, the_prompt, '', 'Y' ) THEN eve$$replace_error_handler; eve$learn_abort; return (FALSE); ENDIF; CASE find_reply [1]:find_reply := eve$x_yes; [0]:find_reply := eve$x_no; ENDCASE; endif; if not eve$$x_replace_array {eve$$k_replace_asking} then ! turn screen update off again, then return to last found string & continue set (SCREEN_UPDATE, OFF); position (eve$$x_replace_array {eve$$k_replace_temp_mark}); endif; ! Hitting return or do means yes; hitting another non-typing ! key is probably a mistake, so interpret as no. if find_reply = "" then change_direction_key := eve$$lookup_comment (last_key, ""); if eve$test_synonym ("do", change_direction_key) or eve$test_synonym ("return", change_direction_key) then if (eve$$x_replace_array {eve$$k_repeat_find_range} <> 0) or ((eve$$x_replace_array {eve$$k_replace_range} <> 0) and eve$$x_replace_array {eve$$k_switched_pivot_point}) or ((eve$$x_replace_array {eve$$k_replace_range} <> 0) and eve$$x_replace_array {eve$$k_found_forward} and eve$$x_replace_array {eve$$k_found_reverse}) then find_reply := eve$x_no; ! 2nd pass starting else find_reply := eve$x_yes; ! more new ones endif; else find_reply := eve$x_yes; ! not default key = yes endif; else change_case (find_reply, LOWER); endif; !+ ! test the reply and return if 'no' !- position (eve$$x_replace_array {eve$$k_replace_here}); if substr (eve$x_no, 1, length (find_reply)) = find_reply then return (FALSE); endif; if (eve$$x_replace_array {eve$$k_replace_range} = 0) and (eve$$x_replace_array {eve$$k_repeat_find_range} <> 0) then eve$$x_replace_array {eve$$k_replace_range} := eve$$x_replace_array {eve$$k_repeat_find_range}; ! new replace range endif; ! go to the find string (these eve$$finds do not position to it) position (eve$$x_replace_array {eve$$k_replace_range}); ! flip dir for next find if eve$$x_replace_array {eve$$k_other_direction} = FORWARD then eve$$x_replace_array {eve$$k_other_direction} := REVERSE; else eve$$x_replace_array {eve$$k_other_direction} := FORWARD; endif; return (TRUE); endprocedure; ! EVE$EDIT.TPU Page 19 procedure eve$$replace_action ! Replace subprocedure (; the_action) local action_length, this_occurrence, the_rep_str, str2, the_replacement_expression, the_index, replacement_length, saved_replacement, saved_string; on_error [TPU$_CONTROLC]: ! let it ripple up to where message is output eve$learn_abort; abort; [TPU$_COMPILEFAIL, TPU$_EXECUTEFAIL]: if get_info (lse$search, 'lse$pattern') <> lse$os_tpu then eve$$replace_error_handler; endif; [OTHERWISE]: eve$$replace_error_handler; endon_error; ! Hilight the occurrence and ask user what to do with it. if current_direction = FORWARD then eve$$x_replace_array {eve$$k_found_forward} := TRUE; else eve$$x_replace_array {eve$$k_found_reverse} := TRUE; endif; if eve$$x_replace_array {eve$$k_replace_range} = 0 then return(false); endif; !+ ! LSE ADD THE FOLLOWING !- saved_replacement := eve$$x_replace_array {eve$$k_replacement}; replacement_length := length(saved_replacement); if ((get_info (lse$search, 'lse$pattern') <> lse$os_tpu) or (lse$$x_search_type <> 2)) and (eve$$x_replace_array {eve$$k_replace_range} <> 0) then execute(lse$$case_matching_prog); eve$$x_replace_array {eve$$k_replacement} := lse$$actual_replacement_string; endif; if eve$$x_replace_array {eve$$k_replace_asking} then eve$$x_replace_array {eve$$k_highlight_range} := create_range (beginning_of ( eve$$x_replace_array {eve$$k_replace_range}), end_of (eve$$x_replace_array {eve$$k_replace_range}), eve$x_highlighting); endif; position (beginning_of (eve$$x_replace_array {eve$$k_replace_range})); ! ! ### LSE change ! ! Expand sufficent lines to make the cursor position visible if current ! record is invisible. ! lse$make_visible(0); ! ! end of LSE change ! if mark (NONE) = eve$$x_replace_array {eve$$k_pivot_point} then eve$$x_replace_array {eve$$k_erasing_pivot_point} := TRUE; endif; if eve$$x_replace_array {eve$$k_replace_asking} then update (current_window); endif; loop if eve$$x_replace_array {eve$$k_replace_asking} and (the_action = tpu$k_unspecified) then eve$$x_replace_array {eve$$k_replace_action} := eve$prompt_line ( message_text (EVE$_REPLPROMPT,1), eve$$x_prompt_terminators); if eve$$x_replace_array {eve$$k_replace_action} = 0 then ! always restore original direction and mode eve$$replace_error_handler; eve$learn_abort; return (FALSE); endif; if eve$test_synonym ( "exit", eve$$lookup_comment (last_key, eve$x_key_map_list)) then ! EXIT = quit replacing eve$$x_replace_array {eve$$k_replace_action} := eve$x_quit; endif; change_case (eve$$x_replace_array {eve$$k_replace_action}, LOWER); else if the_action = tpu$k_unspecified then eve$$x_replace_array {eve$$k_replace_action} := eve$x_yes; else eve$$x_replace_array {eve$$k_replace_action} := the_action; endif; endif; action_length := length (eve$$x_replace_array {eve$$k_replace_action}); if (eve$$x_replace_array {eve$$k_replace_action} = substr (eve$x_yes, 1, action_length)) or (eve$$x_replace_array {eve$$k_replace_action} = substr (eve$x_all, 1, action_length)) or (eve$$x_replace_array {eve$$k_replace_action} = substr (eve$x_last, 1,action_length)) or (action_length = 0) then eve$$x_replace_array {eve$$k_highlight_range} := 0; if (get_info (lse$search, 'lse$pattern') = lse$os_tpu) and (lse$$x_search_type = 2) then if (eve$$x_replace_array {eve$$k_replacement} <> '') then the_replacement_expression := 'RETURN(' + eve$$x_replace_array {eve$$k_replacement} + ')'; if length(the_replacement_expression) > 256 then eve$message (EVE$_TARGETTOOBIG); eve$$replace_error_handler; return (FALSE); endif; the_rep_str := EXECUTE (the_replacement_expression); if (get_info(the_rep_str, "type")<>STRING) then message('Error in replacement string'); eve$$replace_error_handler; return (FALSE); endif; else the_rep_str := eve$$x_replace_array {eve$$k_replacement}; endif; ! Remove carriage return characters adjacent to line ! feed characters (to make consistent with the incorrect ! handling of line feed and carriage return by undo ! processing). ! str2 := the_rep_str; if (index(str2, ascii(13)) <> 0) and (index(str2, ascii(10)) <> 0) then the_rep_str := ''; loop exitif length(str2) = 0; the_index := index (str2, ascii(10)); if the_index = 0 then the_rep_str := the_rep_str + str2; exitif; else ! Line feed found. ! Process the string to the left of the line feed. ! Ignore trailing carriage returns. the_index2 := the_index - 1; loop exitif the_index2 <= 0; exitif substr(str2,the_index2,1) <> ascii(13); the_index2 := the_index2 - 1; endloop; if the_index2 > 0 then the_rep_str := the_rep_str + substr(str2,1,the_index2); endif; ! Process the line feed the_rep_str := the_rep_str + ascii(10); ! Process the string to the right of the line feed. ! Ignore leading carriage returns. the_index := the_index + 1; loop exitif the_index > length(str2); exitif substr(str2,the_index,1) <> ascii(13); the_index := the_index + 1; endloop; exitif the_index > length(str2); str2 := substr(str2,the_index); endif; endloop; endif; ! Case matching if (eve$$x_replace_array {eve$$k_replace_range} <> 0) then saved_string := lse$$replace_string; lse$$replace_string := the_rep_str; execute(lse$$case_matching_prog); the_rep_str := lse$$actual_replacement_string; eve$$x_replace_array {eve$$k_replacement} := the_rep_str; lse$$replace_string := saved_string; endif; ! For TPU pattern style the length can vary. replacement_length := length (the_rep_str); lse$$add_substitute_entry ( eve$$x_replace_array {eve$$k_replace_range}, beginning_of (eve$$x_replace_array {eve$$k_replace_range}), the_rep_str); erase( eve$$x_replace_array {eve$$k_replace_range} ); ! Treat lf as end of record. ! There is a TPU routine tpu$add_string_with_lf (BLISS) ! that could be used (this also removes adjacent cr ! characters). loop exitif length(the_rep_str) = 0; the_index := index (the_rep_str, ascii(10)); if the_index = 0 then copy_text(the_rep_str); exitif; else if the_index > 1 then copy_text(substr(the_rep_str,1,the_index-1)); endif; split_line; exitif the_index = length(the_rep_str); the_rep_str := substr(the_rep_str,the_index+1); endif; endloop; else if (saved_replacement <> eve$$x_replace_array {eve$$k_replacement}) then lse$$add_substitute_entry ( eve$$x_replace_array {eve$$k_replace_range}, beginning_of ( eve$$x_replace_array {eve$$k_replace_range}), eve$$x_replace_array {eve$$k_replacement}); else lse$$add_substitute_entry ( eve$$x_replace_array {eve$$k_replace_range}, beginning_of ( eve$$x_replace_array {eve$$k_replace_range}), ''); endif; erase( eve$$x_replace_array {eve$$k_replace_range} ); copy_text (eve$$x_replace_array {eve$$k_replacement}); endif; if eve$$x_replace_array {eve$$k_erasing_pivot_point} then ! 'pivot_point' marker text erased, redo the marker eve$$x_replace_array {eve$$k_replace_temp_mark}:=mark(FREE_CURSOR); move_horizontal (-replacement_length); eve$$x_replace_array {eve$$k_pivot_point} := mark (FREE_CURSOR); position (eve$$x_replace_array {eve$$k_replace_temp_mark}); endif; if current_direction = REVERSE then move_horizontal (-replacement_length); endif; eve$$x_replace_array {eve$$k_replacement} := saved_replacement; eve$$x_replace_array {eve$$k_replace_occurrences} := eve$$x_replace_array{eve$$k_replace_occurrences} + 1; if eve$$x_replace_array {eve$$k_replace_asking} then update (current_window); if (eve$$x_replace_array {eve$$k_replace_action} = substr (eve$x_all, 1, action_length)) and (action_length > 0) then eve$$x_replace_array {eve$$k_replace_asking} := FALSE; eve$$x_replace_array {eve$$k_replace_saved_mark} := mark (FREE_CURSOR);! return here when done set (SCREEN_UPDATE, OFF); endif; endif; exitif; else if (eve$$x_replace_array {eve$$k_replace_action} = substr (eve$x_no, 1, action_length)) or (eve$$x_replace_array {eve$$k_replace_action} = substr (eve$x_quit, 1, action_length)) then eve$$replace_no; exitif; endif; endif; endloop; if (action_length > 0) and ((eve$$x_replace_array {eve$$k_replace_action} = substr (eve$x_quit, 1, action_length)) or (eve$$x_replace_array {eve$$k_replace_action} = substr (eve$x_last, 1, action_length))) then return (FALSE); else return (TRUE); endif; endprocedure; ! EVE$EDIT.TPU Page 21 procedure eve$$replace_clean_up ! Replace subprocedure on_error [TPU$_CONTROLC]: ! let it ripple up to where message is output eve$learn_abort; abort; [OTHERWISE]: eve$$replace_error_handler; endon_error; ! ! ### LSE change ! ! In LSE, DON'T go to last saved_mark only if 'all'. ! !if not eve$$x_replace_array {eve$$k_replace_asking} !then ! go to last saved_mark only if 'all' ! position (eve$$x_replace_array {eve$$k_replace_saved_mark}); !endif; ! ! ### END OF LSE CHANGE ! ! always restore original direction and mode set (eve$$x_replace_array {eve$$k_replace_saved_direction}, eve$$x_replace_array {eve$$k_replace_this_buffer}); set (eve$$x_replace_array {eve$$k_replace_saved_mode}, eve$$x_replace_array {eve$$k_replace_this_buffer}); set (SCREEN_UPDATE, ON); eve$message (EVE$_REPLCOUNT, 0, eve$$x_replace_array {eve$$k_replace_occurrences}); %if eve$x_option_decwindows %then if (eve$$x_state_array {eve$$k_command_line_flag} = eve$k_invoked_by_menu) and (eve$$x_state_array {eve$$k_dialog_box}) then if eve$x_decwindows_active then if get_info (eve$x_replace_each_dialog, "type") = WIDGET then unmanage_widget (eve$x_replace_each_dialog); endif; endif; endif; %endif endprocedure; ! EVE$EDIT.TPU Page 48 procedure eve$delete_start_word ! EDT-like delete word (reverse) local end_mark, word_range, number_chars; on_error [OTHERWISE]: endon_error; if mark (NONE) = beginning_of (current_buffer) then move_vertical (-1); ! force an error message endif; if not eve$declare_intention (eve$k_action_erase_to_left) then return (FALSE); endif; move_horizontal (-1); end_mark := mark (NONE); move_horizontal (1); number_chars := eve$start_of_word; if number_chars = 0 then move_horizontal (-1); ! erase line break endif; word_range := create_range (mark (NONE), end_mark, NONE); eve$x_erased_word_forward := FALSE; eve$x_restore_word := eve$erase_text (word_range, eve$x_word_buffer, FALSE); ! If space before eol, remove the space; then, if not beyond the ! screen edge then free cursor back to eol (so FILL won't add a 2nd space) ! ! LSE CHANGE to comment out the following lines ! !if current_character = "" !then ! if not eve$in_prompt ! then ! if mark (NONE) <> beginning_of (current_buffer) ! then ! move_horizontal (-1); ! if current_character = " " ! then ! erase_character (1); ! if (get_info (mark (FREE_CURSOR), "offset_column") + ! get_info (current_window, "shift_amount")) <= ! (get_info (current_window, "width")) ! then ! cursor_horizontal (1); ! endif; ! else ! move_horizontal (1); ! endif; ! endif; ! endif; !endif; return (TRUE); endprocedure; ! eve$delete_start_word ! EVE$EDIT.TPU Page 39 ! ! LSE Supercedes to get insert mode deletion in overstrike mode at prompts ! procedure eve_delete ! Delete character to left of cursor ! Delete previous character ! ! If eve$x_fast_delete is true, then use the fast erase_character builtin ! which does not preserve font information; otherwise, preserve ! fonts by using proc eve$erase_text (which uses ranges for deletes). ! Note: deletes in column 1 will be slower even with eve$x_fast_delete = 1 ! because ranges must be used to preserve the end-of-line information ! for the undelete. local here, this_buffer, the_range, ok, cursor_is_free, char_range, ! Range containing the character to delete saved_mark; on_error [TPU$_CONTROLC]: eve$$restore_position (saved_mark); eve$learn_abort; abort; [TPU$_BEGOFBUF]: if not eve$x_bound_cursor then return (TRUE); ! silently return endif; eve$message (error_text, error); eve$learn_abort; return (FALSE); [OTHERWISE]: eve$$restore_position (saved_mark); endon_error; ! if pending delete is active, put select range into $RESTORE$SELECTION$ buffer if eve$x_select_position <> 0 then if eve$$x_state_array {eve$$k_pending_delete_active} then if eve$$pending_delete (0) then return (TRUE); endif; endif; endif; if not eve$declare_intention (eve$k_action_erase_to_left) then return (FALSE); endif; saved_mark := mark (FREE_CURSOR); ! to restore buffer after errors this_buffer := current_buffer; eve$x_erased_char_forward := FALSE; cursor_is_free := not (get_info (current_buffer, "bound")); if (current_offset = 0) and eve$x_fast_delete then ! this will force an error if before_bol in buffer's 1st line move_horizontal (-1); ! the following code is a simple version of eve$erase_text here := mark (NONE); char_range := create_range (mark (NONE), mark (NONE), NONE); position (eve$x_char_buffer); erase (eve$x_char_buffer); copy_text (char_range); move_horizontal (-1); eve$x_restore_char := create_range (beginning_of (eve$x_char_buffer), mark (NONE), NONE); position (here); move_horizontal (1); if mark (NONE) = end_of (this_buffer) then move_horizontal (-1); if current_offset = 0 then move_horizontal (1); append_line; ! Warning issued in unmodifiable buffer endif; else append_line; ! Warning issued in unmodifiable buffer endif; return (TRUE); else if eve$x_fast_delete then ! prevent erase_character when in a prompt & not at offset = 0 if not eve$in_prompting_window then ! make this as fast as possible ok := TRUE; else if not eve$in_prompt then ok := TRUE; endif; endif; if ok then eve$x_restore_char := erase_character (-1); ! Warning issued in ! unmodifiable buffer if (get_info (current_buffer, "mode") = OVERSTRIKE) !*** LSE CHANGE and (eve$in_prompting_window = FALSE) !*** END OF LSE CHANGE then if current_character <> "" ! no space at eol then eve$insert_text (" "); move_horizontal (-1); endif; endif; endif; return (TRUE); endif; endif; ! eve$x_fast_delete = 0 if cursor_is_free then if current_offset = 0 then ! this will error if before_bol in 1st line & bound cursor mode move_horizontal (-1); char_range := create_range (mark (NONE), mark (NONE), NONE); move_horizontal (1); else if not eve_move_left then return (FALSE); endif; char_range := " "; endif; else ! get_info (current_buffer, "bound") move_horizontal (-1); char_range := create_range (mark (NONE), mark (NONE), NONE); move_horizontal (1); endif; eve$x_restore_char := eve$erase_text (char_range, eve$x_char_buffer, FALSE); return (TRUE); endprocedure; ! eve_delete