! EVE$FILE.TPU 29-DEC-1992 10:47 Page 1 module eve$file ident "V03-076" !************************************************************************* ! * ! © 2002 BY * ! COMPAQ COMPUTER CORPORATION * ! © 2002 BY * ! ELECTRONIC DATA SYSTEMS LIMITED * ! * ! THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED * ! ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND WITH THE * ! INCLUSION OF THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE OR ANY OTHER * ! COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY * ! OTHER PERSON. NO TITLE TO OR OWNERSHIP OF THE SOFTWARE IS HEREBY * ! TRANSFERRED. * ! * ! THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE * ! AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY COMPAQ COMPUTER * ! CORPORATION OR EDS. * ! * ! NEITHER COMPAQ NOR EDS ASSUME ANY RESPONSIBILITY FOR THE USE OR * ! RELIABILITY OF THIS SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY * ! COMPAQ. * ! * !************************************************************************* !++ ! FACILITY: ! DECTPU - Text Processing Utility ! EVE - Extensible Versatile Editor ! ! ABSTRACT: ! This is the source program for the EVE interface advanced file, buffer, ! and window features. This file was obtained from the old ! evesecini.tpu file. ! ! ENVIRONMENT: ! OpenVMS VAX, OpenVMS AXP, RISC/ULTRIX ! !Author: Bill Robinson ! ! CREATION DATE: 10-Oct-1986 ! ! MODIFIED BY: ! ! V03-76 RAJENDER/EDS 14-MARCH-2003 Modified Procedure ! Eve_get_wildcarded_files to fix PTR 70-18-50 ! ! V03-75 EDS 15-JAN-2002 fix TPU_XBUGS 335 ! ! V03-74 RAM 26-OCT-1994 fixed eve$get_wildcarded_files to exclude ! temporary files. !-- ! EVE$FILE.TPU Page 2 !++ ! Table of Contents ! ! EVE$FILE.TPU ! 29-DEC-1992 10:47 ! ! Procedure name Page Description ! -------------- ---- ------------ ! ! eve$dcl_input_file_logic 3 EVE logic for input file lists ! eve$dcl_single_input_file_logic 4 EVE logic for input file ! eve$dcl_file_mods_logic 5 EVE logic for file qualifiers ! eve$dcl_jrnl_file_logic 6 EVE logic for /JOURNAL ! eve$dcl_start_file_logic 7 EVE logic for /START ! eve$dcl_init_file_logic 8 EVE logic for /INIT ! eve$dcl_file_qualifiers 9 Process file qualifiers from DCL ! eve$create_main_buffer 10 Create and map main buffer ! eve$$set_dcl_pgm 11 Sets user DCL pgms to overide EVE's ! eve$set_dcl_start_file_pgm 12 Sets pgm used for /START logic ! eve$set_dcl_init_file_pgm 12 Sets pgm used for /INIT logic ! eve$set_dcl_jrnl_file_pgm 12 Sets pgm used for /JOURNAL logic ! eve$set_dcl_input_file_pgm 12 Sets pgm used for input file logic ! eve$set_dcl_file_mods_pgm 12 Sets pgm used for mod switches logic ! eve$$file_search 13 Perform a FILE_SEARCH ! eve$$file_search_loop 13 Loop doing a FILE_SEARCH ! eve$$journal_open 14 Perform a JOURNAL_OPEN ! eve$nowrite_status_field 15 Status line indicator ! eve$test_default_directory 16 Test if illegal default directory ! eve_open 17 DECwindows synonym for GET FILE ! eve$open1 17 DECwindows synonym for GET FILE ! eve_open_selected 18 GET FILE whose name is the selection ! eve$open_selected 19 Open global selection ! eve$open_multi_selected 20 Open multiple selected files ! eve_new 21 DECwindows synonym for BUFFER ! eve$new1 21 DECwindows synonym for BUFFER ! eve$create_new_buffer 22 EVE buffer function ! eve_buffer 23 Go to a (create a new) buffer ! eve_include_file 24 Include a file at current position ! eve_exit 25 Exit the editor ! eve$exit_dispatch 25 Dispatch to exit handlers ! eve$exit 25 EXIT subprocedure ! eve$$exit1 26 EXIT subprocedure ! eve$$exit2 27 EXIT subprocedure ! eve$$exit_loop 28 EXIT subprocedure ! eve$$get_write_file 29 EXIT support procedure ! eve_get 30 Get a file. ! eve_get_wildcarded_files 31 Get all files matching ! eve_get_file 32 Get a file ! eve$get_file1 33 Get a file subprocedure ! eve$reset_file_search 34 Null out file_search context ! eve$is_wildcard 35 Test for wildcard string ! eve$create_buffer 36 GET_FILE subprocedure ! eve$write_file 37 Write a buffer to a file ! eve$$write_file 37 Perform a WRITE_FILE ! eve$trim_buffer 38 Trim lines in a buffer ! eve$init_buffer 39 Init an EVE system buffer ! eve_write_file 40 Write file ! eve_save_file 40 DECwindows WRITE command ! eve_save_file_as 40 DECwindows write with name ! eve$save_file_as1 40 DECwindows write with name ! eve__at_file 41 Execute a file of EVE commands ! eve$execute_file 42 "@" subprocedure ! eve$file_declare_synonym 43 Declare Synonyms for args ! eve_set_buffer 44 Set Buffer ! eve_previous_buffer 46 Previous user buffer ! eve$$previous_buffer 46 Previous buffer subprocedure ! eve_next_buffer 46 Next user buffer ! eve$$next_buffer 46 Buffer indicator = Next buffer ! eve_quit 47 Quit the editor ! eve$quit_dispatch 48 Dispatch to quit handlers ! eve$quit 49 Actual EVE quit ! eve_recover_buffer_all 50 Recover all journaled buffers ! eve_recover 51 Synonym for RECOVER BUFFER ! eve_recover_buffer 51 Recover journaled buffer ! eve$recover 52 Recover Buffer subprocedure ! eve_set_journaling_all 53 Start journaling all buffers ! eve_set_journaling 54 Start journaling a buffer ! eve$set_journaling 54 Set journaling subprocedure ! eve_set_nojournaling_all 55 Stop journaling all buffers ! eve_set_nojournaling 56 Stop journaling a buffer ! eve$find_buffer 57 Find buffer with specified name ! eve$$get_info_journal 58 Perform a GET_INFO(STRING,"JOURNAL") ! eve$$fix_recovery 59 Bad recovery: write buffer, start journaling ! eve_set_file_backup 60 Backup ULTRIX output files ! eve_set_nofile_backup 60 Don't backup ULTRIX output files ! eve_set_backup_control_string 61 Set ULTRIX backup control string ! eve$backup_file 62 Make backup copy of an existing file ! eve_show_file_backup 63 Display ULTRIX file backup control string ! eve$delete_processes 64 Delete EVE processes !-- ! EVE$FILE.TPU Page 3 procedure eve$dcl_input_file_logic ! EVE logic for input file lists local old_head, ! device/directory of previous input_file the_buffer, ! current buffer we are examining file_count, ! count of files in input parameter the_parameter, ! entire string of input files (for error) separator, ! os-specific input file separator input_file; ! Input file spec from command line ! Insure buffer MAIN has a name if eve$x_buf_str_main = tpu$k_unspecified then eve$x_buf_str_main := "MAIN"; endif; ! Get the first file and create a buffer for it input_file := get_info (COMMAND_LINE, "first_file_name"); eve$dcl_single_input_file_logic (input_file); old_head := ""; ! Check if there are more filenames that need to set up buffers if input_file <> 0 then if not eve$x_ultrix_active then ! Propagate directory names through the list of input files for VMS loop old_head := file_parse (input_file, old_head, "", head); input_file := get_info (COMMAND_LINE, "next_file_name"); exitif input_file = 0; ! Apply last valid device/directory input_file := file_parse (input_file, old_head); eve$dcl_single_input_file_logic (input_file); endloop; else ! Don't propagate anything on ULTRIX loop input_file := get_info (command_line, "next_file_name"); exitif input_file = 0; eve$dcl_single_input_file_logic (input_file); endloop; endif; endif; ! Loop through buffers, applying command line qualifiers to user buffers. ! Leave user in first user buffer (=first file on the command line). If in ! the command buffer, MAIN and possibly other user buffers have been created. the_buffer := get_info (buffers, "last"); if (current_buffer <> the_buffer) and not get_info (the_buffer, "system") then ! We must first position to the last user buffer. eve_buffer (get_info (the_buffer, "name")); endif; if not get_info (the_buffer, "system") then loop eve$dcl_file_qualifiers; the_buffer := get_info (buffers, "previous"); exitif get_info (the_buffer, "system"); eve_previous_buffer; endloop; endif; ! Delete buffer MAIN if we've got another user buffer if (current_buffer <> eve$x_main_buffer) and (current_window = eve$main_window) and (get_info (eve$x_main_buffer, "name") = eve$x_buf_str_main) and (not get_info (current_buffer, "system")) and (not eve$$x_user_main_buf) then delete (eve$x_main_buffer); eve$x_main_buffer := current_buffer; endif; ! If /NOCREATE (-nN on ULTRIX), no file(s) exist, and user doesn't have ! to resolve an ambiguous filespec, abort the session. if (eve$$x_input_count = 0) and (get_info (COMMAND_LINE, "create") = 0) and (eve$$x_ambiguous_input_file = 0) then ! Generate the string of input files. if eve$x_ultrix_active then separator := " "; else separator := ","; endif; the_parameter := ""; input_file := get_info (COMMAND_LINE, "first_file_name"); loop exitif input_file = 0; if file_count = 0 then the_parameter := input_file; else the_parameter := the_parameter + separator + input_file; endif; input_file:= get_info (COMMAND_LINE, "next_file_name"); file_count := file_count + 1; endloop; if the_parameter <> "" ! don't exit if in MAIN then eve$message (EVE$_NOSUCHINFILES, 0, the_parameter); exit; endif; endif; endprocedure !eve$dcl_input_file_logic ! EVE$FILE.TPU Page 4 procedure eve$dcl_single_input_file_logic ! EVE logic for input file (input_file) ! file to open, or "" or 0 for none local status, temp_file_name, ! Temporary for get_file file_count, ! Counts files found by file_search facility, ! For prompt_line key test legend, ! For prompt_line key test topic, ! For prompt_line key test buffer_name, ! For recovery doing_recovery, ! Recovery flag input_error, ! Bogus input file name is_wildcard; ! For wildcard output file on_error [TPU$_TRUNCATE]: eve$message (error_text, error); [OTHERWISE]: endon_error; ! create temporary buffer MAIN without mapping/status/journaling eve$create_main_buffer (TRUE); map (eve$main_window, eve$x_main_buffer); ! Test if user is recovering from a buffer change journal file if eve$$x_buffer_change_journaling and eve$$x_recover_qualifier then doing_recovery := TRUE; endif; ! Test if user specified an input file. Apply DCL file-related qualifiers ! to the buffer later in startup. if (input_file = "") or (input_file = 0) then if doing_recovery then ! user wants to recover buffer MAIN if not eve_recover_buffer (eve$x_buf_str_main) then delete (eve$x_main_buffer); eve$create_main_buffer; ! create MAIN anyway else eve$x_main_buffer := current_buffer; eve$set_status_line (current_window); endif; else ! create MAIN buffer delete (eve$x_main_buffer); eve$create_main_buffer; endif; else ! Create a buffer using eve_get ! make it look like we executed a GET command position (end_of (eve$command_buffer)); copy_text (eve$x_command_prompt + "get " + input_file); position (BUFFER_END); ! Protect against earlier file_search with same file name. eve$reset_file_search; temp_file_name := ""; temp_file_name := eve$$file_search_loop (input_file, file_count, FALSE); if temp_file_name = 0 then temp_file_name := ""; input_error := TRUE; endif; if (file_count > 1) and (not (eve$x_get_wild_active)) then if not get_info (COMMAND_LINE, "display") then ! User error, ambiguous file in /NODISPLAY mode...exit EVE eve$message (EVE$_AMBFILE, 0, input_file); exit; endif; if eve$$x_ambiguous_input_file <> 0 then ! More than 1 ambiguous file name on command line eve$message (EVE$_MULTIAMBIG); return; endif; ! Ambiguous input file and buffer change journaling /RECOVER: exit if doing_recovery then eve$message (EVE$_AMBRECOVFILE, 0, input_file); exit; endif; ! Set flag to postpone applying qualifiers until user resolves ! ambiguity. Get resolved node/dev/dir if search_list or [...]. eve$$x_ambiguous_input_file := file_parse (temp_file_name, "", "", HEAD) + file_parse (input_file, "", "", TAIL); temp_file_name := ""; else if temp_file_name = "" ! No file found? then if (input_error = 0) and ! Not a bogus file spec, (file_count = 0) ! just non-existent. then if eve$is_wildcard (input_file) ! And, does is have wildcards? then eve$message (EVE$_NOFILMATCH, 0, input_file); else ! No file exists, get_file will use bogus file name temp_file_name := input_file; endif; endif; endif; endif; if temp_file_name <> "" then if doing_recovery then ! User wants to recover previous input file. Do so instead of ! opening it as the input file. buffer_name := file_parse (temp_file_name, "", "", NAME, TYPE); if eve_recover_buffer (buffer_name) then ! remember if user specified MAIN as input file if buffer_name = eve$x_buf_str_main then eve$$x_user_main_buf := TRUE; eve$x_main_buffer := current_buffer; endif; eve$set_status_line (current_window); else ! don't delete MAIN if it was user input file if not eve$$x_user_main_buf then delete (eve$x_main_buffer); eve$create_main_buffer; ! full creation endif; endif; else if eve$x_get_wild_active then status := eve_get (input_file); else status := eve_get (temp_file_name); endif; if status then ! remember if user specified MAIN as input file if (file_parse (input_file, "", "", NAME) = eve$x_buf_str_main) and (get_info (current_buffer, "name") = eve$x_buf_str_main) then eve$$x_user_main_buf := TRUE; endif; else if not eve$$x_user_main_buf then ! don't delete MAIN if it was user input file delete (eve$x_main_buffer); eve$create_main_buffer; ! full creation endif; endif; endif; else ! invalid input file if doing_recovery then ! User wants to recover previous input file, which is MAIN due ! to invalid input file name. if not eve_recover_buffer (eve$x_buf_str_main) then delete (eve$x_main_buffer); eve$create_main_buffer; else eve$set_status_line (current_window); endif; else ! create MAIN buffer delete (eve$x_main_buffer); eve$create_main_buffer; endif; endif; if (current_buffer <> eve$x_main_buffer) and (current_window = eve$main_window) and (get_info (eve$x_main_buffer, "name") = eve$x_buf_str_main) and (not get_info (current_buffer, "system")) and (not eve$$x_user_main_buf) then ! don't delete MAIN if it was user input file delete (eve$x_main_buffer); ! make eve$x_main_buffer point to the current buffer eve$x_main_buffer := current_buffer; endif; endif; endprocedure; ! eve$dcl_single_input_file_logic ! EVE$FILE.TPU Page 5 procedure eve$dcl_file_mods_logic ! EVE logic for file qualifiers local output_file_name, ! Original output file name parsed_output_file_name,! Full filespec for output file input_file, ! Buffer's input file input_file_name_only, ! No node, disk, directory, or version temp, ! Temporary for a get_info return output_error, ! True if can't parse/find output file name nowrite, ! No_write setting is_wildcard; ! For wildcard output file on_error [TPU$_TRUNCATE]: eve$message (error_text, error); [OTHERWISE]: endon_error; ! Process the qualifiers (eve$dcl_input_file_logic will handle /NOCREATE) ! Called for each and every input file. Assumes we are in the buffer to ! which the qualifiers are being applied. ! /NOOUTPUT implies NO_WRITE to ON for the buffer. if not get_info (COMMAND_LINE, "output") then set (NO_WRITE, current_buffer, ON); endif; ! /READ_ONLY implies NO_WRITE to ON and MODIFIABLE to OFF for the buffer. if get_info (COMMAND_LINE, "read_only") then set (NO_WRITE, current_buffer, ON); set (MODIFIABLE, current_buffer, OFF); endif; ! /WRITE implies NO_WRITE to OFF and MODIFIABLE to ON for the buffer. if get_info (COMMAND_LINE, "write") then set (NO_WRITE, current_buffer, OFF); set (MODIFIABLE, current_buffer, ON); endif; ! /MODIFY implies MODIFIABLE to ON for the buffer. if get_info (COMMAND_LINE, "modify") then set (MODIFIABLE, current_buffer, ON); endif; ! /NOMODIFY implies MODIFIABLE to OFF for the buffer. if get_info (COMMAND_LINE, "nomodify") then set (MODIFIABLE, current_buffer, OFF); endif; ! Abort the editing session if the user specified an output file, ! but also set the buffer NO_WRITE. output_file_name := get_info (COMMAND_LINE, "output_file"); nowrite := get_info (current_buffer, "no_write"); if nowrite and (output_file_name <> "") then if get_info (COMMAND_LINE, "read_only") then eve$message (EVE$_ILLQUALCOMB, 0, "/OUTPUT=filespec", "/READ_ONLY"); else eve$message (EVE$_ILLQUALCOMB, 0, "/OUTPUT=filespec", "/NOWRITE"); endif; exit; endif; ! The output file should be written to the current directory by default ! unless there is another directory specified in the output_file_name. ! We also DON'T want the node, device or directory of the input file, just ! the name and type. if not nowrite then if output_file_name <> "" then input_file := get_info (current_buffer, "file_name"); if input_file = "" then input_file := get_info (current_buffer, "name"); endif; input_file_name_only := file_parse (input_file, "", "", NAME, TYPE); parsed_output_file_name := file_parse (output_file_name, input_file_name_only); if parsed_output_file_name <> "" then if eve$is_wildcard (parsed_output_file_name) then ! Don't call eve$popup_message during initialization eve$message (EVE$_CANTCREATE, 0, parsed_output_file_name); is_wildcard := TRUE; else temp := parsed_output_file_name; parsed_output_file_name := eve$$file_search (temp); if parsed_output_file_name = 0 then output_error := TRUE; endif; if not output_error then set (OUTPUT_FILE, current_buffer, temp); if get_info (current_buffer, "name") <> eve$x_buf_str_main then eve$$x_output_count := eve$$x_output_count + 1; endif; if eve$$x_output_count > 1 then eve$message (EVE$_MULTIOUTPUT); endif; endif; endif; else temp := output_file_name; output_file_name := eve$$file_search (output_file_name); if output_file_name = 0 then output_error := TRUE; endif; if not output_error then set (OUTPUT_FILE, current_buffer, temp); if get_info (current_buffer, "name") <> eve$x_buf_str_main then eve$$x_output_count := eve$$x_output_count + 1; endif; if eve$$x_output_count > 1 then eve$message (EVE$_MULTIOUTPUT); endif; endif; endif; if (not is_wildcard) and (get_info (current_buffer, "modifiable")) and (not output_error) then ! Want this buffer to be considered modified so it will ! be written on exit - for use especially with mail/edit split_line; append_line; endif; endif; endif; ! Show any new buffer settings just set. eve$set_status_line (current_window); endprocedure ! eve$dcl_file_mods_logic ! EVE$FILE.TPU Page 6 procedure eve$dcl_jrnl_file_logic ! EVE logic for /JOURNAL ! /JOURNAL --> buffer change journaling ! /JOURNAL=file_name --> buffer change journaling & keystroke journaling ! /NOJOURNAL --> no journaling local journal_file, ! Journal file spec from command line journal_name; ! Name only if get_info (COMMAND_LINE, "recover") then eve$$x_recover_qualifier := TRUE; ! for buffer-change recovery endif; if get_info (COMMAND_LINE, "journal") then ! enable buffer change journaling eve$$x_buffer_change_journaling := TRUE; ! test for keystroke journaling journal_file := get_info (COMMAND_LINE, "journal_file"); if journal_file = "" then if eve$$x_recover_qualifier then ! prevent TPU$_JNLNOTOPEN if /RECOVER but no keystroke journaling ! (forces GET_INFO(COMMAND_LINE,'RECOVER') to 0) set (KEYSTROKE_RECOVERY, OFF); endif; else ! /JOURNAL=file_name --> also do keystroke journaling. ! prevent buffer-change recovery eve$$x_recover_qualifier := FALSE; ! parse name portion of journal filespec journal_name := file_parse (journal_file, "", "", NAME); ! default journal to filename, if null if journal_name = "" then journal_name := get_info (COMMAND_LINE, 'FILE_NAME'); journal_name := file_parse (journal_name, "", "", NAME); endif; if not eve$x_ultrix_active then ! insure .TJL type for VMS journal_name := journal_name + ".tjl"; endif; journal_file := file_parse (journal_file, journal_name); if not eve$$journal_open (journal_file) then ! tell user if bogus default directory is cause of error eve$test_default_directory; endif; endif; else eve$$x_buffer_change_journaling := FALSE; if eve$$x_recover_qualifier then ! prevent TPU$_JNLNOTOPEN if /RECOVER but no keystroke journaling ! (forces GET_INFO(COMMAND_LINE,'RECOVER') to 0) set (KEYSTROKE_RECOVERY, OFF); endif; endif; endprocedure ! eve$dcl_jrnl_file_logic ! EVE$FILE.TPU Page 7 procedure eve$dcl_start_file_logic ! EVE logic for /START local temp; ! Temporary for a get_info return ! Position to the location specified by /START_POSITION ! in the command line, defaulting to 1,1. position (BUFFER_BEGIN); temp := get_info (COMMAND_LINE, "start_record"); if temp < 0 then message (EVE$_BADSTARTREC, 0, temp); else if temp > get_info (current_buffer, "record_count") then position (BUFFER_END); else if temp <> 0 then move_vertical (temp - 1); endif; endif; endif; temp := get_info (COMMAND_LINE, "start_character"); if (temp < 0) then message (EVE$_BADSTARTCHAR, 0, temp); else if mark (NONE) <> end_of (current_buffer) then if temp > length (current_line) then move_horizontal (length (current_line)); else if temp <> 0 then move_horizontal (temp - 1); endif; endif; endif; endif; endprocedure ! eve$dcl_start_file_logic ! EVE$FILE.TPU Page 8 procedure eve$dcl_init_file_logic ! EVE logic for /INIT if get_info (COMMAND_LINE, "initialization") then eve$$x_state_array {eve$$k_in_init_file} := TRUE; eve__at_file (""); ! Execute an EVE command file eve$$x_prefs_modified := FALSE; ! User settings have not changed eve$$x_state_array {eve$$k_in_init_file} := FALSE; endif; endprocedure ! eve$dcl_init_file_logic ! EVE$FILE.TPU Page 9 procedure eve$dcl_file_qualifiers ! Process file qualifiers from DCL ! /START_POSITION if get_info (eve$$x_dcl_start_file_pgm, "type") = UNSPECIFIED then eve$dcl_start_file_logic ! EVE default logic else if execute (eve$$x_dcl_start_file_pgm) ! User specified logic then eve$dcl_start_file_logic ! EVE default logic endif; endif; ! /CREATE /MODIFY /OUTPUT /READ_ONLY /WRITE if get_info (eve$$x_dcl_file_mods_pgm, "type") = UNSPECIFIED then eve$dcl_file_mods_logic ! EVE default logic else if execute (eve$$x_dcl_file_mods_pgm) ! User specified logic then eve$dcl_file_mods_logic ! EVE default logic endif; endif; endprocedure ! eve$dcl_file_qualifiers ! EVE$FILE.TPU Page 10 procedure eve$create_main_buffer ! Create and map main buffer (; just_create) ! Boolean, true = do not map, set status line, or ! start buffer change journaling local simplified; ! local copy of not (just_create) if just_create = TRUE then simplified := TRUE; endif; ! ! Must prevent multiple copies of main. Some may left from input file we tried ! to read in before. ! if (get_info (buffer, "find_buffer", "MAIN") <> 0) and (simplified) then return (TRUE); !no point in creating it again endif; ! Create the default user buffer "MAIN" if eve$x_buf_str_main = tpu$k_unspecified then eve$x_buf_str_main := "MAIN"; endif; if get_info (eve$default_buffer, "type") <> BUFFER then ! i.e., no default buffer during startup eve$x_main_buffer := create_buffer (eve$x_buf_str_main); set (EOB_TEXT, eve$x_main_buffer, message_text (EVE$_EOBTEXT, 1)); set (LEFT_MARGIN, eve$x_main_buffer, eve$x_default_left_margin); set (RIGHT_MARGIN, eve$x_main_buffer, (get_info (eve$main_window, "width") - eve$x_default_right_margin)); set (RIGHT_MARGIN_ACTION, eve$x_main_buffer, eve$kt_word_wrap_routine); else eve$x_main_buffer := create_buffer (eve$x_buf_str_main, "", eve$default_buffer); set (MODIFIABLE, eve$x_main_buffer, ON); ! override default buffer set (NO_WRITE, eve$x_main_buffer, OFF); ! override default buffer if eve$$x_word_wrap_indent {eve$default_buffer} <> tpu$k_unspecified then eve$$x_word_wrap_indent {eve$x_main_buffer} := eve$$x_word_wrap_indent {eve$default_buffer}; endif; if eve$$x_paragraph_indent {eve$default_buffer} <> tpu$k_unspecified then eve$$x_paragraph_indent {eve$x_main_buffer} := eve$$x_paragraph_indent {eve$default_buffer}; endif; endif; if not simplified then map (eve$main_window, eve$x_main_buffer); eve$set_status_line (eve$main_window); if (eve$$x_buffer_change_journaling) and (not get_info (eve$x_main_buffer, "journaling")) then set (JOURNALING, eve$x_main_buffer, ON); endif; endif; return (TRUE); endprocedure ! eve$create_main_buffer ! EVE$FILE.TPU Page 11 procedure eve$$set_dcl_pgm ! Sets user DCL pgms to overide EVE's (eve_program_variable, ! EVE's variable to store user programs user_program); ! Program source to use instead of EVE's default if get_info (eve_program_variable, "type") = UNSPECIFIED then if get_info (user_program, "type") <> PROGRAM then eve_program_variable := compile (user_program); else eve_program_variable := user_program; endif; return TRUE; else return FALSE; ! A user or layered product has already overridden endif; endprocedure; ! eve$$set_dcl_pgm ! EVE$FILE.TPU Page 12 procedure eve$set_dcl_start_file_pgm ! Sets pgm used for /START logic (user_program); ! Program source to use instead of EVE's default return eve$$set_dcl_pgm (eve$$x_dcl_start_file_pgm, user_program); endprocedure; ! eve$set_dcl_start_file_pgm procedure eve$set_dcl_init_file_pgm ! Sets pgm used for /INIT logic (user_program); ! Program source to use instead of EVE's default return eve$$set_dcl_pgm (eve$$x_dcl_init_file_pgm, user_program); endprocedure; ! eve$set_dcl_init_file_pgm procedure eve$set_dcl_jrnl_file_pgm ! Sets pgm used for /JOURNAL logic (user_program); ! Program source to use instead of EVE's default return eve$$set_dcl_pgm (eve$$x_dcl_jrnl_file_pgm, user_program); endprocedure; ! eve$set_dcl_jrnl_file_pgm procedure eve$set_dcl_input_file_pgm ! Sets pgm used for input file logic (user_program); ! Program source to use instead of EVE's default return eve$$set_dcl_pgm (eve$$x_dcl_input_file_pgm, user_program); endprocedure; ! eve$set_dcl_input_file_pgm procedure eve$set_dcl_file_mods_pgm ! Sets pgm used for mod switches logic (user_program); ! Program source to use instead of EVE's default return eve$$set_dcl_pgm (eve$$x_dcl_file_mods_pgm, user_program); endprocedure; ! eve$set_dcl_file_mods_pgm ! EVE$FILE.TPU Page 13 procedure eve$$file_search ! Perform a FILE_SEARCH (the_file_name) ! file to search ! Do a FILE_SEARCH allowing all RMS error messages to be output. on_error [OTHERWISE]: ! return zero if can't parse filename endon_error; return file_search (the_file_name); ! return null string if no file endprocedure; ! eve$$file_search procedure eve$$file_search_loop ! Loop doing a FILE_SEARCH (the_file_name, ! file to search, in/out file_count, ! count of files found, in/out use_builtin) ! boolean, 1 = use FILE_SEARCH ! 0 = use EVE$$FILE_SEARCH ! Loop searching for all matching files, count number found, put choices into ! choices buffer, allow files from only one node/dev/dir to prevent search-list ! ambiguities. Return last file name found (may be ""), or 0 if error. local node_dev_dir, first_node_dev_dir, file_search_result, temp_file_name, saved_mark, rec_cnt, first_file; on_error [TPU$_CONTROLC]: eve$$restore_position (saved_mark); eve$learn_abort; abort; [TPU$_SEARCHFAIL]: eve$message (EVE$_NOSUCHFILE, 0, the_file_name); eve$learn_abort; return (FALSE); [OTHERWISE]: ! return zero if can't parse filename endon_error; temp_file_name := ""; loop if use_builtin then file_search_result := file_search (the_file_name); else file_search_result := eve$$file_search (the_file_name); if file_search_result = 0 then return (FALSE); endif; endif; exitif file_search_result = ""; temp_file_name := file_search_result; node_dev_dir := file_parse (file_search_result, "", "", HEAD); if file_count = 0 then ! save first file's name and node/dev/dir first_file := temp_file_name; first_node_dev_dir := node_dev_dir; else if first_node_dev_dir <> node_dev_dir then ! search list or [...] ! stop at 1st node/dev/dir in search list, and return first ! file spec to show resolved node/dev/dir if ambiguous command line temp_file_name := first_file; exitif; endif; endif; file_count := file_count + 1; eve$add_choice (file_search_result); endloop; if file_count > 1 then ! See if all files are the same name. This can happen when a search list ! is a concealed logical name. If so, force the count to 1 and return ! that name because opening it will get the first one in the list. saved_mark := mark (NONE); position (eve$choice_buffer); position (BUFFER_BEGIN); rec_cnt := get_info (current_buffer, "record_count") + 1; loop if get_info (current_buffer, "record_number") = rec_cnt then file_count := 1; exitif; endif; exitif current_line <> temp_file_name; move_vertical (1); endloop; position (saved_mark); endif; return (temp_file_name); endprocedure; ! eve$$file_search_loop ! EVE$FILE.TPU Page 14 procedure eve$$journal_open ! Perform a JOURNAL_OPEN (the_file_name) ! file to open ! Do a JOURNAL_OPEN allowing all RMS error messages to be output. on_error [OTHERWISE]: endon_error; %if eve$x_option_decwindows %then if eve$x_decwindows_active then ! avoid TPU$_REQUIRESTERM with DECwindows screen mgr eve$message (EVE$_NOJRNLDECW); return (FALSE); endif; %endif journal_open (the_file_name); ! return null string if no file return (TRUE); endprocedure; ! eve$$journal_open ! EVE$FILE.TPU Page 15 procedure eve$nowrite_status_field ! Status line indicator (the_length, the_format) ! Procedure to put up the "Read Only" indicator on NO_WRITE buffers on_error [OTHERWISE]: endon_error; if get_info (current_buffer, "no_write") then return fao (the_format, eve$x_read_only); else return fao (the_format, eve$x_write); endif; endprocedure; ! eve$nowrite_status_field ! EVE$FILE.TPU Page 16 procedure eve$test_default_directory ! Test if illegal default directory !+ ! Output a message and return false if in an illegal default directory; ! otherwise return true. ! Called by eve$$init_files during keystroke journaling startup. ! EVE will output tpu$_nojournal message at end of startup. !_ local file_spec, temp; on_error [TPU$_PARSEFAIL]: ! = "Error parsing DEV:[DIR]" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! The following substr's must be synchronized with TPU$_PARSEFAIL !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! if eve$x_ultrix_active then eve$message (EVE$_NODEFDIR, 0, substr (error_text, 15)) else temp := index (error_text, "]"); eve$message (EVE$_NODEFDIR, 0, substr (error_text, 15, temp - 15 + 1)); !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! endif; return (FALSE); [OTHERWISE]: endon_error; file_spec := file_search (""); return (TRUE); endprocedure; ! eve$test_default_directory ! EVE$FILE.TPU Page 17 procedure eve_open ! DECwindows synonym for GET FILE (the_file) ! Open a new file - create a new EVE buffer and read the contents of the ! specified file into the new buffer. ! In DECwindows the file will be retrieved via a file selection box. return (eve$open1 (the_file)); endprocedure; ! eve_open procedure eve$open1 ! DECwindows synonym for GET FILE (the_file) ! Parameters: ! the_file = name of the file - optional input on_error [OTHERWISE]: endon_error; return (eve_get (the_file)); endprocedure; ! eve$open1 ! EVE$FILE.TPU Page 18 procedure eve_open_selected ! GET FILE whose name is the selection ! Open a file using the current selection as a file name. ! Use the following order: EVE's selection, text of the global selection, ! file associated with the global selection, EVE's found range. ! Cancel EVE's selection/found_range active regardless of it being opened. local the_range, ! the selection the_buffer, ! buffer containing the selection saved_box_flag, ! current box select flag setting saved_mark, ! current position select_string; ! the string value of the selection on_error [TPU$_CONTROLC]: eve$x_box_select_flag := saved_box_flag; eve$$restore_position (saved_mark); eve$$release_scratch_buffer; eve$learn_abort; abort; [OTHERWISE]: eve$x_box_select_flag := saved_box_flag; eve$$restore_position (saved_mark); eve$$release_scratch_buffer; endon_error; saved_box_flag := eve$x_box_select_flag; saved_mark := mark (FREE_CURSOR); ! position to the buffer containing the selection/found range if eve$x_select_position <> 0 then the_buffer := get_info (eve$x_select_position, "buffer"); if the_buffer <> current_buffer then position (the_buffer); endif; else if get_info (eve$x_found_range, "type") = RANGE then the_buffer := get_info (eve$x_found_range, "buffer"); if the_buffer <> current_buffer then position (the_buffer); endif; else if eve$x_box_array <> 0 then eve$x_box_select_flag := TRUE; ! force box to be chosen the_buffer := get_info (eve$x_box_array {0}, "buffer"); if the_buffer <> current_buffer then position (the_buffer); endif; endif; endif; endif; ! Get EVE's select range the_range := eve$selection (FALSE, ! no messages FALSE, ! no found range FALSE, ! no global select TRUE, ! extend null ranges TRUE, ! cancel EVE's selection TRUE); ! will take a box selection eve$x_box_select_flag := saved_box_flag; if get_info (the_range, "type") = RANGE then position (saved_mark); ! If more than one file in selection, make a LF-separated list of ! filespecs, get them all in, and put user into last file read. ! If just a single filespec, get that one. return (eve$open_multi_selected (str (the_range, ascii (10)))); else if get_info (the_range, "type") = ARRAY then ! box selection position (saved_mark); ! Check for multi-line select ranges. if get_info (the_range, "last") = 1 then ! {0}=marker, {1}=range of box selection return (eve_get (str (the_range {1}))); else 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); eve$$box_cut (the_range, ! box array eve$$x_scratch_buffer, ! paste buffer FALSE, ! don't delete range FALSE); ! no messages position (saved_mark); eve$$release_scratch_buffer; return (eve$open_multi_selected (str (eve$$x_scratch_buffer, ascii (10)))); endif; endif; endif; ! Else, try the global selection. Multi-line global selections will ! contain LF's for linebreaks, and EVE_GET will treat each line as a ! separate filespec. select_string := eve$open_selected; if select_string <> 0 then position (saved_mark); return (eve$open_multi_selected (select_string)); endif; ! Else, try EVE's found range the_range := eve$selection (TRUE, ! allow messages (no selection) TRUE, ! found range FALSE, ! no global select TRUE, ! extend null ranges TRUE); ! cancel EVE's selection position (saved_mark); if get_info (the_range, "type") = RANGE then return (eve$open_multi_selected (str (the_range, ascii (10)))); endif; endprocedure; ! eve_open_selected ! EVE$FILE.TPU Page 19 procedure eve$open_selected ! Open global selection ! Returns the string of the current global selection. ! First tries for STRING (text of selection), and then for FILE_NAME (file ! associated with the selection). If decwindows is not active, ! or we own the global selection, or GET_GLOBAL_SELECT doesn't return ! a string, then return 0. local string_value, the_file, file_name; on_error [TPU$_PARSEFAIL]: ! continue if file_search fails [TPU$_GBLSELOWNER]: ! we own the global select return (FALSE); [OTHERWISE]: endon_error; %if eve$x_option_decwindows %then if eve$x_decwindows_active then string_value := get_global_select (PRIMARY, "STRING"); if get_info (string_value, "type") = STRING then ! use the STRING value eve$reset_file_search; the_file := file_search (string_value); ! Return if a file matches the global selection string, or if ! it contains a LF indicating more than one file. NOTE: LF's are ! not legal in file names, and may indicate multiple files. if (the_file <> "") or (index (string_value, ascii (10)) <> 0) then return (string_value); else ! bogus STRING, now try FILE_NAME file_name := get_global_select (PRIMARY, "FILE_NAME"); if get_info (file_name, "type") = STRING then the_file := file_search (file_name); if the_file <> "" then ! use the FILE_NAME value return (file_name); else ! still bogus, use the STRING value return (string_value); endif; endif; endif; endif; endif; %endif return (FALSE); endprocedure; ! eve$open_selected ! EVE$FILE.TPU Page 20 procedure eve$open_multi_selected ! Open multiple selected files (the_string) ! A filespec or list of LF-separated file specs ! This procedure opens all files contained in the lf-separated list. ! It leaves positioned to the last buffer successfully read from a file. ! It displays choices only for first ambiguous filespec, rejecting others. local lf_ix, temp, file_count, no_get, ambiguous_get, ! 0 or first ambiguous file when eve$x_get_wild_active=0 one_file; lf_ix := index (the_string, ascii (10)); if lf_ix = 0 then lf_ix := length (the_string) + 1; endif; ambiguous_get := 0; loop one_file := substr (the_string, 1, lf_ix - 1); if one_file = "" then eve$message (EVE$_NOFILESPEC); else if eve$x_get_wild_active then eve_get_wildcarded_files (one_file); else ! Search for files and call EVE_GET_FILE only if no search error ! and only 1 file matched. Remember first ambiguous filespec ! for resolving when done, and reject other ambiguous ones. This ! imitates multiple ambiguous input filespec behavior at startup. file_count := 0; no_get := 0; eve$reset_file_search; temp := eve$$file_search_loop (one_file, file_count, FALSE); if file_count > 1 then if ambiguous_get = 0 then ambiguous_get := one_file; ! save first ambig filespec else eve$message (EVE$_IGNOREAMBIGS); endif; no_get := TRUE; endif; if (temp <> 0) and (not no_get) then eve_get_file (one_file); endif; endif; endif; ! Get the next file to open the_string := substr (the_string, lf_ix + 1); exitif the_string = ""; lf_ix := index (the_string, ascii (10)); if lf_ix = 0 then ! we run out of lf's before filespecs lf_ix := 9999; endif; endloop; if ambiguous_get <> 0 then ! display ambiguous choices return (eve_get_file (ambiguous_get)); endif; return (TRUE); endprocedure; ! eve$open_multi_selected ! EVE$FILE.TPU Page 21 procedure eve_new ! DECwindows synonym for BUFFER ! Create a new (empty) EVE buffer. If "MAIN" doesn't exist then create a buffer ! MAIN. If "MAIN" exists then prompt for a (unique) buffer name. if not eve$declare_intention (eve$k_action_new_buffer) then return (FALSE); endif; return (eve$new1); endprocedure; ! eve_new procedure eve$new1 ! DECwindows synonym for BUFFER (; buffer_arg) ! buffer name - optional ! true/false status allows eve$$widget_new_ok to unmanage the dialog box, ! while eve$k_async_prompting means leave it managed (buffer already exists) local the_buffer; on_error [TPU$_CONTROLC]: eve$learn_abort; abort; [OTHERWISE]: endon_error; if (buffer_arg = tpu$k_unspecified) or (buffer_arg = "") then the_buffer := eve$x_buf_str_main; else the_buffer := buffer_arg; endif; edit (the_buffer, TRIM); ! trim leading/trailing whitespace if get_info (BUFFER, "find_buffer", the_buffer) = 0 ! new buffer name then if not eve$create_new_buffer (the_buffer) then return (FALSE); endif; else ! the_buffer is in use if (eve$$x_state_array {eve$$k_command_line_flag} = eve$k_invoked_by_menu) and (eve$$x_state_array {eve$$k_dialog_box}) then %if eve$x_option_decwindows %then if eve$x_decwindows_active then eve$message (EVE$_BUFEXIST, 1, the_buffer); eve$manage_widget (eve$x_new_dialog, "NEW_DIALOG"); endif; %endif return (eve$k_async_prompting); else loop eve$message (EVE$_BUFEXIST, 1, the_buffer); ! *** message, dialog if not eve$prompt_string ("", the_buffer, message_text (EVE$_NEWBUFPROMPT, 1), message_text (EVE$_NOBUFFCREA, 1)) then eve$learn_abort; return (FALSE); endif; exitif get_info (BUFFER, "find_buffer", the_buffer) = 0 endloop; if not eve$create_new_buffer (the_buffer) then return (FALSE); endif; endif; endif; eve$clear_message; eve$set_status_line (current_window); return (TRUE); endprocedure; ! eve$new1 ! EVE$FILE.TPU Page 22 procedure eve$create_new_buffer ! EVE buffer function (buffer_name) ! the name of the buffer to create; input if get_info (eve$create_buffer (buffer_name, "", "", TRUE), "type") = BUFFER then return (TRUE); else return (FALSE); endif; endprocedure; ! eve$create_new_buffer ! EVE$FILE.TPU Page 23 procedure eve_buffer ! Go to a (create a new) buffer (buffer_parameter) ! String containing buffer name - input ! Map a buffer to the current window. If the buffer doesn't already ! exist, create a new buffer. local buffer_name, ! Local copy of buffer_parameter saved_buffer, ! Current buffer saved_mark, ! Current cursor position saved_window, ! Current window loop_buffer, ! Current buffer being checked in loop loop_buffer_name, ! String containing name of loop_buffer found_a_buffer, ! True if buffer found with same exact name possible_buffer_name, ! Most recent string entered in choice buffer possible_buffer, ! Buffer whose name is possible_buffer_name how_many_buffers, ! Number of buffers listed in choice buffer new_buffer, ! New buffer created when there is no match upcase_name, ! Upcased name for non-Ultrix buffers status; on_error [TPU$_CONTROLC]: eve$$x_upcased_buffer_name := FALSE; eve$$restore_position (saved_window, saved_mark); eve$learn_abort; abort; [OTHERWISE]: eve$$x_upcased_buffer_name := FALSE; eve$$restore_position (saved_window, saved_mark); endon_error; if eve$check_bad_window then eve$message (EVE$_CURSINTEXT); eve$learn_abort; return (FALSE); endif; if not eve$declare_intention (eve$k_action_new_buffer) then return (FALSE); endif; if not (eve$prompt_string (buffer_parameter, buffer_name, message_text (EVE$_BUFNAM, 1), message_text (EVE$_BUFNOTSWITCH, 0))) then eve$learn_abort; return (FALSE); endif; eve$cleanse_string (buffer_name); ! See if we already have a buffer by that name saved_mark := mark (FREE_CURSOR); saved_window := current_window; saved_buffer := current_buffer; loop_buffer := get_info (BUFFERS, "first"); if not eve$x_ultrix_active then change_case (buffer_name, UPPER); ! buffer names are uppercase on VMS endif; erase (eve$choice_buffer); loop exitif loop_buffer = 0; loop_buffer_name := get_info (loop_buffer, "name"); if buffer_name = loop_buffer_name then found_a_buffer := 1; how_many_buffers := 1; exitif 1; else if buffer_name = substr (loop_buffer_name, 1, length (buffer_name)) then eve$add_choice (loop_buffer_name); possible_buffer := loop_buffer; possible_buffer_name := loop_buffer_name; how_many_buffers := how_many_buffers + 1; endif; endif; loop_buffer := get_info (BUFFERS, "next"); endloop; if not eve$x_ultrix_active then ! (buffer names are uppercase on VMS) change_case (buffer_name, LOWER); ! for messages endif; if found_a_buffer then if loop_buffer = saved_buffer then eve$message (EVE$_INBUFF, 0, loop_buffer_name); return (TRUE); ! no learn abort here else map (current_window, loop_buffer); endif; else if get_info (eve$choice_buffer, "record_count") > 0 then if how_many_buffers = 1 then if possible_buffer = saved_buffer then eve$message (EVE$_INBUFF, 0, possible_buffer_name); return (TRUE); ! no learn abort here else map (current_window, possible_buffer); endif; else eve$display_choices (message_text (EVE$_AMBBUF, 0, buffer_name), !** How do we get the synonym for the key that was defined to this command? "buffer ", buffer_name); eve$learn_abort; return (FALSE); endif; else ! didn't find a buffer if (not eve$x_ultrix_active) or (eve$x_ultrix_active and not eve$x_upcase_bufnam_if_none) then if not eve$create_new_buffer (buffer_name) then return (FALSE); endif; else ! Ultrix_active and upcase_bufnam_if_none. Call self to try ! matching an upcased buffer name. if eve$$x_upcased_buffer_name then return (FALSE); ! return to else code just below else eve$$x_upcased_buffer_name := TRUE; upcase_name := change_case (buffer_name, UPPER, NOT_IN_PLACE); status := eve_buffer (upcase_name); eve$$x_upcased_buffer_name := FALSE; if not status then ! No upcased buffer, just make case-sensitive buffer. if not eve$create_new_buffer (buffer_name) then return (FALSE); endif; endif; endif; endif; endif; endif; eve$set_status_line (current_window); return (TRUE); endprocedure; ! eve_buffer ! EVE$FILE.TPU Page 24 procedure eve_include_file ! Include a file at current position (include_file_parameter) ! String containing file name - input ! Like read_file built-in, but positions the cursor at the start of ! the inserted file. Handles wildcarding in file name. local include_file_name, ! Local copy of include_file_parameter started_at_bof, ! True if current position at start of file include_position, ! Marker for where cursor should end up file_count, ! Number of files matching the spec temp, temp_file_name; ! First file name string - from file_parse on_error [TPU$_CONTROLC]: eve$learn_abort; return (FALSE); [TPU$_TRUNCATE]: eve$message (error_text, error); [OTHERWISE]: endon_error; position (TEXT); ! no padding if eve$check_bad_window then eve$message (EVE$_CURSINTEXT); eve$learn_abort; return (FALSE); endif; if not eve$declare_intention (eve$k_action_include_file) then return (FALSE); endif; if not (eve$prompt_string (include_file_parameter, include_file_name, message_text (EVE$_INCLPROMPT, 1), message_text (EVE$_NOFILEINCL, 0))) then eve$learn_abort; return (FALSE); endif; if mark (FREE_CURSOR) = beginning_of (current_buffer) then started_at_bof := 1; endif; if started_at_bof then include_position := mark (FREE_CURSOR); else move_horizontal (-1); include_position := mark (FREE_CURSOR); move_horizontal (1); endif; ! Initialize to null string and protect against earlier file_search ! with same file name. eve$reset_file_search; temp_file_name := file_parse (include_file_name); erase (eve$choice_buffer); temp := eve$$file_search_loop (include_file_name, file_count, TRUE); if temp <> "" then temp_file_name := temp; endif; case file_count from 0 to 1 [0]: ! use parsed name to exclude real password eve$message (EVE$_CANTINCLFILE, 0, temp_file_name); [1]: read_file (temp_file_name); if started_at_bof then position (BUFFER_BEGIN); else position (include_position); move_horizontal (1); endif; return (TRUE); [OUTRANGE]: ! give resolved node/dev/dir if search_list or [...] temp_file_name := file_parse (temp_file_name, "", "", HEAD) + file_parse (include_file_name, "", "", TAIL); eve$display_choices (message_text (EVE$_AMBFILE, 0, include_file_name), !** How do we get the synonym for the key that was defined to this command? "include file ", temp_file_name); endcase; eve$learn_abort; return (FALSE); endprocedure; ! eve_include_file ! EVE$FILE.TPU Page 25 procedure eve_exit ! Exit the editor ! Exit Eve. Write the current buffer if modified, and ask the user ! about writing out any other modified buffers. ! Insure eve$write_file is called with a filename: ! ask for one first (in eve$$get_write_file), and if none supplied, ! warn the user that buffer is as good as gone. eve$exit_dispatch; endprocedure; ! eve_exit procedure eve$exit_dispatch ! Dispatch to exit handlers eve$exit; endprocedure; ! eve$exit_dispatch procedure eve$exit ! EXIT subprocedure if get_info (eve$prompt_window, "buffer") <> 0 then eve$message (EVE$_CANTEXIT); eve$learn_abort; return (FALSE); endif; if get_info (eve$$x_exit_array, "type") = ARRAY then delete (eve$$x_exit_array); endif; eve$$x_exit_array := create_array; eve$$x_exit_array {TYPE} := eve$$k_exit_context; eve$$x_exit_array {"state"} := 0; ! sequential integer states eve$$x_exit_array {"the_file"} := ""; eve$$x_exit_array {"the_buffer"} := current_buffer; return (eve$$exit1); endprocedure; ! eve$exit ! EVE$FILE.TPU Page 26 procedure eve$$exit1 ! EXIT subprocedure ! Try to write the current buffer, then loop writing all other buffers ! before exiting (only modified/writeable buffer get written). local status; status := eve$$exit2 (0); if status <> eve$k_success then return (status); endif; eve$$x_exit_array {"the_buffer"} := get_info (BUFFERS, "first"); return (eve$$exit_loop); endprocedure; ! eve$$exit1 ! EVE$FILE.TPU Page 27 procedure eve$$exit2 ! EXIT subprocedure (loop_flag) ! True if called from EVE$$EXIT_LOOP ! Try to write a buffer after insuring file a name exists. ! eve$$x_exit_array {"state"} = 0 do eve$$get_write_file local status; on_error [TPU$_CONTROLC]: eve$learn_abort; abort; [OTHERWISE]: endon_error; if get_info (eve$$x_exit_array {"the_buffer"}, "modified") and not get_info (eve$$x_exit_array {"the_buffer"}, "no_write") then eve$$x_exit_array {"the_buffer_name"} := substr ( get_info (eve$$x_exit_array {"the_buffer"}, "name"), 1, eve$x_max_buffer_name_length ); if eve$$x_exit_array {"state"} = 0 then status := eve$$get_write_file (eve$$x_exit_array {"the_buffer"}, eve$$x_exit_array {"the_file"}, eve$$x_exit_array {"got_a_file"}, loop_flag); if not status then eve$learn_abort; return (FALSE); endif; if status = eve$k_async_prompting then return (status); endif; eve$$x_exit_array {"state"} := 1; endif; if eve$$x_exit_array {"state"} = 1 then if (eve$$x_exit_array {"the_file"} <> "") or ! pressed RETURN at prompt eve$$x_exit_array {"got_a_file"} ! file_name or output_file exist then %if eve$x_option_decwindows %then if eve$x_decwindows_active then if (eve$$x_state_array {eve$$k_command_line_flag} = eve$k_invoked_by_menu) and (eve$$x_state_array {eve$$k_dialog_box}) then if get_info (eve$x_writebuf_dialog, "type") = WIDGET then ! don't manage two uncascaded modals at once eve$unmanage_widget (eve$x_writebuf_dialog); endif; endif; endif; %endif status := eve$write_file (eve$$x_exit_array {"the_buffer"}, eve$$x_exit_array {"the_file"}, 0); if not status then %if eve$x_option_decwindows %then if eve$x_decwindows_active then if (eve$$x_state_array {eve$$k_command_line_flag} = eve$k_invoked_by_menu) and (eve$$x_state_array {eve$$k_dialog_box}) then eve$popup_message (message_text (EVE$_CANTWRITE, 1, eve$$x_exit_array {"the_buffer_name"})); eve$$set_responder (eve$$k_writefileprompt_ok, "eve$invalid_event (" + str (eve$$k_writefileprompt_ok) + ")"); eve$$set_responder (eve$$k_message_ok, "eve$unmanage_widget(" + "eve$x_message_dialog)"); endif; endif; %else eve$message (EVE$_CANTWRITE, 0, eve$$x_exit_array {"the_buffer_name"}); %endif eve$learn_abort; return (FALSE); endif; if status = eve$k_async_prompting then return (status); endif; endif; eve$$x_exit_array {"state"} := 2; endif; endif; return (TRUE); endprocedure; ! eve$$exit2 ! EVE$FILE.TPU Page 28 procedure eve$$exit_loop ! EXIT subprocedure ! eve$$x_exit_array {"state"} = 0 to do eve$$get_write_file (eve$$exit2) ! = 1 to do eve$write_file (eve$$exit2) ! = 2 to do eve$insist_y_n local saved_success, status; on_error [TPU$_CONTROLC]: %if eve$x_option_decwindows %then if (eve$$x_state_array {eve$$k_command_line_flag} = eve$k_invoked_by_menu) and (eve$$x_state_array {eve$$k_dialog_box}) then if eve$x_decwindows_active then eve$unmanage_widget (eve$x_writebuf_dialog); endif; endif; %endif set (SUCCESS, saved_success); eve$learn_abort; abort; [OTHERWISE]: %if eve$x_option_decwindows %then if (eve$$x_state_array {eve$$k_command_line_flag} = eve$k_invoked_by_menu) and (eve$$x_state_array {eve$$k_dialog_box}) then if eve$x_decwindows_active then eve$unmanage_widget (eve$x_writebuf_dialog); endif; endif; %endif set (SUCCESS, saved_success); endon_error; saved_success := get_info (SYSTEM, "success"); ! for error handler loop exitif eve$$x_exit_array {"the_buffer"} = 0; if (eve$$x_exit_array {"the_buffer"} <> current_buffer) and get_info (eve$$x_exit_array {"the_buffer"}, "modified") and (not get_info (eve$$x_exit_array {"the_buffer"}, "no_write")) then eve$$x_exit_array {"the_buffer_name"} := substr ( get_info (eve$$x_exit_array {"the_buffer"}, "name"), 1, eve$x_max_buffer_name_length ); status := TRUE; if eve$$x_exit_array {"state"} = 2 then if (eve$$x_state_array {eve$$k_command_line_flag} = eve$k_invoked_by_menu) and (eve$$x_state_array {eve$$k_dialog_box}) then %if eve$x_option_decwindows %then if eve$x_decwindows_active then if get_info (eve$x_writebuf_dialog, "type") <> WIDGET then eve$x_writebuf_dialog := create_widget ("WRITEBUF_DIALOG", eve$x_widget_hierarchy, SCREEN, eve$kt_callback_routine); endif; status := set (WIDGET, get_info (WIDGET, "widget_id", eve$x_writebuf_dialog, "WRITEBUF_DIALOG.WRITEBUF_LABEL"), eve$x_resource_array {eve$k_nlabel}, message_text (EVE$_WRITEBUF, 1, eve$$x_exit_array {"the_buffer_name"})); eve$manage_widget (eve$x_writebuf_dialog); eve$set_min_widget_size (eve$x_writebuf_dialog, TRUE ); endif; %endif return (eve$k_async_prompting); else status := eve$insist_y_n (message_text (EVE$_WRITEBUF, 1, eve$$x_exit_array {"the_buffer_name"})); eve$$x_exit_array {"state"} := 0; endif; endif; if status then status := eve$$exit2 (1); if not status then eve$learn_abort; %if eve$x_option_decwindows %then if (eve$$x_state_array {eve$$k_command_line_flag} = eve$k_invoked_by_menu) and (eve$$x_state_array {eve$$k_dialog_box}) then if eve$x_decwindows_active then eve$unmanage_widget (eve$x_writebuf_dialog); endif; endif; %endif return (FALSE); endif; if status = eve$k_async_prompting then return (status); endif; else if status = eve$k_error ! read_key was aborted then %if eve$x_option_decwindows %then if (eve$$x_state_array {eve$$k_command_line_flag} = eve$k_invoked_by_menu) and (eve$$x_state_array {eve$$k_dialog_box}) then if eve$x_decwindows_active then eve$unmanage_widget (eve$x_writebuf_dialog); endif; endif; %endif return (status); endif; endif; endif; eve$$x_exit_array {"state"} := 2; eve$$x_exit_array {"the_buffer"} := get_info (BUFFERS, "next"); endloop; ! Delete all modified buffers so we can use EXIT without TPU prompting ! (need to return %TPU-S-EXITING for callable interface) eve$$x_exit_array {"the_buffer"} := get_info (BUFFERS, "first"); loop exitif eve$$x_exit_array {"the_buffer"} = 0; if get_info (eve$$x_exit_array {"the_buffer"}, "modified") and (not get_info (eve$$x_exit_array {"the_buffer"}, "no_write")) then ! delete causes "next" delete (eve$$x_exit_array {"the_buffer"}); ! to return 0, must ! restart from "first" eve$$x_exit_array {"the_buffer"} := get_info (BUFFERS, "first"); else eve$$x_exit_array {"the_buffer"} := get_info (BUFFERS, "next"); endif; endloop; %if eve$x_option_decwindows %then if (eve$$x_state_array {eve$$k_command_line_flag} = eve$k_invoked_by_menu) and (eve$$x_state_array {eve$$k_dialog_box}) then if eve$x_decwindows_active then if get_info (eve$x_writebuf_dialog, "type") = WIDGET then eve$unmanage_widget (eve$x_writebuf_dialog); endif; endif; endif; %endif ! Delete EVE subprocesses *without* the "subprocess terminated" message. eve$delete_processes; exit; endprocedure; ! eve$$exit_loop ! EVE$FILE.TPU Page 29 procedure eve$$get_write_file ! EXIT support procedure (the_buffer, ! buffer for which to find output file the_file, ! resulting file name if success_flag = false, ! else "" - output success_flag; ! set true if found file (in which case the_file is set ! to ""), else set false - output loop_flag) ! True if called from EVE$$EXIT_LOOP, input ! Description ! Procedure used by EVE_EXIT. ! See if a file name is associated with the buffer, either the "file_name" ! from the command line, or the "output_file" from SET(OUTPUT_FILE...). ! If either of these exists, ! then set the success_flag argument true, and null out the file_name ! argument (this is needed for correct prompting interaction ! between EVE_EXIT and EVE$WRITE_FILE). ! else set success_flag false, and prompt for a file name from the ! user (return whatever the user enters, if "", then output ! a warning message). ! Status ! eve$k_warning (0) -- prompt_line failed ! eve$k_async_prompting (3) -- dialog box is prompting for filename ! eve$k_success (1) -- otherwise local the_value, status, the_loop_flag; on_error [OTHERWISE]: ! parameters are of wrong type endon_error; success_flag := FALSE; the_file := get_info (the_buffer, "output_file"); if the_file = 0 then the_file := get_info (the_buffer, "file_name"); endif; if the_file <> "" then success_flag := TRUE; ! Ok to null out, we've just insured that the_file := ""; ! eve$write_file will get a file name from get_info. else if (eve$$x_state_array {eve$$k_command_line_flag} = eve$k_invoked_by_menu) and (eve$$x_state_array {eve$$k_dialog_box}) then if loop_flag = tpu$k_unspecified then the_loop_flag := 0; else the_loop_flag := loop_flag; endif; %if eve$x_option_decwindows %then if eve$x_decwindows_active then if get_info (eve$x_needfilename_dialog, "type") <> WIDGET then eve$x_needfilename_dialog := create_widget ("NEEDFILENAME_DIALOG", eve$x_widget_hierarchy, SCREEN, eve$kt_callback_routine); endif; the_value := message_text (EVE$_FILENAMEPROMPT, 0, get_info (the_buffer, "name")); status := set (WIDGET, get_info (WIDGET, "widget_id", eve$x_needfilename_dialog, "NEEDFILENAME_DIALOG.NEEDFILENAME_LABEL"), eve$x_resource_array {eve$k_nlabel}, the_value); eve$$set_responder (eve$$k_needfilename_ok, fao ("eve$$widget_needfilename_ok (!UL)", the_loop_flag)); eve$$set_responder (eve$$k_needfilename_cancel, fao ("eve$$widget_needfilename_cancel (!UL)", the_loop_flag)); if get_info (eve$x_writebuf_dialog, "type") = WIDGET then ! don't manage two uncascaded modals at once eve$unmanage_widget (eve$x_writebuf_dialog); endif; eve$manage_widget (eve$x_needfilename_dialog); eve$set_min_widget_size (eve$x_needfilename_dialog); endif; %endif return (eve$k_async_prompting); else the_file := eve$prompt_line (message_text (TPU$_NEEDFILENAME, 1, get_info (the_buffer, "name")), eve$$x_prompt_terminators, ""); if the_file = 0 then return (FALSE); endif; if the_file = "" then eve$message (EVE$_NOFILESPECEXIT, 0, get_info (the_buffer, "name")); endif; endif; endif; return (TRUE); endprocedure; ! eve$$get_write_file ! EVE$FILE.TPU Page 30 procedure eve_get ! Get a file. (get_file_parameter) ! input file spec local get_file_name; ! If wild card gets are set, then grab all file names from the input parameter. ! Otherwise, get a single file. if eve$x_get_wild_active then return eve_get_wildcarded_files (get_file_parameter); else return eve_get_file (get_file_parameter); endif; endprocedure; ! eve_get ! EVE$FILE.TPU Page 31 ! Modified Procedure Eve_get_wildcarded_files to fix PTR 70-18-50 procedure eve_get_wildcarded_files ! Get all files matching (get_file_parameter) ! input file spec local file_count, get_file_name, status, first_buffer, file_search_result; on_error [TPU$_CONTROLC]: eve$learn_abort; abort; [TPU$_SEARCHFAIL]: eve$message (EVE$_NOSUCHFILE, 0, get_file_name); eve$learn_abort; return (FALSE); endon_error; if eve$check_bad_window then eve$message (EVE$_CURSINTEXT); eve$learn_abort; return (FALSE); endif; if not eve$declare_intention (eve$k_action_new_buffer) then return (FALSE); endif; if (eve$$x_state_array {eve$$k_command_line_flag} = eve$k_invoked_by_menu) and (eve$$x_state_array {eve$$k_dialog_box}) and (get_file_parameter = "") then %if eve$x_option_decwindows %then if eve$x_decwindows_active then eve$$manage_file_selection; endif; %endif return (eve$k_async_prompting); else if not (eve$prompt_string (get_file_parameter, get_file_name, message_text (EVE$_GETFILEPROMPT, 1), message_text (EVE$_NOFILESPEC, 0))) then eve$$x_ambiguous_input_file := 0; eve$learn_abort; return (FALSE); endif; endif; init_file_count := 0; file_count := 0; first_buffer := current_buffer; status := TRUE; filename_array := CREATE_ARRAY; eve$reset_file_search; loop file_search_result := file_search (get_file_name); exitif file_search_result = ""; init_file_count := init_file_count + 1; filename_array{init_file_count} := file_search_result; endloop; if init_file_count <> 0 then ! This line is added to fix PTR 70-18-50 loop if eve$get_file1 (filename_array{init_file_count}, , TRUE) then file_count := file_count + 1 else status := FALSE; endif; init_file_count := init_file_count - 1; exitif init_file_count = 0; endloop; endif; ! This line is added to fix PTR 70-18-50 delete (filename_array); if file_count > 1 then if first_buffer <> current_buffer then if (not eve$x_starting_up) and (not eve$x_post_starting_up) then eve$message (EVE$_GOINGBUF, 0, get_info (current_buffer, "name")); endif; endif; else if file_count <= 0 then eve$message (EVE$_NOFILMATCH, 0, get_file_name); status := FALSE; endif; endif; return status; endprocedure; ! eve_get_wildcarded_files ! EVE$FILE.TPU Page 32 procedure eve_get_file ! Get a file (get_file_parameter) ! String containing file name - input ! Edit a file in the current window. If the file is already in a buffer, ! use the old buffer. If not, create a new buffer. return (eve$get_file1 (get_file_parameter)); endprocedure; ! eve_get_file ! EVE$FILE.TPU Page 33 procedure eve$get_file1 ! Get a file subprocedure (get_file_parameter; ! File name ! Optional parameters: new_buf_name, ! Unique buffer name from dialog box wildcard_get) ! Doing a wildcard get. ! Don't do any file searches (to avoid ! resetting file search context) ! Don't message if file already in a buffer local get_file_name, ! Local copy of get_file_parameter temp_buffer_name, ! String for buffer name based on get_file_name file_search_result, ! Latest string returned by file_search temp_file, ! Save the filename temp_file_name, ! First file name string returned by file_search file_exists, ! True if file of that name found on disk file_count, ! Number of files matching the spec temp_answer, ! Answer to "Create file?" new_buffer, ! New buffer created if needed found_a_buffer, ! Buffer of same name, or zero ultrix_main, ! non-zero if Ultrix input file = MAIN want_new_buffer; ! True if file should go into a new buffer on_error [TPU$_CONTROLC]: eve$$x_ambiguous_input_file := 0; eve$learn_abort; abort; [TPU$_SEARCHFAIL]: eve$$x_ambiguous_input_file := 0; eve$message (EVE$_NOSUCHFILE, 0, get_file_name); eve$learn_abort; return (FALSE); [OTHERWISE]: eve$$x_ambiguous_input_file := 0; endon_error; if new_buf_name = tpu$k_unspecified then new_buf_name := ""; endif; if wildcard_get = tpu$k_unspecified then wildcard_get := false; endif; if eve$check_bad_window then eve$message (EVE$_CURSINTEXT); eve$learn_abort; return (FALSE); endif; if not eve$declare_intention (eve$k_action_new_buffer) then return (FALSE); endif; if (eve$$x_state_array {eve$$k_command_line_flag} = eve$k_invoked_by_menu) and (eve$$x_state_array {eve$$k_dialog_box}) and (get_file_parameter = "") then %if eve$x_option_decwindows %then if eve$x_decwindows_active then eve$$manage_file_selection; endif; %endif return (eve$k_async_prompting); else if not (eve$prompt_string (get_file_parameter, get_file_name, message_text (EVE$_GETFILEPROMPT, 1), message_text (EVE$_NOFILESPEC, 0))) then eve$$x_ambiguous_input_file := 0; eve$learn_abort; return (FALSE); endif; endif; if wildcard_get or (new_buf_name <> "") then file_exists := TRUE; temp_file_name := get_file_parameter; if new_buf_name <> "" then temp_buffer_name := new_buf_name; else temp_buffer_name := file_parse (temp_file_name, "", "", NAME, TYPE); endif; else ! Protect against earlier file_search with same file name. eve$reset_file_search; temp_file_name := ""; erase (eve$choice_buffer); temp_file_name := eve$$file_search_loop (get_file_name, file_count, FALSE); if temp_file_name = 0 then eve$learn_abort; return (FALSE); endif; if file_count > 1 then ! give resolved node/dev/dir if search_list or [...] temp_file_name := file_parse (temp_file_name, "", "", HEAD) + file_parse (get_file_name, "", "", TAIL); eve$display_choices (message_text (EVE$_AMBFILE, 0, get_file_name), !** How do we get the synonym for the key that was defined to this command? "get file ", temp_file_name); eve$learn_abort; return (FALSE); endif; ! Set-up to see if we already have a buffer by that name file_exists := temp_file_name <> ""; if not file_exists then temp_file_name := get_file_name; endif; temp_buffer_name := file_parse (temp_file_name, "", "", NAME, TYPE); temp_file := get_file_name; get_file_name := file_search (get_file_name); if get_file_name = "" then get_file_name := temp_file; endif; ! Make sure we don't try to use a wildcard file-spec to create a new file. if not eve$x_ultrix_active then if file_count = 0 then if eve$is_wildcard (get_file_name) then eve$message (EVE$_NOFILMATCH, 0, get_file_name); eve$learn_abort; return (FALSE); endif; endif; endif; endif; found_a_buffer := get_info (buffers, "find_buffer", temp_buffer_name); ! See if user is editing input file named MAIN on Ultrix if eve$x_ultrix_active and eve$x_starting_up and (found_a_buffer <> 0) then if temp_buffer_name = eve$x_buf_str_main then ! The following delete positions to message window+buffer. ! Map a temporary buffer to the main window so eve$create_buffer ! maps the MAIN buffer to the main window, then delete the temp buffer. delete (eve$x_main_buffer); eve$x_temp_buffer := create_buffer ("temp_buffer"); map (eve$main_window, eve$x_temp_buffer); found_a_buffer := 0; ultrix_main := TRUE; endif; endif; ! If there is a buffer by that name, is it the exact same file? ! If so, switch to that buffer. Otherwise use a new buffer. ! Check to see if the user wants file names constructed on the fly file_count := 2; loop if found_a_buffer <> 0 then ! Have a buffer with the same name want_new_buffer := temp_file_name <> get_info (found_a_buffer, "output_file"); if file_exists then want_new_buffer := want_new_buffer AND (temp_file_name <> get_info (found_a_buffer, "file_name")); endif; else want_new_buffer := false; endif; exitif not want_new_buffer; exitif not eve$x_generate_bufnames; temp_buffer_name := fao ("!AS [!UL]", file_parse (temp_file_name, "", "", NAME, TYPE), file_count); found_a_buffer := get_info (buffers, "find_buffer", temp_buffer_name); file_count := file_count + 1; endloop; if found_a_buffer <> 0 then if want_new_buffer then eve$message (EVE$_BUFINUSE, 0, temp_buffer_name); if (eve$$x_state_array {eve$$k_command_line_flag} = eve$k_invoked_by_menu) and (eve$$x_state_array {eve$$k_dialog_box}) then %if eve$x_option_decwindows %then if eve$x_decwindows_active then ! supercede the program bound to the "ok" button if get_info (eve$x_openbuffer_dialog, "type") <> WIDGET then eve$x_openbuffer_dialog := eve$create_widget ("OPENBUFFER_DIALOG"); endif; eve$$set_responder (eve$$k_openbuffer_ok, fao ("eve$$widget_openbuffer_ok ('!AS')", get_file_name)); eve$$set_responder (eve$$k_openbuffer_apply, fao ("eve$$widget_openbuffer_apply ('!AS')", get_file_name)); eve$manage_widget (eve$x_openbuffer_dialog); endif; %endif return (eve$k_async_prompting); else temp_buffer_name := eve$prompt_line (message_text (EVE$_NEWBUFPROMPT, 1), eve$$x_prompt_terminators, ""); if temp_buffer_name = 0 then eve$learn_abort; return (FALSE); endif; if temp_buffer_name = "" then eve$message (EVE$_NOBUFFCREA); eve$learn_abort; return (FALSE); else edit (temp_buffer_name, TRIM); if file_exists then new_buffer := eve$create_buffer (temp_buffer_name, get_file_name, temp_file_name); else new_buffer := eve$create_buffer (temp_buffer_name, get_file_name, ""); endif; want_new_buffer := false; if new_buffer = 0 then return (FALSE); endif; endif; endif; else if (current_buffer = found_a_buffer) and not wildcard_get then eve$message (EVE$_ALREDIT, 0, get_file_name); return (TRUE); ! no learn abort here else map (current_window, found_a_buffer); endif; endif; else ! No buffer with same name, so create a new buffer + map to current window if file_exists then eve$$x_input_count := eve$$x_input_count + 1; new_buffer := eve$create_buffer (temp_buffer_name, get_file_name, temp_file_name); else new_buffer := eve$create_buffer (temp_buffer_name, get_file_name, ""); endif; if new_buffer = 0 then return (FALSE); endif; if ultrix_main then ! User is editing input file named MAIN on Ultrix eve$x_main_buffer := new_buffer; delete (eve$x_temp_buffer); endif; endif; ! Apply dcl qualifiers to new buffer if resolving input ! file ambiguity after startup. if (eve$$x_ambiguous_input_file <> 0) and (not eve$x_starting_up) and (not eve$x_post_starting_up) ! ignore GET FILE's in /INIT or /COMMAND then eve$dcl_file_qualifiers; ! apply qualifiers to resolved file eve$$x_ambiguous_input_file := 0; ! Delete temp buffer MAIN if we've created another user buffer, ! but not if it was user input file if (current_buffer <> eve$x_main_buffer) and (current_window = eve$main_window) and (get_info (eve$x_main_buffer, "name") = eve$x_buf_str_main) and (not get_info (current_buffer, "system")) and (not eve$$x_user_main_buf) then delete (eve$x_main_buffer); eve$x_main_buffer := current_buffer; endif; endif; ! Correct the status line in any event eve$set_status_line (current_window); ! restore invalid event program %if eve$x_option_decwindows %then if eve$x_decwindows_active then eve$$set_responder (eve$$k_openbuffer_ok, "eve$invalid_event (" + str (eve$$k_openbuffer_ok) + ")"); eve$$set_responder (eve$$k_openbuffer_apply, "eve$invalid_event (" + str (eve$$k_openbuffer_apply) + ")"); endif; %endif return (TRUE); endprocedure; ! eve$get_file1 ! EVE$FILE.TPU Page 34 procedure eve$reset_file_search ! Null out file_search context !+ ! Reset the file_search context to null. !- local temp_string; on_error ! this prevents error message if no default directory [TPU$_PARSEFAIL]: [OTHERWISE]: endon_error; temp_string := file_search (""); endprocedure; ! eve$reset_file_search ! EVE$FILE.TPU Page 35 procedure eve$is_wildcard ! Test for wildcard string (the_string) on_error [OTHERWISE]: ! argument the_string of wrong type endon_error; if index (the_string, "*") <> 0 then return (TRUE); endif; if not eve$x_ultrix_active then if index (the_string, "%") <> 0 then return (TRUE); endif; if index (the_string, "...") <> 0 then return (TRUE); endif; else if index (the_string, "?") <> 0 then return (TRUE); endif; if index (the_string, "[") <> 0 then return (TRUE); endif; if index (the_string, "{") <> 0 then return (TRUE); endif; endif; return (FALSE); endprocedure; ! eve$is_wildcard ! EVE$FILE.TPU Page 36 procedure eve$create_buffer ! GET_FILE subprocedure (buffer_name, ! Name of new buffer - input requested_file_name, ! Full VMS filespec to use - input actual_file_name; ! From file_search; "" if not on disk - input no_file_flag) ! Boolean, true to disable msg+set(output_file) ! Procedure called by eve_get_file to create a new buffer and map it ! to the current window. Returns the created buffer, or zero if error. local new_buffer, ! Buffer created create_failed, parsed_name, default_exists; on_error [TPU$_CONTROLC]: eve$learn_abort; if get_info (new_buffer, "type") = BUFFER then delete (new_buffer); endif; abort; [TPU$_DUPBUFNAME]: eve$message (EVE$_BUFEXIST, 0, substr (buffer_name, 1, eve$x_max_buffer_name_length)); return (FALSE); [TPU$_OPENIN, TPU$_OPENOUT]: eve$message (error_text, error); create_failed := TRUE; [TPU$_TRUNCATE]: eve$message (error_text, error); [TPU$_JRNLOPENERR, TPU$_BADJOUFILE]: ! Allow ULTRIX journaling to fail, and continue with creation. eve$message (error_text, error); create_failed := TRUE; [OTHERWISE]: endon_error; ! default buffer not created until after end of startup ! (after /INIT processing in procedure TPU$INIT_POSTPROCEDURE) default_exists := (get_info (eve$default_buffer, "type") = BUFFER); if actual_file_name = "" then if not default_exists ! i.e., during startup then new_buffer := create_buffer (buffer_name); else new_buffer := create_buffer (buffer_name, "", eve$default_buffer); set (MODIFIABLE, new_buffer, ON); ! override default buffer set (NO_WRITE, new_buffer, OFF); ! override default buffer if eve$$x_word_wrap_indent {eve$default_buffer} <> tpu$k_unspecified then eve$$x_word_wrap_indent {new_buffer} := eve$$x_word_wrap_indent {eve$default_buffer}; endif; if eve$$x_paragraph_indent {eve$default_buffer} <> tpu$k_unspecified then eve$$x_paragraph_indent {new_buffer} := eve$$x_paragraph_indent {eve$default_buffer}; endif; endif; if create_failed then delete (new_buffer); return (FALSE); endif; if (no_file_flag = tpu$k_unspecified) or (no_file_flag <> TRUE) then ! Parse it to hide password if user specified "username password" parsed_name := file_parse (requested_file_name); eve$message (EVE$_FILENOTFOUND, 0, parsed_name); set (OUTPUT_FILE, new_buffer, parsed_name); endif; else if not default_exists then new_buffer := create_buffer (buffer_name, actual_file_name); else new_buffer := create_buffer (buffer_name, actual_file_name, eve$default_buffer); set (MODIFIABLE, new_buffer, ON); ! override default buffer set (NO_WRITE, new_buffer, OFF); ! override default buffer if eve$$x_word_wrap_indent {eve$default_buffer} <> tpu$k_unspecified then eve$$x_word_wrap_indent {new_buffer} := eve$$x_word_wrap_indent {eve$default_buffer}; endif; if eve$$x_paragraph_indent {eve$default_buffer} <> tpu$k_unspecified then eve$$x_paragraph_indent {new_buffer} := eve$$x_paragraph_indent {eve$default_buffer}; endif; endif; if create_failed then delete (new_buffer); return (FALSE); endif; set (OUTPUT_FILE, new_buffer, actual_file_name); endif; if not default_exists then set (EOB_TEXT, new_buffer, message_text (EVE$_EOBTEXT, 1)); set (LEFT_MARGIN, new_buffer, eve$x_default_left_margin); set (RIGHT_MARGIN, new_buffer, (get_info (eve$main_window, "width") - eve$x_default_right_margin)); set (RIGHT_MARGIN_ACTION, new_buffer, eve$kt_word_wrap_routine); endif; if eve$$x_buffer_change_journaling and (not get_info (new_buffer, "journaling")) then set (JOURNALING, new_buffer, ON); ! EVE's default endif; map (current_window, new_buffer); return (new_buffer); endprocedure; ! eve$create_buffer ! EVE$FILE.TPU Page 37 procedure eve$write_file ! Write a buffer to a file (write_buffer, ! Required buffer -- the buffer to write out write_file_name, ! Optional string -- file name to use; if null, use ! buffer's output_file; if null, ask for one; if null ! don't write it out. format_arg) ! Required integer -- Format number to write in ! 0 -- Editor default (ASCII for base EVE) ! 1 -- ASCII ! 2 -- DDIF (not supported in base EVE) ! else -- No other formats defined at present ! Procedure to write out a buffer to a file. Used by EXIT, WRITE FILE, ! and DELETE BUFFER. ! Return value: ! eve$k_success (1) -- File was written ! eve$k_warning (0) -- File was not written ! eve$k_async_prompting (3) -- dialog box is prompting for filename local the_file, ! Copy of write_file_name or prompted file name the_format, ! Local copy of format_arg status, ! Result from set(widget) the_value, ! Value for widget the_output_file, ! Buffer's output_file full_parse, ! User's + output + input filespecs need_prompt, ! Flag true if need more info name_type, ! Name and type null_name_type, ! Name and type for null filespec write_result, ! Name of file actually written the_head; ! Device+directory on_error [TPU$_PARSEFAIL]: ! This will happen if the user has entered an invalid filespec with ! the WRITE command, set the output_file to an invalid filespec, ! or used CREATE_BUFFER to set an invalid input filespec. ! ONly the first case will produce a meaningful error message. eve$message (EVE$_DONTUNDERFILE, 0, the_file); eve$learn_abort; return (FALSE); [OTHERWISE]: endon_error; case format_arg from 0 to 2 [0]: the_format := 1; [1]: the_format := format_arg; [2]: return (FALSE); [OUTRANGE]: return (FALSE); endcase; if eve$x_trimming then eve$message (EVE$_TRIMMING); eve$trim_buffer (write_buffer); eve$message (EVE$_DONETRIM); endif; the_file := write_file_name; the_output_file := get_info (write_buffer, "output_file"); if the_output_file = 0 then the_output_file := ""; endif; if eve$x_ultrix_active then null_name_type := ""; else null_name_type := "."; endif; ! Determine if we have enough info to write out a file, otherwise prompt. if (the_file = "") then if (the_output_file = "") then ! The /COMMAND buffer is the only one that we'll use that doesn't ! look like an EVE buffer (i.e., has no output file but has an ! input file). if write_buffer = get_info (BUFFER, "find_buffer", "$LOCAL$INI$") then full_parse := file_parse (get_info (write_buffer, "file_name"), "", "", HEAD, NAME, TYPE); else need_prompt := TRUE; endif; else full_parse := file_parse (the_output_file, "", "", HEAD, NAME, TYPE); endif; else if eve$x_ultrix_active then if file_parse (the_file, "", "", NAME, TYPE) <> "" then the_output_file := ""; ! use only user's filespec, not output endif; endif; ! Get name/type from user & output filespecs, get head from only user ! filespec to maintain previous EVE behavior. name_type := file_parse (the_file, the_output_file, "", NAME, TYPE); if name_type = null_name_type then need_prompt := TRUE; else the_head := file_parse (the_file, "", "", HEAD); full_parse := the_head + name_type; endif; endif; ! Prompt if no input/output filespec exists, or the parse has no name+type. if need_prompt then ! This branch taken only from WRITE FILE, not from EXIT procedures if (eve$$x_state_array {eve$$k_command_line_flag} = eve$k_invoked_by_menu) and (eve$$x_state_array {eve$$k_dialog_box}) then %if eve$x_option_decwindows %then if eve$x_decwindows_active then if get_info (eve$x_writefileprompt_dialog, "type") <> WIDGET then eve$x_writefileprompt_dialog := eve$create_widget ("WRITEFILEPROMPT_DIALOG"); endif; the_value := message_text (EVE$_FILENAMEPROMPT, 0, get_info (write_buffer, "name")); status := set (WIDGET, get_info (WIDGET, "widget_id", eve$x_writefileprompt_dialog, "WRITEFILEPROMPT_DIALOG.WRITEFILEPROMPT_LABEL" ), eve$x_resource_array {eve$k_nlabel}, the_value); eve$$set_responder (eve$$k_writefileprompt_ok, fao ( "eve$$widget_writefileprompt_ok ('!AS', !UL)" , get_info (write_buffer, "name"), the_format)); eve$manage_widget (eve$x_writefileprompt_dialog); endif; %endif return (eve$k_async_prompting); else the_file := eve$prompt_line (message_text (EVE$_WRITEFILEPROMPT, 1, get_info (write_buffer, "name")), eve$$x_prompt_terminators, ""); if (the_file = 0) or (the_file = "") then eve$message (EVE$_NOFILESPEC); if (the_file = 0) then return (FALSE); ! abort else return (TRUE); ! harmless return if no filename endif; endif; return (eve$write_file (write_buffer, the_file, the_format)); endif; endif; write_result := eve$$write_file (write_buffer, full_parse); if write_result = 0 then eve$learn_abort; return (FALSE); endif; if write_result <> "" then set (OUTPUT_FILE, write_buffer, write_result); endif; return (TRUE); endprocedure; ! eve$write_file procedure eve$$write_file ! Perform a WRITE_FILE (the_buffer; the_file_name) ! Do a WRITE_FILE allowing all RMS error messages to be output. ! Also make a backup copy of the file if it exists. local version_number; on_error [OTHERWISE]: ! return zero if can't parse filename endon_error; ! Make a backup copy if enabled, fail if couldn't backup if eve$x_file_backup then version_number := eve$$x_buf_ver_array {the_buffer}; if version_number = tpu$k_unspecified then eve$$x_buf_ver_array {the_buffer} := 1; version_number := 1; endif; endif; if not eve$backup_file (the_buffer, the_file_name, version_number, eve$x_backup_string) then return (FALSE); endif; if the_file_name = tpu$k_unspecified then return write_file (the_buffer); else return write_file (the_buffer, the_file_name); endif; endprocedure; ! eve$$write_file ! EVE$FILE.TPU Page 38 procedure eve$trim_buffer ! Trim lines in a buffer (trim_buffer) ! Buffer to trim - input ! Trim whitespace characters from each line in a buffer. ! Put cursor on last non-whitespace char if beyond_eol. local saved_mark, ! Marker for current cursor position original_mark, ! Current position in trim_buffer trim_range; ! Range with trailing spaces on_error [TPU$_CONTROLC]: eve$$restore_position (original_mark); ! move off of trim_range eve$$restore_position (saved_mark); eve$learn_abort; abort; [OTHERWISE]: ! unmodifiable buffer eve$$restore_position (original_mark); ! move off of trim_range eve$$restore_position (saved_mark); endon_error; ! If user hasn't modified eve$pattern_trim, then trim with the fast EDIT ! built-in; otherwise, use old (slow) method of trimming by line. ! EDIT(trim_trailing) uses space+tab. if eve$pattern_trim = (span (" " + ascii (9)) + LINE_END) then edit (trim_buffer, TRIM_TRAILING,OFF); return; endif; saved_mark := mark (FREE_CURSOR); position (trim_buffer); position (TEXT); ! snap cursor to text so it ends on original_mark := mark (NONE); ! last non-whitespace char after trim position (BUFFER_BEGIN); loop trim_range := search_quietly (eve$pattern_trim, FORWARD, EXACT); exitif trim_range = 0; position (beginning_of (trim_range)); erase_character (length (trim_range)); endloop; position (original_mark); position (saved_mark); endprocedure; ! eve$trim_buffer ! EVE$FILE.TPU Page 39 procedure eve$init_buffer ! Init an EVE system buffer (new_buffer_name, ! String for name of new buffer - input new_eob_text; ! String for eob_text of new buffer - input make_permanent) ! Boolean, 1 = make it permanent, 0 = not permanent ! Procedure used to create an Eve system buffer. Returns the new buffer. ! If a buffer exists with the specified name, deletes the buffer. ! Makes the buffer permanent unless optional arg says not to. The only ! EVE system buffers not permanent are DCL and SPELL because they have an ! associated subprocesses - deleting the buffer is easy to delete subprocess. local temp_buffer, ! In case user already made one new_buffer; ! New buffer on_error [OTHERWISE]: endon_error; temp_buffer := get_info (BUFFERS, "find_buffer", new_buffer_name); if temp_buffer <> 0 then ! user must have created one delete (temp_buffer); endif; new_buffer := create_buffer (new_buffer_name); set (EOB_TEXT, new_buffer, new_eob_text); set (NO_WRITE, new_buffer); set (SYSTEM, new_buffer); if make_permanent = tpu$k_unspecified then set (PERMANENT, new_buffer); else if make_permanent then set (PERMANENT, new_buffer); endif; endif; return (new_buffer); endprocedure; ! eve$init_buffer ! EVE$FILE.TPU Page 40 procedure eve_write_file ! Write file (write_file_name) ! String containing file name - input ! Write the current buffer to a specified file. If no file specified, ! use the default file name. if not eve$declare_intention (eve$k_action_write_buffer) then return (FALSE); endif; if eve$write_file (current_buffer, write_file_name, 0) then return (TRUE); else eve$learn_abort; return (FALSE); endif; endprocedure; ! eve_write_file procedure eve_save_file ! DECwindows WRITE command ! Write out the current buffer ! return (eve_write_file ("")); endprocedure; ! eve_save_file procedure eve_save_file_as ! DECwindows write with name (the_file) ! Write out the current buffer into the specified filename. return (eve$save_file_as1 (the_file)); endprocedure; ! eve_save_file_as procedure eve$save_file_as1 ! DECwindows write with name (; the_file) ! the file name to which the buffer is to be written local the_value, ! Value for widget file_name; ! Name of the file to write buffer to ! we need to make sure we have a file name before calling write file file_name := the_file; if (file_name = "") or (file_name = tpu$k_unspecified) then if (eve$$x_state_array {eve$$k_command_line_flag} = eve$k_invoked_by_menu) and (eve$$x_state_array {eve$$k_dialog_box}) then %if eve$x_option_decwindows %then if eve$x_decwindows_active then eve$manage_widget (eve$x_save_file_as_dialog, "SAVE_FILE_AS_DIALOG"); endif; %endif return (eve$k_async_prompting); else the_value := message_text (EVE$_FILENAMEPROMPT, 0, get_info (current_buffer, "name")); file_name := eve$prompt_line (the_value, eve$$x_prompt_terminators, ""); if file_name = 0 then return (FALSE); endif; endif; endif; return (eve_write_file (file_name)); endprocedure; ! eve$save_file_as1 ! EVE$FILE.TPU Page 41 procedure eve__at_file ! Execute a file of EVE commands (file_parameter) ! String containing file name - input ! Description ! Execute a file containing EVE commands. local file_name, ! Local copy of file_parameter saved_mark, ! Remember current position saved_window, ! Remember current window the_file, ! One file_search file default_string, ! OS-specific default filespec disk_string, ! OS-specific sys$disk init file string login_string, ! OS-specific login init file string ini_string, ! OS-specific init file string type_string, ! ULTRIX file type null_device, ! OS-specific null device new_buffer, ! New buffer created if needed count, second, ! Second arg to file_search third, ! Third arg to file_search dir_exists; ! User file has directory on_error [TPU$_CONTROLC]: eve$$x_state_array {eve$$k_in_init_file} := FALSE; eve$x_executing_file := FALSE; eve$$restore_position (saved_window, saved_mark); eve$learn_abort; abort; [TPU$_PARSEFAIL]: if eve$$x_state_array {eve$$k_in_init_file} then if not ((file_name = "") or (file_name = '""')) then ! keep silent if /INIT and no file name, or /INIT="" eve$message (EVE$_DONUNDERCMDINIT, 0, file_name); endif; else eve$message (EVE$_DONTUNDERFILE, 0, file_name); eve$learn_abort; endif; eve$$x_state_array {eve$$k_in_init_file} := FALSE; eve$x_executing_file := FALSE; eve$$restore_position (saved_window, saved_mark); return (FALSE); [TPU$_SEARCHFAIL]: if eve$$x_state_array {eve$$k_in_init_file} then ! allow null device if index (file_parse (file_name, ini_string, "", DEVICE), null_device) <> 0 then eve$$x_state_array {eve$$k_in_init_file} := FALSE; eve$x_executing_file := FALSE; eve$$restore_position (saved_window, saved_mark); return (TRUE); else ! do file_search again, but force all error messages this time eve$$file_search (file_parse (file_name, ini_string, default_string)); endif; else ! do file_search again, but force all error messages this time eve$$file_search (file_parse (file_name, default_string)); eve$learn_abort; endif; eve$$x_state_array {eve$$k_in_init_file} := FALSE; eve$x_executing_file := FALSE; eve$$restore_position (saved_window, saved_mark); return (FALSE); [OTHERWISE]: eve$$x_state_array {eve$$k_in_init_file} := FALSE; eve$x_executing_file := FALSE; eve$$restore_position (saved_window, saved_mark); endon_error; ! Prevent nested @'s if eve$x_executing_file then eve$message (EVE$_CANTNESTEXECFIL); eve$learn_abort; return (FALSE); endif; if not eve$declare_intention (eve$k_action_commands) then return (FALSE); endif; eve$x_executing_file := TRUE; position (TEXT); saved_mark := mark (FREE_CURSOR); saved_window := current_window; ! Protect against earlier file_search with same file name. eve$reset_file_search; erase (eve$choice_buffer); if eve$x_ultrix_active then disk_string := "./"; ! Ultrix file strings type_string := ".eve"; ini_string := "eve_init.eve"; null_device := "/dev/null"; login_string := "~/"; else disk_string := "SYS$DISK:.EVE"; ! VMS file strings ini_string := "EVE$INIT"; null_device := "NL"; login_string := "SYS$LOGIN:.EVE"; endif; if eve$$x_state_array {eve$$k_in_init_file} then ! Don't use eve$message here because eve$message doesn't output ! info/success messages during /INIT file processing. ! Get init file name from the DCL command line. ! Assume get_info(command_line,'initialization') is true. ! (ambiguity is NOT allowed in /INIT file name) file_name := get_info (COMMAND_LINE, "initialization_file"); if eve$is_wildcard (file_name) then message (EVE$_WILDFILENAME); eve$x_executing_file := FALSE; eve$$restore_position (saved_window, saved_mark); return (FALSE); endif; default_string := disk_string; ! On ULTRIX, look for files in the following order. (Don't apply defaults ! that contain a dir if user's spec has a dir.) ! - user's filespec (user dir or work dir) ! - apply ULTRIX default name+type (user dir or work dir) ! - apply ULTRIX default home dir ! - apply ULTRIX default name+type+home dir if eve$x_ultrix_active then ! Use random directory spec to see if user specified a dir. (ULTRIX ! TPU returns "" for directory if none is specified in file_name.) dir_exists := (file_parse (file_name, "/asdf1/qwer2/", "", DIRECTORY) <> "/asdf1/qwer2/"); count := 0; loop case count [0]: second := ""; third := ""; [1]: second := ini_string; [2]: exitif dir_exists; if file_name <> "" then second := ""; else ! prevent finding home directory file, ! skip last step (same as this one) count := count + 1; endif; third := login_string; [3]: second := ini_string; [4]: exitif; endcase; the_file := file_search (file_name, second, third); exitif the_file <> ""; count := count + 1; endloop; else the_file := file_search (file_name, ini_string, default_string); if the_file = "" then default_string := login_string; the_file := file_search (file_name, ini_string, default_string); endif; endif; if the_file = "" then if file_name <> "" then message (EVE$_NOINITFILMATCH, 0, file_name); endif; eve$x_executing_file := FALSE; eve$$restore_position (saved_window, saved_mark); return (FALSE); else message (EVE$_EXECINITCMDS, 0, the_file); eve$execute_file (the_file); ! make user think we did an "@" command saved_window := current_window; position (end_of (eve$command_buffer)); if file_name = "" then copy_text (eve$x_command_prompt + "@" + ini_string); else copy_text (eve$x_command_prompt + "@" + file_name); endif; position (BUFFER_END); ! so command will be invisible eve$x_executing_file := FALSE; position (saved_window); return (TRUE); endif; else ! Interactive "@" command executed, NO ambiguity allowed in file name. if eve$check_bad_window then eve$message (EVE$_CURSINTEXT); eve$x_executing_file := FALSE; eve$learn_abort; eve$$restore_position (saved_window, saved_mark); return (FALSE); endif; if not (eve$prompt_string (file_parameter, file_name, message_text (EVE$_INITFILEPROMPT, 1), message_text (EVE$_NOFILESPEC, 0))) then eve$x_executing_file := FALSE; eve$learn_abort; eve$$restore_position (saved_window, saved_mark); return (FALSE); endif; if eve$is_wildcard (file_name) then eve$message (EVE$_WILDFILENAME); eve$x_executing_file := FALSE; eve$$restore_position (saved_window, saved_mark); return (FALSE); endif; default_string := disk_string; if eve$x_ultrix_active then ! Use random directory spec to see if user specified a dir. (ULTRIX ! TPU returns "" for directory if none is specified in file_name.) dir_exists := (file_parse (file_name, "/asdf1/qwer2/", "", DIRECTORY) <> "/asdf1/qwer2/"); count := 0; loop case count [0]: second := ""; third := ""; [1]: second := type_string; [2]: exitif dir_exists; second := ""; third := login_string; [3]: second := type_string; [4]: exitif; endcase; the_file := file_search (file_name, second, third); exitif the_file <> ""; count := count + 1; endloop; else the_file := file_search (file_name, default_string); if the_file = "" then default_string := login_string; the_file := file_search (file_name, default_string); endif; endif; if the_file = "" then eve$message (EVE$_NOINITFILMATCH, 0, file_name); eve$x_executing_file := FALSE; eve$$restore_position (saved_window, saved_mark); return (FALSE); else eve$message (EVE$_EXECINITCMDS, 0, the_file); eve$execute_file (the_file); eve$x_executing_file := FALSE; return (TRUE); endif; endif; endprocedure; ! eve__at_file ! EVE$FILE.TPU Page 42 procedure eve$execute_file ! "@" subprocedure (file_name) ! Read file_name into either the eve$x_init_buffer (/INITIALIZATION) buffer ! or the eve$x_at_buffer (interactive @ command) buffer, and execute the ! EVE commands in it. The eve$x_init_buffer buffer is created once. ! The eve$x_at_buffer is deleted and re-created at each "@" command. ! They are all created using the CREATE_BUFFER built-in to prevent the ! buffer being marked modified (until the user modifies the buffer). local saved_success, the_range, the_init_buffer, saved_mark, ! Remember cursor position saved_window; ! Remember current window on_error [TPU$_CONTROLC]: eve$$restore_position (saved_window, saved_mark); set (SUCCESS, saved_success); eve$learn_abort; abort; [OTHERWISE]: eve$$restore_position (saved_window, saved_mark); set (SUCCESS, saved_success); endon_error; saved_mark := mark (FREE_CURSOR); saved_window := current_window; if get_info (SYSTEM, "success") then saved_success := ON; else saved_success := OFF; endif; set (SUCCESS, OFF); if eve$$x_state_array {eve$$k_in_init_file} then ! the /INITIALIZATION buffer must be created if eve$x_buf_str_init_file = tpu$k_unspecified then eve$x_buf_str_init_file := "$INIT$FILE$"; endif; eve$x_init_buffer := create_buffer (eve$x_buf_str_init_file, file_name); ! better be a valid filespec set (SYSTEM, eve$x_init_buffer); set (PERMANENT, eve$x_init_buffer); set (EOB_TEXT, eve$x_init_buffer, message_text (EVE$_EOBINIT, 1)); position (beginning_of (eve$x_init_buffer)); the_init_buffer := eve$x_init_buffer; else if get_info (eve$x_at_buffer, "TYPE") = BUFFER then delete (eve$x_at_buffer); endif; if eve$x_buf_str_at_file = tpu$k_unspecified then eve$x_buf_str_at_file := "@FILE"; endif; eve$x_at_buffer := create_buffer (eve$x_buf_str_at_file, file_name); ! better be a valid filespec set (SYSTEM, eve$x_at_buffer); set (EOB_TEXT, eve$x_at_buffer, message_text (EVE$_EOBTEXT, 1)); position (beginning_of (eve$x_at_buffer)); the_init_buffer := eve$x_at_buffer; endif; set (SUCCESS, saved_success); loop exitif mark (FREE_CURSOR) = end_of (the_init_buffer); eve$$x_current_init_cmd := current_line; the_range := search_quietly (ANCHOR + (span (eve$kt_whitespace) | "") + "!", FORWARD); if (the_range = 0) and (eve$$x_current_init_cmd <> "") then position (saved_window); if not eve$parser_dispatch (eve$$x_current_init_cmd) then position (saved_window); eve$message (EVE$_ATFILEABORT, 0, file_name); return; endif; saved_window := current_window; ! track new buffer positions position (the_init_buffer); endif; move_vertical (1); endloop; position (saved_window); endprocedure; ! eve$execute_file ! EVE$FILE.TPU Page 43 procedure eve$file_declare_synonym ! Declare Synonyms for args ! Declare synonyms for Set Buffer arguments eve$build_synonym ("write",, 2); eve$build_synonym ("nowrite",, 2); eve$build_synonym ("read-only",, 2); eve$build_synonym ("read_only",, 2); eve$build_synonym ("noread-only",, 2); eve$build_synonym ("noread_only",, 2); eve$build_synonym ("modifiable",, 2); eve$build_synonym ("unmodifiable",, 2); eve$build_synonym ("nomodifiable",, 2); endprocedure; ! eve$file_declare_synonyms ! EVE$FILE.TPU Page 44 procedure eve_set_buffer ! Set Buffer (the_argument) local local_argument, ! Local copy of the_argument matched_string, ! Full argument matched the_result, ! Integer ID for the argument saved_mark, ! Current position in buffer the_command; ! "Set Buffer" string or synonym for choices on_error [TPU$_CONTROLC]: eve$$restore_position (saved_mark); eve$learn_abort; abort; [OTHERWISE]: eve$$restore_position (saved_mark); endon_error; local_argument := the_argument; if local_argument = "" then if not eve$prompt_string (the_argument, local_argument, message_text (EVE$_SETBUFPROMPT, 1), message_text (EVE$_NOBUFSETCHNG, 1)) then eve$learn_abort; return (FALSE); endif; endif; edit (local_argument, TRIM); translate (local_argument, "__", " -"); saved_mark := mark (FREE_CURSOR); position (TEXT); ! snap cursor !** How do we get the synonym for this command? the_command := "set buffer "; erase (eve$choice_buffer); if eve$test_synonym ("write", local_argument, 1, matched_string) then the_result := 1; eve$add_choice (matched_string); endif; if eve$test_synonym ("nowrite", local_argument, 1, matched_string) then the_result := 2; eve$add_choice (matched_string); endif; if eve$test_synonym ("read_only", local_argument, 1, matched_string) or eve$test_synonym ("read-only", local_argument, 1, matched_string) then the_result := 3; eve$add_choice (matched_string); endif; if eve$test_synonym ("noread_only", local_argument, 1, matched_string) or eve$test_synonym ("noread-only", local_argument, 1, matched_string) then the_result := 4; eve$add_choice (matched_string); endif; if eve$test_synonym ("modifiable", local_argument, 1, matched_string) then the_result := 5; eve$add_choice (matched_string); endif; if eve$test_synonym ("unmodifiable", local_argument, 1, matched_string) or eve$test_synonym ("nomodifiable", local_argument, 1, matched_string) then the_result := 6; eve$add_choice (matched_string); endif; if get_info (eve$choice_buffer, "record_count") > 1 then ! display choices if eve$$x_state_array {eve$$k_help_active} <> 4 then ! messages enabled if eve$$x_state_array {eve$$k_in_init_file} then eve$$x_state_array {eve$$k_ambiguous_parse} := TRUE; eve$message (EVE$_AMBCMDINIT, 0, eve$$x_current_init_cmd); position (saved_mark); else eve$display_choices (message_text (EVE$_AMBCMD, 0, the_command + local_argument), the_command, local_argument); endif; endif; eve$learn_abort; return (FALSE); endif; case the_result [1, 4]: ! WRITE or NOREAD-ONLY set (NO_WRITE, current_buffer, OFF); set (MODIFIABLE, current_buffer, ON); eve$message (EVE$_BUFWRITENABLED, 0, get_info (current_buffer, "name")); eve$update_status_lines; [2, 3]: ! NOWRITE or READ-ONLY set (NO_WRITE, current_buffer, ON); set (MODIFIABLE, current_buffer, OFF); eve$message (EVE$_BUFWRITELOCKED, 0, get_info (current_buffer, "name")); eve$update_status_lines; [5]: ! MODIFIABLE set (MODIFIABLE, current_buffer, ON); eve$message (EVE$_BUFMODIFIABLE, 0, get_info (current_buffer, "name")); eve$update_status_lines; [6]: ! UNMODIFIABLE set (MODIFIABLE, current_buffer, OFF); eve$message (EVE$_BUFUNMODIFIABLE, 0, get_info (current_buffer, "name")); eve$update_status_lines; [OTHERWISE]: eve$message (EVE$_BADSETBUFFUNC, 0, the_argument); eve$learn_abort; return (FALSE); endcase; return (TRUE); endprocedure; ! eve_set_buffer ! EVE$FILE.TPU Page 45 ! EVE$FILE.TPU Page 46 procedure eve_previous_buffer ! Previous user buffer return (eve$$previous_buffer); endprocedure; ! eve_previous_buffer procedure eve$$previous_buffer ! Previous buffer subprocedure local the_current_buffer, the_previous_buffer; ! Point to the current buffer in the buffer list, then switch to the first ! non-system buffer before that. If we get to the first buffer in the ! list, circle around to the last one. Quit if we get back to our starting ! point. the_current_buffer := get_info (BUFFERS, "current"); loop the_previous_buffer := get_info (BUFFERS, "previous"); if the_previous_buffer = 0 then the_previous_buffer := get_info (BUFFERS, "last"); endif; if the_previous_buffer = the_current_buffer then eve$message (EVE$_NOOTHERBUFFERS); return (FALSE); endif; if not get_info (the_previous_buffer, "system") then return (eve_buffer (get_info (the_previous_buffer, "name"))); endif; endloop; endprocedure; ! eve$$previous_buffer procedure eve_next_buffer ! Next user buffer return (eve$$next_buffer); endprocedure; ! eve_next_buffer procedure eve$$next_buffer ! Buffer indicator = Next buffer local the_current_buffer, the_next_buffer; ! Point to the current buffer in the buffer list, then switch to the first ! non-system buffer after that. If we get to the last buffer in the list, ! circle around to the first one. Quit if we get back to our starting ! point. the_current_buffer := get_info (BUFFERS, "current"); loop the_next_buffer := get_info (BUFFERS, "next"); if the_next_buffer = 0 then the_next_buffer := get_info (BUFFERS, "first"); endif; if the_next_buffer = the_current_buffer then eve$message (EVE$_NOOTHERBUFFERS); return (FALSE); endif; if not get_info (the_next_buffer, "system") then return (eve_buffer (get_info (the_next_buffer, "name"))); endif; endloop; endprocedure; ! eve$$next_buffer ! EVE$FILE.TPU Page 47 procedure eve_quit ! Quit the editor ! Quit Eve. If any buffers are modified, asks if you really want to ! quit. If you do quit, none of the buffers are written out before ! leaving Eve. eve$quit_dispatch; endprocedure; ! eve_quit ! EVE$FILE.TPU Page 48 procedure eve$quit_dispatch ! Dispatch to quit handlers eve$quit; endprocedure; ! eve$quit_dispatch ! EVE$FILE.TPU Page 49 procedure eve$quit ! Actual EVE quit (; answer) local modified_buffers, ! Modified buffers exist saved_success, ! Save current SUCCESS setting the_prompt, ! Prompt string the_answer, ! Optional reply in lieu of prompting the_buffer; ! Buffer to be checked if modified on_error [TPU$_CONTROLC]: if saved_success then set (SUCCESS, ON); ! its currently OFF endif; eve$learn_abort; abort; [OTHERWISE]: if saved_success then set (SUCCESS, ON); ! its currently OFF endif; endon_error; if NOT (get_info (COMMAND_LINE, "display")) then quit (off); endif; eve$clear_message; saved_success := get_info (SYSTEM, "success"); set (SUCCESS, OFF); the_buffer := get_info (BUFFERS, "first"); modified_buffers := FALSE; loop exitif the_buffer = 0; if get_info (the_buffer, "modified") and not get_info (the_buffer, "no_write") then modified_buffers := TRUE; else the_buffer := get_info (BUFFERS, "next"); endif; exitif modified_buffers; endloop; if answer <> tpu$k_unspecified then the_answer := answer; edit (the_answer, TRIM, LOWER); if the_answer = substr (eve$x_yes, 1, length (answer)) then the_answer := eve$x_yes; else the_answer := eve$x_no; endif; endif; if (modified_buffers) and (the_answer <> eve$x_yes) then if (eve$$x_state_array {eve$$k_command_line_flag} = eve$k_invoked_by_menu) and (eve$$x_state_array {eve$$k_dialog_box}) then ! supersede the program bound to "yes" button in reallyquit caution box ! (can call this procedure directly cause no data expected from widget) %if eve$x_option_decwindows %then if eve$x_decwindows_active then eve$manage_widget (eve$x_reallyquit_dialog, "REALLYQUIT_DIALOG"); endif; %endif if saved_success then set (SUCCESS, ON); ! it's currently OFF endif; return (eve$k_async_prompting); else the_prompt := message_text (EVE$_REALLYQUIT, 1); if not eve$insist_y_n (the_prompt) then if saved_success then set (SUCCESS, ON); ! it's currently OFF endif; return (TRUE); endif; endif; quit (OFF, 1); ! quit else if (eve$$x_state_array {eve$$k_command_line_flag} = eve$k_invoked_by_menu) and (eve$$x_state_array {eve$$k_dialog_box}) then quit (OFF, 1); else quit (ON, 1); endif; endif; if saved_success then set (SUCCESS, ON); ! its currently OFF endif; endprocedure; ! eve$quit ! EVE$FILE.TPU Page 50 procedure eve_recover_buffer_all ! Recover all journaled buffers ! Recover all buffers from the journal files held in TPU$JOURNAL. ! Display info about each journal file in the show window ! for confirmation before recovering the associated buffer. local input_file, ! Filename to look for file_search_result, ! Latest string returned by file_search recovered_buffer, ! Last buffer recovered saved_mark, saved_window, status; on_error [TPU$_CONTROLC]: eve$unmap_help; eve$$restore_position (saved_window, saved_mark); eve$learn_abort; abort; [OTHERWISE]: eve$unmap_help; eve$$restore_position (saved_window, saved_mark); endon_error; saved_mark := mark (FREE_CURSOR); saved_window := current_window; eve$message (EVE$_RECOVERALL); ! Protect against earlier file_search with same file name. eve$reset_file_search; erase (eve$choice_buffer); if eve$x_ultrix_active then input_file := eve$x_buf_str_journal + "*.tpu_journal"; else input_file := eve$x_buf_str_journal + "*.TPU$JOURNAL"; endif; status := TRUE; ! loop thru all journal files loop eve$map_help (tpu$x_show_buffer); file_search_result := eve$$file_search (input_file); if file_search_result = 0 then status := FALSE; exitif; endif; exitif file_search_result = ""; status := eve$recover (file_search_result, TRUE); ! allow quiting the loop exitif not status; ! error or quit if status = TRUE then ! recovered a buffer recovered_buffer := current_buffer; ! remember last buffer recov'd endif; endloop; eve$unmap_if_mapped (tpu$x_show_window); ! leave the user in the (last) recovered buffer if recovered_buffer <> 0 then ! if existing buffer was deleted before recovery, and it was the only ! mapped buffer, then put it into the main window, else position to ! saved window if not eve$check_bad_window then eve$$restore_position (saved_window); endif; if current_buffer <> recovered_buffer then eve_buffer (get_info (recovered_buffer, "name")); endif; else ! nothing recovered eve$$restore_position (saved_window, saved_mark); eve$learn_abort; endif; return (status); endprocedure; ! eve_recover_buffer_all ! EVE$FILE.TPU Page 51 procedure eve_recover ! Synonym for RECOVER BUFFER (journal_file_parameter) ! file name (or buffer name) to recover from return (eve_recover_buffer (journal_file_parameter)); endprocedure; ! eve_recover procedure eve_recover_buffer ! Recover journaled buffer (journal_file_parameter) ! file name to recover from ! Recover a buffer from the journal files held in TPU$JOURNAL. Abort ! if no file name is specified. If ambiguous file name, display them ! in choices buffer. Display info about each journal file in the show window ! for confirmation before recovering the associated buffer. ! The command RECOVER BUFFER ALL requires quotes around buffer names ! "A", "AL", and "ALL". local saved_mark, ! Initial position information saved_window, status, ! Return status code journal_file, ! Argument given to this command default_devdir, ! Default journal file device/directory default_type, ! Default journal file type jrnl_file_w_dflts, ! Input argument with journal file defaults applied file_count, ! Number of files located using supplied specification recovered_buffer, ! Buffer that was recovered not_a_journal, the_journal_file, buffer_ptr; ! Pointer to buffer possibly named in the argument on_error [TPU$_CONTROLC]: eve$unmap_if_mapped (tpu$x_show_window); eve$$restore_position (saved_window, saved_mark); eve$learn_abort; abort; [TPU$_NOTJOURNAL, ! For VMS. TPU$_JOURNALEOF, ! These 2 are for Ultrix RMS - it fails TPU$_READERR]: ! different from VMS if not a journal file. not_a_journal := TRUE; [TPU$_PARSEFAIL]: ! let non-RMS friendly buffer names be converted to journal names [TPU$_OPENIN]: ! if no file exists or is locked [OTHERWISE]: eve$unmap_if_mapped (tpu$x_show_window); eve$$restore_position (saved_window, saved_mark); endon_error; status := TRUE; ! Record initial position in case an error is encountered. ! saved_mark := mark (FREE_CURSOR); saved_window := current_window; ! Clear the message buffer. ! eve$clear_message; ! Get argument for the command. ! if not (eve$prompt_string (journal_file_parameter, journal_file, message_text (EVE$_RECOVFILEPROMPT, 1), message_text (EVE$_NOFILESPEC, 1))) then eve$learn_abort; return (FALSE); endif; eve$cleanse_string (journal_file); ! Assume that we were given a file spec as the argument to this command. ! Apply the defaults and see if we can locate any files using this name. ! default_devdir := eve$x_buf_str_journal; if eve$x_ultrix_active then default_type := ".tpu_journal" else default_type := ".TPU$JOURNAL" endif; ! Don't add default type to journal_file since it maybe a complete filespec jrnl_file_w_dflts := file_parse (journal_file, default_devdir + default_type); eve$reset_file_search; erase (eve$choice_buffer); the_journal_file := eve$$file_search_loop (jrnl_file_w_dflts, file_count, TRUE); ! If we found a file, see if it is a journal file if file_count = 1 then ! Ignore open failures if locked or non-existent - let ! eve$recover handle locked journal by trying next lower version on VMS status := get_info (the_journal_file, "journal"); if not_a_journal then ! pretend no matching file if not a journal file file_count := 0; endif; endif; ! Choose how to recover based on the number of matches which were found. ! if file_count > 1 then eve$display_choices (message_text (EVE$_AMBFILE, 0, journal_file_parameter), "recover buffer ", jrnl_file_w_dflts); status := FALSE; else if file_count = 0 then ! No files found using this name, or it wasn't a journal file. ! Treat the command line argument as a buffer name. ! eve$message (EVE$_CONVTOJOURNAME, 0, journal_file); buffer_ptr := get_info (BUFFER, "find_buffer", journal_file); if get_info (buffer_ptr, "type") = BUFFER then ! The input argument matched a buffer name. If the buffer ! is journaling, use that spec. Otherwise, construct a journal ! file spec based on the buffer name. ! if get_info (buffer_ptr, "journaling") then the_journal_file := get_info (buffer_ptr, "journal_file"); file_count := 1; else ! We cannot locate more than one journal file here as ! TPU-generated journal file names will not have wildcard ! characters in them. File name characters other than ! A-Z, a-z, 0-9 and $ will be coerced to "_" characters. ! ! Prevent logical name collision by adding default type to ! converted buffer name. jrnl_file_w_dflts := file_parse (get_info (buffer_ptr, "journal_name") + default_type, default_devdir); eve$reset_file_search; the_journal_file := eve$$file_search_loop (jrnl_file_w_dflts, file_count, TRUE); endif; else ! The input parameter may correspond to a buffer name that is not ! in the editor. Convert the name to a journal file specification, ! apply the journal file defaults and attempt to locate the journal ! file. ! ! Prevent logical name collision by adding default type to ! converted buffer name. jrnl_file_w_dflts := file_parse (get_info (journal_file, "journal_name") + default_type, default_devdir); eve$reset_file_search; the_journal_file := eve$$file_search_loop (jrnl_file_w_dflts, file_count, TRUE); endif; ! If the file_count was zero, we were completely unsuccessful. ! if file_count = 0 then status := FALSE; endif; endif; endif; ! If we have located a file using the specification that was given to this ! procedure. We'll call EVE$RECOVER with the file specification and allow ! it to determine if a recovery can be performed. ! if file_count = 1 then eve$map_help (tpu$x_show_buffer); status := eve$recover (the_journal_file); if status = TRUE then recovered_buffer := current_buffer endif; eve$unmap_if_mapped (tpu$x_show_window); ! Establish the correct cursor position based on whether a ! recovery operation took place. ! if get_info (recovered_buffer, "type") = BUFFER then eve$$restore_position (saved_window); eve$check_bad_window; if current_buffer <> recovered_buffer then eve_buffer (get_info (recovered_buffer, "name")) endif else if get_info (saved_mark, "type") = MARKER then eve$$restore_position (saved_window, saved_mark); else ! oops - original buffer was deleted, restore something useful eve$check_bad_window; endif; endif; else if file_count = 0 then eve$message (EVE$_NOFILMATCH, 0, journal_file) endif; eve$$restore_position (saved_window, saved_mark); endif; if not status then eve$learn_abort; endif; return status; endprocedure; ! eve_recover_buffer ! EVE$FILE.TPU Page 52 procedure eve$recover ! Recover Buffer subprocedure (the_file; ! file to recover from all_flag) ! boolean, true if looping thru all journal files ! (allow reply=quit (besides yes/no), and don't ! return false if can't open journal file) ! Recover from the specified journal file. Display info about the ! journaled buffer, and ask user to verify before doing the recovery. ! All_flag = TRUE adds "quit" to the confirm prompt (we're looping thru ! all journal files). Returns (1) true if a buffer was recovered, ! (2) eve$k_informational if user replies "no" (to allow looping thru more ! files) or if journal file is locked and all_flag=1, (3) false ! if user replies "quit" and all_flag=1 or other errors. local file_info, ! journal file info array temp_buffer, ! recovered buffer old_buffer, ! from journal info new_buffer, ! for replacing deleted buffer the_version, map_count, local_file, max_length, ! fao parameter local_all_flag, saved_mark, the_prompt, recover_error, do_message, ! false if eve$$fix_recovery already output message default_exists, reply; on_error [TPU$_CONTROLC]: eve$$restore_position (saved_mark); if get_info (file_info, "type") = ARRAY then eve$message (EVE$_BUFNOTRECOVERED, 0, file_info {1}); endif; if local_all_flag then ! ^C = "no" = continue RECOVER BUFFER ALL loop ("quit" exits loop) return (eve$k_informational); endif; return (FALSE); [TPU$_JRNLNOTSAFE]: ! Journal file was corrupted. Buffer is recovered (and modified), ! but journaling is off. Write it out, set journaling on. recover_error := TRUE; ! continue with recovery [TPU$_RECOVERQUIT]: ! Cancel button or "" for new source file name if local_all_flag ! from DECwindows widget (original not found), then ! don't recover this buffer. ! Cancel or "" = continue RECOVER BUFFER ALL loop return (eve$k_informational); endif; return (FALSE); [OTHERWISE]: eve$$restore_position (saved_mark); endon_error; do_message := TRUE; saved_mark := mark (FREE_CURSOR); local_file := the_file; the_prompt := message_text (EVE$_RECOVBUFPROMPT, 1); if all_flag = TRUE then local_all_flag := TRUE; the_prompt := message_text (EVE$_RECOVQUITPROMPT, 1); endif; eve$map_if_not_mapped (tpu$x_show_window, tpu$x_show_buffer); set (STATUS_LINE, tpu$x_show_window, REVERSE, message_text (EVE$_PATSTATSMALL, 1)); ! get info about this journal file file_info := eve$$get_info_journal (local_file); if file_info = 0 then ! Don't break RECOVER BUFFER ALL file_search context if local_all_flag then return (eve$k_informational); endif; ! Specified version is (VMS) locked or non-existent. Try next lower version. if eve$x_ultrix_active then return (FALSE); ! no lower version on Ultrix endif; file_info := file_parse (local_file, eve$x_buf_str_journal + ".TPU$JOURNAL", "", HEAD, NAME, TYPE); the_version := file_parse (local_file, "", "", VERSION); ! ";nn" the_version := substr (the_version, 2); if length (the_version) > 0 then ! a version number was specified local_file := eve$$file_search (file_info + ";" + str (int (the_version) - 1)); else ! top version, do -1 local_file := eve$$file_search (file_info + ";-1"); endif; if (local_file = "") or (local_file = 0) then ! no lower version exists return (FALSE); else ! not much room, so tell only file name reply := eve$insist_y_n (message_text (EVE$_RECOVLOWVERSION, tpu$k_message_text, file_parse (local_file, "", "", NAME))); if not reply then return (FALSE); endif; file_info := eve$$get_info_journal (local_file); if file_info = 0 then ! no lower version exists return (FALSE); endif; endif; endif; ! display this file's info in the show window erase (tpu$x_show_buffer); position (end_of (tpu$x_show_buffer)); set (INSERT, tpu$x_show_buffer); ! just in case... max_length := length (message_text (EVE$_RECOVEDITTIME, 1)); split_line; copy_text (message_text (EVE$_RECOVERENTRY, 1, max_length, message_text (EVE$_BUFNAM, 1), file_info {1})); split_line; copy_text (message_text (EVE$_RECOVERENTRY, 1, max_length, message_text (EVE$_RECOVINPUTFILE, 1), file_info {6})); split_line; copy_text (message_text (EVE$_RECOVERENTRY, 1, max_length + 1, ! +1 = adjust for space message_text (EVE$_SHOW_OUTPUTFILE, 1, ""), file_info {5})); position (LINE_BEGIN); erase_character (1); ! erase EVE$_SHOW_OUTPUTFILE leading space position (LINE_END); split_line; copy_text (message_text (EVE$_RECOVERENTRY, 1, max_length, message_text (EVE$_RECOVSRCFILE, 1), file_info {4})); split_line; split_line; copy_text (message_text (EVE$_RECOVERENTRY, 1, max_length, message_text (EVE$_RECOVEDITTIME, 1), file_info {3})); split_line; split_line; copy_text (message_text (EVE$_RECOVERENTRY, 1, max_length, message_text (EVE$_RECOVJRNLTIME, 1), file_info {2})); split_line; split_line; update (tpu$x_show_window); ! ask user if this one should be recovered loop reply := eve$prompt_line (the_prompt, eve$$x_prompt_terminators); if reply = 0 then ! aborted return (FALSE); endif; edit (reply, LOWER, TRIM); ! like REPLACE, Exit = Quit (or no if quit not allowed) if eve$test_synonym ("exit", eve$$lookup_comment (last_key, eve$x_key_map_list)) then if local_all_flag then reply := eve$x_quit; else reply := eve$x_no; endif; endif; if reply = "" then ! = yes reply := eve$x_yes; endif; if local_all_flag and (reply = substr (eve$x_quit, 1, length (reply))) then return (FALSE); endif; exitif (reply = substr (eve$x_yes, 1, length (reply))) or (reply = substr (eve$x_no, 1, length (reply))); endloop; ! either YES or NO at this point if reply = substr (eve$x_yes, 1, length (reply)) then ! Delete the buffer if it already exists (ask for confirmation if ! it is also modified). old_buffer := get_info (BUFFER, "find_buffer", file_info {1}); if old_buffer <> 0 then ! On Ultrix, there are no lower versions of the ! journal file, so just abort the recovery. if eve$x_ultrix_active then if get_info (old_buffer, "journal_file") = local_file then eve$message (EVE$_RECOVERBUFBUSY); return (FALSE); endif; endif; if get_info (old_buffer, "modified") then reply := eve$insist_y_n (message_text (EVE$_DELMODBUFFER, tpu$k_message_text, file_info {1})); if not reply then if local_all_flag then return (eve$k_informational); else eve$message (EVE$_RECOVERYABORT); return (FALSE); endif; endif; endif; ! If old_buffer (same name as buffer to recover) is mapped, ! then fix its window mapping before deleting it: ! 1. If it's the only buffer mapped, then insure it's mapped only once. ! 2. If another user buffer exists, and old_buffer is not the ! only buffer mapped, then remap every occurrence to other buffer. ! These steps prevent leaving empty window slots, and also prevent ! EVE$REMAP_WINDOWS from remapping EVERY window which would cause ! TPU$_WINDNOTVIS when it tries to position back to the now occluded ! Show window (mapped to the entire screen). map_count := get_info (old_buffer, "map_count"); if (map_count > 0) then if (eve$x_number_of_windows = map_count) and (eve$x_number_of_windows > 1) then ! force one window eve$unmap_if_mapped (tpu$x_show_window); eve_one_window; eve$map_help (tpu$x_show_buffer); endif; new_buffer := get_info (BUFFERS, "first"); loop exitif new_buffer = 0; exitif (not get_info (new_buffer, "system")) and (new_buffer <> old_buffer); new_buffer := get_info (BUFFERS, "next"); endloop; if (new_buffer <> 0) and (get_info (old_buffer, "map_count") <> eve$x_number_of_windows) then ! remap all windows mapped to new_buffer eve$remap_windows (old_buffer, new_buffer); endif; endif; delete (old_buffer); ! and its journal file endif; ! recover this buffer if get_info (eve$default_buffer, "type") <> BUFFER then ! i.e., no default buffer during startup temp_buffer := recover_buffer (file_info {1}, local_file); else temp_buffer := recover_buffer (file_info {1}, local_file, eve$default_buffer); default_exists := TRUE; endif; if recover_error then ! Journaling is off. Write out modified buffer and set journaling on. temp_buffer := get_info (BUFFER, "find_buffer", file_info {1}); if temp_buffer = 0 then position (saved_mark); eve$message (EVE$_BUFNOTRECOVERED, 0, file_info {1}); return (FALSE); endif; eve$message (EVE$_BUFNOTSAFE, 1, get_info (temp_buffer, "name")); if eve$$fix_recovery (temp_buffer) then do_message := FALSE; endif; endif; if default_exists then !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! Synchronize this code with that in EVE$CREATE_BUFFER !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! set (MODIFIABLE, temp_buffer, ON); ! override default buf settings set (NO_WRITE, temp_buffer, OFF); ! override default buf settings if eve$$x_word_wrap_indent {eve$default_buffer} <> tpu$k_unspecified then eve$$x_word_wrap_indent {temp_buffer} := eve$$x_word_wrap_indent {eve$default_buffer}; endif; if eve$$x_paragraph_indent {eve$default_buffer} <> tpu$k_unspecified then eve$$x_paragraph_indent {temp_buffer} := eve$$x_paragraph_indent {eve$default_buffer}; endif; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! End of synchronization. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! endif; ! position to the recovered buffer if get_info (temp_buffer, "output_file") = 0 then ! eve$$fix_recovery may have written file and set the output file set (OUTPUT_FILE, temp_buffer, get_info (temp_buffer, "file_name")); endif; position (temp_buffer); if do_message then eve$message (EVE$_BUFRECOVERED, 0, file_info {1}); endif; return (TRUE); else position (saved_mark); eve$message (EVE$_BUFNOTRECOVERED, 0, file_info {1}); return (eve$k_informational); endif; endprocedure; ! eve$recover ! EVE$FILE.TPU Page 53 procedure eve_set_journaling_all ! Start journaling all buffers ! Turn buffer change journaling on for all user buffers, and for the ! default buffer. Continues thru buffers if any buffer fails by being ! not safe for journaling. local count, error_flag, loop_buffer; on_error [TPU$_CONTROLC]: eve$learn_abort; abort; [TPU$_JRNLNOTSAFE]: eve$message (EVE$_BUFNOTSAFE, 1, get_info (loop_buffer, "name")); error_flag := TRUE; count := count - 1; [OTHERWISE]: endon_error; loop_buffer := get_info (BUFFERS, "first"); loop exitif loop_buffer = 0; if get_info (loop_buffer, "system") = 0 then ! only user buffers if not get_info (loop_buffer, "journaling") then set (JOURNALING, loop_buffer, ON); count := count + 1; if error_flag then if not eve$insist_y_n (message_text (EVE$_SETJRNLERROR, 1, get_info (loop_buffer, "name")), "") then exitif; endif; error_flag := FALSE; endif; endif; endif; loop_buffer := get_info (BUFFERS, "next"); endloop; if get_info (eve$default_buffer, "type") = BUFFER then ! i.e., default buffer exists, not during startup if not get_info (eve$default_buffer, "journaling") then if eve$x_ultrix_active then set (JOURNALING, eve$default_buffer, ON, "/dev/null"); else set (JOURNALING, eve$default_buffer, ON, "NL:"); endif; endif; endif; eve$$x_buffer_change_journaling := TRUE; if count > 0 then eve$message (EVE$_JOURNALINGON); else if not error_flag then eve$message (EVE$_NOJOURNALINGON); endif; endif; return (TRUE); endprocedure; ! eve_set_journaling_all ! EVE$FILE.TPU Page 54 procedure eve_set_journaling ! Start journaling a buffer (buffer_parameter) ! buffer to journal ! Turn buffer change journaling on for a user buffer. ! The command SET JOURNALING ALL requires quotes around buffer names ! "A", "AL", and "ALL". local buffer_name, the_buffer; on_error [TPU$_CONTROLC]: eve$learn_abort; abort; [OTHERWISE]: endon_error; if eve$check_bad_window then eve$message (EVE$_CURSINTEXT); eve$learn_abort; return (FALSE); endif; if not (eve$prompt_string (buffer_parameter, buffer_name, message_text (EVE$_JRNLONPROMPT, 1), message_text (EVE$_NOBUFNAME, 1))) then eve$learn_abort; return (FALSE); endif; eve$cleanse_string (buffer_name); !** How do we get the synonym for the key that was defined to this command? the_buffer := eve$find_buffer (buffer_name, "set journaling"); if the_buffer <> 0 then if get_info (the_buffer, "system") then eve$message (EVE$_NOJOURNALSYSBUF); return (FALSE); else return (eve$set_journaling (the_buffer)); endif; endif; return (FALSE); endprocedure; ! eve_set_journaling procedure eve$set_journaling ! Set journaling subprocedure (the_buffer) ! buffer to journal on_error [TPU$_JRNLNOTSAFE]: eve$message (EVE$_BUFNOTSAFE, 1, get_info (the_buffer, "name")); return (FALSE); [OTHERWISE]: endon_error; set (JOURNALING, the_buffer, ON); eve$message (EVE$_BUFJOURNALON, 0, get_info (the_buffer, "name")); return (TRUE); endprocedure; ! eve$set_journaling ! EVE$FILE.TPU Page 55 procedure eve_set_nojournaling_all ! Stop journaling all buffers ! Turn buffer change journaling off for all user buffers, and for the ! default buffer. local loop_buffer; on_error [TPU$_CONTROLC]: eve$learn_abort; abort; [OTHERWISE]: endon_error; loop_buffer := get_info (BUFFERS, "first"); loop exitif loop_buffer = 0; if get_info (loop_buffer, "system") = 0 then ! only user buffers set (JOURNALING, loop_buffer, OFF); endif; loop_buffer := get_info (BUFFERS, "next"); endloop; if get_info (eve$default_buffer, "type") = BUFFER then ! i.e., default buffer exists, not during startup set (JOURNALING, eve$default_buffer, OFF); endif; eve$$x_buffer_change_journaling := FALSE; eve$message (EVE$_JOURNALINGOFF); return (TRUE); endprocedure; ! eve_set_nojournaling_all ! EVE$FILE.TPU Page 56 procedure eve_set_nojournaling ! Stop journaling a buffer (buffer_parameter) ! buffer to not journal local buffer_name, the_buffer; on_error [TPU$_CONTROLC]: eve$learn_abort; abort; [OTHERWISE]: endon_error; if eve$check_bad_window then eve$message (EVE$_CURSINTEXT); eve$learn_abort; return (FALSE); endif; if not (eve$prompt_string (buffer_parameter, buffer_name, message_text (EVE$_JRNLOFFPROMPT, 1), message_text (EVE$_NOBUFNAME, 1))) then eve$learn_abort; return (FALSE); endif; eve$cleanse_string (buffer_name); !** How do we get the synonym for the key that was defined to this command? the_buffer := eve$find_buffer (buffer_name, "set nojournaling"); if the_buffer <> 0 then if get_info (the_buffer, "system") then eve$message (EVE$_NOJOURNALSYSBUF); return (FALSE); else ! setting off only closes the journal file, doesn't delete it set (JOURNALING, the_buffer, OFF); eve$message (EVE$_BUFJOURNALOFF, 0, get_info (the_buffer, "name")); return (TRUE); endif; endif; return (FALSE); endprocedure; ! eve_set_nojournaling ! EVE$FILE.TPU Page 57 procedure eve$find_buffer ! Find buffer with specified name (buffer_name; ! buffer name string command_name) ! command for ambiguous choices cmd prompt ! Find buffer with name equal to, or a substring of, buffer_name. ! If multiple buffers exist and optional command_name arg is provided, ! then display them in the choices buffer. ! ! Returns a buffer, or returns zero and outputs a message if none or multiple. local loop_buffer, ! Current buffer being checked in loop loop_buffer_name, ! String containing name of loop_buffer the_buffer, ! Copy of buffer_name the_command, ! Copy of command_name possible_buffer_name, ! Most recent string entered in choice buffer possible_buffer; ! Buffer whose name is possible_buffer_name on_error [TPU$_CONTROLC]: eve$learn_abort; abort; [OTHERWISE]: endon_error; the_buffer := buffer_name; edit (the_buffer, COMPRESS, TRIM); ! See if we have a buffer by the given name loop_buffer := get_info (BUFFER, "find_buffer", the_buffer); if get_info (loop_buffer, "type") = BUFFER then return (loop_buffer); ! exact match endif; ! no exact match, find unique substring or multiple, ambiguous substrings if not eve$x_ultrix_active then change_case (the_buffer, UPPER); ! buffer names are uppercase on VMS endif; erase (eve$choice_buffer); loop_buffer := get_info (BUFFERS, "first"); loop exitif loop_buffer = 0; loop_buffer_name := get_info (loop_buffer, "name"); if the_buffer = substr (loop_buffer_name, 1, length (the_buffer)) then ! substring of buffer name eve$add_choice (loop_buffer_name); possible_buffer := loop_buffer; possible_buffer_name := loop_buffer_name; endif; loop_buffer := get_info (BUFFERS, "next"); endloop; ! how many did we find if get_info (eve$choice_buffer, "record_count") > 0 then if get_info (eve$choice_buffer, "record_count") = 1 then loop_buffer := possible_buffer; else if (command_name <> tpu$k_unspecified) then the_command := command_name; edit (the_command, COMPRESS, TRIM); the_command := the_command + " "; if not eve$x_ultrix_active then ! buffer names are uppercase on VMS change_case (the_buffer, LOWER); endif; eve$display_choices (message_text (EVE$_AMBBUF, 0, the_buffer), the_command, the_buffer); eve$learn_abort; return (FALSE); endif; endif; endif; if loop_buffer = 0 then eve$message (EVE$_NOBUFMATCH, 0, buffer_name); endif; return (loop_buffer); endprocedure; ! eve$find_buffer ! EVE$FILE.TPU Page 58 procedure eve$$get_info_journal ! Perform a GET_INFO(STRING,"JOURNAL") (the_file_name) ! file to get journal info about ! Do a GET_INFO(STRING,"JOURNAL") allowing all RMS error messages to be output. on_error [OTHERWISE]: ! return zero if fails endon_error; return get_info (the_file_name, "journal"); ! return 0 if not journal file endprocedure; ! eve$$get_info_journal ! EVE$FILE.TPU Page 59 procedure eve$$fix_recovery ! Bad recovery: write buffer, start journaling (the_buffer) ! buffer whose recovery ! The buffer-change journal file was corrupted. Buffer is recovered ! (and modified), but journaling is off. Ask user to write it out, and ! if so, turn journaling back on. local status, saved_flag; on_error [TPU$_CONTROLC]: eve$$x_state_array {eve$$k_command_line_flag} := saved_flag; eve$learn_abort; abort; [OTHERWISE]: eve$$x_state_array {eve$$k_command_line_flag} := saved_flag; endon_error; ! prevent dialog box prompting saved_flag := eve$$x_state_array {eve$$k_command_line_flag}; eve$$x_state_array {eve$$k_command_line_flag} := eve$k_invoked_by_command; status := eve$insist_y_n (message_text (EVE$_WRITEBUF, 1, get_info (the_buffer, "name"))); if status then ! the following also returns true if user gave no filename to not write it status := eve$write_file (the_buffer, "", 0); if status then status := get_info (the_buffer, "output_file") <> 0; if status then ! actually wrote the buffer, turn journaling on status := eve$set_journaling (the_buffer); endif; endif; endif; eve$$x_state_array {eve$$k_command_line_flag} := saved_flag; return (status); endprocedure; ! eve$$fix_recovery ! EVE$FILE.TPU Page 60 procedure eve_set_file_backup ! Backup ULTRIX output files on_error [OTHERWISE]: endon_error; if not eve$x_ultrix_active then eve$message (TPU$_REQUIRESULTRIX); return (TRUE); endif; eve$x_file_backup := TRUE; if eve$x_backup_string = tpu$k_unspecified then eve$x_backup_string := message_text (EVE$_BACKUPFAO, tpu$k_message_text); endif; eve$message (EVE$_BACKUPON); return (eve$define_attr ("eve_set_file_backup", "eve_set_file_backup;", message_text (EVE$_BACKUPON, 0))); endprocedure; ! eve_set_file_backup procedure eve_set_nofile_backup ! Don't backup ULTRIX output files on_error [OTHERWISE]: endon_error; if not eve$x_ultrix_active then eve$message (TPU$_REQUIRESULTRIX); return (TRUE); endif; eve$x_file_backup := FALSE; if get_info (COMMAND_LINE, "journal") then if get_info (COMMAND_LINE, "journal_file") <> "" then ! keystroke journaling was on at start of session eve$message (EVE$_BACKUPOFFWARN); return (TRUE); endif; endif; eve$message (EVE$_BACKUPOFF); return (eve$define_attr ("eve_set_file_backup", "eve_set_nofile_backup;", message_text (EVE$_BACKUPOFF, 0))); endprocedure; ! eve_set_nofile_backup ! EVE$FILE.TPU Page 61 procedure eve_set_backup_control_string ! Set ULTRIX backup control string (string_param) ! format control string ! Sets the FAO format control string EVE uses on ULTRIX to create backup ! copies of existing files before writing buffers or saving a section file. ! The format control string defaults to: "!AS!AS.!SL" local temp, saved_string, control_string; on_error [TPU$_INVFAOPARAM]: eve$message (error_text, error); eve$message (EVE$_INVBACKUPSTR); eve$x_backup_string := saved_string; eve$learn_abort; return (FALSE); [OTHERWISE]: endon_error; if not eve$x_ultrix_active then eve$message (TPU$_REQUIRESULTRIX); return (TRUE); endif; if not (eve$prompt_string (string_param, control_string, message_text (EVE$_BACKUPPROMPT, 1), message_text (EVE$_NOBACKUPSTR, 0))) then eve$learn_abort; return (FALSE); endif; saved_string := eve$x_backup_string; edit (control_string, TRIM); eve$x_backup_string := control_string; if eve$x_backup_string = "" then eve$message (EVE$_NOBACKUPSTR); eve$learn_abort; return (FALSE); endif; ! try it out to flag any errors here, restore original if failure temp := fao (control_string, "a", "b", 1); eve$message (EVE$_BACKUPSET, 0, eve$x_backup_string); return (eve$define_attr ("eve_set_backup_control_string", "eve_set_backup_control_string('" + eve$x_backup_string + "'); ", message_text (EVE$_BACKUPSET, 0, eve$x_backup_string))); endprocedure; ! eve_set_backup_control_string ! EVE$FILE.TPU Page 62 procedure eve$backup_file ! Make backup copy of an existing file (out_buffer, ! Buffer to be written, or 0 if saving a section file new_out_file, ! New file to create (overrides buffer's output_file) version_number, ! Version for backup copy format_ctrl_string;! FAO control string backup_name) ! Output: name of backup file written ! This procedure makes a backup copy of an existing file. Call this procedure ! before actually writing the buffer/section to a file (which on ULTRIX ! clobbers the existing file). If the file does not exist, this procedure ! does nothing. If the backup file already exists, and version numbers are ! being used, this procedure bumps the version number until a new file ! will be created. local saved_success, back_file, ! where we backup out_file, ! where we look for an existing file the_head, ! device+directory the_tail, ! name+type random, ! to see if version numbers are in control string temp; on_error [TPU$_CONTROLC]: eve$$release_scratch_buffer; set (SUCCESS, saved_success); eve$learn_abort; abort; [OTHERWISE]: eve$$release_scratch_buffer; set (SUCCESS, saved_success); endon_error; saved_success := get_info (SYSTEM, "success"); ! for error handler if not eve$x_file_backup then return (TRUE); endif; if get_info (out_buffer, "type") = BUFFER then out_file := get_info (out_buffer, "output_file"); if out_file = 0 then out_file := get_info (out_buffer, "file_name"); ! input file if out_file = "" then ! first write, start the version number at 1 out_file := get_info (out_buffer, "name"); version_number := 1; endif; endif; if (new_out_file <> tpu$k_unspecified) ! may be unspecified then ! user is writing to a different file if new_out_file <> out_file then out_file := new_out_file; version_number := 1; ! restart the version number at 1 endif; endif; else if out_buffer = 0 then ! saving a section file out_file := new_out_file; if out_file <> eve$x_last_section_backup then ! user is saving to a different section file version_number := 1;! restart the version number at 1 endif; else eve$message (EVE$_BADARGUMENT, 0, str (get_info (out_file, "type")), str (BUFFER) + ", " + str (INTEGER)); return (FALSE); ! error endif; endif; eve$reset_file_search; if file_search (out_file) = "" then return (TRUE); ! file doesn't exist, no backup needed endif; if not eve$$reserve_scratch_buffer then eve$message (EVE$_ILLSCRATCHRES); return (FALSE); endif; if (get_info (eve$$x_backup_process, "type") <> PROCESS) then saved_success := set (SUCCESS, OFF); ! silence tpu$_processbeg eve$$x_backup_process := create_process (eve$$x_scratch_buffer); set (SUCCESS, saved_success); endif; the_head := file_parse (out_file, "", "", directory); the_tail := file_parse (out_file, "", "", name, type); back_file := fao (format_ctrl_string, the_head, the_tail, version_number); ! See if version numbers are included in the control string eve$reset_file_search; random := 562139748; ! hope this is random enough temp := fao (format_ctrl_string, "","", random); if index (temp, str (random)) <> 0 then ! Maximize the version number if backup files already exist (actually, ! find the next available filespec that doesn't exist, may not be highest) loop exitif file_search (back_file) = ""; ! no file exists w/this version version_number := version_number + 1; back_file := fao (format_ctrl_string, the_head, the_tail, version_number); endloop; endif; backup_name := back_file; ! return the name version_number := version_number + 1; ! bump the version send (FAO (eve$x_backup_command, out_file, back_file), eve$$x_backup_process); eve$$release_scratch_buffer; return (TRUE); endprocedure; ! eve$backup_file ! EVE$FILE.TPU Page 63 procedure eve_show_file_backup ! Display ULTRIX file backup control string on_error [OTHERWISE]: endon_error; if eve$x_ultrix_active then eve$message (EVE$_SHOWBACKUP, 0, eve$x_backup_string); else eve$message (TPU$_REQUIRESULTRIX); endif; return (TRUE); endprocedure; ! eve_show_file_backup ! EVE$FILE.TPU Page 64 procedure eve$delete_processes ! Delete EVE processes ! Delete all processes associated with system buffer. This lets EVE exit ! without any "subprocess terminated" messages. local a_process, saved_success; on_error [TPU$_CONTROLC]: set (SUCCESS, saved_success); eve$learn_abort; abort; [OTHERWISE]: set (SUCCESS, saved_success); endon_error; saved_success := set (SUCCESS, OFF); a_process := get_info (process, "first"); loop exitif get_info (a_process, "type") <> PROCESS; if get_info (get_info (a_process, "buffer"), "system") then delete (a_process); ! list of processes may be indeterminate a_process := get_info (process, "first"); else a_process := get_info (process, "next"); endif; endloop; set (SUCCESS, saved_success); return (TRUE); endprocedure; ! eve$delete_processes ! EVE$FILE.TPU Page 65 ! Module initialization code local line_editing_mode, ! Line editing mode of terminal logical, parse_error, ! for parsing EVEKEYPAD on ULTRIX the_keypad; on_error [TPU$_NONAMES]: eve$message (EVE$_NOKEYPADMATCH, 0, logical); return; [TPU$_MULTIPLENAMES]: eve$message (EVE$_AMBKEYPAD, 0, logical); return; [TPU$_PARSEFAIL]: parse_error := TRUE; endon_error; eve$$x_ambiguous_input_file := false; ! need to flag ambiguous files for ! processing after initialization if eve$x_get_wild_active = tpu$k_unspecified then ! Don't get more than one file on eve$x_get_wild_active := false; ! a get endif; if eve$x_generate_bufnames = tpu$k_unspecified then ! Prompt for new buffer name(s) if not eve$x_generate_bufnames := false; ! unique during a get endif; eve$x_upcase_bufnam_if_none := 1; ! Look for upcase buffer name if can't ! find case-sensitive match on Ultrix. eve$$x_upcased_buffer_name := 0; eve$$x_current_action_type := 0; eve$$x_current_pre_array := 0; eve$$x_current_post_array := 0; eve$x_file_backup := eve$x_ultrix_active; ! enable backups on ULTRIX eve$$x_backup_process := 0; ! file backup subprocess if eve$x_backup_string = tpu$k_unspecified then eve$x_backup_string := message_text (EVE$_BACKUPFAO, tpu$k_message_text); endif; if eve$x_backup_command = tpu$k_unspecified then eve$x_backup_command := "/bin/cp -p !AS !AS"; ! Ultrix copy command endif; eve$$x_user_main_buf := 0; ! input file = MAIN eve$$x_input_count := 0; ! no. of input files that exist eve$$x_output_count := 0; ! no. of bufs with /output=file applied eve$$x_buffer_change_journaling := FALSE; eve$$x_recover_qualifier := FALSE; eve$x_starting_up := TRUE; ! True during eve$init_procedure eve$x_post_starting_up := FALSE; ! True from end of eve$init_procedure ! until end of eve$init_postprocedure eve$x_read_only := message_text (EVE$_READ_ONLY, 1); eve$x_nowrite := message_text (EVE$_NOWRITE, 1); eve$x_write := message_text (EVE$_WRITE, 1); eve$x_max_buffer_name_length := 43;! Buffer names can be any size, but this is ! the largest size that will be shown on ! the status line without being truncated eve$$x_right_action_program := 0; ! default action routine (no left) eve$arg1_buffer := "string"; ! leave in for V1 compatibility ! (EVE assigned to this variable ! so users probably did too) eve$arg1_set_width := "integer"; eve$arg1_shift_left := "integer"; eve$arg1_shift_right := "integer"; ! If this pattern changes, change procedure eve$trim_buffer also. eve$pattern_trim := span (" " + ascii (9)) + LINE_END; ! Used for trimming buffer ! create the mark array, index = mark name (string), element = marker ! create array of buffer version numbers, ix = buffer, element = version number eve$$x_mark_array := create_array (); eve$$x_buf_ver_array := create_array (); ! Create all the necessary default system buffers ! Command buffer if eve$x_buf_str_commands = tpu$k_unspecified then eve$x_buf_str_commands := "COMMANDS"; endif; eve$command_buffer := eve$init_buffer (eve$x_buf_str_commands, ""); set (KEY_MAP_LIST, eve$x_command_key_map_list, eve$command_buffer); set (REVERSE, eve$command_buffer); ! for VMS V4 line-editing compatibility if (get_info (eve$command_window, "type") = WINDOW) then map (eve$command_window, eve$command_buffer); endif; ! Prompt buffer if eve$x_buf_str_prompts = tpu$k_unspecified then eve$x_buf_str_prompts := "$PROMPTS$"; endif; eve$prompt_buffer := eve$init_buffer (eve$x_buf_str_prompts, ""); set (REVERSE, eve$prompt_buffer); ! for VMS V4 line-editing compatibility line_editing_mode := get_info (SCREEN, "line_editing"); if line_editing_mode <> 0 then set (line_editing_mode, eve$command_buffer); set (line_editing_mode, eve$prompt_buffer); else set (OVERSTRIKE, eve$command_buffer);! for VMS V4 line-editing compatibility set (OVERSTRIKE, eve$prompt_buffer); endif; if (get_info (eve$prompt_window, "type") = WINDOW) then set (VIDEO, eve$prompt_window, REVERSE); endif; ! Message buffer--mapped to the message window ! ! No message buffer if /NODISPLAY mode (TPU writes messages to terminal) if get_info (COMMAND_LINE, "display") then if eve$x_buf_str_messages = tpu$k_unspecified then eve$x_buf_str_messages := "MESSAGES"; endif; tpu$x_message_buffer := eve$init_buffer (eve$x_buf_str_messages, ""); if message_window <> 0 then map (message_window, tpu$x_message_buffer); eve$clear_message; ! remove /COMMAND file-read message endif; ! output to sys$output endif; ! Misc buffers if eve$x_buf_str_show = tpu$k_unspecified then eve$x_buf_str_show := "SHOW"; endif; tpu$x_show_buffer := eve$init_buffer (eve$x_buf_str_show, ""); eve$set_fixed_status_line (tpu$x_show_buffer, compile ("return eve$$show_window_status")); ! Buffer used by parser to display choices when a name is ambiguous if eve$x_buf_str_choices = tpu$k_unspecified then eve$x_buf_str_choices := "$CHOICES$"; endif; eve$choice_buffer := eve$init_buffer (eve$x_buf_str_choices, ""); eve$set_fixed_status_line (eve$choice_buffer, compile ("return eve$$sys_window_status")); ! Buffer used by prompt_line, to get the previous reply if eve$x_buf_str_recall_line = tpu$k_unspecified then eve$x_buf_str_recall_line := "$RECALL$LINE$"; endif; eve$recall_line_buffer := eve$init_buffer (eve$x_buf_str_recall_line, ""); ! Now do the paste buffer if eve$x_buf_str_insert_here = tpu$k_unspecified then eve$x_buf_str_insert_here := "INSERT HERE"; endif; paste_buffer := eve$init_buffer (eve$x_buf_str_insert_here, message_text (EVE$_PASTEEOBTEXT, 1)); ! Restore buffers if eve$x_buf_str_restore = tpu$k_unspecified then eve$x_buf_str_restore := "$RESTORE$"; endif; eve$restore_buffer := eve$init_buffer (eve$x_buf_str_restore, ""); if eve$x_buf_str_restore_char = tpu$k_unspecified then eve$x_buf_str_restore_char := "$RESTORE$CHAR$"; endif; eve$x_char_buffer := eve$init_buffer (eve$x_buf_str_restore_char, ""); if eve$x_buf_str_restore_word = tpu$k_unspecified then eve$x_buf_str_restore_word := "$RESTORE$WORD$"; endif; eve$x_word_buffer := eve$init_buffer (eve$x_buf_str_restore_word, ""); if eve$x_buf_str_restore_line = tpu$k_unspecified then eve$x_buf_str_restore_line := "$RESTORE$LINE$"; endif; eve$x_line_buffer := eve$init_buffer (eve$x_buf_str_restore_line, ""); if eve$x_buf_str_restore_sent = tpu$k_unspecified then eve$x_buf_str_restore_sent := "$RESTORE$SENT$"; endif; eve$x_sentence_buffer := eve$init_buffer (eve$x_buf_str_restore_sent, ""); ! Pending delete's restore selection buffer if eve$x_buf_str_restore_select = tpu$k_unspecified then eve$x_buf_str_restore_select := "$RESTORE$SELECTION$"; endif; eve$x_selection_buffer := eve$init_buffer (eve$x_buf_str_restore_select, ""); ! DCL buffer if eve$x_buf_str_dcl = tpu$k_unspecified then if eve$x_ultrix_active then eve$x_buf_str_dcl := "SHELL"; else eve$x_buf_str_dcl := "DCL"; endif; endif; eve$dcl_buffer := eve$init_buffer (eve$x_buf_str_dcl, "", FALSE); ! Spell if eve$$x_buf_str_spell = tpu$k_unspecified then eve$$x_buf_str_spell := "SPELL"; endif; eve$$spell_buffer := eve$init_buffer (eve$$x_buf_str_spell, "", FALSE); if eve$$x_buf_str_spell_save = tpu$k_unspecified then eve$$x_buf_str_spell_save := "$SPELL$"; endif; eve$$x_spell_save_buffer := eve$init_buffer (eve$$x_buf_str_spell_save, ""); ! EVE's scratch buffer (reserved before use, then released) if eve$x_buf_str_scratch = tpu$k_unspecified then eve$x_buf_str_scratch := "$SCRATCH$"; endif; eve$$x_scratch_buffer := eve$init_buffer (eve$x_buf_str_scratch, ""); ! Help buffers if eve$x_buf_str_caption = tpu$k_unspecified then eve$x_buf_str_caption := "$CAPTION$"; endif; eve$$x_caption_buffer := eve$init_buffer (eve$x_buf_str_caption, "[EOB]"); if eve$x_buf_str_help = tpu$k_unspecified then eve$x_buf_str_help := "HELP"; endif; help_buffer := eve$init_buffer (eve$x_buf_str_help, ""); eve$set_fixed_status_line (help_buffer, compile ("return eve$$sys_window_status")); if eve$x_buf_str_help_prompt = tpu$k_unspecified then eve$x_buf_str_help_prompt := "$HELP$PROMPT$"; endif; eve$help_prompt_buffer := eve$init_buffer (eve$x_buf_str_help_prompt, ""); ! SHOW BUFFER if eve$x_buf_str_buffer_list = tpu$k_unspecified then eve$x_buf_str_buffer_list := "BUFFER LIST"; endif; eve$x_bufed_buffer := eve$init_buffer (eve$x_buf_str_buffer_list, ""); ! set the status line as unmodifiable by eve$set_status_line eve$set_fixed_status_line (eve$x_bufed_buffer, compile ("return eve$$buffer_list_status")); ! WPS ruler if eve$$x_buf_str_wps_ruler = tpu$k_unspecified then eve$$x_buf_str_wps_ruler := "$WPS$RULER$"; endif; eve$$x_ruler_buffer := eve$init_buffer (eve$$x_buf_str_wps_ruler, "[End of ruler]"); ! allow applications to specify the buffer change journal directory ! in a module pre-init assignment to this variable if eve$x_buf_str_journal = tpu$k_unspecified then if eve$x_ultrix_active then eve$x_buf_str_journal := ""; else eve$x_buf_str_journal := "TPU$JOURNAL:"; endif; endif; ! /JOURNAL if get_info (eve$$x_dcl_jrnl_file_pgm, "type") = UNSPECIFIED then eve$dcl_jrnl_file_logic ! EVE default logic else if execute (eve$$x_dcl_jrnl_file_pgm) ! User specified logic then eve$dcl_jrnl_file_logic ! EVE default logic endif; endif; ! Input File (and /MODIFY /OUTPUT /READ /NOCREATE) if get_info (eve$$x_dcl_input_file_pgm, "type") = UNSPECIFIED then eve$dcl_input_file_logic ! EVE logic for input file else if execute (eve$$x_dcl_input_file_pgm) then eve$dcl_input_file_logic ! EVE logic for input file endif; endif; ! The following can be overwritten by the user /COMMAND or ! /INITIALIZATION files to specify the buffer whose attributes are ! copied to the default buffer in procedure TPU$INIT_POSTPROCEDURE. eve$x_source_for_default_buffer := current_buffer; eve$define_indicator ("eve_next_buffer", "Buffer", "next_buffer"); eve$define_indicator ("eve_set_buffer('read_only')", "write", "set_buffer (set_buffer ""read_only"")"); eve$define_indicator ("eve_set_buffer('write')", "read-only", "set_buffer (set_buffer ""write"")"); eve$define_indicator ("eve_set_buffer('modifiable')", "unmodifiable", "set_buffer (set_buffer ""modifiable"")"); ! Set the keypad from the EVE$KEYPAD logical name on VMS or the EVEKEYPAD ! environment variable on ULTRIX. if eve$x_ultrix_active then ! File_parse translates environment variable XXX if formatted as ${XXX}. ! If no logical, tpu$_parsefail error results. logical := "${EVEKEYPAD}"; else ! If no logical, parse returns "EVE$KEYPAD" logical := "EVE$KEYPAD"; endif; logical := file_parse (logical, "", "", NAME); if not ((logical = "EVE") or ! logical/env var = EVE (eve$x_ultrix_active and parse_error) or ! no env var on Ultrix ((not eve$x_ultrix_active) and ! no logical on VMS (logical = "EVE$KEYPAD"))) then case logical ["EDT"]: eve_set_keypad_edt; ["NUMERIC"]: eve_set_keypad_numeric; ["VT100"]: eve_set_keypad_vt100; ["WPS"]: eve_set_keypad_wps; [OTHERWISE]: the_keypad := expand_name ("eve_set_keypad_" + logical, PROCEDURES); execute ("eve_set_keypad_" + logical); endcase; endif; ! Layered applications can delay menu creation by assigning to this ! variable in a module pre_init procedure. Menu bar is managed in ! eve$init_postprocedure; if eve$x_delay_menu_creation = tpu$k_unspecified then eve$create_menu_bar; ! UID, icon, menu_bar, popups endif; ! Define Ultrix attributes if eve$x_ultrix_active then eve$define_attr ("eve_set_file_backup", "eve_set_file_backup;", message_text (EVE$_BACKUPON, 0)); eve$define_attr ("eve_set_backup_control_string", "eve_set_backup_control_string('" + eve$x_backup_string + "'); ", message_text (EVE$_BACKUPSET, 0, eve$x_backup_string)); endif; endmodule; ! EVE$FILE.TPU Page 66 ! ! Global constant and variable declarations ! constant eve$kt_whitespace := ! Whitespace characters: space & horizontal tab %if eve$x_option_2byte ! NOTE: We need a mechanism for handling %then ! Latin-1 non-breaking space. " ¡¡" + ascii (9); ! Asian 2-byte space %else " " + ascii (9); %endif variable eve$x_generate_bufnames, ! User defined. If set, don't prompt for ! unique bufnames, just generate them eve$x_get_wild_active, ! User defined. If set, get all files instead ! of prompting with choice buffer eve$$x_current_action_type, eve$$x_current_pre_array, eve$$x_current_post_array, eve$x_quit, eve$x_select_position, eve$x_found_range, eve$x_not_alphabetic, eve$$x_dcl_start_file_pgm, ! User defined pgm used for /START logic eve$$x_dcl_init_file_pgm, ! User defined pgm used for /INIT logic eve$$x_dcl_jrnl_file_pgm, ! User defined pgm used for /JOURNAL logic eve$$x_dcl_input_file_pgm, ! User defined pgm used for input file logic eve$$x_dcl_file_mods_pgm; ! User defined pgm used for mod switches logic ! EVE$FILE.TPU Page 67 ! ! EVE$BUILD time executable code ! ! The minimal EVE editor requires EVE$FILE.TPU plus the following modules. ! One is commented out because eve$$require doesn't work for modules ! positioned after this one in EVE$MASTER.FILE. Forward procedure references ! to that module are allowed. eve$$require ("eve$terminals"); ! Build dependency eve$$require ("eve$windows"); !eve$$require ("eve$core");