!++9! Note: use of this procedure assumes that the procedure9! lsi_determine_line_number is present. Source for that'! procedure is found in WHAT_LINE.TPU.!--PROCEDURE lsi_buffer_menu lsi_buffer_menu_dispatch (0)ENDPROCEDURE ! lsi_buffer_menu 0PROCEDURE lsi_buffer_menu_dispatch (system_flag) LOCAL menu_buf;ON_ERROR* POSITION (lsi_before_buffer_menu_spot);4 MAP (lsi_before_buffer_menu_wdw, CURRENT_BUFFER);4 lse$set_status_line (lsi_before_buffer_menu_wdw); SET (SCREEN_UPDATE, ON);' UPDATE (lsi_before_buffer_menu_wdw); ABORT ENDON_ERROR+lsi_before_buffer_menu_spot := MARK (NONE);-lsi_before_buffer_menu_wdw := CURRENT_WINDOW;!++! Create the menu buffer.!--+IF NOT lsi_create_buffer_menu (system_flag)THEN EXECUTE ("")ENDIF;!++*! Set up the key map for the buffer menu.!--<SET (KEY_MAP_LIST, 'lsi_buffer_key_map_list', lsi_menu_buf);.SET (UNDEFINED_KEY, 'lsi_buffer_key_map_list',; 'MESSAGE ("Use only UP, DOWN, SELECT, REMOVE, or DO")');2SET (SELF_INSERT, 'lsi_buffer_key_map_list', OFF);!++! Display the menu.!--SET (SCREEN_UPDATE, OFF);5MAP (lsi_menu_header_window, lsi_menu_header_buffer);$MAP (lsi_menu_window, lsi_menu_buf);SET (SCREEN_UPDATE, ON);POSITION (lsi_menu_window);!++.! Update the window and get answer from user.!--IF GET_INFO (SCREEN, 'VT200')THEN. SET (STATUS_LINE, lsi_menu_window, REVERSE,< 'Move the cursor to desired line and press SELECT, ' + 'or press DO to escape')ELSE. SET (STATUS_LINE, lsi_menu_window, REVERSE,< 'Move the cursor to desired line and press RETURN, ' + 'or press KP0 to escape')ENDIF;UPDATE (lsi_menu_window);UPDATE (LSE$MESSAGE_WINDOW);$SET (MODIFIABLE, lsi_menu_buf, OFF);ENDPROCEDURE ! lsi_buffer_menu! .PROCEDURE lsi_create_buffer_menu (system_flag)LOCAL this_spot, saved_buf, saved_name, curr_wdw, curr_wdw_top, curr_wdw_bottom, curr_wdw_length, loop_buffer, start_line, menu_size, line_count, loop_buffer_name, status_string, current_flag, modified_str, modifiable_str, read_write_str, format_str;this_spot := MARK (NONE);saved_buf := CURRENT_BUFFER;+saved_name := GET_INFO (saved_buf, "name");!++5! Create menu and menu header buffers, if necessary.!--0IF GET_INFO (lsi_menu_buf, "TYPE") = UNSPECIFIEDTHEN5 lsi_menu_buf := create_buffer ("lsi_menu_buffer");ENDIF;+SET (EOB_TEXT, lsi_menu_buf, " *Current");SET (NO_WRITE, lsi_menu_buf);SET (SYSTEM, lsi_menu_buf);#SET (MODIFIABLE, lsi_menu_buf, ON);!:IF GET_INFO (lsi_menu_header_buffer, "TYPE") = UNSPECIFIEDTHENF lsi_menu_header_buffer := create_buffer ("lsi_menu_header_buffer");. SET (EOB_TEXT, lsi_menu_header_buffer, '');* SET (NO_WRITE, lsi_menu_header_buffer);( SET (SYSTEM, lsi_menu_header_buffer);0 SET (MODIFIABLE, lsi_menu_header_buffer, ON); !++) ! Create the header and menu windows. !-- curr_wdw := CURRENT_WINDOW;6 curr_wdw_top := GET_INFO (curr_wdw, "visible_top");< curr_wdw_bottom := GET_INFO (curr_wdw, "visible_bottom");< curr_wdw_length := GET_INFO (curr_wdw, "visible_length");B lsi_menu_header_window := CREATE_WINDOW (curr_wdw_top, 2, OFF);K lsi_menu_window := CREATE_WINDOW (curr_wdw_top+2, curr_wdw_length-2, ON)ENDIF;ERASE (lsi_menu_header_buffer);"POSITION (lsi_menu_header_buffer);/format_str := '!1AS!#AS !5UL !8AS, !6AS, !5AS';#title_str := ' !#AS !5AS !8AS';0IF GET_INFO (buffer_name_len, 'type') <> INTEGERTHEN buffer_name_len := 43ENDIF;JCOPY_TEXT (FAO (title_str, buffer_name_len, 'Buffer', 'Lines', 'Status'));!1POSITION (BEGINNING_OF (lsi_menu_header_buffer));'POSITION (BEGINNING_OF (lsi_menu_buf));ERASE (lsi_menu_buf);menu_size := 0;start_line := MARK (NONE);!++>! Get all the buffer names and put them into the menu buffer.!--+loop_buffer := GET_INFO (BUFFERS, "first");LOOP5 loop_buffer_name := GET_INFO (loop_buffer,"name");; IF (GET_INFO (loop_buffer, "SYSTEM") = 0) OR system_flag THEN! menu_size := menu_size + 1; !++ ! Get other buffer info. !--; line_count := GET_INFO (loop_buffer, "record_count"); status_string := "";4 IF GET_INFO (loop_buffer, "modified") = 1 THEN modified_str := "modified" ELSE modified_str := "unmodified" ENDIF;6 IF GET_INFO (loop_buffer, "modifiable") = 1 THEN modifiable_str := "modify" ELSE modifiable_str := "nomodify" ENDIF;4 IF GET_INFO (loop_buffer, "no_write") = 1 THEN read_write_str := "read" ELSE read_write_str := "write" ENDIF;% IF loop_buffer = saved_buf THEN current_flag := "*" ELSE current_flag := " " ENDIF; !++F ! Enter the information about the current buffer into the menu. !--@ COPY_TEXT (FAO (format_str, current_flag, buffer_name_len,= loop_buffer_name, line_count, modified_str, modifiable_str, read_write_str));  SPLIT_LINE;+ IF loop_buffer_name = saved_name THEN MOVE_VERTICAL (-1); start_line := MARK (NONE); MOVE_VERTICAL (1) ENDIF ENDIF;, loop_buffer := GET_INFO (BUFFERS,"next"); EXITIF loop_buffer = 0ENDLOOP; ERASE_LINE;POSITION (start_line);POSITION (this_spot);IF menu_size <> 0THEN RETURN 1ELSE) MESSAGE ("No user buffers available"); RETURN 0ENDIF%ENDPROCEDURE ! lsi_create_buffer_menu! PROCEDURE lsi_buffer_select!++H! This routine is the dispatcher for functions while the buffer menu is ! in place.!-- LOCAL line, line_num, this_spot, the_key, buf_name; ON_ERROR lsi_goto_main; ABORT ENDON_ERRORthis_spot := MARK (NONE);the_key := LAST_KEY;!++3! Perform an action based on the last key pressed.!--$IF (the_key = DO) OR (the_key = KP0)THEN !++D ! Action: return to the buffer which was current when the menu  ! was invoked. !--" UNMAP (lsi_menu_header_window); UNMAP (lsi_menu_window);> IF GET_INFO (lsi_before_buffer_menu_spot, 'type') <> MARKER THEN !++< ! That buffer is gone: go to the main buffer instead. !-- lsi_goto_main;+ lse$set_status_line (CURRENT_WINDOW); ABORT ELSE- POSITION (lsi_before_buffer_menu_spot);+ MAP (CURRENT_WINDOW, CURRENT_BUFFER);+ lse$set_status_line (CURRENT_WINDOW); UPDATE (CURRENT_WINDOW); RETURN ENDIFENDIF;!++J! Other actions require that we know which buffer is named on the current3! line, and thus we must know what line we are on.!--&line_num := lsi_determine_line_number;5IF line_num > GET_INFO (lsi_menu_buf, 'record_count')THEN ABORTENDIF;"buf_name := lsi_strip_buffer_name;!++F! Pressing E3 (Remove) or PF4 (Delete Line) deletes the named buffer.!--$IF (the_key = E3) OR (the_key = PF4)THEN !++5 ! Freeze the screen to avoid distracting updates. !-- SET (SCREEN_UPDATE, OFF); UNMAP (lsi_menu_window);" UNMAP (lsi_menu_header_window); !++. ! Go to the buffer which is to be deleted. !--8 lse$do_command (FAO ('GOTO BUFFER "!AS"', buf_name)); buf_ptr := CURRENT_BUFFER; !++ ! Delete it. !-- lsi_kill_buffer (buf_ptr); !++ ! Re-map the menu. !--8 MAP (lsi_menu_header_window, lsi_menu_header_buffer);' MAP (lsi_menu_window, lsi_menu_buf); POSITION (lsi_menu_window); POSITION (this_spot);& SET (MODIFIABLE, lsi_menu_buf, ON); !++9 ! Delete the line containing the deleted buffer name. !-- ERASE_LINE;' SET (MODIFIABLE, lsi_menu_buf, OFF); !++ ! Refresh the screen. !-- SET (SCREEN_UPDATE, ON); UPDATE (lsi_menu_window);# UPDATE (lsi_menu_header_window); UPDATE (lse$message_window)ENDIF;!++H! Pressing E4 (Select) or RETURN selects the named buffer and positions! into that buffer.!--(IF (the_key = E4) OR (the_key = RET_KEY)THEN" UNMAP (lsi_menu_header_window); UNMAP (lsi_menu_window);) POSITION (lsi_before_buffer_menu_wdw);7 lse$do_command (FAO ('GOTO BUFFER "!AS"', buf_name))ENDIF ENDPROCEDURE ! lsi_buffer_select! PROCEDURE lsi_strip_buffer_name!++J! This procedure returns the full buffer name from the current menu line.!--LOCAL buf_name, line; 5buf_name := SUBSTR(CURRENT_LINE, 2, buffer_name_len);EDIT (buf_name, TRIM);RETURN buf_name;$ENDPROCEDURE ! lsi_strip_buffer_name! 'PROCEDURE lsi_initialize_buffer_key_map!++?! This procedure is only called to initially create the key map6! because TPU only allows ON_ERROR within a procedure.!--ON_ERROR ENDON_ERROR;&CREATE_KEY_MAP ('lsi_buffer_key_map');FCREATE_KEY_MAP_LIST ('lsi_buffer_key_map_list', 'lsi_buffer_key_map');?DEFINE_KEY ('lsi_buffer_select', DO, '', 'lsi_buffer_key_map');@DEFINE_KEY ('lsi_buffer_select', KP0, '', 'lsi_buffer_key_map');?DEFINE_KEY ('lsi_buffer_select', E3, '', 'lsi_buffer_key_map');@DEFINE_KEY ('lsi_buffer_select', PF4, '', 'lsi_buffer_key_map');DDEFINE_KEY ('lsi_buffer_select', RET_KEY, '', 'lsi_buffer_key_map');?DEFINE_KEY ('lsi_buffer_select', E4, '', 'lsi_buffer_key_map');@DEFINE_KEY ('move_vertical(1)', DOWN, '', 'lsi_buffer_key_map');?DEFINE_KEY ('move_vertical(-1)', UP, '', 'lsi_buffer_key_map');5DEFINE_KEY ('POSITION (BEGINNING_OF (lsi_menu_buf))',8 KEY_NAME (KP5, SHIFT_KEY), '', 'lsi_buffer_key_map');/DEFINE_KEY ('POSITION (END_OF (lsi_menu_buf))',8 KEY_NAME (KP4, SHIFT_KEY), '', 'lsi_buffer_key_map');,ENDPROCEDURE ! lsi_initialize_buffer_key_map! lsi_initialize_buffer_key_map;