!**************************************** PROCEDURE EVE$POSITION_IN_MIDDLE (NEW_POSITION) ! Move to a new position in the current window, putting the new position ! in the middle of the window by temporarily resetting the scrolling region. ! ! Parameters: ! ! new_position New cursor position - input local scroll_offset, ! New value for scroll_top and scroll_bottom old_scroll_top, ! Original value of scroll_top old_scroll_bottom, ! Original value of scroll_bottom old_scroll_amount, ! Original value of scroll_amount this_window; ! Current window this_window := current_window; ! next line changed 880202 - RHS scroll_offset := (get_info (this_window, eve$kt_visible_length) / 2); if scroll_offset < 0 then scroll_offset := 0; endif; old_scroll_top := get_info (this_window, "scroll_top"); old_scroll_bottom := get_info (this_window, "scroll_bottom"); old_scroll_amount := get_info (this_window, "scroll_amount"); set (scrolling, this_window, on, scroll_offset, scroll_offset, 0); position (new_position); update (this_window); set (scrolling, this_window, on, old_scroll_top, old_scroll_bottom, old_scroll_amount); ENDPROCEDURE; !**************************************** PROCEDURE EVE_BUFFER (BUFFER_PARAMETER) ! Map a buffer to the current window. If the buffer doesn't already ! exist, create a new buffer. ! ! Parameters: ! ! buffer_parameter String containing buffer name - input local buffer_name, ! Local copy of buffer_parameter this_buffer, ! Current buffer loop_buffer, ! Current buffer being checked in loop loop_buffer_name, ! String containing name of loop_buffer found_a_buffer, ! True if buffer found with same exact name possible_buffer_name, ! Most recent string entered in choice buffer possible_buffer, ! Buffer whose name is possible_buffer_name how_many_buffers, ! Number of buffers listed in choice buffer new_buffer; ! New buffer created when there is no match if eve$check_bad_window then message ("Cursor has been moved to a text window; try command again"); return; endif; if not (eve$prompt_string (buffer_parameter, buffer_name, "Buffer name: ", "Buffer not switched")) then return; endif; eve$cleanse_string (buffer_name); ! See if we already have a buffer by that name this_buffer := current_buffer; loop_buffer := get_info (buffers, eve$kt_first); change_case (buffer_name, upper); ! buffer names are uppercase erase (eve$choice_buffer); loop exitif loop_buffer = 0; loop_buffer_name := get_info (loop_buffer, eve$kt_name); if buffer_name = loop_buffer_name then found_a_buffer := 1; how_many_buffers := 1; exitif 1; else if buffer_name = substr (loop_buffer_name, 1, length (buffer_name)) then eve$add_choice (loop_buffer_name); possible_buffer := loop_buffer; possible_buffer_name := loop_buffer_name; how_many_buffers := how_many_buffers + 1; endif; endif; loop_buffer := get_info (buffers, "next"); endloop; change_case (buffer_name, lower); ! for messages if found_a_buffer then if loop_buffer = this_buffer then message (fao ("Already in buffer !AS", loop_buffer_name)); else map (current_window, loop_buffer); eve$position_in_middle(loop_buffer); endif; else if get_info (eve$choice_buffer, eve$kt_record_count) > 0 then if how_many_buffers = 1 then if possible_buffer = this_buffer then message (fao ("Already in buffer !AS", possible_buffer_name)); else map (current_window, possible_buffer); eve$position_in_middle(possible_buffer); endif; else change_case (buffer_name, lower); eve$display_choices(fao ("Ambiguous buffer name: !AS", buffer_name)); endif; else new_buffer := create_buffer (buffer_name); eve$create_buffer_globals (new_buffer); map (current_window, new_buffer); set (eob_text, new_buffer, "[End of file]"); set (margins, new_buffer, eve$x_default_left_margin, get_info (current_window, eve$kt_width) - eve$x_default_right_margin); eve$position_in_middle(new_buffer); endif; endif; eve$set_status_line (current_window); ENDPROCEDURE; !**************************************** PROCEDURE EVE_ERASE_WORD ! Erase next word local this_buffer, ! Current buffer this_mode, ! Keyword for current mode temp_string, ! String used to check for start of line start_erase_word, ! Marker for beginning of previous word end_erase_word, ! Marker for end of previous word spaces_to_erase, ! Number of between-word spaces to erase erase_word_range; ! Range for previous word if current_window = eve$command_window then eve_erase_previous_word; return; endif; this_buffer := current_buffer; if mark (none) = end_of (this_buffer) then return; endif; ! Are we on a space between words? If so, compress whitespace and ! move to start of next word. if index (eve$x_whitespace, current_character) <> 0 then eve$compress_whitespace; endif; ! Check for end of line if current_character = eve$kt_null then if current_offset = 0 then temp_string := ascii (10); else move_horizontal (-1); temp_string := current_character; move_horizontal (1); endif; move_horizontal (1); eve$append_line; if mark (none) <> end_of (this_buffer) then if index (eve$x_word_separators, temp_string) = 0 then this_mode := get_info (this_buffer, eve$kt_mode); set (insert, this_buffer); copy_text (" "); set (this_mode, this_buffer); endif; endif; eve$x_restoring_line := 1; eve$x_restore_text := eve$kt_null; else if not eve$at_start_of_word then eve$start_of_word; endif; start_erase_word := mark (none); eve$end_of_word; move_horizontal (-1); end_erase_word := mark (none); erase_word_range := create_range (start_erase_word, end_erase_word, none); position (start_erase_word); eve$x_restore_text := erase_character (length (erase_word_range)); ! ***** pce_deleted_item := eve$x_restore_text; pce_deleted_item_position := mark(none); pce_deleted_item_type := 0; ! ***** eve$x_restoring_line := 0; endif; ENDPROCEDURE; !**************************************** PROCEDURE EVE_GET_FILE (GET_FILE_PARAMETER) ! Edit a file in the current window. If the file is already in a buffer, ! use the old buffer. If not, create a new buffer. ! ! Parameters: ! ! get_file_parameter String containing file name - input local get_file_name, ! Local copy of get_file_parameter temp_buffer_name, ! String for buffer name based on get_file_name file_search_result, ! Latest string returned by file_search temp_file_name, ! First file name string returned by file_search loop_buffer, ! Buffer currently being checked in loop new_buffer, ! New buffer created if needed found_a_buffer, ! True if buffer found with same name want_new_buffer, ! True if file should go into a new buffer current_file_name, current_file_type; on_error if error = tpu$_parsefail then message (fao ("Don't understand file name: !AS", get_file_name)); if eve$x_starting_up then eve$set_status_line (current_window); endif; return; endif; endon_error; if eve$check_bad_window then message ("Cursor has been moved to a text window; try command again"); return; endif; if not (eve$prompt_string (get_file_parameter, get_file_name, "File to get: ", "No file specified")) then return; endif; ! ! If no file type is given use file type of name of current buffer or ! * for the file type. ! current_file_name := get_info(current_buffer, "name"); current_file_type := substr(current_file_name, index(current_file_name, '.'), length(current_file_name)); get_file_name := file_parse(get_file_name, "", "", node) + file_parse(get_file_name, "", "", device) + file_parse(get_file_name, "", "", directory) + file_parse(get_file_name, "", "", name) + file_parse(get_file_name, current_file_type, "*", type) + file_parse(get_file_name, "", "", version); ! Protect against earlier file_search with same file name. file_search_result := file_search (eve$x_null); temp_file_name := eve$x_null; erase (eve$choice_buffer); loop file_search_result := file_search (get_file_name); exitif file_search_result = eve$x_null; eve$add_choice (file_search_result); temp_file_name := file_search_result; endloop; if get_info (eve$choice_buffer, "record_count") > 1 then ! If get_file is called from tpu$init_procedure, can't handle ! multiple choices, so set status line on main window and return if eve$x_starting_up then eve$set_status_line (current_window); eve$display_choices (fao ("Ambiguous file name: !AS", get_file_name)); return; endif; ! otherwise if we are in the editor already, past the init part then, ! get all files specified by the user's use of wildcards loop ! set up to search for the files again, ! this time pull each one into the editor using ! a separate buffer for each file file_search_result := file_search (get_file_name); exitif file_search_result = eve$x_null; temp_file_name := file_search_result; ! See if we already have a buffer by that name if temp_file_name = eve$x_null then temp_buffer_name := file_parse (get_file_name, eve$x_null, eve$x_null, name) + file_parse (get_file_name, eve$x_null, eve$x_null, type); else temp_buffer_name := file_parse (temp_file_name, eve$x_null, eve$x_null, name) + file_parse (temp_file_name, eve$x_null, eve$x_null, type); endif; get_file_name := file_parse (get_file_name); loop_buffer := get_info (buffers, "first"); loop exitif loop_buffer = 0; if temp_buffer_name = get_info (loop_buffer, "name") then found_a_buffer := 1; exitif 1; endif; loop_buffer := get_info (buffers, "next"); endloop; ! If there is a buffer by that name, is it the exact same file? ! If so, switch to that buffer. Otherwise use a new buffer, ! asking for a new buffer name (null new name will abort). if found_a_buffer then ! Have a buffer with the same name if temp_file_name = eve$x_null then ! No file on disk if get_file_name = get_info (loop_buffer, "output_file") then want_new_buffer := 0; else want_new_buffer := 1; endif; else ! Check to see if the same file if (temp_file_name = get_info (loop_buffer, "output_file")) or (temp_file_name = get_info (loop_buffer, "file_name")) then want_new_buffer := 0; else want_new_buffer := 1; endif; endif; if want_new_buffer then message (fao ("Buffer name !AS is in use", temp_buffer_name)); temp_buffer_name := read_line ("Type a new buffer name or press Return to cancel: "); if temp_buffer_name = eve$x_null then message ("No new buffer created"); else new_buffer := eve$create_buffer (temp_buffer_name, get_file_name, temp_file_name); endif; else if current_buffer = loop_buffer then message (fao ("Already editing file !AS", get_file_name)); else map (current_window, loop_buffer); endif; endif; else ! No buffer with the same name, so create a new buffer new_buffer := eve$create_buffer (temp_buffer_name, get_file_name, temp_file_name); endif; if new_buffer <> 0 then set (eob_text, new_buffer, "[End of file]"); set (margins, new_buffer, eve$x_default_left_margin, get_info (current_window, "width") - eve$x_default_right_margin); endif; ! Correct the status line in any event eve$set_status_line (current_window); endloop; else ! See if we already have a buffer by that name if temp_file_name = eve$x_null then temp_buffer_name := file_parse (get_file_name, eve$x_null, eve$x_null, name) + file_parse (get_file_name, eve$x_null, eve$x_null, type); else temp_buffer_name := file_parse (temp_file_name, eve$x_null, eve$x_null, name) + file_parse (temp_file_name, eve$x_null, eve$x_null, type); endif; get_file_name := file_parse (get_file_name); loop_buffer := get_info (buffers, "first"); loop exitif loop_buffer = 0; if temp_buffer_name = get_info (loop_buffer, "name") then found_a_buffer := 1; exitif 1; endif; loop_buffer := get_info (buffers, "next"); endloop; ! If there is a buffer by that name, is it the exact same file? ! If so, switch to that buffer. Otherwise use a new buffer, ! asking for a new buffer name (null new name will abort). if found_a_buffer then ! Have a buffer with the same name if temp_file_name = eve$x_null then ! No file on disk if get_file_name = get_info (loop_buffer, "output_file") then want_new_buffer := 0; else want_new_buffer := 1; endif; else ! Check to see if the same file if (temp_file_name = get_info (loop_buffer, "output_file")) or (temp_file_name = get_info (loop_buffer, "file_name")) then want_new_buffer := 0; else want_new_buffer := 1; endif; endif; if want_new_buffer then message (fao ("Buffer name !AS is in use", temp_buffer_name)); temp_buffer_name := read_line ("Type a new buffer name or press Return to cancel: "); if temp_buffer_name = eve$x_null then message ("No new buffer created"); else new_buffer := eve$create_buffer (temp_buffer_name, get_file_name, temp_file_name); endif; else if current_buffer = loop_buffer then message (fao ("Already editing file !AS", get_file_name)); else map (current_window, loop_buffer); endif; endif; else ! No buffer with the same name, so create a new buffer new_buffer := eve$create_buffer (temp_buffer_name, get_file_name, temp_file_name); endif; if new_buffer <> 0 then set (eob_text, new_buffer, "[End of file]"); set (margins, new_buffer, eve$x_default_left_margin, get_info (current_window, "width") - eve$x_default_right_margin); endif; ! Correct the status line in any event eve$set_status_line (current_window); endif; ENDPROCEDURE; !**************************************** PROCEDURE EVE_HELP (TOPIC) ! ! user help routine (accesses sys$help:tpuhelp.hlb) ! This routine replaces the DEC-supplied EVE_HELP routine, provides for ! interactive help -- more like the system HELP routine ! local this_topic, this_window, this_text, this_buffer; this_topic := topic; this_window := current_window; this_buffer := current_buffer; set(status_line, info_window, reverse, "Press to leave help and resume editing"); map (info_window, help_buffer); set(text, info_window, no_translate); change_case(this_topic, upper); if (this_topic = "KEYPAD_DIAGRAMS USER_100KEYPAD") or (this_topic = "KEYPAD_DIAGRAMS USER_200KEYPAD") then help_text("tpuhelp", this_topic, off, help_buffer); position(beginning_of(help_buffer)); erase_line; ! display only the keypad erase_line; ! not the help header garbage erase_line; erase_line; erase_line; update(info_window); this_topic := read_line('',1); ! sit here until user tells us to ! go back to editing else help_text("tpuhelp", this_topic, on, help_buffer); endif; set(text, info_window, blank_tabs); unmap(info_window); position (this_window); set(text, this_window, blank_tabs); update(this_window); ENDPROCEDURE; !**************************************** PROCEDURE EVE_INCLUDE_FILE (INCLUDE_FILE_PARAMETER) ! ! Modified 880225 - RHS ! ! Like read_file built-in, but positions the cursor at the start of ! the inserted file. Allows wildcarding in file name. ! ! Parameters: ! ! include_file_parameter String containing file name - input local include_file_name, ! Local copy of include_file_parameter started_at_bof, ! True if current position at start of file include_position, ! Marker for where cursor should end up temp_file_name, ! First file name string - from file_parse file_search_result, ! Latest string returned by file_search current_file_name, current_file_type; on_error if error = tpu$_parsefail then message (fao("Don't understand file name: !AS", include_file_name)); return; endif; endon_error; if eve$check_bad_window then message ("Cursor has been moved to a text window; try command again"); return; endif; if not (eve$prompt_string (include_file_parameter, include_file_name, "File to include: ", "No file included")) then return; endif; ! ! If no file type is given use file type of name of current buffer ! current_file_name := get_info(current_buffer, "name"); current_file_type := substr(current_file_name, index(current_file_name, '.'), length(current_file_name)); include_file_name := file_parse(include_file_name, "", "", node) + file_parse(include_file_name, "", "", device) + file_parse(include_file_name, "", "", directory) + file_parse(include_file_name, "", "", name) + file_parse(include_file_name, current_file_type, "", type) + file_parse(include_file_name, "", "", version); if mark (none) = beginning_of (current_buffer) then started_at_bof := 1; else started_at_bof := 0; endif; if started_at_bof then include_position := mark (none); else move_horizontal (-1); include_position := mark (none); move_horizontal (1); endif; ! Initialize to null string and protect against earlier file_search ! with same file name. temp_file_name := file_search (eve$x_null); temp_file_name := file_parse (include_file_name); erase (eve$choice_buffer); loop file_search_result := file_search (include_file_name); exitif file_search_result = eve$x_null; eve$add_choice (file_search_result); temp_file_name := file_search_result; endloop; case get_info (eve$choice_buffer, "record_count") from 0 to 1 [0] : ! can't find the file specified message (fao ("Could not include file: !AS", include_file_name)); [1] : ! only one file -- get it read_file (temp_file_name); if started_at_bof then position (beginning_of (current_buffer)); else position (include_position); move_horizontal (1); endif; [outrange] : ! multiple files specified (wild-carded) position(beginning_of(eve$choice_buffer)); loop choice_position := mark(none); if current_line <> eve$kt_null then temp_file_name := current_line; position(include_position); read_file (temp_file_name); endif; position(choice_position); move_vertical(1); exitif mark(none) = end_of(current_buffer); endloop; if started_at_bof then position (include_position); position (beginning_of (current_buffer)); else position (include_position); move_horizontal (1); endif; update(current_window); endcase; ENDPROCEDURE; !**************************************** PROCEDURE EVE_SET_TABS_AT (SET_PARAMETER) ! Set tabs at specified positions ! ! Parameters: ! ! set_parameter String that contains tab settings - input local tab_settings; ! Local copy of set_parameter on_error message ("Could not change tab stops as specified"); return; endon_error; if eve$prompt_string (set_parameter, tab_settings, "Set tabs at: ", "Tab settings not changed") then set (tab_stops, current_buffer, tab_settings); message ("Tab stops set"); endif; ! ***** pce_tab_setting := "SPACES"; ! added - 860704 -- RHS ! ***** ENDPROCEDURE; !**************************************** PROCEDURE EVE_SET_TABS_EVERY (SET_PARAMETER) ! Set tabs at constant increments - every n columns ! ! Parameters: ! ! set_parameter Integer increment for tab stops - input local tab_increment; ! Local copy of set_parameter on_error message ("Could not change tab stops as specified"); return; endon_error; if eve$prompt_number (set_parameter, tab_increment, "Set tabs every: ", "Tab settings not changed") then if tab_increment <= 0 then message ("Tabs must be set at least 1 space apart"); else set (tab_stops, current_buffer, tab_increment); message ("Tab stops set"); endif; endif; ! ***** pce_tab_setting := "TABS"; ! added - 860704 -- RHS ! ***** ENDPROCEDURE;