! LSE$METHOD.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 LSE's Method Functionality. ! ! ENVIRONMENT: ! Portable/LSE ! ! Author: Don Hamson ! ! CREATION DATE: 16-October-1991 ! ! MODIFIED BY: ! ! X3.1 DBH 16-Oct-91 New module ! X4.0-1 DAS 17-Oct-91 Commented out call to LSE$$GOTO_LIBRARY_MODULE ! X4.0-2 DBH 23-Oct-91 Added lse$method_open_file, uncomment above. ! X4.0-3 DAS 24-Oct-91 Changed LSE$METHOD_POSTPROC to LSE$$METHOD_POSTPROC(1) ! X4.0-4 DBH 24-Oct-91 Init lse$method_executing ! X4.0-5 DAS 27-Oct-91 Missing LOCAL buffer_array declarations ! Missing LOCAL the_filename declaration ! X4.0-5 DBH 30-Oct-91 Method_open_file uses lse_fetch_element, new ! grammar routines used in many places ! X4.0-6 DBH 1-Nov-91 Removed input focus grab. ! X4.0-7 DBH 7-Nov-91 ErrorList processing. ! X4.0-8 WC3 12-DEC-91 Removed the MODULE/ENDMODULE construct ! X4.0-9 DEC 10-Apr-92 Implement lse$method_showui ! X4.0-10 WC3 08-May-92 Added missing local declarations ! ! NOTE - FOR ADDING PROCEDURES ! ! The following is a documentation template which is used with PDF to ! create documentation. When creating a new procedure, copy the template ! above the procedure. The information will be supplied by the documentation ! group. ! !doc_begin ! ! ONE LINE DEFINITION: ! «TBS» ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! Procedure LSE$Method_Module_Ident return "X4.0-10"; Endprocedure; !-------------------------- Method Worker Routines -------------------------- ! LSE Method Preprocessing Procedure LSE$$Method_PreProc lse$method_executing := 1; lse$$method_message_mark := mark(none, message_buffer); lse$$prompt_save(); Endprocedure; ! LSE Method Postprocessing Procedure LSE$$Method_PostProc (expose, status) lse$$prompt_restore(); lse$post_command_proc(); ! Move Errors to the ErrorList ! if not status then lse$$push_position(); position (lse$$method_message_mark); move_vertical(1); loop exitif mark(none) = end_of (current_buffer); if (current_line <> '') then lse$$method_copy_errorlist (current_line); endif; move_vertical(1); endloop; lse$$pop_position(); endif; update(all); if expose and eve$x_decwindows_active then lse$$raise_screen(); endif; lse$method_executing := 0; Endprocedure; ! Set position in the file Procedure LSE$$Method_Position (line, column) local status; status := lse_line(str(line), ''); if status then move_horizontal(column); endif; return (status); Endprocedure; ! Collect user buffers for the *all* methods Procedure LSE$$Method_All (buffernames, n, modify_option) local the_buffer, buffer_modified; n := 0; buffernames := create_array; the_buffer := get_info (buffers, "first"); loop exitif the_buffer = 0; if not get_info (the_buffer, "system") then buffer_modified := get_info(the_buffer,'modified') and not get_info(the_buffer,'no_write'); if (modify_option and buffer_modified) or not modify_option then n := n + 1; buffernames{n} := get_info (the_buffer, 'file_name'); endif; endif; the_buffer := get_info (buffers, "next"); endloop; Endprocedure; ! File Access Semantics for Edit, Browse, PositionInFile Methods Procedure lse$$method_open_file (;file_spec, edit_option) ! edit_option permits different end-game processing for the Edit Method ! over the others, edit will create the file if it's not within the repository. LOCAL the_file_spec, the_buffer, the_dir_spec, the_filename; ON_ERROR [LSE$_IMAGEACTERROR]: eve$message (ERROR_TEXT); eve$learn_abort; return false; [TPU$_OPENIN, LSE$_COMMANDCANCEL, LSE$_FILEOPENFAIL, LSE$_FILEREADFAIL]: delete(the_buffer); the_buffer := 0; [OTHERWISE]: eve$message (str (error)); lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$method_open_file "); ENDON_ERROR; ! ! Get the file specification (lest parm is unspecified) ! if not lse$prompt_existing_file (file_spec, the_file_spec, lse$_filenameprompt, ! prompt to use eve$_nofilespec, ! failure prompt to use tpu$k_unspecified) ! buffer preference then return false; endif; ! ! Get the buffer that this file is in or read the file. ! the_buffer := lse$create_buffer ( tpu$k_unspecified, ! No specific buffer name the_file_spec, ! File name eve$default_buffer, ! Defaults buffer tpu$k_unspecified, ! Journal file name off); ! Do not create the file ! ! Position to the buffer if we have one ! if the_buffer <> 0 then return lse_goto_buffer (the_buffer); endif; ! ! Try again without the directory information... ! This will find existing buffers, and use the source searchlist to locate ! the file. ! the_filename := file_parse (the_file_spec,'','',name,type); if (the_file_spec <> the_filename) then the_buffer := lse$create_buffer ( tpu$k_unspecified, the_filename, eve$default_buffer, tpu$k_unspecified, off); if the_buffer <> 0 then return lse_goto_buffer (the_buffer); endif; endif; ! ! File Access Completion: ! ! For most (browse, position...), just fetch ! if (edit_option = tpu$k_unspecified) or (edit_option = 0) then message("File not found: " + the_file_spec); return 0; !lse_fetch_element (the_filename); endif; ! ! edit_option, if fetch unsuccessful, create lse_file_spec ! !if lse_fetch_element (the_filename) then ! return true; !else the_buffer := lse$create_buffer ( tpu$k_unspecified, the_file_spec, eve$default_buffer, tpu$k_unspecified, on); if the_buffer <> 0 then return lse_goto_buffer (the_buffer); endif; eve$message (error_text); return false; !endif; Endprocedure; !-------------------------- LSE Method Functions -------------------------- Procedure LSE$Method_Edit (;file_spec); !doc_begin ! ! ONE LINE DEFINITION: ! Read the specified file into a user buffer. ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! LOCAL status; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$method_edit"); lse$$method_postproc(0,0); return 0; ENDON_ERROR; lse$$method_preproc(); status := lse$$method_open_file (file_spec,1); lse$$method_postproc (1, status); return (status); Endprocedure; Procedure LSE$Method_PositionInFile (;file_spec, line, column) !doc_begin ! ! ONE LINE DEFINITION: ! Read the specified file and position to given line, and column. ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! LOCAL status; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$method_positioninfile"); lse$$method_postproc(0,0); return 0; ENDON_ERROR; lse$$method_preproc(); status := lse$$method_open_file(file_spec); if status then status := lse$$method_position (line, column); endif; lse$$method_postproc (1, status); return (status); Endprocedure; Procedure LSE$Method_PositionInLibrary (library, modulename, line, column) !doc_begin ! ! ONE LINE DEFINITION: ! Position to line, column within the module from text library (VMS only). ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! LOCAL status; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$method_positioninlibrary"); lse$$method_postproc (0, status); return 0; ENDON_ERROR; lse$$method_preproc(); status := lse$$goto_library_module (library, modulename); if status then status := lse$$method_position (line, column) endif; lse$$method_postproc (1, status); return (status); Endprocedure; Procedure LSE$Method_Browse (;file_spec) !doc_begin ! ! ONE LINE DEFINITION: ! This method reads the specified file into a read-only user buffer. ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! LOCAL status; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$method_browse"); lse$$method_postproc (0, 0); return 0; ENDON_ERROR; lse$$method_preproc(); status := lse_view_file (file_spec); lse$$method_postproc(1, status); return (status); Endprocedure; Procedure LSE$Method_WriteContents (;file_spec) !doc_begin ! ! ONE LINE DEFINITION: ! This method writes the specified user buffer to disk. ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! LOCAL status, the_file_spec; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$method_writecontents"); lse$$method_postproc (0, 0); return 0; ENDON_ERROR; lse$$method_preproc(); ! ! Methods are asynchronous, don't default to current_buffer ! if lse$prompt_existing_file (file_spec, the_file_spec, lse$_filenameprompt, ! prompt to use eve$_nofilespec, ! failure prompt to use tpu$k_unspecified) ! buffer preference then status := lse_save_file (the_file_spec); else status := false; endif; lse$$method_postproc (0, status); return (status); Endprocedure; Procedure LSE$Method_CloseContents (;file_spec) !doc_begin ! ! ONE LINE DEFINITION: ! This method writes and deletes the specified user buffer. ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! LOCAL status, the_file_spec; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$method_closecontents"); lse$$method_postproc (0,0); return 0; ENDON_ERROR; lse$$method_preproc(); ! ! Methods are asynchronous, don't default to current buffer. ! if lse$prompt_existing_file (file_spec, the_file_spec, lse$_filenameprompt, ! prompt to use eve$_nofilespec, ! failure prompt to use tpu$k_unspecified) ! buffer preference then status := lse_close_file (the_file_spec); else status := false; endif; lse$$method_postproc (0, status); return (status); Endprocedure; Procedure LSE$Method_WriteAllModified !doc_begin ! ! ONE LINE DEFINITION: ! This method writes all modified user buffers to disk. ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! LOCAL buffernames, n, i, st; ON_ERROR [OTHERWISE]: delete(buffernames); lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$method_writeallmodified"); lse$$method_postproc (0,0); return 0; ENDON_ERROR; lse$$method_preproc(); ! Collect the names of all modified user buffers ! lse$$method_all (buffernames, n, 1); ! Write buffers to disk ! i := 1; st:=1; loop exitif i > n; st := st and lse_save_file (buffernames{i}); i := i + 1; endloop; delete (buffernames); lse$$method_postproc (0, st); return st; Endprocedure; Procedure LSE$Method_CloseAll !doc_begin ! ! ONE LINE DEFINITION: ! This method deletes all user buffers, writing those modified to disk. ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! LOCAL buffernames, n, i, st; ON_ERROR [OTHERWISE]: delete(buffernames); lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$method_closeall"); lse$$method_postproc (0,0); return 0; ENDON_ERROR; lse$$method_preproc(); ! Collect all user buffers lse$$method_all (buffernames, n, 0); ! Close all user buffers ! i := 1; st := 1; loop exitif i > n; st := st and lse_close_file (buffernames{i}); i := i + 1; endloop; delete (buffernames); lse$$method_postproc (0,st); return st; Endprocedure; Procedure LSE$Method_Terminate !doc_begin ! ! ONE LINE DEFINITION: ! The method causing LSE to quit. ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! LOCAL status; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$method_writeallmodified"); lse$$method_postproc(0,0); return 0; ENDON_ERROR; lse$$method_preproc(); lse_refresh(); status := lse_quit(); lse$$method_postproc (0,status); return (status); Endprocedure; Procedure LSE$Method_GetVersion (version_string) !doc_begin ! ! ONE LINE DEFINITION: ! This method reports LSE's version string. ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$method_getversion"); lse$$method_postproc(0,0); return 0; ENDON_ERROR; lse$$method_preproc(); version_string := get_info (lse$system, 'lse$version'); lse$$method_postproc (0,1); return 1; Endprocedure; Procedure LSE$Method_ShowUI !doc_begin ! ! ONE LINE DEFINITION: ! The method that causes LSE's user interface to become visible. ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$method_showui"); lse$$method_postproc(0,0); return 0; ENDON_ERROR; lse$$method_preproc(); lse$$method_postproc(1,1); return 1; Endprocedure; Procedure LSE$Method_HideUI !doc_begin ! ! ONE LINE DEFINITION: ! This method causes LSE's user interface to become invisible. ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$method_hideui"); lse$$method_postproc(0,0); return 0; ENDON_ERROR; lse$$method_preproc(); lse$$method_postproc(0,0); return 1; Endprocedure;