! LSE$EVE_FILE.TPU !************************************************************************* ! * ! © Copyright 2005 Hewlett-Packard Development Company, L.P. * ! * ! Confidential computer software. Valid license from HP required for * ! possession, use or copying. Consistent with FAR 12.211 and 12.212, * ! Commercial Computer Software, Computer Software Documentation, and * ! Technical Data for Commercial Items are licensed to the U.S. * ! Government under vendor's standard commercial license. * ! * !************************************************************************* ! !++ ! FACILITY: ! VAX Language-Sensitive Editor ! ! ABSTRACT: ! This file contains superceded EVE procedures that are located in the ! file EVE$FILE.TPU. ! ! ENVIRONMENT: ! VAX/VMS ! ! CREATION DATE: 21-DEC-1989 ! ! MODIFIED BY: ! ! X3.1-1 DAS 21-Dec-89 First pass. ! X3.1-2 CCC 2-Apr-90 Add to set buffer permanent for all system buffers ! X3.1-3 DAS 05-Nov-90 Added initialization of 2 new eve variables in init. ! X3.2 GJJ 10-Mar-91 Incorporated EVE 3.0's file module init. ! X4.0 GJJ 16-Apr-91 Incorporated more Eve changes into the module init ! code. Temporarly patched in our new recover buffer ! until is's available in Eve. ! X4.0-1 GJJ 30-May-91 Removed our copy of EVE_RECOVER_BUFFER, ! EVE$BACKUP_FILE and associated EVE$FILE_MODULE_INIT ! procedure changes as our overrides in these ! procedures have been incorporated into Eve. ! X4.0-2 WC3 11-Jul-91 Replace use of eve$display_choices ! w/lse$prompt_list_buffer ! X4.0-2 WC3 30-Jul-91 Add declaration for lse$command_window ! X4.0-3 DAS 26-Oct-91 Moved declaration of lse$command_window to ! lse$eve_decwindows.tpu. ! X4.0-4 DAS 27-Oct-91 Missing declaration of the_journal_file ! X4.0-5 DAS 15-Nov-91 No module/endmodule ! X4.0-6 SHE 03-Nov-91 Remove EVE's eve$$set_responder paradigm. ! X4.0-7 SHE 25-Apr-92 Re-superseded code from eve$file's module init ! X4.0-8 DEC 15-Jul-92 Fix eve_recover_buffer to handle file names !- procedure lse$eve_file_module_ident return "4.7-1"; endprocedure; procedure eve$file_module_init ! EVE$FILE.TPU Page 50 ! 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_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 (PERMANENT, eve$command_buffer); ! LSE change: Use the LSE$CMD_WINDOW_KEY_MAP_LIST for the EVE$COMMAND_BUFFER. ! !set (KEY_MAP_LIST, eve$x_command_key_map_list, eve$command_buffer); set (KEY_MAP_LIST, "LSE$CMD_WINDOW_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 !### LSE Change: Set the video attributes of the command window so that ! the prompt is displayed in reverse video. set (VIDEO, eve$command_window, REVERSE); 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, ""); !### LSE Change: Mark the buffer as permanent and disable overviews. ! set (PERMANENT, eve$prompt_buffer); set (lse$overviews, eve$prompt_buffer, off); set (REVERSE, eve$prompt_buffer); ! for VMS V4 line-editing compatibility ! LSE change: Set the LSE$CMD_KEY_MAP_LIST on the EVE$PROMPT_BUFFER. ! set (KEY_MAP_LIST, "LSE$CMD_KEY_MAP_LIST", eve$prompt_buffer); 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, ""); set (PERMANENT, tpu$x_message_buffer); ! ! LSE change ! set (lse$overviews, tpu$x_message_buffer, off); 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, ""); !### LSE Change: Mark the buffer as permanent and disable overviews. ! set (PERMANENT, tpu$x_show_buffer); set (lse$overviews, tpu$x_show_buffer, off); 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")); set (PERMANENT, eve$choice_buffer); ! 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, ""); set (PERMANENT, eve$recall_line_buffer); ! ! LSE added ! set (lse$overviews, eve$recall_line_buffer, off); set (PERMANENT, eve$recall_line_buffer); ! 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, ""); ! 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, ""); ! 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) ! ! LSE change: LSE will do the input file processing and handle the /NOCREATE ! qualifier. LSE must handle the current file as well as the SET SOURCE ! SET DIRECTORY/READ_ONLY directories. ! !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"")"); ! LSE Change - removed ! 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; endprocedure; ! EVE$FILE.TPU Page 46 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? !LSE CHANGE: Call EVE$FIND_BUFFER with just one parameter) ! !the_buffer := eve$find_buffer (buffer_name, "set journaling"); the_buffer := eve$find_buffer (buffer_name); 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 ! EVE$FILE.TPU Page 48 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? !LSE CHANGE: Call EVE$FIND_BUFFER with just one parameter) ! !the_buffer := eve$find_buffer (buffer_name, "set nojournaling"); the_buffer := eve$find_buffer (buffer_name); 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 procedure eve_recover_buffer (journal_file_parameter) ! 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, return_status, ! Return status code journal_file, ! Argument given to this command default_spec, ! Default journal file specification 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 buffer_ptr, ! Pointer to buffer possibly named in the argument not_a_journal, status, the_journal_file; 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 [OTHERWISE]: eve$unmap_if_mapped (tpu$x_show_window); eve$$restore_position (saved_window, saved_mark); return_status := FALSE; endon_error; return_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_spec := eve$x_buf_str_journal; if eve$x_ultrix_active then default_spec := default_spec + ".tpu_journal" else default_spec := default_spec + ".TPU$JOURNAL" endif; jrnl_file_w_dflts := file_parse (journal_file, default_spec); eve$reset_file_search; erase (eve$choice_buffer); file_count := 0; 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 status := get_info (the_journal_file, "journal"); if not_a_journal then file_count := 0; endif; endif; ! Choose how to recover based on the number of matches which were found. ! if file_count > 1 then ! Multiple matches to the input. Display them with EVE$DISPLAY_CHOICES. ! eve$message( EVE$_AMBFILE, 0, journal_file_parameter ); POSITION( BEGINNING_OF( eve$choice_buffer ) ); lse$prompt_list_buffer( eve$choice_buffer, lse$command_window ); POSITION( saved_window ); POSITION( saved_mark ); eve_recover_buffer( GET_INFO( eve$choice_buffer, 'line' ) ); return_status := FALSE; else if file_count = 0 then ! No files found using this name. 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. ! jrnl_file_w_dflts := file_parse (get_info (buffer_ptr, "journal_name"), default_spec); 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. ! jrnl_file_w_dflts := file_parse (get_info (journal_file,"journal_name"), default_spec); 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 return_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); return_status := eve$recover (the_journal_file); if return_status = TRUE then recovered_buffer := current_buffer else recovered_buffer := 0 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; eve$learn_abort; endif; else if file_count = 0 then eve$message (EVE$_NOFILMATCH, 0, journal_file) endif; eve$$restore_position (saved_window, saved_mark); eve$learn_abort; endif; return return_status; endprocedure; ! ! This procedure is superceded to comment out the message being displayed at the ! end. The correct fix would be to add a do_messages optional argument, but the ! procedure already has an optional argument. ! ! EVE$FILE.TPU Page 52 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 change_case (the_buffer, UPPER); ! to match get_info uppercase names 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 + " "; change_case (the_buffer, LOWER); 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 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 ! ## LSE Change if not lse$prompt_string ( '', the_file, FAO (lse$get_message_text (EVE$_WRITEFILEPROMPT), get_info (write_buffer, "name")), '' ) then return false; else if (the_file = "") then eve$message (EVE$_NOFILESPEC); return (TRUE); ! harmless return if no filename endif; endif; return (eve$write_file (write_buffer, the_file, the_format)); 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; if not eve$backup_file (the_buffer, the_file_name, version_number, eve$x_backup_string) then return (FALSE); endif; 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 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"})); ! ## LSE Change - we're not using EVE's responders ! ! 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 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 ! ## LSE Change if not lse$prompt_string ( '', the_file, FAO (lse$get_message_text (TPU$_NEEDFILENAME), get_info (the_buffer, "name")), '') then return false; else if the_file = "" then eve$message (EVE$_NOFILESPECEXIT, 0, get_info (the_buffer, "name")); endif; endif; endif; return (TRUE); endprocedure; ! eve$$get_write_file 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]: set (SUCCESS, saved_success); eve$learn_abort; abort; [OTHERWISE]: 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 ! ## LSE Change if not lse$prompt_boolean ( '', status, FAO (lse$get_message_text (EVE$_WRITEBUF), eve$$x_exit_array {"the_buffer_name"})) then return false; endif; eve$$x_exit_array {"state"} := 0; endif; if status then status := eve$$exit2 (1); if not status then eve$learn_abort; return (FALSE); endif; if status = eve$k_async_prompting then return (status); endif; else if status = eve$k_error ! read_key was aborted then 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; ! Delete EVE subprocesses *without* the "subprocess terminated" message. eve$delete_processes; exit; endprocedure; ! eve$$exit_loop