MODULE TPUPlus_MAPP IDENT "900501" ! ! PROCEDURE EVE_SET_MAPPING ! Enable main keyboard digits as mapping keys ! PROCEDURE EVE_SET_NOMAPPING ! Disable main keyboard digits as mapping keys ! PROCEDURE EVE_DISPLAY_MAP ! Show/update the map window, toggle LOCKING it ON ! PROCEDURE EVE_MAP_BUFFER (BUFFER_ARG) ! Map the numbered buffer to window ! PROCEDURE PCE$INIT_BUFFER (NEW_BUFFER_NAME, NEW_EOB_TEXT) ! PROCEDURE EAG_SHOW_MAP ! PROCEDURE EAG_SHOW_WINDOW (NEEDED_LINES) ! PROCEDURE PCE_TOGGLE_MAPPING ! PROCEDURE EAG$DEFINE_KEYS ! ! version 5.00-000 original ! version 5.00-001 890306 fixed bug in EAG_SHOW_WINDOWS that caused ! error message when mapping turned off ! version 5.01-000 900501 deleted EAG$INIT_VARIABLES, used MODULE ! statement, added PCE_TOGGLE_MAPPING ! !**************************************** PROCEDURE EVE_SET_MAPPING ! Enable main keyboard digits as mapping keys eag$x_pre_command_window := current_window; if (eag$x_pre_command_window = 0) or (eag$x_pre_command_window = tpu$k_unspecified) then message ('Internal Error -- Cannot define eag$x_pre_command_window'); return; endif; if eag$x_map_on = 1 then message ('Mapping / Windows is already enabled'); return; else if eag_map_buffer = 0 then eag_map_buffer := pce$init_buffer ("Buffers", ""); endif; if eag_map_buffer = tpu$k_unspecified then eag_map_buffer := pce$init_buffer ("Buffers", ""); endif; eag$x_map_on := 1; add_key_map (eve$x_key_map_list, "first", eag$x_keys); eve_display_map; if (eag$x_pre_command_window <> 0) and (eag$x_pre_command_window <> "") and (eag$x_pre_command_window <> tpu$k_unspecified) then position (eag$x_pre_command_window); else message ("Internal Error -- Cannot reposition"); message (" Attempting different code"); eve$position_in_middle (eag$x_pre_command_window); endif; pce$map_mode := "MAPON"; ! message ('Mapping / Windows is enabled'); endif; ENDPROCEDURE; !**************************************** PROCEDURE EVE_SET_NOMAPPING ! Disable main keyboard digits as mapping keys eag$x_pre_command_window := current_window; if eag$x_map_on = 0 then message ("Mapping / Window keys are already disabled"); return; else eve_display_map; eag$x_map_on := 0; eag_map_window_size := 0; remove_key_map (eve$x_key_map_list, "eag$key_map", ALL); eve$position_in_middle (eag$x_pre_command_window); ! message ('Mapping / Window keys disabled.'); pce$map_mode := "NORMAL"; endif; ENDPROCEDURE; !**************************************** PROCEDURE EVE_DISPLAY_MAP ! Show/update the map window, toggle LOCKING it ON if eag_map_lock = 0 then eag_map_lock := 1; eag_show_map; ! message ( "Map window is now set ON" ); else eag_map_lock := 0; eag_show_window (0); ! message ( "Map window is now set OFF" ); endif; return; ENDPROCEDURE; !**************************************** PROCEDURE EVE_MAP_BUFFER (BUFFER_ARG) ! Map the numbered buffer to window ! This routine will convert its argument into an integer. It will then ! count through the non-system buffers till it finds the corresponding ! buffer and map that buffer to the current window. LOCAL buffer_var, ! Holds buffer variable buffer_number, ! Argument converted to a number buffer_save, ! Buffer on entry to this routine buffer_count; ! Index/counter for counting loop on_error endon_error; if current_window = eag_map_window then position (eag$x_pre_command_window); endif; eag$x_pre_command_window := get_info (WINDOW, "current"); buffer_save := current_buffer; buffer_number := int (buffer_arg); if buffer_arg <> 0 then buffer_count := 0; buffer_var := GET_INFO (BUFFER, "FIRST"); loop exitif buffer_var = 0; if get_info (buffer_var, "system") = 0 then buffer_count := buffer_count + 1; endif; exitif buffer_count = buffer_number; buffer_var := GET_INFO (BUFFER, "NEXT"); endloop; if buffer_count = buffer_number then if buffer_var <> current_buffer then eve_buffer (GET_INFO (buffer_var, "NAME")); endif; else eve_get_file (''); !read_line ('File name? ')); endif; endif; eag$x_pre_command_window := get_info (WINDOW, "current"); eag_show_map; position (eag$x_pre_command_window); eve$position_in_middle (mark (free_cursor)); ENDPROCEDURE; !**************************************** PROCEDURE PCE$INIT_BUFFER (NEW_BUFFER_NAME, NEW_EOB_TEXT) ! Procedure used to create an EVE system buffer. Returns the new buffer. local new_buffer; new_buffer := create_buffer (new_buffer_name); set (eob_text, new_buffer, new_eob_text); set (no_write, new_buffer); set (system, new_buffer); return (new_buffer); ENDPROCEDURE; !**************************************** PROCEDURE EAG_SHOW_MAP ! ! Revised to work under VMS V.5 -- 881115 - R. Stacks ! ! Builds a new map buffer based on available info ! This routine will erase and re-build the contents of the map buffer to ! reflect the current non-system buffers that exist. It will then call ! eag_show_window to insure that the buffers are properly displayed. LOCAL saved_position, ! Holds text position on entry prev_largest_string,! Holds the last value of largest buffer name string buffer_name, ! Holds string name of buffer buffer_var, ! Holds buffer variable buffer_number, ! Argument converted to a number buffer_count, ! Index/counter for counting loop temp_line; if eag_map_buffer = 0 then message ("Map buffer/window not initilized - use SET MAPPING to init"); return; endif; if (eag$x_pre_command_window = 0) or (eag$x_pre_command_window = tpu$k_unspecified) then eag$x_pre_command_window := get_info (WINDOW, "current"); endif; eag_map_width := get_info (SCREEN, "width"); set (width, current_window, eag_map_width); if eag_largest_string <> eag_map_width then eag_largest_string := eag_map_width; if eag_map_width = 80 then eag_buf_per_line := 5; else if eag_map_width = 132 then eag_buf_per_line := 8; else eag_buf_per_line := 5; endif; endif; endif; LOOP ! Till we paint a map buffer that's accurate erase (eag_map_buffer); position (beginning_of (eag_map_buffer)); if (eag_min_prefered_string > eag_largest_string) then eag_curr_min_string := eag_largest_string; else eag_curr_min_string := eag_min_prefered_string; endif; prev_largest_string := eag_largest_string; eag_largest_string := 0; eag_buf_per_line := (eag_map_width + 4) / (eag_curr_min_string + 4); eag_map_lines := eag_buffer_count / eag_buf_per_line; if (eag_buffer_count <> (eag_map_lines * eag_buf_per_line)) then eag_map_lines := eag_map_lines +1; endif; eag_buf_per_line := eag_buffer_count / eag_map_lines; if (eag_buffer_count <> eag_buf_per_line * eag_map_lines) then eag_buf_per_line := eag_buf_per_line + 1; endif; eag_slot_size := ((eag_map_width + 4) / eag_buf_per_line) - 4; buffer_var := GET_INFO (BUFFER, "FIRST"); buffer_count := 0; line_count := 1; buffer_line_index := 0; LOOP exitif buffer_var = 0; if get_info (buffer_var, "system") = 0 then buffer_count := buffer_count + 1; if buffer_line_index >= eag_buf_per_line then split_line; buffer_line_index := 1; line_count := line_count + 1; else buffer_line_index := buffer_line_index + 1; endif; if buffer_line_index <> 1 then copy_text ( ' ' ); endif; copy_text (str (buffer_count) + ' '); buffer_name := GET_INFO (buffer_var, "NAME" ); if (length (buffer_name ) > (eag_slot_size - 1 ) ) then copy_text (substr (buffer_name, 1, (eag_slot_size -1 ))); else copy_text (substr (buffer_name, 1, length (buffer_name ))); copy_text (substr (eag_blank_string, 1, (eag_slot_size - 1 - (length (buffer_name ))))); endif; if (length (buffer_name )) > (eag_largest_string ) then eag_largest_string := length (buffer_name ); endif; endif; buffer_var := GET_INFO (BUFFER, "NEXT"); ENDLOOP; ! Get rid of any trailing blanks on each line of the map display temp_line := erase_line; edit (temp_line, trim_trailing); copy_text (temp_line); ! exitif (buffer_count = eag_buffer_count) AND (prev_largest_string >= eag_largest_string); eag_buffer_count := buffer_count; ENDLOOP; if (eag$x_pre_command_window <> 0) and (eag$x_pre_command_window <> tpu$k_unspecified) then position (eag$x_pre_command_window); endif; eag_show_window (eag_map_lines); ENDPROCEDURE; !**************************************** PROCEDURE EAG_SHOW_WINDOW (NEEDED_LINES) ! Adjusts map window if needed. ! This procedure checks, and if necessary, creates/adjusts/deletes the ! map window so as to display the specified number of map_window lines. ! If the argument is 0, the map window will go away. If a size change ! is needed, this routine adjusts the size of the lower EVE window and ! the EVE main window to compensate for the size of the map_window, keeping ! track of the buffers kept in the EVE windows as well. LOCAL save_window, ! Temporary storage for current window buffer_var, ! Temporary storage for buffer variable adjustment; ! Needed adjustment to map window if (((eag$x_pre_command_window = 0) or (eag$x_pre_command_window = tpu$k_unspecified)) and (current_window <> eag_map_window)) then eag$x_pre_command_window := get_info (WINDOW, "current"); endif; save_window := current_window; adjustment := eag_map_window_size - needed_lines; eag$x_screen_length := get_info (SCREEN, 'visible_length'); eag$x_window_length := get_info (current_window, "visible_length"); if (needed_lines) = 0 then ! Get rid of map window if eag_map_window <> 0 then delete (eag_map_buffer); delete (eag_map_window); eag_map_window := 0; adjust_window (current_window, 0, eag_map_lines); ! if eag$x_screen_length - eag$x_window_length <> 2 then ! adjustment := eag$x_screen_length - eag$x_window_length - 2; ! adjust_window (eag_map_window, 0, adjustment); ! endif; return; endif; endif; if adjustment <> 0 then ! we must adjust the size of the mapping window SET (SCREEN_UPDATE, OFF); ! For speed and to avoid confusion if adjustment > 0 then ! Window is too big if (needed_lines) <> 0 then ! Window exists adjust_window (eag_map_window, adjustment, 0); endif; endif; if eve$x_number_of_windows = 1 then position (eve$main_window); adjust_window (eve$main_window, 0, adjustment); else position (eve$bottom_window); adjust_window (eve$main_window, 0, adjustment); endif; if adjustment < 0 then ! window is too small (might not exist) if (eag_map_window <> 0) or (get_info (eag_map_window, "type") = window ) then adjust_window (eag_map_window, adjustment, 0); else eag_map_window := create_window ( ((eag$x_screen_length - needed_lines) - 1), needed_lines, off); map (eag_map_window, eag_map_buffer); endif; endif; SET (SCREEN_UPDATE, ON); endif; position (beginning_of (eag_map_buffer)); eag_map_window_size := needed_lines; if (save_window <> 0) and (save_window <> tpu$k_unspecified) then position (save_window); endif; ENDPROCEDURE; !**************************************** PROCEDURE PCE_TOGGLE_MAPPING if pce$map_mode = tpu$k_unspecified then pce$map_mode := "NORMAL"; endif; if pce$map_mode = "MAPON" then eve_set_nomapping; else eve_set_mapping; endif; ENDPROCEDURE; !**************************************** PROCEDURE EAG$DEFINE_KEYS eag$x_keys := "eag$key_map"; create_key_map (eag$x_keys); define_key ('eve_map_buffer ("1")', key_name ('1', shift_key), "map_buffer (buffer #1)", eag$x_keys); define_key ('eve_map_buffer ("2")', key_name ('2', shift_key), "map_buffer (buffer #2)", eag$x_keys); define_key ('eve_map_buffer ("3")', key_name ('3', shift_key), "map_buffer (buffer #3)", eag$x_keys); define_key ('eve_map_buffer ("4")', key_name ('4', shift_key), "map_buffer (buffer #4)", eag$x_keys); define_key ('eve_map_buffer ("5")', key_name ('5', shift_key), "map_buffer (buffer #5)", eag$x_keys); define_key ('eve_map_buffer ("6")', key_name ('6', shift_key), "map_buffer (buffer #6)", eag$x_keys); define_key ('eve_map_buffer ("7")', key_name ('7', shift_key), "map_buffer (buffer #7)", eag$x_keys); define_key ('eve_map_buffer ("8")', key_name ('8', shift_key), "map_buffer (buffer #8)", eag$x_keys); define_key ('eve_map_buffer ("9")', key_name ('9', shift_key), "map_buffer (buffer #9)", eag$x_keys); define_key ('eve_map_buffer ("10")', key_name ('0', shift_key), "map_buffer (buffer #10)", eag$x_keys); ENDPROCEDURE; eve$arg1_map_buffer := "string"; eag_blank_string := ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' '; pce$map_mode := "NORMAL"; eag$x_keys := "eag$key_map"; eag$x_map_on := 0; eag_map_lock := 0; eag_map_buffer := 0; eag_map_window := 0; eag_map_window_size := 0; eag_map_width := 132; eag_buffer_count := 1; eag_buf_per_line := 8; eag_min_prefered_string := 16; eag_largest_string := 132; eag_curr_min_string := 0; ENDMODULE; define_key ("pce_toggle_mapping", key_name (f11, shift_key), "internal_routines pce_toggle_mapping", eve$x_user_keys); define_key ("pce_toggle_mapping", key_name (f11, shift_key), "internal_routines pce_toggle_mapping", eve$x_edt_keys); eag$define_keys; compile ("procedure eag$define_keys endprocedure");