! LSE$HIGHLIGHT.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: ! Module deals with LSE's highlighting. ! ! ENVIRONMENT: ! VAX/VMS ! ! Author: Walter Carrell III ! Norman M. Chan ! ! CREATION DATE: 19-May-89 ! ! MODIFIED BY: ! X2.3-1 JPW 07-Sep-88 Rewrote the pre and post filters to work better with ! the mouse. ! X2.3-2 JPW 19-Sep-88 Rewrote the highlighting to use undefined key ! procedures instead of pre and post filters on ! the key map lists. ! X2.3-3 GHL 16-Dec-88 Move creation of key maps and key map lists out of ! init procedure to end of file. Delete init ! procedure. ! X2.3-4 WC3 14-Mar-89 Make QUERY and REVIEW highlighting command driven ! Remove all the ket driven stuff. ! X2.3-4 WC3 31-Mar-89 Create lse$$kerr and lse$$hlt ! X2.3-5 DAS 07-Apr-89 Removed ABORT statement from the handlers. ! X3.0-01 CCC 26-May-89 Added to expand visible lines in lse$$highlight() ! X3.0-02 CCC 13-Jun-89 Remove lse$is_visible in lse$$highlight(). ! X3.0-03 ch 13-Jun-89 New calling sequence for lse$make_visible. ! X3.0-04 WC3 19-Jun-89 Use LSE$$IS_QUERY to determine if a buffer is a ! query buffer ! X3.0-05 SAA 22-Jun-89 Add routine to refresh/update $BUFFERS if it ! is mapped (visible). Currently commented out. ! X3.0-06 DAS 14-Jul-89 Add onerror handler to lse$$highlight procedure ! X3.0-07 GJJ 17-Jul-89 Add cursor sync workaround to LSE$$HIGHLIGHT. ! X3.0-07 WC3 14-Jul-89 Add generalized highlighting support procedures ! X3.0-08 WC3 18-Aug-89 Convert to preprocessor BLISS calling TPU ! X3.0-09 PBP 14-Aug-89 Create missing local defintion of window_index to ! lse$$attach_cursor ! X3.0-10 PBP 30-Aug-89 Merged with EVE V2.4 ! X3.0-11 PBP 30-Aug-89 Fixed problem with endmodule statement ! X3.0-12 WC3 25-Aug-89 Undo X3.0-07 ! X3.0-13 WC3 22-Sep-89 Use LSE$$PUSH/POP_POSITION ! Fix lse$$hlt_enable to make the count 0 when it ! should be. ! X3.0-14 WC3 23-May-90 Change the name of LSE$$HIGHLIGHT to ! LSE$POST_COMMAND_PROC ! X3.2-15 SHE 06-Dec-90 Added documentation header. ! X3.2-16 NMC 18-Dec-90 Added highlight capability for buffer list buffer in ! lse$post_command_proc. ! X3.2-17 NMC 26-Dec-90 Added lse$$current_highlight_type, lse$is_review ! X3.2-18 NMC 10-Jan-90 Modified lse$$current_highlight_type to return ! review highlight when not in review buffer. ! X4.0-1 WC3 09-Apr-91 Protected highlight calls in post_command_proc ! so they are called less often ! Added show list highlighting support ! lse$$current_highlight_buffer ! lse$$highlight_show_list ! Removed call to lse$$refresh_show_buffers; ! Fixed highlight flicker caused by local range ! Changed lse$$current_highlight_type to ! lse$$is_highlight_sca ! X4.0-2 WC3 12-Apr-91 Fix off screen reviews ! X4.0-3 DAS 12-Apr-91 Change MARK(NONE) to MARK(FREE_CURSOR) ! X4.0-4 AVH 17-Apr-91 Add Haley header to lse$is_review. ! X4.0-5 WC3 29-Apr-91 Change lse$is_show_list to return a boolean !-- procedure lse$highlight_module_ident return "X4.0-6"; endprocedure; procedure lse$post_command_proc ! ! FUNCTION ! ! Called after every LSE command to make sure the highlighting ! and the current item are the same. The current cursor position is used ! as the current item. This will also expand sufficent lines to make the ! cursor position visible if current record is invisible. ! ! INPUT ! ! current buffer and position ! ! OUTPUT ! ! Highlighting and current item are updated based on the current ! cursor position. Making the cursor position visible. ! ! !doc_begin ! ! ONE LINE DEFINITION: ! «TBS» ! Returns the text portion of a message ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! ON_ERROR ! During initialization CURRENT_BUFFER signals this one. ! [TPU$_NOCURRENTBUF]: RETURN TRUE; [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$post_command_proc"); ENDON_ERROR; ! Any thing to do? ! if lse$$hlt_need_reset THEN IF lse$$is_query( CURRENT_BUFFER ) THEN lse$$highlight_query; RETURN TRUE; ENDIF; IF GET_INFO(CURRENT_BUFFER, "name") = "$REVIEW" THEN lse$$highlight_review; RETURN TRUE; ENDIF; IF lse$is_show_list(current_buffer) THEN lse$$highlight_show_list; RETURN TRUE; ENDIF; ENDIF; ! Expand sufficient lines to make the cursor position visible if current ! record is invisible. This is not applicable to query/review buffers. ! lse$make_visible(0); RETURN TRUE; endprocedure; procedure lse$$kerr ! ! FUNCTION ! ! The error handler code for key definitions. Calls to LSE$POST_COMMAND_PROC ! made the string passed to TPU very long. So we call this procedure ! to shorten the string. ! ! INPUT ! ! ! ! OUTPUT ! ! Highlighting and current item are updated based on the current ! cursor position. ! ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$kerr"); ENDON_ERROR; lse$post_command_proc; eve$learn_abort; endprocedure; procedure lse$$hlt ! ! FUNCTION ! ! Short name for LSE$POST_COMMAND_PROC. Calls to LSE$POST_COMMAND_PROC ! made the string passed to TPU very long. So we call this procedure ! to shorten the string. ! ! INPUT ! ! OUTPUT ! ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$hlt"); ENDON_ERROR; LSE$POST_COMMAND_PROC; endprocedure; ! ! CURRENT ITEM highlighting support ! ! The following routines support the highlighting of the current item: ! ! LSE$$HLT_ADD_RANGE - Add a highlighted region ! LSE$$HLT_DELETE - Delete all the highlighted regions ! LSE$$HLT_DISABLE - Flag as disabled all the regions ! LSE$$HLT_ENABLE - Delete any ranges flagged as disabled ! LSE$$HLT_NEED_RESET - Return true if the current position is different ! from the last time called. ! ! As of this writing (15-Jul-89) REVIEW does not use these routines and ! the SCA support is the only one using them. When we move to the SHOW ! commands begin context sensitive it will be apparent that we need a ! central place to do the current item's highlighting. When we do that ! none of the places that want to set the current item will have to ! worry about the rest of the places that know about their current item. ! ! Requirements: ! ! o Only change the highlighted ranges when we have to ! o Hide the highlighting details ! ! Design overview: ! ! In normally when LSE wants to establish a current item it calls: ! ! o LSE$$HLT_DISABLE to logically remove any highlighting ! o LSE$$HLT_ADD_RANGE to all the new ranges ! o LSE$$HLT_ENABLE to delete any ranges still disabled. ! ! LSE$$HLT_ADD_RANGE doesn't blindly add ranges, but creates one ! and sees if any of the current ones are a match, if it is it flips ! the diabled flag so it won't be deleted by LSE$$HLT_ENABLE ! ! LSE$$HLT_NEED_RESET is for use to tell if the current position ! has changed since the last time called. If it hasn't, the ! highlighting will be the same and we don't need to do the work. ! ! LSE$$HLT_DELETE is a consession to REVIEW mode because it doesn't ! use these routines and needs a way to make sure any other highlighting ! goes away. ! ! Futures: ! ! Highlighting renditions are left to those who enhance this for ! use by all of LSE. ! PROCEDURE lse$$hlt_add_range( rec_num_start, char_offset_start, rec_num_end, char_offset_end ) ! ! FUNCTION ! ! LSE$$HLT_ADD_REGION adds a highlight region to the query highlighting ! list if it isn't already there. ! ! Assumes that the current buffer is the on to be highlighted ! ! FORMAL PARAMTERS: ! ! rec_num_start - The record the start of the range is on ! ! char_offset_start - The character offset of the start of the range ! ! rec_num_end - The record the end of the range is on ! ! char_offset_end - The character offset of the end of the range ! ! IMPLICIT INPUTS: ! ! lse$$hlt_range_array ! lse$$hlt_range_array_flags; ! lse$$hlt_range_array_count; ! ! OUTPUT ! ! lse$$hlt_range_array, lse$$hlt_range_array_count and ! lse$$hlt_range_array_flags are updated ! LOCAL array_index, end_mark, start_mark; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$hlt_add_range"); ENDON_ERROR; ! Loop over looking for a match ! array_index := 1; LOOP EXITIF array_index > lse$$hlt_range_array_count; ! Simply clear the disable flag if we find a match ! IF lse$$hlt_range_array{ array_index } <> tpu$k_unspecified THEN ! Note, is would be easier to create the range here and compare ! ranges. However, this creates a duplicate local reverse video ! range that is deleted on procedure exit. This causes the screen ! updater to redo the reverse video, causing a flicker at 9600 ! baud and awful waits at lower bauds. ! start_mark := BEGINNING_OF(lse$$hlt_range_array{ array_index }); end_mark := END_OF(lse$$hlt_range_array{ array_index }); IF (rec_num_start = GET_INFO( start_mark, 'record_number' )) AND (char_offset_start = GET_INFO( start_mark, 'offset' )) AND (rec_num_end = GET_INFO( end_mark, 'record_number' )) AND (char_offset_END = GET_INFO( end_mark, 'offset' )) THEN lse$$hlt_range_array_flags{ array_index } := 0; RETURN; ENDIF; ENDIF; array_index := array_index + 1; ENDLOOP; ! If we get here we have to really add the range ! ! Go over the array looking for a hole to put the new one in ! array_index := 1; LOOP EXITIF array_index > lse$$hlt_range_array_count; EXITIF GET_INFO(lse$$hlt_range_array{array_index},'type') = UNSPECIFIED; array_index := array_index + 1; ENDLOOP; IF array_index > lse$$hlt_range_array_count THEN lse$$hlt_range_array_count := array_index; ENDIF; ! Load up the new element ! ! Save the current position and mark ! lse$$push_position; ! Create the range ! POSITION( rec_num_start ); POSITION( LINE_BEGIN ); MOVE_HORIZONTAL( char_offset_start ); start_mark := MARK( NONE ); POSITION( rec_num_end ); POSITION( LINE_BEGIN ); MOVE_HORIZONTAL( char_offset_end ); lse$$hlt_range_array{ array_index } := CREATE_RANGE( start_mark, MARK( NONE ), REVERSE ); lse$$hlt_range_array_flags{ array_index } := 0; ! Restore the position here because it simplifies the following loop ! lse$$pop_position; ENDPROCEDURE; PROCEDURE lse$$hlt_delete ! ! FUNCTION ! ! LSE$$HLT_DELETE deletes all the highlight regions ! ! IMPLICIT INPUTS: ! ! lse$$hlt_range_array ! lse$$hlt_range_array_flags; ! lse$$hlt_range_array_count; ! lse$$hlt_need_reset_mark; ! ! OUTPUT ! ! lse$$hlt_range_array, lse$$hlt_range_array_count and ! lse$$hlt_range_array_flags are updated ! ! lse$$hlt_need_reset_mark is cleared ! ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$hlt_delete"); ENDON_ERROR; lse$$hlt_disable; lse$$hlt_enable; DELETE( lse$$hlt_need_reset_mark ); ENDPROCEDURE; PROCEDURE lse$$hlt_disable ! ! FUNCTION ! ! LSE$$HLT_DISABLE flags all the highlight regions as disabled ! ! IMPLICIT INPUTS: ! ! lse$$hlt_range_array_flags; ! lse$$hlt_range_array_count; ! ! OUTPUT ! ! lse$$hlt_range_array_flags is updated ! LOCAL array_index; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$hlt_disable"); ENDON_ERROR; array_index := 1; LOOP EXITIF array_index > lse$$hlt_range_array_count; lse$$hlt_range_array_flags{ array_index } := 1; array_index := array_index + 1; ENDLOOP; ENDPROCEDURE; PROCEDURE lse$$hlt_dump ! ! FUNCTION ! ! LSE$$HLT_DUMP dumps the contents of the highlight array to the message ! buffer ! ! IMPLICIT INPUTS: ! ! lse$$hlt_range_array ! lse$$hlt_range_array_flags ! lse$$hlt_range_array_count ! ! OUTPUT ! ! The message buffer is altered ! LOCAL array_index; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$hlt_dump"); ENDON_ERROR; message( 'Highlight array count: ' + STR( lse$$hlt_range_array_count ) ); array_index := 1; LOOP EXITIF array_index > lse$$hlt_range_array_count; IF GET_INFO( lse$$hlt_range_array{ array_index }, 'type' ) = UNSPECIFIED THEN message( str( array_index ) + '. ' + str( lse$$hlt_range_array_flags{ array_index } ) + ' UNSPECIFIED' ); ELSE message( str( array_index ) + '. ' + str( lse$$hlt_range_array_flags{ array_index } ) + ' "' + str( lse$$hlt_range_array{ array_index } ) + '"' ); ENDIF; array_index := array_index + 1; ENDLOOP; ENDPROCEDURE; PROCEDURE lse$$hlt_test ! ! FUNCTION ! ! LSE$$HLT_TEST dumps the "good" contents of the highlight array to the ! message buffer for testing purposes. ! ! IMPLICIT INPUTS: ! ! lse$$hlt_range_array ! lse$$hlt_range_array_flags ! lse$$hlt_range_array_count ! ! OUTPUT ! ! The message buffer is altered ! LOCAL array_index, good_index; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$hlt_test"); ENDON_ERROR; good_index := 0; array_index := 1; LOOP EXITIF array_index > lse$$hlt_range_array_count; IF GET_INFO( lse$$hlt_range_array{array_index}, 'type' ) <> UNSPECIFIED THEN good_index := good_index + 1; message( str( good_index ) + '. ' + str( lse$$hlt_range_array_flags{ array_index } ) + ' "' + str( lse$$hlt_range_array{ array_index } ) + '"' ); ENDIF; array_index := array_index + 1; ENDLOOP; ENDPROCEDURE; PROCEDURE lse$$hlt_enable ! ! FUNCTION ! ! LSE$$HLT_ENABLE removes all the ranges flagged as disabled ! ! IMPLICIT INPUTS: ! ! lse$$hlt_range_array ! lse$$hlt_range_array_flags; ! lse$$hlt_range_array_count; ! ! OUTPUT ! ! lse$$hlt_range_array, lse$$hlt_range_array_count and ! lse$$hlt_range_array_flags are updated ! LOCAL array_index; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$hlt_enable"); ENDON_ERROR; ! If you are using these routines, review highlighting needs to go away. ! lse$delete_review_highlight; ! Walk over deleting ! array_index := 1; LOOP EXITIF array_index > lse$$hlt_range_array_count; ! If we find one to delete ! IF lse$$hlt_range_array_flags{ array_index } = 1 THEN ! Delete it and clear the flag ! DELETE( lse$$hlt_range_array{ array_index } ); lse$$hlt_range_array_flags{ array_index } := 0; ! Next ! array_index := array_index - 1; ENDIF; array_index := array_index + 1; ENDLOOP; ENDPROCEDURE; PROCEDURE lse$$hlt_need_reset ! ! FUNCTION ! ! LSE$$HLT_NEED_RESET returns TRUE if the current position is the same ! as the last time it was called. ! ! IMPLICIT INPUTS: ! ! lse$$hlt_need_reset_mark ! ! IMPLICIT OUTPUTS: ! ! lse$$hlt_need_reset_mark ! ! RETURN VALUE: ! ! TRUE if the current position matches the save one ! FALSE is not. ! ON_ERROR [TPU$_NOCURRENTBUF]: [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$hlt_need_reset"); ENDON_ERROR; IF GET_INFO( lse$$hlt_need_reset_mark, 'type' ) = MARKER THEN IF lse$$hlt_need_reset_mark = MARK( FREE_CURSOR ) THEN RETURN FALSE; ENDIF; ENDIF; lse$$hlt_need_reset_mark := MARK( FREE_CURSOR ); RETURN true; ENDPROCEDURE; PROCEDURE lse$is_review(;buffer_ptr) !doc_begin ! ! ONE LINE DEFINITION: ! LSE$IS_REVIEW checks whether the current position is in the $REVIEW buffer ! «TBS» ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end !++ ! ! INPUTS: ! ! none ! ! OUTPUTS: ! ! none ! ! RETURN VALUE: ! ! TRUE - the current position is in the $REVIEW buffer ! FALSE - the current position is not in the $REVIEW buffer ! LOCAL the_buffer_ptr; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$is_review"); ENDON_ERROR; if get_info(buffer_ptr, "type") <> BUFFER then the_buffer_ptr := current_buffer; else the_buffer_ptr := buffer_ptr; endif; if get_info(the_buffer_ptr, "name") = "$REVIEW" then return TRUE; else return FALSE; endif; ENDPROCEDURE; PROCEDURE lse$$is_highlight_sca ! ! FUNCTION ! ! LSE$$is_highlight_sca returns true is the highlight is in a QUERY buffer ! ! IMPLICIT INPUTS: ! ! lse$$hlt_range_array ! ! IMPLICIT OUTPUTS: ! ! lse$$hlt_range_array ! ! RETURNS; ! ! True is the current highlight buffer is a query buffer ! False otherwise ! LOCAL array_index, hlt_buffer; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$is_highlight_sca"); ENDON_ERROR; ! ! Go through the highlight array database and find out the buffer the ! current highlight is on ! array_index := 1; LOOP EXITIF array_index > lse$$hlt_range_array_count; EXITIF lse$$hlt_range_array{array_index} <> TPU$K_UNSPECIFIED; array_index := array_index + 1; ENDLOOP; if lse$$hlt_range_array{array_index} <> TPU$K_UNSPECIFIED then if lse$$is_query(get_info(lse$$hlt_range_array{array_index}, "buffer")) then RETURN true; endif; endif; return false; ENDPROCEDURE; PROCEDURE lse$$current_highlight_buffer ! ! FUNCTION ! ! LSE$$CURRENT_HIGHLIGHT_BUFFER returns the buffer of the current highlighting ! ! IMPLICIT INPUTS: ! ! lse$$hlt_range_array ! ! IMPLICIT OUTPUTS: ! ! lse$$hlt_range_array ! ! RETURN VALUE: ! ! buffer or 0 ! one of the above specified buffers ! LOCAL array_index, hlt_buffer; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$current_highlight_buffer"); ENDON_ERROR; ! Go through the highlight array database and find out the buffer the ! current highlight is on ! array_index := 1; LOOP EXITIF array_index > lse$$hlt_range_array_count; EXITIF lse$$hlt_range_array{array_index} <> TPU$K_UNSPECIFIED; array_index := array_index + 1; ENDLOOP; if lse$$hlt_range_array{array_index} <> TPU$K_UNSPECIFIED then return GET_INFO( lse$$hlt_range_array{array_index}, "buffer" ); endif; ! We're here when we can't find any highlight ! return get_info(BUFFERS, "find_buffer","$REVIEW"); ENDPROCEDURE; !++ ! FUNCTIONAL DESCRIPTION: ! ! LSE$$HIGHLIGHT_SHOW_LIST highlights the current buffer list line in the buffer ! list buffer. ! ! INPUTS ! ! none ! ! OUTPUTS: ! ! none - return tpu$k_unspecified ! ! COMPLETION CODES: ! ! none ! PROCEDURE lse$$highlight_show_list ! !doc_begin ! ! ONE LINE DEFINITION: ! «TBS» ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! LOCAL replacement_range; ON_ERROR [TPU$_NOEOBSTR]: ; [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$highlight_show_list"); ENDON_ERROR; ! Get the range ! replacement_range := lse$shlst_hlt_range( MARK( NONE ) ); ! Do the highlighting ! lse$$hlt_disable; lse$$hlt_add_range( GET_INFO( BEGINNING_OF( replacement_range ), 'record_number' ), 0, GET_INFO( END_OF( replacement_range ), 'record_number' ), GET_INFO( END_OF( replacement_range ), 'offset' ) ); lse$$hlt_ENABLE; RETURN true; ENDPROCEDURE; variable lse$$hlt_range_array; variable lse$$hlt_range_array_flags; variable lse$$hlt_range_array_count; variable lse$$hlt_need_reset_mark;