! ! LSE$$MULTI_WINDOW.TPU ! !************************************************************************* ! * ! © Copyright 2003 Hewlett-Packard Development Company, L.P. * ! * ! Confidential computer software. Valid license from HP and/or its * ! subsidiaries 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: ! LSE Language-Sensitive Editor ! ! ABSTRACT: ! This module implements LSE's multiple window support. ! ! AUTHOR: ! Walter Carrell III, Technical Languages and Environments ! ! CREATION DATE: 23-Jun-89 ! ! MODIFICATION HISTORY: ! X3.0-2 WC3 18-Aug-89 Convert to preprocessor BLISS calling TPU ! X3.0-3 WC3 20-SEP-89 Cut dependency on query buffer having $QUERY ! in it's name ! X3.0-4 DAS 11-Nov-89 Issue an UPDATE(ALL) after splitting to workaround ! a screen updater problem. ! X3.1 DAS 13-Feb-90 Change call to lse$$goto_buffer to pass integers ! X3.2 WC3 02-Aug-90 Changee eve$x_scroll_top/bottom to get_info ! X3.2-1 WC3 15-Aug-90 Fix all procedures return true on success ! Use GET_INFO instead of variables where appropriate ! X3.2-2 AVH 29-AUg-90 Move procedure lse$$one_window to lse$grammar and ! change the procedure name to lse_one_window to ! support the new grammar. ! X3.2-3 DEC 29-Aug-90 Change lse$$goto_buffer to lse$buffer ! X3.2-4 WC3 01-Oct-90 Change parameters to many GET_INFOS ! X3.2-5 DAS 03-Oct-90 Change lse$buffer to lse$buffer_util ! X3.2-6 NMC 21-Jan-91 Added t/f return argument for lse$$split_window_auto ! Modified lse$other_window to add 'show' buffer type ! X3.2-7 LRH 18-Feb-91 Checked for current_buf <> 0 in lse$$other_window ! X4.0 ch 28-Mar-91 Fix unexpected error in lse$$pos_buf_if_vis when ! doing SCA FIND with /NODISP. ! X4.0-1 WC3 11-Jul-91 Remove unnecessary update call ! X4.0-2 DAS 27-Oct-91 Added missing declarations ! X4.0-3 WC3 23-Jan-92 lse$$balance_wind_always could get an unexpected ! UNSPECIFED error if the algorithm thought the ! top window's top needed adjusting ! X4.0-4 WC3 29-Jan-92 Protect lse$$multi_window from being in the ! command of prompt window ! X4.0-5 WC3 15-Apr-92 Fix unexpected TPU$_WINDNOTVIS !-- ! FORWARD ROUTINE ! lse$$adjust_window_prep ! lse$$auto_pick_a_window ! lse$$balance_windows ! lse$$balance_windows_always ! lse$$length_of_all_windows ! lse$$multi_window ! lse$$max_number_of_windows ! lse$$not_current_window ! lse_one_window ! lse$$other_window ! lse$$output_window_state - debugging help ! lse$$pop_and_position_buffer ! lse$$pop_buffer ! lse$$pop_util ! lse$$split_wind_always ! lse$$split_window_auto ! lse$$two_windows ! procedure lse$multi_window_module_ident return "X4.0-5"; endprocedure; !+ ! LSE$$ADJUST_WINDOW_PREP ! ! FUNCTION ! ! LSE$$ADJUST_WINDOW_PREP is used by LSE$$BALANCE_WINDOW_ALWAYS to make ! sure that as it adjusts the windows no windows become "invisible". ! An invisible window can't be adjusted. ! ! It assumes that we are walking the windows from bottom to top. ! ! INPUT ! ! window_index - The window number about to be adjusted ! top - The amount the top of the window will be moved ! ! OUTPUT ! ! The window above the one passed will not be made invisible by the ! adjustment. ! !- PROCEDURE lse$$adjust_window_prep( window_index, top ) LOCAL min_lines, new_top; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$adjust_window_prep"); ENDON_ERROR; ! We're done if we're at the top ! IF window_index <= 1 THEN RETURN TRUE; ENDIF; ! Set the minimum number of lines allowed in a window ! IF GET_INFO( eve$$x_windows{ window_index-1 }, "status_line" ) = 0 THEN min_lines := 1; ELSE min_lines := 2; ENDIF; ! Correct for the horizontal scroll bar ! IF eve$x_decwindows_active THEN IF GET_INFO( eve$$x_windows{window_index}, 'scroll_bar', HORIZONTAL ) <> 0 THEN min_lines := min_lines + 1; ENDIF; ENDIF; ! Will the next window up be made invisible ! ! New top of passed window - next window's top < minimum lines in a window ! IF GET_INFO(eve$$x_windows{window_index}, "visible_top") + top - GET_INFO(eve$$x_windows{window_index-1},"visible_top") < min_lines THEN ! It will be made invisible. Se we'll adjust it so it won't be. ! This means of course that we'll call recursively ! ! Amount to move the next windows is ! New top of passed window - munimum number of lines in a window - ! the next windows's current top ! ! Put another way: The next window's top must be at least the minimum ! window length above the New top of the passed window. ! new_top := GET_INFO( eve$$x_windows{window_index}, "visible_top" ) + top - min_lines - GET_INFO( eve$$x_windows{window_index-1}, "visible_top" ); lse$$adjust_window_prep( window_index-1, new_top ); ADJUST_WINDOW( eve$$x_windows{window_index-1}, new_top, 0 ); ENDIF; RETURN TRUE; ENDPROCEDURE; !+ ! LSE$$AUTO_PICK_A_WINDOW ! ! FUNCTION ! ! Split a window if possible, and use and use LSE$$OTHER_WINDOW to ! chose a window ! ! INPUT ! ! buffer_type - The type of buffer being looked for. ! ! OUTPUT ! ! The cursor is positioned in the window chosen ! !- PROCEDURE lse$$auto_pick_a_window( buffer_type ) ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$auto_pick_a_window"); ENDON_ERROR; lse$$auto_pick_a_window := lse$$split_window_auto( 2 ); lse$$other_window( buffer_type ); ENDPROCEDURE; !+ ! LSE$$BALANCE_WINDOWS ! ! FUNCTION ! ! Balance the size of all the windows on the screen if we're suposed to ! ! INPUT ! ! ! OUTPUT ! ! !- PROCEDURE lse$$balance_windows ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$balance_windows"); ENDON_ERROR; ! Nothing to do if there is one window. ! IF (eve$x_number_of_windows = 1) OR (GET_INFO( lse$window, 'lse$balance_windows' ) = FALSE) THEN RETURN TRUE; ENDIF; RETURN lse$$balance_wind_always; ENDPROCEDURE; !+ ! LSE$$BALANCE_WIND_ALWAYS ! ! FUNCTION ! ! Balance the size of all the windows on the screen ! ! INPUT ! ! ! OUTPUT ! ! !- PROCEDURE lse$$balance_wind_always LOCAL bot_change, ! The number of lines the bottom will change current_bot, ! The row of the bottom current_top, ! The row of the top height_left, ! The number of lines left for use mumble, ! Required parameter we throw away saved_mark, ! saved_window, ! top_change, ! The number of lines the top will change window_index, ! The current index into the eve$$x_windows array window_height; ON_ERROR [TPU$_WINDNOTVIS]: eve$set_all_windows(SCROLLING, GET_INFO( lse$window, 'lse$top_scroll_margin' ), GET_INFO( lse$window, 'lse$bottom_scroll_margin' )); RETURN true; [OTHERWISE]: eve$set_all_windows(SCROLLING, GET_INFO( lse$window, 'lse$top_scroll_margin' ), GET_INFO( lse$window, 'lse$bottom_scroll_margin' )); lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$balance_wind_always"); ENDON_ERROR; ! Nothing to do if there is one window. ! IF eve$x_number_of_windows <= 1 THEN RETURN TRUE; ENDIF; ! Save the current position in case ADJUST_WINDOW changes it ! saved_window := CURRENT_WINDOW; saved_mark := MARK( FREE_CURSOR ); ! We're done when the window height is small ! height_left := eve$main_window_length; IF (height_left/eve$x_number_of_windows) < 2 THEN RETURN TRUE; ENDIF; ! Turn scroll margins off to supress a information from ADJUST_WINDOW ! about changing the scroll margins behind the user's back ! eve$set_all_windows( SCROLLING, 0, 0); ! Walk over the windows, adjusting them ! window_index := eve$x_number_of_windows; LOOP ! Init the top and bottom row number for this window ! current_top := GET_INFO( eve$$x_windows{window_index}, "visible_top" ) - 1; current_bot := current_top + GET_INFO( eve$$x_windows{window_index}, "visible_length" ); ! Calculate the window length for this window. Note ! that the calculation favors the bottom windows. That is ! the rond off is added to the bottom windows first ! window_height := (height_left + window_index - 1) / window_index; bot_change := height_left - current_bot; top_change := (height_left - window_height) - current_top; IF (top_change <> 0) OR (bot_change <> 0) THEN ! Adjust the window ! lse$$adjust_window_prep( window_index, top_change ); ADJUST_WINDOW( eve$$x_windows{window_index}, top_change, bot_change); ! This ADJUST_WINDOW's purpose is to move the visible_top ! and visible_bottom to Original_top and original_bottom. ! This is so that subsequent MAPs of the window will result ! in a window is the size we've carefully made visible. ! Without this call, should this window ever have it's buffer ! changed, It would put the original window size on the screen, ! Thus messing up what we've done here. ! IF (top_change <> 0) AND (window_index > 1) THEN ADJUST_WINDOW( eve$$x_windows{ window_index-1 }, 0, 0 ); ENDIF; IF bot_change <> 0 THEN ADJUST_WINDOW( eve$$x_windows{ window_index }, 0, 0 ); ENDIF; ENDIF; ! Calculate the remaining window space ! height_left := height_left - window_height; ! Next window ! window_index := window_index - 1; EXITIF window_index < 1; ENDLOOP; ! Put the cursor back and restore the scroll margins ! eve$set_all_windows(SCROLLING, GET_INFO( lse$window, 'lse$top_scroll_margin' ), GET_INFO( lse$window, 'lse$bottom_scroll_margin' )); POSITION( saved_window ); POSITION( saved_mark ); RETURN TRUE; ENDPROCEDURE; !+ ! LSE$$LENGTH_OF_ALL_WINDOWS ! ! FUNCTION ! ! Usable screen length for user windows. ! ! INPUT ! ! EVE$X_WINDOWS context ! ! OUTPUT ! ! The length of the usable windows ! !- PROCEDURE lse$$length_of_all_windows LOCAL return_value; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$length_of_all_windows"); ENDON_ERROR; return_value := GET_INFO( EVE$$X_WINDOWS{ EVE$X_NUMBER_OF_WINDOWS }, 'visible_bottom' ) - GET_INFO( EVE$$X_WINDOWS{ 1 }, 'visible_top' ) + 1; IF GET_INFO( EVE$$X_WINDOWS{ EVE$X_NUMBER_OF_WINDOWS }, 'status_line' ) <> 0 THEN return_value := return_value + 1; ENDIF; RETURN return_value; ENDPROCEDURE; !+ ! LSE$$MULTI_WINDOW ! ! FUNCTION ! ! Give the user an arbitrary number of windows. ! ! INPUT ! ! new_number_of_windows - The number of windows to place on the screen ! respect_flag - True (1) if to respect value returned by ! LSE$$MAX_NUMBER_OF_WINDOWS ! False (0) if to simply put number_of_window on ! the screen ! ! lse$message_window ! tpu$x_repeat_count ! eve$x_number_of_windows ! eve$$x_windows{} ! ! OUTPUT ! ! Two windows if appropriate ! !- PROCEDURE lse$$multi_window( new_number_of_windows, respect_flag ) LOCAL max_number_of_windows, number_of_windows, mumble, current_buf, inner_count, outer_count, saved_mark, saved_prompt_window, saved_prompt_buffer, saved_window, temp, window_to_delete; ON_ERROR [OTHERWISE]: if get_info( saved_window, 'type' ) = window then POSITION( saved_window ); endif; if get_info( saved_mark, 'type' ) = marker then POSITION( saved_mark ); endif; lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$multi_window"); ENDON_ERROR; saved_window := CURRENT_WINDOW; saved_mark := MARK( FREE_CURSOR ); number_of_windows := new_number_of_windows; ! There might be no change ! IF number_of_windows = eve$x_number_of_windows THEN RETURN lse$$balance_windows; ENDIF; IF (CURRENT_WINDOW = lse$command_window) OR (CURRENT_WINDOW = lse$prompt_window) THEN saved_prompt_window := current_window; saved_prompt_buffer := current_buffer; UNMAP( CURRENT_WINDOW ); ENDIF; ! Take care of the one ! IF number_of_windows <= 1 THEN temp := eve_one_window; IF saved_prompt_window <> 0 THEN MAP( saved_prompt_window, saved_prompt_buffer ); ENDIF; RETURN temp; ENDIF; ! We either have to split some windows or delete some ! IF number_of_windows < eve$x_number_of_windows THEN ! We have to delete some windows. ! ! Start by looking for "duplicate" windows. i.e. ones with the ! same buffer ! outer_count := 0; LOOP ! Next ! outer_count := outer_count + 1; EXITIF outer_count > eve$x_number_of_windows; ! Walk over the rest to find the match ! inner_count := outer_count; current_buf := GET_INFO( eve$$x_windows{ outer_count }, 'buffer' ); LOOP ! Next ! inner_count := inner_count + 1; EXITIF inner_count > eve$x_number_of_windows; ! Same buffer in two windows? If so, position and we're done ! IF GET_INFO( eve$$x_windows{inner_count}, 'buffer' ) = current_buf THEN POSITION( lse$$not_current_window( eve$$x_windows{outer_count}, eve$$x_windows{inner_count})); EVE_DELETE_WINDOW; POSITION( saved_window ); POSITION( saved_mark ); IF number_of_windows >= eve$x_number_of_windows THEN IF saved_prompt_window <> 0 THEN MAP( saved_prompt_window, saved_prompt_buffer ); ENDIF; RETURN lse$$balance_windows; ENDIF; ENDIF; ENDLOOP; ENDLOOP; ! We've finished looking for "duplicate" windows and there are still ! windows to delete ! ! Blow away from bottom to top, skipping the current window ! LOOP EXITIF number_of_windows >= eve$x_number_of_windows; POSITION( saved_window ); POSITION( saved_mark ); IF CURRENT_WINDOW = eve$$x_windows{ eve$x_number_of_windows } THEN window_to_delete := eve$x_number_of_windows - 1; ELSE window_to_delete := eve$x_number_of_windows; ENDIF; POSITION( eve$$x_windows{ window_to_delete } ); EVE_DELETE_WINDOW; ENDLOOP; POSITION( saved_window ); POSITION( saved_mark ); IF saved_prompt_window <> 0 THEN MAP( saved_prompt_window, saved_prompt_buffer ); ENDIF; RETURN lse$$balance_windows; ELSE ! He wants more windows ! IF respect_flag = 1 THEN ! First figure out the actual number we'll give him. ! ! We are limited by the minimum window size when the windows aren't ! balanced ! IF GET_INFO( lse$window, 'lse$balance_windows' ) = FALSE THEN ! When we are not balancing windows we split the current as many times ! as we can ! temp := number_of_windows - eve$x_number_of_windows; LOOP EXITIF GET_INFO( CURRENT_WINDOW, 'visible_length' )/(temp+1) >= GET_INFO( lse$window, 'lse$min_window_len' ); temp := temp - 1; EXITIF temp < 1; ENDLOOP; number_of_windows := eve$x_number_of_windows + temp; ENDIF; ! We are always limited by the maximum_window_number ! max_number_of_windows := lse$$max_number_of_windows; IF max_number_of_windows < number_of_windows THEN number_of_windows := max_number_of_windows; ENDIF; ! We may be done ! IF number_of_windows <= eve$x_number_of_windows THEN IF saved_prompt_window <> 0 THEN MAP( saved_prompt_window, saved_prompt_buffer ); ENDIF; RETURN lse$$balance_windows; ENDIF; ENDIF; ! Figure out how many windows the current window must become. ! And make sure the current window will split that many times. ! number_of_windows := number_of_windows - eve$x_number_of_windows + 1; IF GET_INFO(CURRENT_WINDOW,"visible_length") < number_of_windows*3 THEN eve$enlarge_window( number_of_windows*3 - GET_INFO( CURRENT_WINDOW, 'visible_length' ), mumble ); ENDIF; eve_split_window( number_of_windows ); IF saved_prompt_window <> 0 THEN MAP( saved_prompt_window, saved_prompt_buffer ); ENDIF; RETURN lse$$balance_windows; ENDIF; IF saved_prompt_window <> 0 THEN MAP( saved_prompt_window, saved_prompt_buffer ); ENDIF; RETURN TRUE; ENDPROCEDURE; !+ ! LSE$$MAX_NUMBER_OF_WINDOWS ! ! FUNCTION ! ! Determine the maximum number of windows that can be on the screen ! ! INPUT ! ! lse$$length_of_all_windows ! ! OUTPUT ! ! The maximum number of windows that are allowed on the screen ! !- PROCEDURE lse$$max_number_of_windows LOCAL max; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$max_number_of_windows"); ENDON_ERROR; max := lse$$length_of_all_windows/GET_INFO( lse$window, 'lse$min_window_len' ); IF max > GET_INFO( lse$window, 'lse$max_windows' ) THEN RETURN GET_INFO( lse$window, 'lse$max_windows' ); ENDIF; RETURN max; ENDPROCEDURE; !+ ! LSE$$NOT_CURRENT_WINDOW ! ! FUNCTION ! ! Return the window which isn't the current window or the first one. ! ! INPUT ! ! first_window - a window variable ! secons_window - a window variable ! ! OUTPUT ! ! returns the windows that isn't the current window ! !- PROCEDURE lse$$not_current_window( first_window, second_window ); ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$not_current_window"); ENDON_ERROR; ! First make sure they are both windows. We assume at least one is. ! IF GET_INFO( second_window, 'type' ) <> window THEN RETURN first_window; ENDIF; IF GET_INFO( first_window, 'type' ) <> window THEN RETURN second_window; ENDIF; IF first_window <> CURRENT_WINDOW THEN RETURN first_window; ENDIF; RETURN second_window; ENDPROCEDURE; !+ ! LSE$$OTHER_WINDOW ! ! FUNCTION ! ! pick a window to use. hopefully an extra one. ! ! INPUT ! ! buffer_type - The "type" of buffer being looked for. ! Valid input is: ! $REVIEW ! $QUERY ! "" ! ! OUTPUT ! ! The cursor is positioned in the window of choice ! !- PROCEDURE lse$$other_window( buffer_type ) LOCAL automatic_windows, buffer_name, current_buf, inner_count, mark1, mark2, outer_count, saved_mark, saved_window, type_match; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$other_window"); ENDON_ERROR; ! ! The local variable 'automatic_windows' will be set to true if the passed in ! parameter is either QUERY, REVIEW, or SHOW. Otherwise, it will be set to ! false. ! automatic_windows := TRUE; IF (buffer_type <> lse$$x_buf_str_review) THEN IF (buffer_type <> '$QUERY') THEN IF (buffer_type <> lse$$k_show_buffer_prefix) THEN automatic_windows := FALSE; ENDIF; ENDIF; ENDIF; ! Main loops over the windows ! ! The first loop over the windows is looking for "exact" duplicates windows. ! By this I mean windows with the same buffer, beside each other on the ! screen and having equivalent current positions. ! ! We do this in case the user has 2 "duplicate" windows, that is ones ! with the same buffer. And LSE has split one. We want to use the one ! that has been split by LSE. Rather than try to keep a state variable ! we apply this test. ! outer_count := 0; type_match := 0; LOOP ! Next ! outer_count := outer_count + 1; EXITIF outer_count >= eve$x_number_of_windows; ! "Exact duplicate" windows? ! IF (GET_INFO( eve$$x_windows{outer_count+1}, 'buffer' ) = GET_INFO( eve$$x_windows{ outer_count }, 'buffer' ) ) THEN ! We've passed the buffers are equal and they are beside each other test ! Now we have to pass the same position test ! saved_mark := MARK( FREE_CURSOR ); saved_window := CURRENT_WINDOW; ! Do the positioning magic to make the test ! POSITION( eve$$x_windows{ outer_count } ); mark1 := MARK( FREE_CURSOR ); POSITION( eve$$x_windows{ outer_count } ); mark2 := MARK( FREE_CURSOR ); ! Restore what we've changed ! POSITION( saved_window ); POSITION( saved_mark ); IF mark1 = mark2 THEN POSITION(lse$$not_current_window(eve$$x_windows{outer_count}, eve$$x_windows{outer_count+1})); RETURN TRUE; ENDIF; ENDIF; ENDLOOP; ! If we find a window with the same buffer in it, we position and we're done ! Otherwise we try to find a window with a buffer of the passed type. ! If we find one we position and we're done, if not just goto the next window. ! outer_count := 0; type_match := 0; LOOP ! Next ! outer_count := outer_count + 1; EXITIF outer_count > eve$x_number_of_windows; ! Walk over the rest to find the match ! inner_count := outer_count; current_buf := GET_INFO( eve$$x_windows{ outer_count }, 'buffer' ); LOOP ! Next ! inner_count := inner_count + 1; EXITIF inner_count > eve$x_number_of_windows; ! Same buffer in two windows? If so, position and we're done ! IF GET_INFO( eve$$x_windows{ inner_count }, 'buffer' ) = current_buf THEN POSITION( lse$$not_current_window( eve$$x_windows{outer_count}, eve$$x_windows{inner_count})); RETURN TRUE; ENDIF; ENDLOOP; ! ! See if the type matches ! IF current_buf <> 0 THEN buffer_name := GET_INFO( current_buf, 'name' ); IF automatic_windows THEN IF (buffer_name = lse$$x_buf_str_review) OR (lse$$is_query( current_buf )) OR (lse$is_show( current_buf )) THEN type_match := lse$$not_current_window( type_match, eve$$x_windows{outer_count} ); ENDIF; ELSE IF (buffer_name <> lse$$x_buf_str_review) THEN IF (lse$$is_query( current_buf ) <> TRUE) THEN IF (lse$is_show( current_buf ) <> TRUE) THEN type_match := lse$$not_current_window( type_match, eve$$x_windows{outer_count} ); ENDIF; ENDIF; ENDIF; ENDIF; ENDIF; ENDLOOP; ! If we found a type match we position to it, otherwise just next window; ! IF type_match <> 0 THEN POSITION( type_match ); ELSE IF eve$x_number_of_windows > 1 THEN eve_next_window; ENDIF ENDIF; RETURN TRUE; ENDPROCEDURE; !+ ! LSE$$OUTPUT_WINDOW_STATE ! ! FUNCTION ! ! LSE$$OUTPUT_WINDOW_STATE outputs messages of the current state ! of the windows of the screen. ! ! I had enough trouble debugging the balanced windows to need such a routine ! ! INPUT ! ! eve$x_window{} ! eve$x_number_of_windows ! ! OUTPUT ! ! Messages are printed ! !- PROCEDURE lse$$output_window_state LOCAL temp_str, window_index; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$output_window_state"); ENDON_ERROR; window_index := eve$x_number_of_windows; loop message( str( window_index ) + '.' + ' original_length: ' + str(GET_INFO(eve$$x_windows{window_index},"original_length")) + ' original_top: ' + str(GET_INFO(eve$$x_windows{window_index},"original_top")) + ' original_bottom: ' + str(GET_INFO(eve$$x_windows{window_index},"original_bottom"))); message( ' ' + ' visible_length: ' + str(GET_INFO(eve$$x_windows{window_index},"visible_length")) + ' visible_top: ' + str(GET_INFO(eve$$x_windows{window_index},"visible_top")) + ' visible_bottom: ' + str(GET_INFO( eve$$x_windows{window_index},"visible_bottom"))); if eve$$x_windows{window_index} = current_window then temp_str := '*'; else temp_str := ' '; endif; message( temp_str + get_info( eve$$x_windows{window_index}, 'status_line' ) ); window_index := window_index - 1; EXITIF window_index < 1; ENDLOOP; RETURN TRUE; ENDPROCEDURE; !+ ! LSE$$POP_POSITION_BUF ! ! FUNCTION ! ! Try to find the buffer in the set of windows. If found position to it. ! If not, check to see if the buffer exists. if it does, split and use ! LSE$$OTHER_WINDOW to chose a window and goto the buffer. ! ! INPUT ! ! buffer_name - The name of buffer being looked for. ! buffer_type - The type of buffer being looked for. ! ! OUTPUT ! ! The cursor is positioned in the window if found ! !- PROCEDURE lse$$pop_position_buf( buffer_name, buffer_type ) ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$pop_position_buf"); ENDON_ERROR; RETURN lse$$pop_util( buffer_name, buffer_type, TRUE ); ENDPROCEDURE; !+ ! LSE$$POP_BUFFER ! ! FUNCTION ! ! Try to find the buffer in the set of windows. If found done. ! If not, check to see if the buffer exists. if it does, split and use ! LSE$$OTHER_WINDOW to chose a window and put the buffer in the window. ! Otherwise do nothing. ! ! INPUT ! ! buffer_name - The name of buffer being looked for. ! buffer_type - The type of buffer being looked for. ! ! OUTPUT ! ! The cursor is positioned in the window if found ! !- PROCEDURE lse$$pop_buffer( buffer_name, buffer_type ) ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$pop_buffer"); ENDON_ERROR; RETURN lse$$pop_util( buffer_name, buffer_type, FALSE ); ENDPROCEDURE; !+ ! LSE$$POP_UTIL ! ! FUNCTION ! ! Pops the specified buffer on the screen and positions depending on the flag ! Called by LSE$$POP_AND_POSITION_BUFFER and LSE$$POP_BUFFER. Note that the ! name of the buffer passed in must match exactly. ! ! INPUT ! ! flag - True, positions to the buffer ! False, leaves cursor in current buffer ! buffer_name - The name of buffer being looked for. ! buffer_type - The type of buffer being looked for. ! ! OUTPUT ! ! The cursor is positioned in the window if found ! !- PROCEDURE LSE$$POP_UTIL( buffer_name, buffer_type, flag ) LOCAL last_buffer, loop_buffer, outer_count, saved_window; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$pop_util"); ENDON_ERROR; ! If it is already the current, we're done. This protects us from situations ! where the buffer is on the screen multiple times and the current buffer is ! not the top one. We'd move the cursor in the next loop instead of leaving it ! alone. ! IF buffer_name = GET_INFO( GET_INFO( CURRENT_WINDOW,'buffer' ), 'name' ) THEN RETURN TRUE; ENDIF; ! See if it is visible first ! outer_count := 0; LOOP ! Next ! outer_count := outer_count + 1; EXITIF outer_count > eve$x_number_of_windows; ! We're done if we've found it ! IF buffer_name = GET_INFO( GET_INFO( eve$$x_windows{ outer_count }, 'buffer' ), 'name' ) THEN IF flag = true THEN POSITION( eve$$x_windows{ outer_count } ); ENDIF; RETURN TRUE; ENDIF; ENDLOOP; ! See if the buffer exists. if it does get it on the screen. ! last_buffer := GET_INFO(BUFFERS, "last"); loop_buffer := GET_INFO(BUFFERS, "first"); LOOP IF buffer_name = GET_INFO(loop_buffer, "name") THEN lse$$split_window_auto( 2 ); saved_window := current_window; lse$$other_window( buffer_type ); lse$buffer_util( loop_buffer ); IF flag = false THEN POSITION( saved_window ); ENDIF; RETURN TRUE; ENDIF; EXITIF loop_buffer = last_buffer; loop_buffer := GET_INFO(BUFFERS, "next"); ENDLOOP; RETURN TRUE; ENDPROCEDURE; !+ ! LSE$$POS_BUF_IF_VIS ! ! FUNCTION ! ! Positions to the specified buffer when it is visible. Otherwise it ! does nothing. ! ! INPUT ! ! buffer_name - The name of buffer being looked for. ! ! OUTPUT ! ! The cursor is positioned in the window if found ! ! Returns TRUE if the buffer was visible ! Returns FALSE if the buffer was NOT visible ! !- PROCEDURE LSE$$POS_BUF_IF_VIS( buffer_name ) LOCAL outer_count; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$pos_buf_if_vis"); ENDON_ERROR; ! No-op if we are in /NODISPLAY mode. ! IF NOT GET_INFO( COMMAND_LINE, 'DISPLAY') THEN RETURN TRUE; ENDIF; ! If it is already the current, we're done. This protects us from situations ! where the buffer is on the screen multiple times and the current buffer is ! not the top one. We'd move the cursor in the next loop instead of leaving it ! alone. ! IF buffer_name = GET_INFO( GET_INFO( CURRENT_WINDOW,'buffer' ), 'name' ) THEN RETURN TRUE; ENDIF; ! See if it is visible first ! outer_count := 0; LOOP ! Next ! outer_count := outer_count + 1; EXITIF outer_count > eve$x_number_of_windows; ! We're done if we've found it ! IF buffer_name = GET_INFO( GET_INFO( eve$$x_windows{ outer_count }, 'buffer' ), 'name' ) THEN POSITION( eve$$x_windows{ outer_count } ); RETURN TRUE; ENDIF; ENDLOOP; RETURN FALSE; ENDPROCEDURE; !+ ! LSE$$SPLIT_WINDOW_AUTO ! ! FUNCTION ! ! Split current window into number of windows specified provided it ! doesn't violate LSE$$MAX_NUMBER_OF_WINDOWS. ! ! The naming is unfortunate. It would seem natural for this procedure ! to correspond to the SPLIT WINDOW command it doesn't. Instead ! it is used to split a window if possible by the automatic window ! creation code in commands like FIND and GOTO SOURCE. ! ! INPUT ! ! number_of_windows - Number to split ! ! OUTPUT ! ! TRUE - a new window has been created ! FALSE - no window has been created ! !- PROCEDURE lse$$split_window_auto( number_of_windows ) LOCAL num_window_before_split; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$split_window_auto"); ENDON_ERROR; num_window_before_split := eve$x_number_of_windows; lse$$multi_window( number_of_windows - 1 + eve$x_number_of_windows, 1 ); if eve$x_number_of_windows > num_window_before_split then RETURN TRUE; ELSE RETURN FALSE; endif; ENDPROCEDURE; !+ ! LSE$$SPLIT_WINDOW_ALWAYS ! ! FUNCTION ! ! Split current window into the number of windows specified ! ! Corresponds to the SPLIT WINDOW and TWO WINDOW commands ! ! INPUT ! ! number_of_windows - Number of windows to split the current window ! ! OUTPUT ! ! A split window if appropriate ! !- PROCEDURE lse$$split_window_always( number_of_windows ) ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$split_window_always"); ENDON_ERROR; RETURN LSE$$multi_window( number_of_windows - 1 + eve$x_number_of_windows, 0 ); ENDPROCEDURE; !+ ! LSE$$TWO_WINDOWS ! ! FUNCTION ! ! Split the current window into two windows, both pointing to the same buffer. ! Move to lower window. Don't do anything if there are more than 2 windows ! or the minimum window length won't allow two windows. ! ! INPUT ! ! lse$message_window ! tpu$x_repeat_count ! eve$x_number_of_windows ! ! OUTPUT ! ! Two windows if appropriate ! !- PROCEDURE lse$$two_windows ! Change to 2 window mode ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$two_windows "); ENDON_ERROR; IF (eve$x_number_of_windows <> 2) AND (lse$$max_number_of_windows >= 2) THEN RETURN eve_two_windows; ENDIF; RETURN TRUE; ENDPROCEDURE;