!++ ! FILENAME: UTILITIES.TPU ! FUNCTION: This file contains utility procedures used by other procedures and ! for miscellaneous functionality. ! AUTHOR: Steven K. Shapiro, (C) Copyright SKS Enterprises, Austin TX. ! All Rights Reserved. ! ! The format, structure and contents of this file are the sole ! property of Steven K. Shapiro and are copyrighted to SKS ! Enterprises, Austin Texas. ! ! The information may be freely distributed, used and modified ! provided that the information in this header block is not ! changed, altered, disturbed or modified in any way. ! ! DATE: 25-AUG-1987 Original. ! HISTORY: current. ! CONTENTS: ! evedt$constant_init ! evedt$copy_append (copy_app_string) ! evedt$create_ruler ! evedt$look_in_other_dir (target, exactness, target_position) ! evedt$select_range (arg_string) ! evedt$size_of_range (range_param) ! eve_status_line_off ! eve_status_line_on ! eve_list_commands ! evedt$ruler ! eve_toggle_traceback ! !23456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H !-- !*----------------------------------------------------------------------------*! procedure utilities_module_ident local file_date, module_vers; file_date := "-<( 1-DEC-1988 15:13:01.99 )>-"; module_vers := substr(file_date,5,2) + substr(file_date,8,3) + substr(file_date,14,2) + substr(file_date,17,5) ; return module_vers; endprocedure; !*----------------------------------------------------------------------------*! procedure evedt$constant_init ! ! This procedure is called during startup to initialize the EVEDT global ! constants and variable storage. This procedure must be compiled before ! any of the procedures that reference the constants which it initializes. ! string constants ! default sentence separators evedt$s_sentence_separators := ".?!;:"; ! All standard ASCII chars plus DEC Multinational characters. evedt$s_eop_chars := ".estyn!:;'" + '"()|?' + "abcdfghijklmopqruvwxz,0123456789" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ@-/<=>#$%&*+[\]^_`{}~" + "àáâãäåæçèéêëìíîïñòóôõö÷øùúûüýÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÑÒÓÔÕÖרÙÚÛÜÝß"; ! pattern constants ! page separators evedt$p_page_separators := line_begin & ('.pg' | '%page' | '.page' | ' '); ! Blank line or Runoff command line evedt$p_paragraph_break := line_begin & (((eve$kt_null | span (eve$$x_word_separators)) & line_end) | ("." & any ("bpsh"))); ! evedt$p_paragraph_break := ! line_begin & ( ! ((spanl(eve$kt_null) | spanl (eve$$x_word_separators)) & ! any(eve$x_runoff_characters)) | ! ("." & any ("bpsh"))); ! evedt$p_paragraph_break := ! line_begin & ( ! (line_end & line_begin & any(eve$x_runoff_characters)) | ! ((eve$kt_null | span (eve$$x_word_separators)) & line_end) | ! ("." & any ("bpsh"))); ! end of sentence evedt$p_sentence_end := (any(evedt$s_sentence_separators) & (any(eve$$x_word_separators) | line_end)); ! Deleted String Storage evedt$sv_deleted_char := eve$kt_null; evedt$sv_deleted_word := eve$kt_null; evedt$sv_deleted_line := eve$kt_null; ! Tab Procedure Integer Constant & Variable Storage evedt$ic_tab_size := 4; evedt$ic_tabs_at_size := 8; evedt$iv_tab_goal := 4; ! Flag Variables evedt$fv_top_ruler := false; ! T = ruler is displayed at top of top window or single window evedt$fv_bottom_ruler := false; ! T = ruler is displayed at top of bottom window evedt$fv_scroll_wndw := false; ! T = scroll window is enabled evedt$fv_txt_f_crlf := false; ! T = when text follows the deleted crlf evedt$fv_txt_p_crlf := false; ! T = when text preceedes the deleted crlf ! Range Variable Storage evedt$x_find_range := 0; evedt$x_select_range := 0; ! Buffer Variable Storage evedt$x_prior_buffer := 0; ! Miscellaneous variables evedt$x_eop_pat_size := 1; ! start with one. endprocedure; procedure evedt$copy_append (copy_app_string) ! ! Copy or Append Copy the select_region to the insert_here buffer. ! ! Parameters: ! ! copy_app_string String indicating type of operation to do. local this_position, ! Marker for current cursor position copy_range; ! Range being copied this_position := mark (none); copy_range := evedt$select_range (copy_app_string); if copy_range <> 0 then if copy_app_string = "Copy" then erase (paste_buffer); endif; position (paste_buffer); if beginning_of (paste_buffer) = end_of (paste_buffer) then split_line; move_vertical (-1); endif; copy_text (copy_range); position (this_position); eve$x_select_position := 0; message (copy_app_string + " completed."); endif; endprocedure; !*----------------------------------------------------------------------------*! procedure evedt$create_ruler ! ! Create the RULER buffer which is used in displaying a ruler line at the top of ! the window. This procedure is called only once during initialization. ! ! 28-SEP-1987 SKS, 132 col wide ruler. local original_wndw; original_wndw := current_window; ruler_b := create_buffer('ruler_line'); position (beginning_of (ruler_b)); copy_text('ruler 1 1 2 2 3 3 4'); copy_text(' 4 5 5 6 6 | 7 7 8'); copy_text(' 8 9 9 0 0 1 1 2'); copy_text(' 2 3 '); split_line; copy_text('1234567890123456789012345678901234567890'); copy_text('1234567890123456789012345678901234567890'); copy_text('1234567890123456789012345678901234567890'); copy_text('123456789012'); set (system,ruler_b); set (no_write,ruler_b); set (eob_text,ruler_b,''); position (beginning_of (ruler_b)); position (original_wndw); endprocedure; !*----------------------------------------------------------------------------*! procedure evedt$look_in_other_dir (target, exactness, target_position) ! ! Search for target in the opposite direction. If found there prompt the user ! for a decision on what to do. ! Returns range if target found and the user responds positively to the ! prompt, otherwise returns false. ! ! Parameters: ! ! target String or pattern to find - input ! exactness case sensitivity - input ! target_position current cursor position - input local find_range, ! Range returned by search other_direction, ! Keyword for opposite direction other_direction_string, ! String for message including other_direction find_reply, ! Reply to inquiry about changing direction this_position, ! local value of current cursor position change_direction_key; ! Keyword for key used to end find_reply on_error if error = tpu$_strnotfound then find_range := 0; endif; endon_error; this_position := target_position; if current_direction = forward then other_direction := reverse; other_direction_string := "reverse"; else other_direction := forward; other_direction_string := "forward"; endif; position (this_position); if other_direction = forward then if this_position <> end_of (current_buffer) then move_horizontal (1); find_range := search (target, forward, exactness); else find_range := 0; endif; else if this_position <> beginning_of (current_buffer) then move_horizontal (-1); find_range := search (target, reverse, exactness); else find_range := 0; endif; endif; if find_range = 0 then if get_info (target, "type") = string then message (fao ("Could not find: !AS", target)); else message ("Could not find pattern "); endif; position (this_position); return (0); else find_reply := read_line (fao ("Found in !AS direction. Go there? ", other_direction_string)); ! Hitting return or do means yes; hitting another non-typing ! key is probably a mistake, so interpret as no. if find_reply = eve$kt_null then change_direction_key := eve$lookup_comment (last_key); if (change_direction_key = "return") or (change_direction_key = "do") then find_reply := "yes"; else find_reply := "no"; endif; else change_case (find_reply, lower); endif; if substr ("yes", 1, length (find_reply)) = find_reply then set (other_direction, current_buffer); eve$update_status_lines; return (find_range); else position (this_position); return (0); endif; endif; endprocedure; !*----------------------------------------------------------------------------*! procedure evedt$select_range (arg_string) ! ! Verify that a select_range exists, if one exists return the range to the ! caller, otherwise return an zero. ! ! Parameters: ! ! arg_string String to be used in error messages. local this_position, selected_range; ! Range that was created with the select function if eve$x_select_position = 0 then message ("Use Select before doing " + arg_string + "."); return 0; else if get_info (eve$x_select_position, "buffer") <> current_buffer then message (arg_string + " must be done in the same buffer as Select."); return 0; else selected_range := select_range; ! Select & Remove/Append in same spot => erase this character if selected_range = 0 then if this_position = end_of (current_buffer) then message ("Nothing to " + arg_string); eve$x_select_position := 0; return 0; else selected_range := create_range (mark (none), mark (none), none); endif; endif; return selected_range; endif; endif; endprocedure procedure evedt$size_of_range (range_param) ! ! Determine the size of the argument range, including line terminators. ! Returns the size of the range received as a parameter. ! ! Parameters: ! ! range_param the range to be sized local char_count, current_position; if range_param = 0 then return (0); else current_position := mark (none); position (beginning_of(range_param)); char_count := 1; ! count the first char loop move_horizontal (1); exitif mark (none) > end_of (range_param); char_count := char_count + 1; endloop; position (current_position); return (char_count); endif; endprocedure; !*----------------------------------------------------------------------------*! ! ! Turn the status line off. Particularly useful in making slides ! directly from the screen. ! procedure eve_status_line_off set (status_line, current_window, none, ""); endprocedure; !*----------------------------------------------------------------------------*! ! Turn the status line on. procedure eve_status_line_on set (status_line, current_window, reverse, " Buffer"); eve$set_status_line (current_window); endprocedure; !*----------------------------------------------------------------------------*! ! Create a list of all commands available in EVEDT and put it into the ! SHOW buffer. procedure eve_list_commands local the_names, column_width, total_width, how_many_columns, temp; eve_mark("evedt_saved_buffer"); the_names := expand_name("eve_", procedures) + " "; position(eve$choice_buffer); erase(eve$choice_buffer); message("Building command list"); loop exitif (the_names = eve$kt_null); temp := index (the_names, " "); if (temp = 0) then message("Can't find space"); return; endif; copy_text (substr (the_names, 1, temp-1)); the_names := substr(the_names, temp+1, length(the_names)); split_line; erase_line; endloop; position(beginning_of(current_buffer)); loop temp := evedt_search_quietly(line_begin & "EVE_", FORWARD); exitif (temp = 0); position(temp); erase(temp); endloop; position(beginning_of(current_buffer)); loop exitif (evedt_replace(" EVE_", " ") = 0); endloop; position(beginning_of(current_buffer)); loop temp := evedt_search_quietly(" ", FORWARD); exitif (temp = 0); position(temp); erase(temp); split_line; endloop; position(beginning_of(current_buffer)); loop exitif (evedt_replace("_", " ") = 0); endloop; if (evedt_defined_procedure("evedt_sort")) then message("Sorting command list"); execute('evedt_sort ( current_buffer , "" );'); endif; eve$format_choices; set (status_line, info_window, reverse, " Eve commands -- DO will remove this list"); position(show_buffer); erase(show_buffer); copy_text(eve$choice_buffer); position(beginning_of(current_buffer)); set(screen_update, off); eve_go_to("evedt_saved_buffer"); set(screen_update, on); map (info_window, show_buffer); message(" "); endprocedure !*----------------------------------------------------------------------------*! procedure evedt$ruler ! ! Toggle Ruler Line Display at Top of Window. ! ! SKS 21-OCT-1988, Since under V2.x of TPU we can have a bazillion windows, ! lets limit our ruler to being just at the top of the ! screen rather than the top of each window. ! local original_wndw; original_wndw := current_window; ! if (eve$x_number_of_windows = 2) and ! (eve$x_this_window <> eve$top_window) ! then ! if evedt$fv_bottom_ruler ! then ! unmap (ruler_w_b); ! evedt$fv_bottom_ruler := false; ! else ! map (ruler_w_b,ruler_b); ! evedt$fv_bottom_ruler := true; ! endif; ! else if evedt$fv_top_ruler then unmap (ruler_w_t); evedt$fv_top_ruler := false; else map (ruler_w_t,ruler_b); evedt$fv_top_ruler := true; endif; ! endif; position (original_wndw); endprocedure; !*----------------------------------------------------------------------------*! procedure eve_toggle_traceback if get_info(system,"traceback") then message("Setting traceback OFF"); set(traceback,off); else message("Setting traceback ON"); set(traceback,on); endif; endprocedure;