!************************************************************************* ! * ! © 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. * ! * !************************************************************************* ! LSE$EVE_MOUSE.TPU ! !++ ! FACILITY: ! VAX Language-Sensitive Editor ! ! ABSTRACT: ! This file contains superceded EVE procedures that are located in the ! file EVE$MOUSE.TPU. ! ! ENVIRONMENT: ! VAX/VMS ! ! CREATION DATE: 21-DEC-1989 ! ! MODIFIED BY: ! ! X3.1-1 DAS 21-Dec-89 First pass. ! X4.0-1 WC3 12-Jul-91 Deal with drag selections ! X4.0-2 WC3 19-Jul-91 Add poor mans SCA integration via global select ! X4.0-3 SHE 25-Jul-91 Removed superseded version of eve$stuff_global_ ! selection; no longer used. ! X4.0-4 WC3 30-Jul-91 Don't send cursor's character on global select string requests ! X4.0-5 GJJ 4-Aug-91 Add support for _DEC_LSE_PushFileToEditor message. ! X4.0-6 WC3 31-Oct-91 Superceed eve$$client_message ! X4.0-7 DAS 14-Nov-91 Removed empty module init ! X4.0-8 WC3 20-Nov-91 Return "" for _DEC_LSE_PositionInFile of ! _DEC_LSE_DoSometing ! X4.0-9 WC3 25-Feb-92 _DEC_LSE_PositoninFile matches files already ! in a buffer by name and type ! Unexpected error in global select responses ! X4.0-10 SHE 03-Mar-92 Pickup up EVE's fix to eve$$client_message ! X4.0-11 WC3 04-Mar-92 Protect against lse$$x_m2drag_range; be unspecified ! X4.0-12 WC3 20-Apr-92 Global select text library support ! X4.0-13 SHE 11-Jun-92 Fixed TARGETS handling to avoid internal error !- procedure lse$eve_mouse_module_ident return "4.7-1"; endprocedure; procedure eve$write_global_select_handler (temp_array) ! ! FUNCTION ! Replace EVE's global selection conversion routine with our own. ! This gets called when some other application wants the global selection ! ! INPUTS ! The requested information kind via GET_INFO ! Current selected region ! Current file name ! Current line number ! Current column number ! Original file name ! Original line number ! Original column number ! ! Current selected region - As a string ! Current file name - As a string ! Current line number - As a SPAN ! Current column number - As a SPAN ! Original file name - As a string ! Original line number - As a SPAN ! _DEC_CHARACTER_OFFSET - As a SPAN ! _DEC_WORD - As a string ! _DEC_WORD_COLUMN_NUMBER - As a SPAN ! _DEC_WORD_CHARACTER_OFFSET - As a SPAN ! TARGETS - As an array ! LOCAL global_file_name, file_name, my_file_name, module_name, saved_position, span_array, the_buffer, the_range, data_to_write, response_status; ON_ERROR [OTHERWISE]: eve$$restore_position( saved_position ); ENDON_ERROR; saved_position := mark (FREE_CURSOR); ! Case on the selection, PRIMARY, SECONDARY, CLIPBOARD... ! IF temp_array{1} = PRIMARY THEN ! We only do primary selection ! ! Set the_buffer and the_range variables ! IF eve$x_select_position = 0 THEN ! There is no selection so we work off the current position ! the_range := CREATE_RANGE( MARK( FREE_CURSOR ), MARK( FREE_CURSOR ), NONE ); the_buffer := CURRENT_BUFFER; ELSE ! There is a selection so we work off it ! the_buffer := GET_INFO( eve$x_select_position, "buffer" ); IF GET_INFO( eve$x_select_position, "type" ) = RANGE THEN the_range := eve$x_select_position ELSE IF GET_INFO( eve$x_select_position, "type" ) = MARKER THEN the_range := select_range; endif; endif; endif; ! At this point the_buffer and the_range for most purposes that ! follow. The exception is that for the no selection case, ! the_range contains 1 character and it should be null. Since ! TPU doesn't allow null ranges, we have to be carefull later on. ! ! Case on the property name, That is wanted ! CASE temp_array{2} ["STRING", "TEXT"]: IF eve$x_select_position = 0 THEN data_to_write := NONE; ELSE data_to_write := str(the_range, ascii(10)); ENDIF; ["LINE_NUMBER"]: ! Initialize what we can ! span_array := create_array( 4, 0 ); span_array{0} := "SPAN"; span_array{1} := 32; span_array{2} := get_info( beginning_of( the_range ), "record_number" ) - 1; span_array{3} := get_info( end_of( the_range ), "record_number" ); data_to_write := span_array; ["COLUMN_NUMBER"]: ! Initialize what we can ! span_array := create_array( 4, 0 ); span_array{0} := "SPAN"; span_array{1} := 32; ! Establish the range of the selection ! ! Begining line ! position( beginning_of( the_range ) ); span_array{2} := get_info( the_buffer, "offset_column" ) - 1; ! Ending line ! IF eve$x_select_position = 0 THEN span_array{3} := span_array{2} ELSE position( end_of( the_range ) ); span_array{3} := get_info( the_buffer, "offset_column" ); ENDIF; data_to_write := span_array; ["_DEC_CHARACTER_OFFSET"]: ! Initialize what we can ! span_array := create_array( 4, 0 ); span_array{0} := "SPAN"; span_array{1} := 32; ! Establish the range of the selection ! ! Begining line ! position( beginning_of( the_range ) ); span_array{2} := get_info( the_buffer, "offset" ); ! Ending line ! IF eve$x_select_position = 0 THEN span_array{3} := span_array{2} ELSE position( end_of( the_range ) ); span_array{3} := get_info( the_buffer, "offset" ) + 1; ENDIF; data_to_write := span_array; ['_DEC_BUFFER_CONTENTS']: data_to_write := str(the_buffer, ascii(10)); ['_DEC_WRITE_MODIFIED_BUFFER']: write_file( the_buffer ); data_to_write := ''; ['FILE_NAME']: my_file_name := LSE$$RESPOND_GLOBAL_SELECT( temp_array{2} ); if my_file_name = '' then my_file_name := GET_INFO( the_buffer, "file_name" ); endif; if my_file_name = '' then data_to_write := NONE; else data_to_write := my_file_name; endif; ['_DEC_LBR_MODULE_NAME']: my_file_name := LSE$$RESPOND_GLOBAL_SELECT( temp_array{2} ); if my_file_name = '' then data_to_write := NONE; else data_to_write := my_file_name; endif; ['_DEC_LSE_ORIGINAL_FILE_NAME' ]: my_file_name := LSE$$RESPOND_GLOBAL_SELECT( temp_array{2} ); ! When LSE doesn't have an original filename we fallback ! to the input filename ! if my_file_name = '' then my_file_name := get_info( the_buffer, "file_name" ); endif; if my_file_name = '' then data_to_write := NONE; else data_to_write := my_file_name; endif; ['_DEC_WORD' ]: ! If there is a range selected just return it ! if eve$x_select_position <> 0 then data_to_write := str( the_range ); else my_file_name := LSE$$RESPOND_GLOBAL_SELECT( temp_array{2} ); if my_file_name = '' then data_to_write := NONE; else data_to_write := my_file_name; endif; endif; ['_DEC_WORD_COLUMN_NUMBER']: ! If there is a range selected just return it ! if eve$x_select_position <> 0 then ! Initialize what we can ! span_array := create_array( 4, 0 ); span_array{0} := "SPAN"; span_array{1} := 32; ! Establish the range of the selection ! ! Begining line ! position( beginning_of( the_range ) ); span_array{2} := get_info(the_buffer, "offset_column" ) - 1; ! Ending line ! position( end_of( the_range ) ); span_array{3} := get_info(the_buffer, "offset_column" ); data_to_write := span_array; else IF LSE$$RESPOND_GLOBAL_SELECT(temp_array{2}) = "FAILURE" then data_to_write := NONE; else data_to_write := lse$$global_selection_array; endif; endif; ! Array returns ! ['_DEC_LSE_ORIGINAL_LINE_NUMBER', '_DEC_WORD_CHARACTER_OFFSET']: IF LSE$$RESPOND_GLOBAL_SELECT(temp_array{2}) = "FAILURE" THEN data_to_write := NONE; ELSE data_to_write := lse$$global_selection_array; ENDIF; ['TARGETS']: response_status := LSE$$RESPOND_GLOBAL_SELECT(temp_array{2}); IF (response_status = "FAILURE") OR (response_status = "") THEN data_to_write := NONE; ELSE data_to_write := lse$$global_selection_array; ENDIF; ! We don't process it ! [OTHERWISE]: data_to_write := NONE; ENDCASE; ELSE IF temp_array{1} = SECONDARY THEN IF lse$$x_m2drag_range = TPU$K_UNSPECIFIED THEN data_to_write := NONE; ELSE data_to_write := lse$$x_m2drag_range; ENDIF; ELSE data_to_write := NONE; IF temp_array{1} = "_DEC_LSE_DoSomething" THEN set (input_focus); CASE temp_array{2} ['_DEC_BUFFER_NAME']: the_buffer := CURRENT_BUFFER; buf_name := GET_INFO(the_buffer, "name"); data_to_write := buf_name; ["_DEC_LSE_PositionInFile"] : lse$$raise_screen; lse$positioninfile_selected; UPDATE( CURRENT_WINDOW ); ! Necessary cause the screen updater won't run RETURN ""; ! *CANNOT* restore position ["_DEC_LSE_PushFileToEditor"]: lse$$raise_screen; global_file_name := get_global_select ("_DEC_LSE_GetPushFileInfo", "STRING"); file_name : = global_file_name; save_cmd_flag := eve$$x_state_array{eve$$k_command_line_flag}; save_diag := eve$$x_state_array {eve$$k_dialog_box}; eve$$x_state_array {eve$$k_command_line_flag} := eve$k_invoked_by_menu; eve$$x_state_array {eve$$k_dialog_box} := true; lse_open_file(file_name); eve$$x_state_array {eve$$k_command_line_flag} := save_cmd_flag; eve$$x_state_array {eve$$k_dialog_box} := save_diag; UPDATE( CURRENT_WINDOW ); RETURN ""; ! Do not restore position. ["_DEC_MMS_PushFileToEditor"]: lse$$raise_screen; global_file_name := get_global_select ("_DEC_LSE_GetPushFileInfo", "STRING"); file_name := file_search(global_file_name); if file_name = '' then file_name := file_parse(global_file_name, '', '', name, type); endif; save_cmd_flag := eve$$x_state_array{eve$$k_command_line_flag}; save_diag := eve$$x_state_array {eve$$k_dialog_box}; eve$$x_state_array {eve$$k_command_line_flag} := eve$k_invoked_by_menu; eve$$x_state_array {eve$$k_dialog_box} := true; lse$review(file_name); eve$$x_state_array {eve$$k_command_line_flag} := save_cmd_flag; eve$$x_state_array {eve$$k_dialog_box} := save_diag; UPDATE( CURRENT_WINDOW ); RETURN ""; ! Do not restore position. ["_DEC_LSE_DELETE_BUFFER"]: global_file_name := get_global_select ("_DEC_LSE_GetPushFileInfo", "STRING"); file_name := file_parse(global_file_name, '', '', name, type); delete_buf := GET_INFO(BUFFER, "find_buffer", file_name); current_buf := CURRENT_BUFFER; IF delete_buf <> 0 THEN found_buf := GET_INFO(BUFFER, "find_buffer", "$main"); IF delete_buf = current_buf THEN lse_goto_buffer(found_buf); ELSE lse_goto_buffer(current_buf); ENDIF; UPDATE(ALL); DELETE(delete_buf); ENDIF; RETURN ""; ! Do not restore position. ["_DEC_LSE_PositionInLibrary"]: ! Module name ! lse$$get_global_select( "_DEC_LBR_MODULE_NAME"); IF GET_INFO( lse$$global_select_return, 'type' ) = STRING THEN module_name := lse$$global_select_return; ! Text library name ! lse$$get_global_select( "FILE_NAME" ); IF GET_INFO( lse$$global_select_return, 'type' ) = STRING THEN ! Do the work ! IF lse$$goto_library_module( lse$$global_select_return, module_name) THEN ! Line and column ! lse$$gs_position; ENDIF; UPDATE( CURRENT_WINDOW ); ENDIF; ENDIF; ! Any errors are silent ! RETURN ""; ["_DEC_LSE_FILE_NAME"]: file_name := get_global_select ("_DEC_LSE_GetPushFileInfo", "STRING"); name_only := FILE_PARSE(file_name, "", "", NAME,TYPE); found_buf := GET_INFO(BUFFER, "find_buffer", name_only); data_to_write := ""; IF found_buf <> 0 then write_file( found_buf, file_name ); data_to_write := GET_INFO(found_buf, "file_name"); ENDIF; RETURN (data_to_write); [OTHERWISE]: data_to_write := NONE; RETURN ""; ENDCASE; ENDIF; ! data_to_write := NONE; ENDIF; ENDIF; eve$$restore_position (saved_position); return (data_to_write); !%ENDIF; endprocedure; procedure lse$positioninfile_selected ! local file_name, global_string, global_file_name, file_opened, open_failed; ON_ERROR [LSE$_IMAGEACTERROR, TPU$_BADVALUE]: eve$message (ERROR_TEXT); eve$learn_abort; lse$post_command_proc; return false; [TPU$_OPENIN, LSE$_COMMANDCANCEL, LSE$_FILEOPENFAIL, LSE$_FILEREADFAIL]: eve$message (error_text); open_failed := true; [TPU$_PARSEFAIL]: [OTHERWISE]: lse$post_command_proc; lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse_open_selected_file "); ENDON_ERROR; ! Init ! global_string := ''; global_file_name := ''; file_opened := false; ! ! First try STRING ! lse$$get_global_select( "STRING"); if get_info( lse$$global_select_return, 'type' ) = STRING then global_string := lse$$global_select_return; if lse$$file_in_buffer( global_string ) then file_opened := true; else file_opened := lse_open_file (global_string); endif; ! We're done because it responded with string and we can't expect ! the column and line number to be correct. ! RETURN true; endif; ! ! If we didn't find a file, try FILE_NAME. Try for the filename ONLY if ! we are not the direct owner of the selection. If we were the owner, ! then we want to end up with a File Not Found path... ! if not file_opened then if (get_info (SCREEN,"global_select",PRIMARY) = 0) then lse$$get_global_select( "FILE_NAME" ); if get_info( lse$$global_select_return, 'type' ) = STRING then global_file_name := lse$$global_select_return; if lse$$file_in_buffer( global_file_name ) then file_opened := true; else file_name := file_search(global_file_name); if file_name = '' then file_name := file_parse(global_file_name, '', '', name, type); endif; file_opened := lse_open_file (file_name); endif; endif; endif; endif; ! ! Now let's do error detection. We only have an error if we do not have ! a filename. The are two global data values that either have a value or ! do not have a value. The goal is to opt to report FNF most of the time ! and only No Selection Data when both responses failed. ! if not file_opened then if ((global_string = '') AND (global_file_name = '')) then ! Nothing sigh... ! eve$message( TPU$_NOGBLSELDATA ); eve$learn_abort; return (FALSE); endif; eve$learn_abort; return (FALSE); endif; ! Position to the right place ! return lse$$gs_position; endprocedure; procedure lse$$file_in_buffer( file_name ) LOCAL input_file, input_filev, curr_buffer, curr_file, curr_filev; on_error [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$file_in_buffer"); endon_error; ! Prepare the input file ! input_file := file_parse( file_name, "", "", name, type ); input_filev := file_parse( file_name, "", "", node, device, directory, name, type, version ); if not eve$x_ultrix_active then input_file := edit( input_file, upper ); endif; curr_buffer := get_info( BUFFER, 'first' ); loop exitif curr_buffer = 0; ! Prepare this buffer's file name ! curr_file := file_parse( get_info( curr_buffer, 'file_name' ), '', '', name, TYPE ); curr_filev := file_parse( get_info( curr_buffer, 'file_name' ), '', '', node, device, directory, name, TYPE, VERSION ); if not eve$x_ultrix_active then curr_file := edit( curr_file, upper ); endif; ! We're done if we get a match ! if input_file = curr_file then input_filev := edit( input_filev, upper ); curr_filev := edit( curr_filev, upper ); if input_filev <> curr_filev then ! Assumes must be SCA, is this correct? lse$$popup_error_message ( 'The requested SCA goto source will fail because' + ascii (13) + ascii (10) + 'buffer ' + curr_file + ' already exists for a different file.' + ascii (13) + ascii (10) + 'The file in the buffer is ' + curr_filev + '.' + ascii (13) + ascii (10) + 'The goto source file is ' + input_filev + '.', get_info(SCREEN, 'widget') ); endif; lse_goto_buffer( curr_buffer ); return true; endif; curr_buffer := get_info( buffer, 'next' ); endloop; return false; endprocedure; procedure eve$write_global_select ! ! FUNCTION ! Replace EVE's global selection conversion routine with our own. ! This gets called when some other application wants the global selection ! ! INPUTS ! The requested information kind via GET_INFO ! Current selected region ! Current file name ! Current line number ! Current column number ! Original file name ! Original line number ! Original column number ! ! OUTPUTS ! Current selected region - As a string ! Current file name - As a string ! Current line number - As a SPAN ! Current column number - As a SPAN ! Original file name - As a string ! Original line number - As a SPAN ! _DEC_WORD - As a string ! _DEC_WORD_COLUMN_NUMBER - As a SPAN ! TARGETS - As an array ! ! ! This procedure now acts like a shell onto the lower level procedure called ! eve$write_global_select_handler. This procedure is called only in response ! to a DECwindows event and must do the actual WRITE_GLOBAL_SELECT calls when ! the lower level procedure returns. The lower level procedure must not be ! required to talk to TPU about global selection information on GET_INFO or ! on the output side of the selection data. ! local global_select_event, the_data_to_write; on_error [TPU$_BUILTININV]: ABORT; [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "eve$write_global_select"); endon_error; ! ! Don't you dare try to do this outside of the DECwindows LSE environment ! if not eve$x_decwindows_active then return (FALSE); endif; ! ! Ask TPU for the event information ! global_select_event := get_info (SCREEN, "event", GLOBAL_SELECT); ! ! Call the handling routine ! the_data_to_write := eve$write_global_select_handler (global_select_event); ! ! Write the returned data to the global selection requester ! write_global_select (the_data_to_write); return (TRUE); endprocedure; procedure eve$$client_message ! Respond to client messages (;passed_data) ! Range (buffer if box selection) to STUFF instead of ! using READ_GLOBAL_SELECT (EVE's 2ndary selection ! when it has focus) ! Action routine to respond to DECwindows client messages received by VAXTPU. ! Also takes arg = EVE's own secondary selection when it has focus. local the_message, the_range, the_type, saved_mode, saved_mark; on_error [TPU$_CONTROLC]: eve$$release_scratch_buffer; if saved_mode = OVERSTRIKE then set (saved_mode, current_buffer); endif; eve$$restore_position (saved_mark); eve$learn_abort; abort; [OTHERWISE]: eve$$release_scratch_buffer; if saved_mode = OVERSTRIKE then set (saved_mode, current_buffer); endif; eve$$restore_position (saved_mark); endon_error; %if eve$x_option_decwindows %then if eve$x_decwindows_active then if passed_data <> tpu$k_unspecified then the_message := STUFF_SELECTION; else the_message := get_info (SCREEN, "client_message"); endif; case the_message [KILL_SELECTION]: ! We have focus, CTRL/M3 just copied select range to ! application without focus, pending delete our select range. saved_mark := mark (FREE_CURSOR); if eve$x_select_position <> 0 then position (get_info (eve$x_select_position, "buffer")); else if eve$x_box_array <> 0 then position (get_info (eve$x_box_array {0}, "buffer")); endif; endif; the_range := eve$selection (TRUE, ! do messages FALSE, ! no found range FALSE, ! no global selection FALSE, ! don't extend null selections FALSE, ! don't cancel selection TRUE); ! will take a box selection the_type := get_info (the_range, "type"); if (the_type = RANGE) or ! standard selection (the_type = ARRAY) ! box selection then if eve$$x_state_array {eve$$k_select_all_active} then eve$message (EVE$_NODELSELECTALL); else eve$$pending_delete (0); endif; endif; position (saved_mark); update (ALL); return (TRUE); [STUFF_SELECTION]: ! We have focus, someone (maybe ourself) has a secondary selection ! to copy to our editing position. saved_mark := mark (FREE_CURSOR); if eve$$x_state_array {eve$$k_pending_delete_active} then ! first pending delete our primary select range if eve$x_select_position <> 0 then position (get_info (eve$x_select_position, "buffer")); eve$$pending_delete (0); position (saved_mark); else if eve$x_box_array <> 0 then position (get_info (eve$x_box_array {0}, "buffer")); eve$$pending_delete (0); ! leave cursor at upperleft corner of deleted box endif; endif; endif; update (ALL); ! in case read_glo_sel aborts if eve$x_box_select_flag then if passed_data <> tpu$k_unspecified then ! always scratch buffer if in box select mode eve$$box_paste (passed_data); else ! box paste the 2ndary selection thru scratch buffer if not eve$$reserve_scratch_buffer then eve$message (EVE$_ILLSCRATCHRES); eve$learn_abort; return (FALSE); endif; erase (eve$$x_scratch_buffer); set (INSERT, eve$$x_scratch_buffer); position (eve$$x_scratch_buffer); read_global_select (SECONDARY, "STRING"); position (saved_mark); eve$$box_paste (eve$$x_scratch_buffer); eve$$release_scratch_buffer; endif; else saved_mode := set (INSERT, current_buffer); if passed_data <> tpu$k_unspecified then copy_text (passed_data); else ! the following changes LF's to linebreaks read_global_select (SECONDARY, "STRING"); endif; set (saved_mode, current_buffer); endif; eve$show_first_line; ! insure it's visible at top of window ! LSE addition begin if current_window = lse$command_window then lse$$prompt_copy_command_prompt; endif; ! LSE addition end update (ALL); return (TRUE); ; endcase; endif; %endif return (FALSE); endprocedure; ! eve$$client_message