MODULE TPUPlus_MENU IDENT "900409" ! ! This module is open for modification by anyone. The possibilities are ! endless as to the functionality and purpose of the menu system. What ! I have here is a sample of what can be done, but it is certainly not ! the limit of the menu system. ! !**************************************** PROCEDURE EVE_MENU !--------------------------------------------------------------------------- ! Display A Menu Of Special Functions And Execute One !--------------------------------------------------------------------------- local original_buffer, original_position, menu_buffer, menu_written, cmd; ! save the current buffer/position original_buffer := current_buffer; original_position := mark (free_cursor); menu_written := false; loop ! test if the menu buffer already exists if test_if_buffer_exists ("SPEC FUNC MENU", menu_buffer) = 0 then ! create the buffer if it doesn't exist menu_buffer := create_buffer ("SPEC FUNC MENU"); set (no_write, menu_buffer, on); set (system, menu_buffer); endif; ! map the menu buffer to the current window if menu_written = false then erase (menu_buffer); endif; map (current_window, menu_buffer); eve$set_status_line (current_window); if menu_written = false then ! write menu items into menu buffer copy_text ("---------------------------- Special Functions Menu -----------------------"); split_line; copy_text (" "); split_line; copy_text ("Option Description "); split_line; copy_text (" "); split_line; copy_text (" 1 Set window columns for window searching and replacing. "); split_line; copy_text (" 2 Perform a columnar find (must set window columns first). "); split_line; copy_text (" 3 Perform a columnar substitution (must set window columns first) "); split_line; copy_text (" 4 Trim trailing spaces, tabs, etc. "); split_line; copy_text (" 5 Convert a Rainbow SELECT file to RUNOFF format. "); split_line; copy_text (" 6 Spawn a subprocess. "); split_line; copy_text (" 99 Exit this menu with no action. "); split_line; copy_text (" "); split_line; copy_text (" "); split_line; copy_text (" "); split_line; copy_text (" "); split_line; copy_text (" "); split_line; copy_text (" "); split_line; copy_text (" "); split_line; menu_written := true; endif; update(current_window); ! ask the user for a function to perform ! cmd := read_line ("Enter menu selection [EXIT] ", 2); cmd := read_line ("Enter menu selection [EXIT] ", 1); ! check for null string ! if cmd = "" then if (cmd = "") or (cmd = "9") then cmd := "99"; endif; cmd := int (cmd); if cmd = 99 then ! go back to the original buffer map (current_window, original_buffer); eve$set_status_line (current_window); eve$position_in_middle (original_position); update (current_window); return; endif; ! case cmd from 1 to 10 case cmd from 1 to 6 [outrange]: ! noop [1]: ! set window columns map (current_window, original_buffer); eve$set_status_line (current_window); eve$position_in_middle (original_position); update (current_window); eve_set_wc ("", ""); [2]: ! perform a column search map (current_window, original_buffer); eve$set_status_line (current_window); eve$position_in_middle (original_position); update (current_window); eve_column_search (""); [3]: ! perform a column exchange map (current_window, original_buffer); eve$set_status_line (current_window); eve$position_in_middle (original_position); update (current_window); eve_column_xchg ("", ""); [4]: ! trim trailing whitespace map (current_window, original_buffer); eve$set_status_line (current_window); eve$position_in_middle (original_position); update (current_window); eve_trim; [5]: ! convert a SELECT WP (Rainbow) file to RUNOFF format ! pull in the command file eve_get_file ("pub:sel2rno.tpu"); ! compile it compile (current_buffer); ! now get rid of it pce_delete_current_buffer; ! go back to the original buffer ! and convert it map (current_window, original_buffer); eve$set_status_line (current_window); position (beginning_of (current_buffer)); update (current_window); eve_sel2rno; [6]: ! spawn a subprocess spawn ("", off); ! [7]: ! [8]: ! [9]: ! [10]: endcase; endloop; ENDPROCEDURE; !**************************************** PROCEDURE EVE_SEL2RNO ! dummy procedure to be replaced at execution time with ! a valid, executable procedure. ENDPROCEDURE; ENDMODULE; define_key ("eve_menu", key_name ("m", shift_key), "menu", eve$x_user_keys); define_key ("eve_menu", key_name ("m", shift_key), "menu", eve$x_edt_keys);