!-- ! LSE$PROMPT.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: ! Module that allows LSE to call EVE$PROMPT_LINE in TPU code from ! LSE$$READ_LINE in BLISS code. Used to implement the EVE command and ! prompt line in LSE. ! ! ENVIRONMENT: ! VAX/VMS ! ! Author: Joe Wild ! ! CREATION DATE: 3-May-88 ! ! MODIFIED BY: ! X2.3-2 GHL 06-Jun-88 Use EVE$$X_FIND_TERMINATORS as terminator list, ! because it seems to handle all the cases we are ! interested in. ! ! X2.3-3 JPW 16-Jun-88 Change LSE$$PROMPT_LINE to return a FALSE status ! if EVE$PROMPT_LINE fails (a failure now acts like a ! Ctrl-Z terminated prompt). Change LSE$$PROMPT_LINE ! to set the prompt buffer line editing mode from the ! screen editing mode. ! X2.3-4 GJJ 21-Sep-88 Add LSE$$DECW_PROMPT_LINE. ! X2.3-5 GJJ 28-Oct-88 Changed the LSE BLISS code to always call ! LSE$$PROMPT_LINE; made LSE$$PROMPT_LINE figure ! out whether we need to call the READ_LINE builtin ! (during DECwindows prompts) or EVE$PROMPT_LINE ! (all other prompts). Removed LSE$$DECW_PROMPT_LINE. ! X2.3-6 DAS 09-Dec-88 Removed line_editing_mode from lse$$prompt_line ! X2.3-7 WCC 14-Dec-88 Add error-handling on CTRL/C for lse$prompt_line so ! that the prompt won't be infinite prompting for a ! string. ! X2.3-8 DAS 10-Jan-89 Initialize global strings in lse$prompt_line ! X2.3-9 WCC 03-Feb-89 Initialize global strings in lse$prompt_line ! X2.3-9 DAS 06-Feb-89 Fix return status from EVE$PROMPT_LINE ! X2.3-10 GJJ 9-Feb-89 Simplified the changes in edit X2.3-9 so that we ! set LSE$$PROMPT_LINE_STRING and ! LSE$$PROMPT_LINE_STATUS fewer times. ! X2.3-11 DAS 25-Apr-89 Made the prompt line routine treat the F10 ! terminator the same as Ctrl/Z terminator. ! X2.3-12 GJJ 1-May-89 Convert LSE$$PROMPT_LINE to use the new ! LSE$$READ_LINE and LSE$$PROMPT_YESNO builtins ! when prompting in DECwindows mode. ! X3.1-1 WC3 23-Feb-90 Call LSE$MAKE_VISIBLE in LSE$PROMPT_LINE so ! we make sure the cursor is visible before prompting ! X3.2 DAS 25-May-90 Rid the editor of LSE$$X_PROMPT_TERMINATORS and ! instead modify the eve variable and use it. All of ! EVE relies on their EVE$$X_PROMPT_TERMINATORS. ! X3.2-1 WC3 03-Aug-90 Add lse$prompt_percent ! lse$prompt_string ! lse$prompt_list ! lse$$parse_precent ! lse$$prompt_novalue ! X3.2-2 AVH 07-Aug-90 Add lse$prompt_number ! X3.2-3 DEC 13-Aug-90 Add lse$prompt_existing_buffer ! X3.2-4 WC3 13-Aug-90 Fix lse$prompt_percent to not fail for: ! default unspecified ! default of '' ! Change tpu$k_unspecified to unspecified ! Add case_sensitive to lse$prompt_list ! Fix lse$prompt_list to deal with: ! default unspecified ! default of '' ! double error message ! X3.2-5 WC3 17-Aug-90 Add lse$prompt_boolean ! Change lse$prompt_list to return an index ! X3.2-6 DAS 24-Aug-90 Fix lse$prompt_number returning a string ! X3.2-7 DEC 29-Aug-90 Add lse$prompt_create_buffer ! X3.2-8 WC3 01-Oct-90 Change LSE$PROMPT_BOOLEAN: ! to allow the keywords ON/OFF as parameters ! to use the unaltered valid responses in the ! error message ! X3.2-9 WC3 08-Oct-90 Support message keywords for prompts, defaults, ! valid responses, valid response delimiters ! X3.2-10 WC3 23-Oct-90 Correct lse$prompt_list's use of default value ! Add Haley Headers ! X3.2-11 WC3 24-Oct-90 Correct bad prompt construction ! X3.2-12 DAS 28-Oct-90 Began calling lse$create_buffer and not TPU's ! X3.2-13 DAS 28-Oct-90 Commented out MESSAGE in LSE$LIST_EXTRACT ! X3.2-14 WC3 29-Oct-90 Removed MESSAGE in LSE$LIST_EXTRACT ! X3.2-15 WC3 29-Oct-90 Fix improper construction of error message ! X3.2-16 DAS 29-Oct-90 Added procedure LSE$FIND_BUFFER ! X3.2-17 DAS 01-Nov-90 Fix lse$find_buffer to call lse$get_buffer ! X3.2-18 DAS 02-Nov-90 Cleanup to support new parser rules for prompting ! Removed all support for eve$k_no_arg which is not ! an integer anyway, it is tpu$k_unspecified. ! X3.2-19 DAS 06-Nov-90 Fixed bug introduced above in prompt_list ! X3.2-20 AVH 15-Nov-90 Added LSE$PROMPT_SEARCH_STRING ! X3.2-21 DAS 19-Nov-90 Fixed prompt_search_string bug breaking test ! X3.2-19 DAS 09-Nov-90 Added lse$decw_prompt_existing_file routine ! X3.2-22 LRH 28-Nov-90 Fixed lse$prompt_key to deal with ..._key keynames ! ! X3.2-23 DAS 27-Nov-90 Changed LSE$CREATE_BUFFER to LSE$CREATE_BUFFER_UTIL ! X3.2-24 SHE 06-Dec-90 Added documentation headers ! X3.2-25 DAS 19-Dec-90 Remove LSE$X_DIALOG_BOX_OVERRIDE dead code paths ! X3.2-26 SHE 08-Jan-91 Make all 2nd args to MESSAGE/EVE$MESSAGE 0. ! X3.2-27 DAS 10-Jan-91 Changed UPCASE_NAME to THE_UPCASE_NAME because of ! a global declaration of this by EVE. ! X3.2-28 LRH 14-Jan-91 Change lse$prompt_string to always return a string ! X3.2-29 DAS 18-Jan-91 Prompt string when not prompting returning string ! X3.2-30 AVH 24-Jan-91 Use local copy of default value in lse$prompt_string ! X3.2-31 LRH 20-Feb-91 Change message string in lse$prompt_key to output ! unparsed_string and use correct message. ! X3.2-32 DEC 22-Mar-91 Add prompt_language, prompt_add_remove and ! NMC prompt_alias. Modify prompt_string to handle ! language and alias types. ! X3.2-32 GJJ 28-Feb-91 Applied name conversions for the resource ! and callback reason names. ! X4.0 NMC 03-Apr-91 Add lse$prompt_lang_elem_param ! X4.0-1 DAS 8-Apr-91 Made default directory specification OS specific ! X4.0-2 DAS 23-Apr-91 Remember dirMask after dismissing file selection ! X4.0-3 WC3 29-Apr-91 Add keyword param to lse$get_lang_elem_message ! Add real element support to lse$prompt_lang_elem_param ! X4.0-4 WC3 15-May-91 Portable language consistency ! X4.0-5 DAS 20-May-91 If no buffer found in LSE$$GET_CLI_BUFFER, then ! return the string given to us. ! X4.0-6 NMC 28_May-91 Add adjustment type to lse$prompt_string ! X4.0-7 SHE 03-Jun-91 Added min_value and max_value to lse$prompt_number. ! X4.0-8 SHE 4-Jun-91 Motif conversion. ! X4.0-9 SHE 10-Jun-91 Removed CMS conflict messages ! X4.0-10 WC3 13-Jun-91 Prompting consistency ! X4.0-11 SHE 1-Jul-91 Added lse$$set_dialog_title. ! Modified lse$prompt_string to warn the user ! when the default value is used because they've ! entered ''. ! X4.0-12 SHE 2-Jul-91 Modified lse$prompt_string to only warn the ! user when the default value is used because ! they've entered '' if they're using dialog boxes. ! X4.0-13 SHE 9-Jul-91 Fixed LSE$$PROMPT_LINE to handle prompting of ! non-booleans for commands invoked by menu. ! X4.0-14 WC3 13-Jun-91 Prompting consistency ! X4.0-15 WC3 11-Jul-91 lse$prompt_list_buffer, Command buffer support ! X4.0-16 DAS 12-Jul-91 Added lse$$set_dialog_title (where did it go?) ! X4.0-17 WC3 22-Jul-91 No longer use EVE$PROCESS_COMMAND ! Fix vms style prompting to put terminators on ! the prompts ! Fix to test if the prompt was successful before ! proceeding ! X4.0-18 WC3 25-Jul-91 Added lse$$prompt_boolean_jacket ! X4.0-19 WC3 26-Jul-91 KP4 and KP5 at the search prompt ! X4.0-20 WC3 30-Jul-91 Use standard procedure to add the end of the prompt ! in lse$prompt_boolean_decw ! X4.0-21 NMC 31-Jul-91 Modified lse$prompt_lang_elem_param for language ! prompting consistency ! X4.0-22 SHE 01-Aug-91 Changed calls to CREATE_WIDGET to calls to ! lse$create_dialog_box to getting min. widths ! and heights for resizeable dialog boxes. ! X4.0-23 SHE 02-Aug-91 Fixed call to lse$$end_prompt in lse$prompt_boolean_decw ! X4.0-24 NMC 02-Aug-91 Added procedure lse$prompt_lang_pack ! Added procedure lse$prompt_lang_pack_elem_param ! Added package type to lse$prompt_string ! X4.0-25 WC3 06-Aug-91 Add lse$prompt_list_buffer support for ! lse$prompt_existing_buffer for ambigious case ! X4.0-26 DEC 08-Aug-91 Changed lse$prompt_string to handle token and ! placeholder types ! X4.0-27 WC3 12-Aug-91 Remove use of eve$parser_dispatch ! X4.0-28 WC3 11-Sep-91 M1CLICK2 in prompt_list_buffer ! X4.0-29 DBJ 13-Sep-91 Added lse$$prompt_save, lse$$prompt_restore. ! X4.0-30 LRH 17-Sep-91 Set buffer to no_write after creating in create_prompt_buffer ! X4.0-31 WC3 13-Sep-91 LSE$PROMPT_LIST_BUFFER was not restoring the ! cursor to the correct window on exit. ! Fix spurious split_line when ^C to ambigious parse ! Add visual feedback that we've heard the terminator ! X4.0-32 WC3 24-Sep-91 Fix missing first character on recalled commands ! X4.0-33 WC3 27-Sep-91 Fix unexpected errors in lse$prompt_list_buffer ! Fix wrong buffers on the screen when upper window ! is used. ! X4.0-34 SAA 2-Oct-91 Add ROUTINE capability to lse$prompt_lang_pack_elem_param ! and fix 'current element' semantics ! X4.0-35 WC3 2-Oct-91 Fix command line prompting to not execute terminator ! keys in the context of the command buffer when ! doing continuous prompting. ! X4.0-36 SAA 3-Oct-91 Add PARAM_STRING capability to lse$prompt_string ! X4.0-37 DAS 8-Oct-91 Missing quote in module ident ! X4.0-38 WC3 03-Oct-91 Do -31 better ! X4.0-39 SHE 16-Oct-91 Re-use file selection widgets ! X4.0-40 NMC 17-Oct-91 Fix bug in lse$prompt_lang_pack_elem_param ! X4.0-41 LRH 21-Oct-91 Return false in lse$prompt_number when prompt_string ! returns false. ! X4.0-42 SAA 21-Oct-91 fixed bug in lse$find_buffer ! X4.0-43 WC3 18-Oct-91 Change LSE$$GET_CLI_BUFFER to use ! lse$prompt_existing_buffer ! Added lse$prompt_show_buffer ! X4.0-44 WC3 22-Oct-91 Restore LSE$$GET_CLI_BUFFER to it's original form ! and add lse$$existing_buffer_jacket ! X4.0-45 DAS 27-Oct-91 Missing local declarations ! X4.0-46 DBH 30-Oct-91 Added lse$prompt_repository_ ! X4.0-47 SHE 31-Oct-91 Modify prompt_string_decw to use XmPromptDialog. ! X4.0-48 WC3 30-Oct-91 Correct missing LSE> prompt when expanding a ! placeholder at the command line by updating ! the user windows instead of ALL ! X4.0-49 LRH 01-Nov-91 Set def dir in prompt_exist_file for decws. ! X4.0-50 WC3 04-NOV-91 Fix lse$prompt_boolean_decw to handle the no prompt case ! X4.0-51 WC3 04-Nov-91 Fix bank lines in ambiguoug buffer prompt ! X4.0-52 LRH 12-Nov-91 Fix ambiguous message from coming out on ctrl_c ! in prompt_existing_buffer ! X4.0-53 WC3 11-Nov-91 Re-write SEARCH ! X4.0-54 WC3 15-Nov-91 Make lse$prompt_language return the name when ! passed the type. ! Unexpected error in lse$prompt_key ! X4.0-55 WC3 22-Nov-91 Change lse$$k_pkeypad_vmscli to lse$$k_pkeypad_vmslse ! X4.0-56 SHE 25-Nov-91 Modified lse$prompt_existing_file to always ! call lse$create_dialog_box so it can do a ! RAISE_WIDGET if necessary. ! X4.0-57 DAS 25-Nov-91 When reusing file selection widgets leave dirmask ! X4.0-58 SHE 03-Dec-91 Use lse$$menus_associate_command for file selection ! dialogs. ! X4.0-59 SHE 12-Dec-91 Force re-evaluation of file filter when file selection ! box is re-used. ! X4.0-60 DBH 20-Dec-91 removed test procedure, fixed prompt_repo_filename ! X4.0-61 WC3 19-Dec-91 Fix command and simple prompting to handle abort ! keys properly. ! Fix lse$$prompt_string_error_cleanup to detect ! an empty buffer ! Krock return value for lse$$prompt_string_jacket ! so the bliss code can detect prompt aborted ! X4.0-62 WC3 03-Jan-91 Separate command prompt display from data ! Separate stalled prompt display from data ! Allow scroll bar usage in prompt lists ! X4.0-63 WC3 21-Jan-92 Make BUFFER LIST more ledgable ! Correct normal exit from lse$prompt_existing_buffer ! to always release the scratch buffer ! Enhance LSE$$PROMPT_STRING to restore state on exit ! during recursion correctly ! Improve the rebustness of lse$$prompt_display_contents ! Prevent users from getting stuck in buffer having ! lse$$command_undefined_key_proc in the keymap ! Improve ^C handling at prompts ! X4.0-64 WC3 27-Jan-92 Output a default value message in LSE$PROMPT_STRING ! for dialog boixes only when there is a default ! X4.0-65 WC3 28-Jan-92 Change the order of GOTO BUFFER prompt output ! X4.0-66 WC3 31-Jan-92 Fix command line to: ! Put command executed as last line when its isn't ! Not insert extra blank lines ! Copy continuation line properly ! X4.0-67 WC3 10-Feb-92 Remove use of ABORT from command prompt processing ! ABORT terminates learn sequences ! Make the command contents buffer reflect the command ! display buffer when mouse actions changed ! the display buffer. ! X4.0-68 WC3 10-Feb-92 Support mouse actions at the stalled prompt ! X4.0-69 DBH 25-Feb-92 Remove lse$prompt_repository_elementname. ! X4.0-70 SHE 27-Feb-92 Added TPU$_NODEFINITION to undefined key procedure ! Force prompt/command buffers to modifiable so user ! can't accidentally turn them to unmodifiable ! X4.0-71 SHE 02-Mar-92 Removed leftover debugging messages. ! X4.0-72 WC3 02-Mar-92 Pull X4.0-68 changes above ! X4.0-73 WC3 06-Mar-92 Unmap the prompt window when the start window ! is the command window during stalled prompts ! X4.0-74 WC3 02-Mar-92 Issue a better message for READ_KEY aborts and ! remove the scroll bars on the prompt list window ! X4.0-75 SHE 10-Apr-92 Removed size_varies parameter to ! lse$create_dialog_box ! X4.0-76 WC3 23-Apr-92 Force cursor to bound while doing stalled prompt ! and cmd prompt. ! Protect recall lines from user modifications ! X4.0-77 WC3 07-May-92 Missing locals ! Replace scroll bars on list prompt windows ! Correct unexpected error in command prompting ! X4.0-78 WC3 26-May-92 Forgot to consider cursor offset in preprocessing ! of command line. ! Corrected KP4/KP5 processing at the search prompt ! caused by changes to help topics. ! X4.0-79 WC3 23-Sep-92 Support SET(MOUSE,ON) better ! Mouse to CMD window before first DO key ! 4.5-1 CJH 14-Aug-96 DECset V12.2 GUI Enhancements. !-- procedure lse$prompt_module_ident ! Ident return "4.7-4"; endprocedure; procedure lse$prompt_module_init ! Module Init eve$$x_prompt_terminators := eve$$x_find_terminators; lse$$prompt_line_string := ""; lse$$prompt_line_status := 0; IF eve$x_ultrix_active THEN lse$x_file_selection_dirmask := '*'; ELSE lse$x_file_selection_dirmask := '*.*'; ENDIF; lse$$prompt_saved_window := tpu$k_unspecified; lse$$prompt_saved_buffer := tpu$k_unspecified; lse$$prompt_saved_position := tpu$k_unspecified; endprocedure; ! LSE$$PROMPT_LINE ! ! This procedure is a jacket for the EVE$PROMPT_LINE routine. It returns the ! string entered at the prompt in LSE$$PROMPT_LINE_STRING. ! procedure lse$$prompt_line(prompt) local prompt_return_value, yesno_prompt, processed_prompt, response; on_error [TPU$_CONTROLC]: lse$$prompt_line_string := ""; lse$$prompt_line_status := 0; [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$prompt_line"); endon_error; ! Initialize the global variables before doing anything else. Have to ! initialize variables as they are declared in LSEGLOBAL.B32 ! lse$$prompt_line_string := ""; lse$$prompt_line_status := 0; ! Make sure the cursor position is visible before prompting ! lse$make_visible(0); ! If we're being called for a prompt for a command that was issued from ! a dialog box dispatch, then prompt using a dialog box. Otherwise, ! prompt using EVE$PROMPT_LINE. EVE$PROMPT_LINE returns 0 if the prompt ! was aborted. ! if eve$$x_state_array {eve$$k_command_line_flag} = eve$k_invoked_by_menu then ! ! Check to see if the prompt string is one that we perform special ! processing on. At the same time, note whether it is a yes/no prompt. ! processed_prompt := lse$$convert_message(prompt, yesno_prompt); processed_prompt := processed_prompt + lse$$end_prompt( processed_prompt, ': ' ); ! ! If this is a yes/no prompt, then prompt using the LSE$$PROMPT_YESNO ! builtin. Otherwise, prompt using LSE$$READ_LINE. ! if yesno_prompt then lse$prompt_boolean_decw (tpu$k_unspecified, response, processed_prompt, "", "", FALSE); lse$$prompt_line_status := 1; case response [0]: lse$$prompt_line_string := "N"; [1]: lse$$prompt_line_string := "Y"; endcase; else prompt_return_value := lse$prompt_string (tpu$k_unspecified, response, processed_prompt); if (prompt_return_value <> TRUE) then return prompt_return_value; else lse$$prompt_line_status := 1; lse$$prompt_line_string := response; endif; endif; else prompt_return_value := lse$$eve_prompt_line(prompt + lse$$end_prompt( prompt, ': ' ), eve$$x_prompt_terminators, ""); ! Return the string and a success code if the prompt succeeded. ! if prompt_return_value <> 0 then if ((LAST_KEY <> ctrl_z_key) AND (LAST_KEY <> f10)) then lse$$prompt_line_string := prompt_return_value; lse$$prompt_line_status := 1; endif; endif; endif; endprocedure; ! This procedure knows about a set of messages that we must change the text ! when prompting via a dialog box under DECwindows. If the prompt string ! that is passed to this routine is one of the messages that we have targeted ! for replacement, then we make that replacement here. ! procedure lse$$convert_message (prompt, yesno_prompt) ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$convert_message "); ENDON_ERROR; ! Default to a yes/no prompt unless we determine otherwise. ! yesno_prompt := 1; if prompt = message_text (lse$_confcorr, 1) then return message_text (lse$_dwconfcorr, 1) endif; if prompt = message_text (lse$_confdelbuf, 1) then return message_text (lse$_dwconfdelbuf, 1) endif; if prompt = message_text (lse$_confreserve, 1) then return message_text (lse$_dwconfreserve, 1) endif; if prompt = message_text (lse$_conffetch, 1) then return message_text (lse$_dwconffetch, 1) endif; if prompt = message_text (lse$_readwrite, 1) then return message_text (lse$_dwreadwrite, 1) endif; if prompt = message_text (lse$_unmodwrite, 1) then return message_text (lse$_dwunmodwrite, 1) endif; if prompt = message_text (lse$_writereaddir, 1) then return message_text (lse$_dwwritereaddir, 1) endif; if prompt = message_text (lse$_nocomment, 1) then return message_text (lse$_dwnocomment, 1) endif; if prompt = message_text (lse$_confdelplch, 1) then return message_text (lse$_dwconfdelplch, 1) endif; ! We've checked all the yes/no messages and have not turned up a match. ! Set the YESNO_PROMPT flag to 0 to indicate this condition; check the ! messages that are not yes/no messages to see if we have to perform a ! conversion. ! yesno_prompt := 0; if prompt = message_text (lse$_getbuf, 1) then return message_text (lse$_dwgetbuf, 1) endif; ! The CLI adds leading underscores to prompt strings. Remove the leading ! "_" character if it exists. ! if substr(prompt, 1, 1) = "_" then return substr(prompt, 2, length(prompt)) else return prompt endif; endprocedure; PROCEDURE lse$prompt_boolean( value_in, value_out, prompt ;novalue_msg, default_value ) ! FUNCTION: ! ! Prompts for a boolean true/false, yes/no value ! ! PARAMETERS: ! ! value_in - String, Integer, or Keywords ON/OFF ! ! value_out - Integer, one or zero ! ! prompt - String or message keyword, used as prompt ! ! novalue_msg - Optional, message to use if no value is entered ! ! default_value - Optional string, value to use if there is ! no value entered ! ! RETURN VALUE: ! ! Values returned by LSE$PROMPT_LIST ! !doc_begin ! ! ONE LINE DEFINITION: ! «TBS» ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! local the_default_value, return_value; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$prompt_boolean"); ENDON_ERROR; ! ! If the input value is an integer, then return true or false without prompting. ! IF GET_INFO (value_in, 'type') = INTEGER THEN value_out := value_in AND 1; return TRUE; ENDIF; ! ! If the input value is the kwrd_on, then return true without prompting ! IF value_in = ON THEN value_out := 1; return TRUE; ENDIF; ! ! If the input value is the kwrd_off, then return false without prompting ! IF value_in = OFF THEN value_out := 0; return TRUE; ENDIF; ! ! Support non-string defaults ! IF (GET_INFO( default_value, 'type' ) = INTEGER) OR (default_value = ON) OR (default_value = OFF) THEN the_default_value := STR( default_value ); ELSE the_default_value := default_value; ENDIF; ! ! Call either the specialized DECwindows support or prompt list to interact ! with the user. ! IF lse$use_dialog_box THEN return_value := lse$prompt_boolean_decw ( value_in, value_out, prompt, lse$_booldelimit, lse$_boollist, FALSE, novalue_msg, the_default_value ); ELSE return_value := lse$prompt_list ( value_in, value_out, prompt, lse$_booldelimit, lse$_boollist, FALSE, novalue_msg, the_default_value ); ENDIF; ! ! If that routine returned true, then set the value_out to 1 or 0. Odd values ! are true/yes/on... ! IF return_value = TRUE THEN value_out := value_out AND 1; ENDIF; RETURN return_value; ENDPROCEDURE; PROCEDURE lse$prompt_boolean_decw ( value_in, value_out, prompt, valid_response_delimiter, valid_response, case_sensitive ;novalue_msg, default_value ) ! FUNCTION: ! ! Uses a dialog box to get yes/no response ! ! PARAMETERS: ! ! value_in - String ! ! value_out - Set to 1 or 0 ! ! prompt - String or message keyword, used as prompt ! ! valid_response_delimiter- String ! ! valid_response - String, responses separated with ! valid_response_delimiter. ! The delimiter must trail and lead each ! element. ! ! case_sensitive - True - The valid_response_delimiter and user input ! are untouched. ! False - The valid_response_delimiter and user input ! are UPPER ! ! novalue_msg - Optional, message to use if no value is entered ! ! default_value - Optional, value to use if there is no value ! entered. This may either be a string or a ! message_text keyword. ! ! RETURN VALUE: ! ! True - Data valid ! False - Prompt aborted ! lse$_invalidtype - Invalid input ! ! !doc_begin ! ! ONE LINE DEFINITION: ! «TBS» ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! LOCAL the_default_value, prompt_list_status, the_prompt_string, prompt_text, dummy; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$prompt_boolean_decw"); ENDON_ERROR; ! ! We need to determine whether to prompt at all. What we will do is call the ! prompt list procedure without passing along the prompt string. It will either ! succeed or not succeed. If it does not succeed, then we will clearly use the ! dialog box. If it does succeeed, we shall look to see if the input string ! was unspecified. We will also prompt in that situation, but use the original ! result as the default value. ! prompt_list_status := lse$prompt_list ( value_in, value_out, "", valid_response_delimiter, valid_response, case_sensitive, "", default_value ); ! ! If that succeeds and the value_in is not unspecified, then we can leave. ! IF ((prompt_list_status) AND (value_in <> tpu$k_unspecified)) or (prompt = '' ) or (prompt = tpu$k_unspecified) THEN RETURN prompt_list_status; ENDIF; ! ! If the routine succeeded, then the current value of value_out is the default ! value. If the routine failed, then we have no default_value. ! IF (prompt_list_status) THEN the_default_value := value_out; ELSE the_default_value := tpu$k_unspecified; ENDIF; ! ! We need to get the prompt string prepared for the dialog box. ! prompt_text := lse$get_message_text (prompt); the_prompt_string := prompt_text + lse$$end_prompt (prompt_text, lse$get_message_text (lse$_endprompt) ); ! ! Create the widget. We will create one of three different widgets whose only ! difference is the default pushbutton. ! IF the_default_value = tpu$k_unspecified THEN lse$create_dialog_box ("PROMPT_BOOLEAN", lse$x_prompt_boolean_widget); SET (WIDGET, GET_INFO (WIDGET, "WIDGET_ID", lse$x_prompt_boolean_widget, "PROMPT_BOOLEAN.PROMPT_BOOLEAN_LABEL"), eve$x_resource_array {eve$k_nlabel}, the_prompt_string); ELSE IF the_default_value THEN lse$create_dialog_box ("PROMPT_BOOLEAN_YES_DEF", lse$x_prompt_boolean_widget); SET (WIDGET, GET_INFO (WIDGET, "WIDGET_ID", lse$x_prompt_boolean_widget, "PROMPT_BOOLEAN_YES_DEF.PROMPT_BOOLEAN_LABEL"), eve$x_resource_array {eve$k_nlabel}, the_prompt_string); ELSE lse$create_dialog_box ("PROMPT_BOOLEAN_NO_DEF", lse$x_prompt_boolean_widget); SET (WIDGET, GET_INFO (WIDGET, "WIDGET_ID", lse$x_prompt_boolean_widget, "PROMPT_BOOLEAN_NO_DEF.PROMPT_BOOLEAN_LABEL"), eve$x_resource_array {eve$k_nlabel}, the_prompt_string); ENDIF; ENDIF; lse$$set_dialog_title (lse$x_prompt_boolean_widget); ! ! Manage the widget ! MANAGE_WIDGET (lse$x_prompt_boolean_widget); ! ! Dispatch events ! IF LSE$$BEGIN_EVENTS THEN ! ! Put the result in the value out parameter and return true. ! value_out := lse$x_prompt_boolean_value; if value_out = tpu$k_unspecified then return FALSE; else return TRUE; endif; ELSE ! ! Something in the architecture of event dispatching failed. Result is ! indeterminate. ! value_out := tpu$k_unspecified; return FALSE; ENDIF; ENDPROCEDURE; PROCEDURE lse$$cb_prompt_boolean_yes ! ! Routine called when okay pushed in prompt_string ! LOCAL dummy; ! ! Stop dispatching events ! LSE$$END_EVENTS; ! ! Delete the widget and return ! DELETE (lse$x_prompt_boolean_widget); ! ! Save the result ! lse$x_prompt_boolean_value := 1; ENDPROCEDURE; PROCEDURE lse$$cb_prompt_boolean_no ! ! Routine called when cancel pushed in prompt_string ! LOCAL dummy; ! ! Stop dispatching events ! LSE$$END_EVENTS; ! ! Delete the widget ! DELETE (lse$x_prompt_boolean_widget); ! ! Save the result ! lse$x_prompt_boolean_value := 0; ENDPROCEDURE; PROCEDURE lse$$cb_prompt_boolean_cancel ! ! Routine called when cancel pushed in prompt_boolean ! LOCAL dummy; ! ! Stop dispatching events ! LSE$$END_EVENTS; ! ! Delete the widget and return ! DELETE (lse$x_prompt_boolean_widget); ! ! Save the result ! lse$x_prompt_boolean_value := tpu$k_unspecified; ENDPROCEDURE; PROCEDURE lse$prompt_percent( value_in, value_out, prompt, percent_entered_flag ;novalue_msg, default_value ) ! FUNCTION: ! ! Prompts for a percentage or number. ! ! PARAMETERS: ! ! value_in - String, Of the form n or n% or "" ! If n then return int(n), percent_entered_flag false ! If n% then return int(n), percent_entered_flag true ! If "" then prompt ! Integer, return int(n), percent_entered_flag false ! ! value_out - Value entered ! ! prompt - String, used as prompt ! ! percent_flag_entered- Output, True when a "%" is entered as the last char ! False otherwise ! ! novalue_msg - Optional, message to use if no value is entered ! ! default_value - Optional, value to use if there is no value entered ! ! RETURN VALUE: ! ! True - Data valid ! False - Data illegal or prompt aborted ! ! !doc_begin ! ! ONE LINE DEFINITION: ! «TBS» ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! LOCAL return_value; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$prompt_percent"); ENDON_ERROR; ! ! Default the percent_entered_flag to FALSE ! percent_entered_flag := FALSE; ! ! Integer values in are short circuited to return that value without a percent. ! IF GET_INFO( value_in, 'type' ) = INTEGER THEN value_out := value_in; RETURN true; ENDIF; ! ! Prompt for the value. Note that all non-string/non-unspecified values will ! be given an error message from the prompt_string routine. ! return_value := lse$prompt_string( value_in, value_out, prompt, novalue_msg, default_value ) ; ! ! It either failed OR we're done ! IF return_value <> TRUE THEN RETURN return_value; ENDIF; RETURN lse$$parse_percent( value_out, value_out, percent_entered_flag); ENDPROCEDURE; ! Get a filename for repository access procedure lse$prompt_repository_filename (element_name, filename) local the_buffer; ! ...using element_name as buffer_name ! the_buffer := get_info(buffer, 'find_buffer', element_name); if the_buffer = 0 then if not lse$prompt_existing_file ( tpu$k_unspecified, ! always prompt filename, ! output filename lse$_filenameprompt, ! "File name" prompt eve$_nofilespec, ! "No file specified." error msg tpu$k_unspecified) ! default value then return false; endif; endif; ! ...input file, output file, then prompt ! filename := file_parse (get_info (the_buffer, 'file_name'),"","", node, device, directory, name, type); if filename = '' then filename := file_parse (get_info (the_buffer, 'output_file'),"","", node, device, directory, name, type); if filename = '' then if not lse$prompt_existing_file ( tpu$k_unspecified, ! always prompt filename, ! output filename lse$_filenameprompt, ! "File name" prompt eve$_nofilespec, ! "No file specified." error msg tpu$k_unspecified) ! default value then return false; endif; endif; endif; return true; endprocedure; PROCEDURE lse$prompt_string( value_in, value_out, prompt ;novalue_msg, default_value, decw_title, decw_array ) ! FUNCTION: ! ! Prompts for a string. If the input is tpu$k_unspecified, then we will ! always prompt. If the input is "", then we will take the default value. ! If there is no default value, then we will prompt. ! ! PARAMETERS: ! ! value_in - Input string ! ! value_out - Output, value entered or default_value. If the ! routine returns TRUE, then the caller is guaranteed ! that the datatype is either STRING or the datatype ! of the default value. ! ! prompt - Input string or message keyword, used as prompt ! ! novalue_msg - Optional, message to use if no value is entered ! ! default_value - Optional, value to use if there is no value entered ! ! decw_title - Optional, title if a dialog box is to be used ! ! decw_array - Optional, list if a selection box dialog is to be used ! ! RETURN VALUE: ! ! True - Data valid ! False - Data illegal or prompt aborted ! ! !doc_begin ! ! ONE LINE DEFINITION: ! «TBS» ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! LOCAL prompt_str, end_prompt, local_default_value, default_string, used_a_dialog_box; ON_ERROR [TPU$_READABORTED]: [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$prompt_string"); ENDON_ERROR; ! ! Initialize the result to unspecified after saving the default_value ! local_default_value := default_value; value_out := tpu$k_unspecified; ! ! We now prepare the default string for displaying ! CASE GET_INFO( local_default_value, 'type' ) [ STRING ]: default_string := local_default_value; [ INTEGER ]: default_string := str(local_default_value); [ UNSPECIFIED ]: default_string := ""; [ BUFFER ]: default_string := get_info(local_default_value, "name"); [ KEYWORD ]: default_string := lse$get_message_text( local_default_value ); [ LSE$ALIAS_TYPE, LSE$ADJUSTMENT_TYPE, LSE$LANGUAGE_TYPE, LSE$PACKAGE_TYPE, LSE$PLACEHOLDER_TYPE, LSE$ROUTINE_TYPE, LSE$PARAMETER_TYPE, LSE$TOKEN_TYPE ]: default_string := get_info(local_default_value, "lse$name"); [ LSE$PARAM_STRING_TYPE ]: default_string := get_info(local_default_value, "lse$param_string"); [ OTHERWISE ]: default_string := str(local_default_value); ENDCASE; ! ! This routine accepts only strings or unspecified as the input value. Strings ! that are not the null strings are processed and returned. If the input value ! is the null string and the output value is specified, then we are done. ! CASE GET_INFO( value_in, 'type' ) [ STRING ]: IF value_in = '' THEN IF local_default_value <> tpu$k_unspecified THEN value_out := default_string; RETURN TRUE; ENDIF; ELSE value_out := value_in; RETURN TRUE; ENDIF; [ UNSPECIFIED ]: [ OTHERWISE ]: eve$message(lse$_invalidtype, 0, STR( GET_INFO( value_in, 'type' ))); RETURN lse$_invalidtype; ENDCASE; ! ! We know at this point that the value_in is either unspecified or it is a null ! string, but we have no default value. Leave now if we have not been given a ! prompt. ! IF (prompt = '') OR (prompt = tpu$k_unspecified) THEN IF local_default_value = tpu$k_unspecified THEN RETURN FALSE; ELSE value_out := default_string; RETURN TRUE; ENDIF; ENDIF; ! ! Add the default value into the prompt string if there is a default value. ! prompt_str := lse$get_message_text( prompt ); end_prompt := lse$$end_prompt( prompt_str, lse$get_message_text( lse$_endprompt ) ); ! ! Only merge the default string in for non-DECwindows behavior ! if lse$use_dialog_box then used_a_dialog_box := TRUE; prompt_str := prompt_str + end_prompt; if decw_array = tpu$k_unspecified then lse$$prompt_string_decw (prompt_str, default_string, decw_title); else lse$$prompt_string_selection_decw ( prompt_str, default_string, decw_title, decw_array); endif else used_a_dialog_box := FALSE; if default_string <> '' then prompt_str := prompt_str + " [" + default_string + "]" + end_prompt; else prompt_str := prompt_str + end_prompt; endif; if lse$$x_use_keypad = lse$$k_pkeypad_vmslse then lse$$prompt_line ( prompt_str ); else lse$$prompt_line_status := lse$$prompt_string( prompt_str, lse$$prompt_line_string); endif; endif; ! ! Did we get something back? ! IF lse$$prompt_line_status <> TRUE THEN RETURN lse$$prompt_line_status; ENDIF; ! ! The result of the prompting is in a global variable. ! value_out := lse$$prompt_line_string; ! ! If the value is a null string, then we will return the default value. If the ! default value is unspecified, then we will also put out the no_value message. ! IF value_out = '' THEN value_out := default_string; IF local_default_value = tpu$k_unspecified THEN IF novalue_msg <> tpu$k_unspecified THEN eve$message( novalue_msg ); ENDIF; RETURN FALSE; ELSE IF used_a_dialog_box THEN ! ! Let the user know that we've used the default value, since ! they didn't enter one. ! IF default_string <> '' THEN eve$message( lse$_defvalused, 0, default_string); ENDIF; ENDIF; ENDIF; ENDIF; return TRUE; ENDPROCEDURE; PROCEDURE lse$$prompt_string_decw (prompt_str, default_string, title) LOCAL the_widget_label, the_widget_text, dummy; lse$create_dialog_box ("PROMPT_STRING", lse$x_prompt_string_widget); lse$$remove_help_button (lse$x_prompt_string_widget); ! ! Set the label widget inside of the dialog box to the prompt ! SET (WIDGET, lse$x_prompt_string_widget, "selectionLabelString", prompt_str); ! ! Set the dialog title if specified ! if title <> tpu$k_unspecified then SET (WIDGET, lse$x_prompt_string_widget, "dialogTitle", title); endif; ! ! Set the default value in the text field ! SET (WIDGET, lse$x_prompt_string_widget, "textString", default_string); lse$$set_dialog_title (lse$x_prompt_string_widget); ! ! Manage the widget ! MANAGE_WIDGET (lse$x_prompt_string_widget); lse$add_minimum_size_to_dialog (lse$x_prompt_string_widget); ! ! Dispatch events ! IF NOT LSE$$BEGIN_EVENTS THEN ! ! Something in the architecture of event dispatching failed. Result is ! indeterminate. ! lse$$prompt_line_string := ""; lse$$prompt_line_status := FALSE; ENDIF; ! ! We're done ! ENDPROCEDURE; PROCEDURE lse$$prompt_string_selection_decw ( prompt_str, default_string, title, list_array) LOCAL the_widget_label, the_widget_text, list, dummy; !on_error ! [OTHERWISE]: ! lse$post_command_proc; ! lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, ! "lse$$prompt_string_selection_decw"); !endon_error; lse$create_dialog_box ( "PROMPT_STRING_SELECTION", lse$x_prompt_string_selection_widget); lse$$remove_help_button (lse$x_prompt_string_selection_widget); lse$$remove_button(lse$x_prompt_string_selection_widget, "Apply"); ! ! Set the list ! list := CREATE_ARRAY; list {eve$x_resource_array {eve$k_nlist_items_count}}:= list_array; set (widget, lse$x_prompt_string_selection_widget, list); ! ! Set the label widget inside of the dialog box to the prompt ! SET (WIDGET, lse$x_prompt_string_selection_widget, "selectionLabelString", prompt_str); ! ! Set the dialog title if specified ! if title <> tpu$k_unspecified then SET (WIDGET, lse$x_prompt_string_selection_widget, "dialogTitle", title); endif; ! ! Set the default value in the text field ! SET (WIDGET, lse$x_prompt_string_selection_widget, "textString", default_string); lse$$set_dialog_title (lse$x_prompt_string_selection_widget); ! ! Manage the widget ! MANAGE_WIDGET (lse$x_prompt_string_selection_widget); lse$add_minimum_size_to_dialog (lse$x_prompt_string_selection_widget); ! ! Dispatch events ! IF NOT LSE$$BEGIN_EVENTS THEN ! ! Something in the architecture of event dispatching failed. Result is ! indeterminate. ! lse$$prompt_line_string := ""; lse$$prompt_line_status := FALSE; ENDIF; ! ! We're done ! ENDPROCEDURE; PROCEDURE lse$$cb_prompt_string_ok ! ! Routine called when okay pushed in prompt_string ! LOCAL status, dummy; ! ! Stop dispatching events ! LSE$$END_EVENTS; ! ! Get the text from the widget ! status := GET_INFO (lse$x_prompt_string_widget, "widget_info", "textString", lse$$prompt_line_string); ! ! Delete the widget and return ! DELETE (lse$x_prompt_string_widget); ! ! Show that we've succeeded. ! lse$$prompt_line_status := TRUE; ENDPROCEDURE; PROCEDURE lse$$cb_prompt_string_cancel ! ! Routine called when cancel pushed in prompt_string ! LOCAL dummy; ! ! Stop dispatching events ! LSE$$END_EVENTS; ! ! Delete the widget ! DELETE (lse$x_prompt_string_widget); ! ! Show that the prompting failed. ! lse$$prompt_line_string := ""; lse$$prompt_line_status := FALSE; ENDPROCEDURE; PROCEDURE lse$$cb_prompt_string_selection_ok ! ! Routine called when okay pushed in prompt_string ! LOCAL status, dummy; ! ! Stop dispatching events ! LSE$$END_EVENTS; ! ! Get the text from the widget ! status := GET_INFO (lse$x_prompt_string_selection_widget, "widget_info", "textString", lse$$prompt_line_string); ! ! Delete the widget and return ! DELETE (lse$x_prompt_string_selection_widget); ! ! Show that we've succeeded. ! lse$$prompt_line_status := TRUE; ENDPROCEDURE; PROCEDURE lse$$cb_prompt_string_selection_cancel ! ! Routine called when cancel pushed in prompt_string ! LOCAL dummy; ! ! Stop dispatching events ! LSE$$END_EVENTS; ! ! Delete the widget ! DELETE (lse$x_prompt_string_selection_widget); ! ! Show that the prompting failed. ! lse$$prompt_line_string := ""; lse$$prompt_line_status := FALSE; ENDPROCEDURE; PROCEDURE lse$prompt_search( value_in, value_out, prompt, novalue_msg, default_value, wildcard_flag ) ! FUNCTION: ! ! Prompts for a search string. The search prompt has various magics ! which make using lse$prompt_string impossible ! ! PARAMETERS: ! ! value_in - String ! ! value_out - Integer, index into the list of options, 1 based ! ! prompt - String or message keyword, used as prompt ! ! novalue_msg - Optional, message to use if no value is entered ! ! default_value - Optional, value to use if there is no value ! entered. This may either be a string or a ! message_text keyword. ! ! wildcard_flag - Is this a wildcard search prompt. Used to set ! the sense of the wildcard toggle in DECwindows ! ! RETURN VALUE: ! ! True - Data valid ! False - Prompt aborted ! lse$_invalidtype - Invalid input ! ! ! !doc_begin ! ! ONE LINE DEFINITION: ! «TBS» ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! LOCAL last_key_comment, local_default, local_prompt, invocation_key, status; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$prompt_search"); ENDON_ERROR; ! We're done if we get a value ! IF (value_in <> TPU$K_UNSPECIFIED) AND (value_in <> "" ) THEN value_out := value_in; RETURN TRUE; ENDIF; ! If we are to use the dialog box ! IF lse$use_dialog_box THEN lse$$widget_search( default_value, wildcard_flag ); RETURN false; ENDIF; ! Initialize the invocation key, that is the key use to get this started ! It will be used later to do FIND NEXT processing ! invocation_key := last_key; ! Init the prompt ! We need to init the prompt, because we can't allow lse$prompt_string ! do the defaulting because we need to know if the user entered anything. ! IF (default_value <> '') AND (GET_INFO( default_value, 'type' ) = STRING ) THEN local_prompt := lse$get_message_text( prompt ) + ' [' + default_value + ']' + lse$$end_prompt( lse$get_message_text( prompt ), lse$get_message_text( lse$_endprompt ) ); ELSE local_prompt := lse$get_message_text( prompt ) + lse$$end_prompt( lse$get_message_text( prompt ), lse$get_message_text( lse$_endprompt ) ); ENDIF; eve$clear_message; ! Loop on LSE$PROMPT_STRING to detect KP4/KP5 as response to the prompt ! LOOP ! Do the prompt ! status := lse$prompt_string(value_in, value_out, local_prompt, novalue_msg, '' ); IF NOT status THEN RETURN status; ENDIF; ! Special processing for KP4 and KP5 ! last_key_comment := eve$$lookup_comment( LAST_KEY, "" ); IF eve$test_synonym( "reverse", last_key_comment ) AND (lse$$key_legend( last_key ) = 'backup') THEN ! KP5, reverse entered ! lse_set_buffer_direction( REVERSE ); UPDATE( CURRENT_WINDOW ); ELSE IF eve$test_synonym( "forward", last_key_comment ) AND (lse$$key_legend( last_key ) = 'advance') THEN ! KP4, forward entered ! lse_set_buffer_direction( FORWARD ); UPDATE( CURRENT_WINDOW ); ENDIF; ENDIF; IF value_out = '' THEN ! Nothing entered ! IF (eve$test_synonym( "reverse", last_key_comment ) AND (lse$$key_legend( last_key ) = 'backup')) OR (eve$test_synonym( "forward", last_key_comment ) AND (lse$$key_legend( last_key ) = 'advance')) THEN ! More special KP4 and KP5 processing, ! If first key, prompt again ! ELSE ! Some other terminator ! IF (invocation_key = LAST_KEY) AND (NOT eve$test_synonym( "return", last_key_comment ) ) THEN ! FIND NEXT, i.e. ! value_out := 0; ELSE ! Normal termination ! value_out := default_value; ENDIF; RETURN TRUE; ENDIF; ELSE ! Something entered ! RETURN TRUE; ENDIF; ENDLOOP; ENDPROCEDURE; PROCEDURE lse$$key_legend( tpu_keyword ) LOCAL comm, topic, legend, remark, cmd; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$key_legend"); ENDON_ERROR; comm:= lookup_key(tpu_keyword, COMMENT); lse$$decode_key_comment(comm, topic, legend, remark, cmd); RETURN EDIT( legend, LOWER ); ENDPROCEDURE; PROCEDURE lse$prompt_list( value_in, value_out, prompt, valid_response_delimiter, valid_response, case_sensitive ;novalue_msg, default_value ) ! FUNCTION: ! ! Prompts for a list of options. ! ! PARAMETERS: ! ! value_in - String ! ! value_out - Integer, index into the list of options, 1 based ! ! prompt - String or message keyword, used as prompt ! ! valid_response_delimiter- String ! ! valid_response - String, responses separated with ! valid_response_delimiter. ! The delimiter must trail and lead each ! element. ! ! case_sensitive - True - The valid_response_delimiter and user input ! are untouched. ! False - The valid_response_delimiter and user input ! are UPPER ! novalue_msg - Optional, message to use if no value is entered ! ! default_value - Optional, value to use if there is no value ! entered. This may either be a string or a ! message_text keyword. ! ! RETURN VALUE: ! ! True - Data valid ! False - Prompt aborted ! lse$_invalidtype - Invalid input ! ! ! !doc_begin ! ! ONE LINE DEFINITION: ! «TBS» ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! LOCAL local_vr, local_vr_del, local_vr_len, local_value_in, local_value_out, the_message, return_value, start, temp_index, local_default_value; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$prompt_list"); ENDON_ERROR; ! Prepare the valid responses ! local_vr_del := lse$$cvt_vr_to_str( valid_response_delimiter ); local_vr := lse$$cvt_vr_to_str( valid_response ); local_vr_len := LENGTH( local_vr ); ! ! If case sensitive matches are not necessary, then uppercase the string ! IF case_sensitive <> TRUE THEN EDIT( local_vr, UPPER ); ENDIF; ! ! Map the default value from a keyword to a string if necessary ! if get_info (default_value, 'type') = keyword then local_default_value := lse$get_message_text (default_value); else local_default_value := default_value; endif; ! ! Default the procedures response to an unspecified input string ! value_out := tpu$k_unspecified; ! ! Initialize the local_value_in string and the user's type separation ! local_value_in := value_in; local_value_out := tpu$k_unspecified; ! ! Loop until we get a valid response or the user says to forget it. ! the_message := ''; LOOP ! ! Do the prompt ! return_value := lse$prompt_string( local_value_in, local_value_out, prompt, novalue_msg, local_default_value ); ! ! The user said to forget it or there was no default value or prompt. ! IF (return_value <> TRUE) THEN RETURN return_value; ENDIF; ! ! See if it is valid ! IF case_sensitive <> TRUE THEN EDIT( local_value_out, UPPER ); ENDIF; ! ! Do we have a match? ! start := INDEX( local_vr, local_vr_del + local_value_out ); IF start <> 0 THEN ! We found one ! IF INDEX( SUBSTR( local_vr, start+1, local_vr_len ), local_vr_del + local_value_out ) = 0 THEN ! It isn't ambigious ! figure out the response position and return ! value_out := 0; temp_index := 0; LOOP temp_index := INDEX( SUBSTR( local_vr, temp_index+1, local_vr_len ), local_vr_del ) + temp_index; value_out := value_out + 1; EXITIF temp_index >= start; ENDLOOP; RETURN TRUE; ELSE ! It IS ambigious ! the_message := MESSAGE_TEXT( lse$_ambigresponse ); ENDIF; ELSE temp_index := LENGTH(lse$$cvt_vr_to_str(valid_response_delimiter)); the_message := MESSAGE_TEXT( lse$_invalidresponse, 1, SUBSTR( lse$$cvt_vr_to_str(valid_response), temp_index + 1, LENGTH(lse$$cvt_vr_to_str(valid_response)) - temp_index * 2 ) ); ENDIF; ! Output the message ! IF the_message <>'' THEN eve$message( the_message ); ENDIF; ! There isn't any prompt so nothing will change, get out ! IF (prompt = '') OR (prompt = tpu$k_unspecified) THEN RETURN FALSE; ENDIF; ! If the value_in is invalid we need to change it so we will prompt ! local_value_in := tpu$k_unspecified; ENDLOOP; ENDPROCEDURE; PROCEDURE lse$list_extract( valid_response_delimiter, valid_response, element_number ); ! FUNCTION: ! ! Returns a element from the valid_response list ! ! PARAMETERS: ! ! valid_response_delimiter- String ! ! valid_response - String, responses separated with ! valid_response_delimiter. ! The delimiter must trail and lead each ! element. ! ! element_number - Integer, the element to return ! ! RETURN VALUE: ! ! The element ! !doc_begin ! ! ONE LINE DEFINITION: ! «TBS» ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! LOCAL local_vr, local_vr_del, local_vr_len, cur_element, temp_index; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$list_extract"); ENDON_ERROR; ! Prepare the valid responses ! local_vr_del := lse$$cvt_vr_to_str( valid_response_delimiter ); local_vr := lse$$cvt_vr_to_str( valid_response ); local_vr_len := LENGTH( local_vr ); ! It isn't ambigious ! figure out the response position and return ! cur_element := 0; temp_index := 0; LOOP temp_index := INDEX( SUBSTR( local_vr, temp_index+1, local_vr_len ), local_vr_del ) + temp_index; cur_element := cur_element + 1; EXITIF cur_element >= element_number; EXITIF temp_index >= local_vr_len - LENGTH( local_vr_del ); ENDLOOP; IF (cur_element = element_number) AND (temp_index <> local_vr_len - LENGTH( local_vr_del ) + 1) THEN RETURN SUBSTR( local_vr, temp_index + LENGTH( local_vr_del ), INDEX( SUBSTR( local_vr, temp_index+1, local_vr_len ), local_vr_del ) - LENGTH( local_vr_del )); ELSE EVE$MESSAGE( lse$_elmnotfnd, 0, element_number, cur_element ); RETURN ''; ENDIF; ENDPROCEDURE; procedure lse$$cvt_vr_to_str( value_in ) ! ! FUNCTION: ! ! Converts a valid response to a string ! ! PARAMETERS: ! ! value_in - String ! ! RETURN VALUE: ! ! converted value ! ! ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$cvt_vr_to_str"); ENDON_ERROR; CASE GET_INFO( value_in, 'type' ) [KEYWORD]: return lse$get_message_text( value_in ); [STRING]: return value_in; [OTHERWISE]: return STR( value_in ); ENDCASE; endprocedure; procedure lse$$parse_percent( value_in, value_out, percent_entered_flag) ! FUNCTION: ! ! Parses a numeric string and distinguishes n from n% ! ! PARAMETERS: ! ! value_in - String ! ! value_out - Value entered ! ! percent_entered_flag- TRUE when a % is the last character ! FLASE when there is no % as the last character ! ! RETURN VALUE: ! ! True - Data valid ! False - Data illegal or prompt aborted ! lse$_invalidtype- The value_in type is invalid ! lse$_invpercent - The value_in was outside 0 and 100 ! ! LOCAL local_value_in; ON_ERROR [TPU$_INVNUMSTR]: eve$message( ERROR_TEXT ); eve$learn_abort; RETURN ERROR; [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$parse_percent"); ENDON_ERROR; ! Initial type separation ! if value_in <> tpu$k_unspecified then local_value_in := value_in; else local_value_in := ''; endif; value_out := tpu$k_unspecified; CASE GET_INFO( local_value_in, 'type' ) [ STRING ]: [ OTHERWISE ]: eve$message(lse$_invalidtype, 0, STR( GET_INFO( local_value_in, 'type' ) ) ); RETURN lse$_invalidtype; ENDCASE; ! Now we have a string ! IF SUBSTR( local_value_in, LENGTH( local_value_in ), 1 ) = '%' THEN ! Last character is a % ! percent_entered_flag := TRUE; local_value_in := INT( SUBSTR( local_value_in, 1, LENGTH( local_value_in ) - 1 ) ); IF (local_value_in < 0) or (local_value_in > 100) THEN eve$message( lse$_invpercent, 0, STR( local_value_in ) ); RETURN lse$_invpercent; ENDIF; ELSE ! Straight up number or '' ! percent_entered_flag := FALSE; IF local_value_in = "" THEN eve$message( lse$_invpercent, 0, STR( local_value_in ) ); RETURN lse$_invpercent; ELSE local_value_in := INT( local_value_in ); IF local_value_in < 0 THEN eve$message( lse$_invpercent, 0, STR( local_value_in ) ); RETURN lse$_invpercent; ENDIF; ENDIF; ENDIF; value_out := local_value_in; RETURN true; ENDPROCEDURE; PROCEDURE lse$prompt_number ( number_in, number_out, prompt ;novalue_msg, default_value, min_value, max_value ) ! FUNCTION: ! ! Prompt for a number. ! ! PARAMETER: ! ! number_in - Read only. Integer, string or unspecified ! ! number_out - Returns valid prompt number. ! ! prompt - String or message keyword for prompting the user. ! ! novalue_msg - Optional, message to use if no value is entered ! ! default_value - Optional, value to use if provided. ! ! min_value - Optional, minimum acceptable value ! ! max_value - Optional, maximum acceptable value ! ! RETURN VALUE: ! ! TRUE - If prompt_number is valid ! RETURNED VALUE from lse$prompt_string - If prompt_number is invalid ! ! !doc_begin ! ! ONE LINE DEFINITION: ! «TBS» ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! LOCAL return_value; ON_ERROR [TPU$_INVNUMSTR]: eve$message( ERROR_TEXT ); eve$learn_abort; return false; [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$prompt_number "); ENDON_ERROR; ! ! If we have been given an integer, then return now. ! IF GET_INFO (number_in, "type") = INTEGER THEN number_out := number_in; return TRUE; ENDIF; ! ! Call lse$prompt_string to prompt the user. ! return_value := lse$prompt_string( number_in, number_out, prompt, novalue_msg, default_value); IF (return_value = TRUE) THEN number_out := INT ( number_out); ELSE return false; ENDIF; IF min_value <> TPU$K_UNSPECIFIED THEN IF number_out < min_value THEN eve$message ( lse$_lessthanmin, 0, number_out, min_value); return FALSE; ENDIF; ENDIF; IF max_value <> TPU$K_UNSPECIFIED THEN IF number_out > max_value THEN eve$message ( lse$_morethanmax, 0, number_out, max_value); return FALSE; ENDIF; ENDIF; RETURN return_value; endprocedure; ! end lse$prompt_number. procedure lse$prompt_existing_buffer (buffer_name_or_ptr, buffer_ptr_out, prompt; novalue_msg, default_buffer) ! lse$prompt_existing_buffer ! ! Function: ! return a pointer to a buffer, given either a pointer to a buffer, ! a buffer name string, or a name entered by the user. ! ! Description: ! ! this procedure returns a pointer to an buffer given a pointer to a buffer ! or a string containing the name of an existing buffer. If the pointer is ! a null string, then the user is prompted for the name of the ! buffer using the prompt parameter. If the prompt parameter ! is null, or if the user doesn't enter a buffer name, then the ! default_buffer_ptr is returned. (If the prompt string is null, the user ! will not be prompted.) If the buffer specified (by the user or ! by the calling routine) doesn't exist, then 0 is returned. ! ! Parameters: ! ! buffer_name_or_ptr: a pointer the desired buffer or a string ! containing the name of the desired buffer; ! or a null string. ! buffer_ptr_out: returns buffer_pointer ! prompt: string or message keyword to use in prompting ! the user to enter a buffer name; ! if prompt is 0 then ! the user will not be prompted. ! novalue_msg: Optional, message to use if no value is entered ! default_buffer_ptr: Optional pointer to the buffer or buffer name ! to be returned if no other buffer is specified ! ! Return Value: ! true if a valid pointer is returned ! buffer_ptr_out: pointer to a buffer; or 0 ! ! NOTE: get_info/find-buffer should be replaced with a routine that ! handles ABBREVIATIONS and CASE SENSITIVITY ! !doc_begin ! ! ONE LINE DEFINITION: ! «TBS» ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! local temp_buffer_name, buffer_name, loop_buffer, how_many_user_buffers, return_value, status, the_upcase_name; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$prompt_existing_buffer "); ENDON_ERROR; ! ! If buffer_name_or_ptr is a pointer then just return that pointer ! IF get_info(buffer_name_or_ptr, "type") = BUFFER THEN buffer_ptr_out := buffer_name_or_ptr; RETURN TRUE; ENDIF; ! ! Since we are not passing the users variable directly to the prompt routine, ! then default it to unspecified. ! buffer_ptr_out := tpu$k_unspecified; ! ! Prompt for the buffer name ! return_value := lse$prompt_string (buffer_name_or_ptr, buffer_name, prompt, novalue_msg, default_buffer); ! ! If the prompt failed, then return that status value. ! IF return_value <> true THEN RETURN return_value; ENDIF; ! ! The result is of type string. Find the buffer given the name. ! status := lse$get_buffer (buffer_name, buffer_ptr_out); ! Prompt for ambigious ! IF status = lse$_ambigbufnam THEN ! Use the scratch buffer for the prompt ! lse$$push_position; eve$$reserve_scratch_buffer; POSITION( eve$$x_scratch_buffer ); ERASE( CURRENT_BUFFER ); SPLIT_LINE; ! Upcase the buffer name ! the_upcase_name := buffer_name; change_case(the_upcase_name, upper); ! Walk over the buffers looking for the buffers that match ! loop_buffer := GET_INFO( BUFFERS, "last" ); LOOP ! Done ! EXITIF loop_buffer = 0; ! Upcase the name ! temp_buffer_name := GET_INFO( loop_buffer, "name" ); CHANGE_CASE( temp_buffer_name, upper ); ! Wildcard match ! IF (lse$$strmatch_wild( temp_buffer_name, the_upcase_name )) OR (SUBSTR(temp_buffer_name,1,LENGTH(the_upcase_name))=the_upcase_name) THEN IF GET_INFO( loop_buffer, 'system' ) THEN POSITION( BUFFER_END ); COPY_TEXT( ' ' ); COPY_TEXT( GET_INFO(loop_buffer, "name") ); ELSE how_many_user_buffers := how_many_user_buffers + 1; POSITION( BUFFER_BEGIN ); COPY_TEXT( ' ' ); COPY_TEXT( GET_INFO(loop_buffer, "name") ); SPLIT_LINE; ENDIF; ENDIF; ! Next ! loop_buffer := GET_INFO( BUFFERS, "previous" ); ENDLOOP; ! When there are multiple user buffers we only show them ! POSITION( BUFFER_BEGIN ); IF how_many_user_buffers > 1 THEN ! Remove system buffers ! LOOP EXITIF GET_INFO( CURRENT_BUFFER, 'record_number' ) >= GET_INFO( CURRENT_BUFFER, 'record_count' ); IF CURRENT_LINE = '' THEN ERASE( CREATE_RANGE( MARK( NONE ), BUFFER_END ) ); EXITIF true; ENDIF; MOVE_VERTICAL( 1 ); ENDLOOP; ELSE ! Remove blank lines ! LOOP EXITIF GET_INFO( CURRENT_BUFFER, 'record_number' ) >= GET_INFO( CURRENT_BUFFER, 'record_count' ); IF CURRENT_LINE = '' THEN ERASE_LINE; ENDIF; MOVE_VERTICAL( 1 ); ENDLOOP; ENDIF; POSITION( BUFFER_BEGIN ); lse$$pop_position; IF lse$prompt_list_buffer( eve$$x_scratch_buffer ) THEN status := lse$get_buffer( EDIT( GET_INFO( eve$$x_scratch_buffer, 'line' ), TRIM), buffer_ptr_out ); eve$$release_scratch_buffer; return true; ELSE eve$$release_scratch_buffer; return false; ENDIF; ENDIF; ! ! Buffer entered was ambiguous or invalid, issue returned error message ! IF status <> true THEN EVE$MESSAGE (status, 0, buffer_name); RETURN false; ENDIF; return true; endprocedure; ! lse$prompt_existing_buffer procedure lse$prompt_create_buffer (buffer_name_or_ptr, buffer_ptr_out, prompt; novalue_msg, default_buffer) ! lse$prompt_create_buffer ! ! Function: ! return a pointer to a buffer, given either a pointer to a buffer, ! a buffer name string, or a name entered by the user. ! ! Description: ! ! this procedure returns a pointer to a buffer given a pointer to a buffer ! or a string containing the name of a existing buffer. If the pointer is ! a null string, then the user is prompted for the name of the ! buffer using the prompt parameter. If the prompt parameter ! is null, or if the user doesn't enter a buffer name, then the ! default_buffer_ptr is returned. (If the prompt string is null, the user ! will not be prompted.) If the buffer specified (by the user or ! by the calling routine) doesn't exist, then the buffer is created ! with the name given, and a pointer to that buffer is returned. ! ! Parameters: ! ! buffer_name_or_ptr: a pointer the desired buffer or a string ! containing the name of the desired buffer; ! or a null string. ! buffer_ptr_out: returns buffer_pointer ! prompt: string or message keyword to use in prompting ! the user to enter a buffer name; ! if prompt is 0 then ! the user will not be prompted. ! novalue_msg: Optional, message to use if no value is entered ! default_buffer_ptr: Optional pointer to the buffer or buffer name ! to be returned if no other buffer is specified ! ! Return Value: ! true if a valid pointer is returned ! buffer_ptr_out: pointer to a buffer; or 0 ! ! !doc_begin ! ! ONE LINE DEFINITION: ! «TBS» ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! local return_value, buffer_name; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$prompt_create_buffer"); ENDON_ERROR; ! ! If buffer_name_or_ptr is a pointer then just return that pointer ! if get_info (buffer_name_or_ptr, "type") = BUFFER then buffer_ptr_out := buffer_name_or_ptr; return TRUE; endif; ! ! Default the users output variable to unspecified ! buffer_ptr_out := tpu$k_unspecified; ! ! Prompt for the buffer name ! return_value := lse$prompt_string (buffer_name_or_ptr, buffer_name, prompt, novalue_msg, default_buffer); ! ! If we did not succeed, then return. ! IF return_value <> true THEN RETURN return_value; ENDIF; ! ! Find a buffer with the exact match and return that if found ! buffer_ptr_out := GET_INFO (BUFFER, 'FIND_BUFFER', buffer_name); IF buffer_ptr_out <> 0 THEN RETURN true; ENDIF; ! ! Create a user buffer ! buffer_ptr_out := lse$create_buffer_util (buffer_name); set(NO_WRITE, buffer_ptr_out); ! ! If that succeeded, then return true. ! IF buffer_ptr_out <> 0 THEN RETURN true; ELSE RETURN false; ENDIF; endprocedure; ! lse$prompt_create_buffer procedure lse$find_buffer (buffer_name) ! ! Function: looks up a buffer and returns either zero or the buffer_ptr ! ! !doc_begin ! ! ONE LINE DEFINITION: ! «TBS» ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! LOCAL buffer_ptr; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$find_buffer "); ENDON_ERROR; if lse$get_buffer (buffer_name, buffer_ptr) = TRUE then return buffer_ptr; else return 0; endif; endprocedure; procedure lse$$existing_buffer_jacket( buffer_name ) ! ! Function: returns full buffer name if it exists ! ! Description: if a valid buffer name, or initial substring of a valid buffer ! name is given, the return value will be the full buffer name. ! If the substring given was not unique the ambiguous error message ! lse$_ambigbufnam will be output. If no buffers are found, then ! the original string is returned to the caller. ! Parameters: ! buffer_name - string ! ! Return values: ! String, full buffer name or same buffer name ! String, '' error was output ! LOCAL the_buffer; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$get_cli_buffer "); ENDON_ERROR; IF lse$prompt_existing_buffer( buffer_name, the_buffer, '', '', '' ) THEN return GET_INFO( the_buffer, 'name' ); ELSE return ''; ENDIF; endprocedure; PROCEDURE lse$prompt_key(value_in, value_out, prompt); ! FUNCTION: ! ! Prompt for a number. ! ! PARAMETERS: ! ! keyname - Name of key ! ! RETURN VALUE: ! ! TRUE - If keyname is valid ! RETURNED VALUE from lse$prompt_string - If keyname is invalid ! ! !doc_begin ! ! ONE LINE DEFINITION: ! «TBS» ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! LOCAL substring_of_key, positionof_key, tpu_keyname, the_response, unparsed_string; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$prompt_key"); ENDON_ERROR; ! Initial type separation ! CASE GET_INFO( value_in, 'type' ) [ KEYWORD ]: value_out := value_in; return true; [ STRING ]: if value_in = '' then if lse$prompt_string( value_in, the_response, prompt, lse$_nokeygiven) then unparsed_string := the_response else return false endif else unparsed_string := value_in endif; [ UNSPECIFIED ]: if lse$prompt_string( value_in, the_response, prompt, lse$_nokeygiven) then unparsed_string := the_response else return false endif; [ OTHERWISE ]: eve$message(lse$_invalidtype, 0, STR( GET_INFO( value_in, 'type' ) ) ); RETURN lse$_invalidtype; ENDCASE; unparsed_string := edit(unparsed_string, UPPER, OFF); tpu_keyname := eve$$parse_keystring(unparsed_string); ! ! If we've got the key name, then we are done ! if get_info (tpu_keyname, 'type') = keyword then value_out := tpu_keyname; return true; endif; ! ! If this key name is supported by EVE, for example CTRL_A_KEY, then let's ! try to parse it ourselves. ! positionof_key := index(unparsed_string, "_KEY"); if positionof_key <> 0 then if positionof_key = length(unparsed_string)-3 then substring_of_key := substr(unparsed_string, 1, positionof_key - 1); tpu_keyname := eve$$parse_keystring(substring_of_key); if tpu_keyname <> 0 then value_out := tpu_keyname; return true endif endif endif; eve$message (lse$_badkeyname, 0, str(unparsed_string)); return false; ENDPROCEDURE PROCEDURE lse$prompt_existing_file (value_in, value_out, prompt; novalue_msg, default_value, decw_title, decw_dirmask, fao_command) ! ! FUNCTION: ! ! Prompt for an existing file specification. Since the user can type the ! response, there is no guarentee that the file actually exists or that it ! is accessible. ! ! PARAMETERS: ! ! value_in - text passed by the user. (unspecified, "", or "string") ! value_out - the resultant string valid if the routine returns true ! prompt - the prompt to use to obtain the information ! novalue_msg - the message to display if no value is selected ! default_value - the default value to display or return ! decw_title - the dialog box title if necessary ! decw_dirmask - the wildcarded file spec used to show initial list ! fao_command - faoed with filespec and executed asynchronously ! ! ! RETURN VALUE: ! ! TRUE - value_out contains a value to be processed ! FALSE - value_out does not contain a value (may have mapped dialog box) ! ! !doc_begin ! ! ONE LINE DEFINITION: ! «TBS» ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! LOCAL status, current_dirmask, dialog_created, the_widget, local_title; ON_ERROR [OTHERWISE]: eve$message( ERROR_TEXT ); eve$learn_abort; abort; ENDON_ERROR; ! ! Determine if any prompting should take place at all. ! IF value_in <> tpu$k_unspecified THEN IF value_in = "" THEN IF default_value <> tpu$k_unspecified THEN value_out := default_value; RETURN true; ENDIF; ELSE value_out := value_in; RETURN true; ENDIF; ENDIF; ! ! Handle non-DECwindows input or synchronous DECwindows input (temporarily) ! IF (not lse$use_dialog_box) or (fao_command = tpu$k_unspecified) THEN RETURN lse$prompt_string (value_in, value_out, prompt, novalue_msg, default_value); ENDIF; IF lse$x_file_selection_widget_array = tpu$k_unspecified THEN lse$x_file_selection_widget_array := create_array; ENDIF; if decw_title = tpu$k_unspecified then local_title := ""; else local_title := decw_title; endif; ! ! We want to create an instance of the generic_file_selection widget. We do ! not call EVE$MANAGE_WIDGET because we want to fill in the title and the ! help frame before doing so. ! the_widget := lse$x_file_selection_widget_array {local_title}; dialog_created := lse$create_dialog_box ("PROMPT_EXISTING_FILE", the_widget); if dialog_created then lse$x_file_selection_widget_array {local_title} := the_widget; ! ! Set the default specification if provided. ! IF decw_dirmask <> tpu$k_unspecified THEN SET (WIDGET, the_widget, eve$x_resource_array {eve$k_ndirmask}, decw_dirmask); ELSE SET (WIDGET, the_widget, eve$x_resource_array {eve$k_ndirmask}, lse$x_file_selection_dirmask); ENDIF; lse$$set_dialog_title (the_widget, decw_title); MANAGE_WIDGET (the_widget); lse$add_minimum_size_to_dialog (the_widget); else ! Using the current file filter in the file selection box, force a ! re-evaluation so the dialog box reflects the current contents of the ! directory. ! status := GET_INFO (the_widget, "widget_info", eve$x_resource_array {eve$k_ndirmask}, current_dirmask); SET (WIDGET, the_widget, eve$x_resource_array {eve$k_ndirmask}, current_dirmask); MANAGE_WIDGET (the_widget); endif; ! Update the FAO command and novalue message even if the widget already ! existed, since these values may be different than when the ! widget was first created. lse$$menus_associate_command (the_widget, fao_command); ! ! Save the novalue message to be used on the other side. ! IF lse$x_novalue_msg_array = tpu$k_unspecified THEN lse$x_novalue_msg_array := create_array; ENDIF; lse$x_novalue_msg_array {the_widget} := novalue_msg; ! ! We've mapped the dialog box. ! RETURN false; ENDPROCEDURE; PROCEDURE lse$$prompt_existing_file_handler ! ! Routine called when okay/cancel in asynchronous prompt_existing_file ! LOCAL status, the_command, ! The command to execute file_spec; ! The name of the file to open ! ! Unmanage the dialog box ! eve$unmanage_widget (eve$x_widget); ! If the user pressed the OKAY button, then get the file_spec. ! IF eve$x_widget_reason = eve$x_callback_array {eve$k_cr_ok} THEN status := GET_INFO (eve$x_widget, "widget_info", eve$x_resource_array {eve$k_ndirspec}, file_spec); ELSE file_spec := ""; ENDIF; ! ! Either issue a novalue_msg or process the FAOed command ! IF file_spec = "" THEN IF lse$x_novalue_msg_array {eve$x_widget} <> tpu$k_unspecified THEN eve$message ( lse$x_novalue_msg_array {eve$x_widget}); ENDIF; ELSE execute( eve$$parse(FAO (lse$$menus_get_associated_command (eve$x_widget), file_spec)) ); ENDIF; RETURN; ENDPROCEDURE; PROCEDURE lse$prompt_language (language_name_or_obj, language_out, prompt; novalue_msg, default_language) ! lse$prompt_language ! ! Function: ! return a language, given either a language, ! a language name string, or a name entered by the user. ! ! Description: ! ! this procedure returns a language object to a given a language object ! or a string containing the name of an existing buffer. If the pointer is ! a null string, then the user is prompted for the name of the ! language using the prompt parameter. If the prompt parameter ! is null, or if the user doesn't enter a buffer name, then the ! default_language is returned. (If the prompt string is null, the user ! will not be prompted.) If the language specified (by the user or ! by the calling routine) doesn't exist, then 0 is returned. ! ! Parameters: ! ! language_name_or_obj: a language or a string ! containing the name of the desired language; ! or a null string. ! language_out: returns language ! prompt: string or message keyword to use in prompting ! the user to enter a language name; ! if prompt is 0 then ! the user will not be prompted. ! novalue_msg: Optional, message to use if no value is entered ! default_language: Optional language object or language name ! to be returned if no other language is specified ! ! Return Value: ! true if a valid pointer is returned ! language_out: language object; or 0 ! !doc_begin ! ! ONE LINE DEFINITION: ! «TBS» ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! LOCAL return_value, language_name; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$prompt_language"); ENDON_ERROR; ! ! If language_name_or_obj is a pointer then just return that pointer ! IF get_info(language_name_or_obj, "type") = lse$language_type THEN language_out := GET_INFO( language_name_or_obj, 'lse$name' ); RETURN TRUE; ENDIF; ! ! Prompt for the language name ! return_value := lse$prompt_string (language_name_or_obj, language_name, prompt, novalue_msg, default_language); ! ! If the prompt failed, then return that status value. ! if return_value <> true then return return_value; endif; ! ! The result is of type string. Find the language given the name. ! language_out := GET_INFO( lse$system, 'lse$find_language', language_name ); ! ! Language was invalid, issue returned error message ! IF language_out = 0 THEN EVE$MESSAGE (lse$_langnotdef, 0, language_name); RETURN false; ENDIF; ! ! We got a language ! return true; ENDPROCEDURE; ! lse$prompt_language PROCEDURE lse$prompt_lang_pack (lang_pack_name_or_obj, lang_pack_out, prompt, lang_pack_kwd; novalue_msg, default_lang_pack) ! lse$prompt_lang_pack ! ! Function: ! Given either a language or package name or object, returns a language ! or package object. ! ! Description: ! ! Given either a language or package name or object, this procedure returns a ! language or package object depending on the language or package type ! specified. If input name is unspecified, the user is prompted for the name of ! the language or package. If a null string is entered, the default language or ! package is returned if a default value has been entered. If no default can be ! found or the language or package specified don't exist, a value of 0 is ! returned. ! ! Parameters: ! ! lang_pack_name_or_obj: A language or package name or ! A language or package object or ! A null string. ! ! lang_pack_out: Returns a language or package object depending ! on language or package type specified. ! ! prompt: String or message keyword use for prompting ! the user to enter a language or package name. ! If this value is not specified, then the user ! will not be prompted. ! ! lang_pack_kwd: Specify language or package type used. ! ! novalue_msg: Optional. Message to use if no value is entered. ! ! default_lang_pack: Optional language/package name or object to be ! returned if no language or package is specified ! ! Return Value: ! TRUE if a valid object is returned ! lang_pack_out: language or package object if found. ! 0 if no language or package object found. ! !doc_begin ! ! ONE LINE DEFINITION: ! «TBS» ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! LOCAL lang_pack_notdef_msg, find_type_str, lang_pack_name, prompt_status, type_keyword; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$prompt_lang_pack" ); ENDON_ERROR; ! Determine the "find type string" and "element type message" for language ! or package ! lse$get_lang_elem_message(lang_pack_kwd, find_type_str,,,, lang_pack_notdef_msg,); CASE lang_pack_kwd [ LSE$LANGUAGE, LSE$PACKAGE ]: CASE get_info(lang_pack_name_or_obj, "type") [ LSE$LANGUAGE_TYPE, LSE$PACKAGE_TYPE ]: lang_pack_out := lang_pack_name_or_obj; return true; [ STRING ]: ; [ UNSPECIFIED ]: ! If upspecified, try to take default lang_pack_name_or_obj := ""; [ OTHERWISE ]: return false; ! type mismatch ENDCASE; [ OTHERWISE ]: return false; !invalid type unsupported ENDCASE; ! Prompt for the language or package name ! prompt_status := lse$prompt_string ( lang_pack_name_or_obj, lang_pack_name, prompt, novalue_msg, default_lang_pack ); ! If the prompt failed, then return that status value. ! if prompt_status <> true then return prompt_status; endif; ! The result is of type string. Find the language or package from its name. ! lang_pack_out := get_info( lse$system, find_type_str, lang_pack_name ); if lang_pack_out <> 0 then return TRUE; ! We got a language/package object else eve$message( lang_pack_notdef_msg, 0, lang_pack_name ); return FALSE; endif; ENDPROCEDURE; ! lse$prompt_lang_pack PROCEDURE lse$prompt_add_remove(value_in, value_out, prompt ;novalue_msg, default_value ) ! FUNCTION: ! ! Prompts for the string "add" or "remove", returns true if add, false if ! remove ! ! PARAMETERS: ! ! value_in - String, Integer, or Keywords ON/OFF ! ! value_out - Integer, one or zero ! ! prompt - String or message keyword, used as prompt ! ! novalue_msg - Optional, message to use if no value is entered ! ! default_value - Optional string, value to use if there is ! no value entered ! ! RETURN VALUE: ! ! Values returned by LSE$PROMPT_LIST ! !doc_begin ! ! ONE LINE DEFINITION: ! «TBS» ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! local return_value; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$prompt_add_remove"); ENDON_ERROR; ! ! If the input value is an integer, then return true or false without prompting. ! IF GET_INFO (value_in, 'type') = INTEGER THEN value_out := value_in AND 1; return TRUE; ENDIF; ! ! If the input value is the kwrd_on, then return true without prompting ! IF value_in = ON THEN value_out := 1; return TRUE; ENDIF; ! ! If the input value is the kwrd_off, then return false without prompting ! IF value_in = OFF THEN value_out := 0; return TRUE; ENDIF; return_value := lse$prompt_list ( value_in, value_out, prompt, lse$_addremovedelimit, lse$_addremovelist, FALSE, novalue_msg, default_value ); ! ! If that routine returned true, then set the value_out to 1 or 0. ! Because prompt_list uses 1 base, subtract 1. ! IF return_value = TRUE THEN value_out := value_out AND 1; ENDIF; RETURN return_value; ENDPROCEDURE; procedure lse$prompt_lang_elem_param (element_name, language_name, lang_elem_kwd, the_element_name, the_lang_name) ! FUNCTION: ! ! This function gets the language name and the language element name using ! the lse$prompt_language and lse$prompt_string routines. It then validates ! that the language exists. ! ! Parameters: ! ! element_name - Name of language element ! ! language_name - Name of language ! ! lang_elem_kwd - Keyword indicating type of language element to check ! if it is associated with the language. ! ! the_element_name - Language element to be returned ! ! the_lang_name - Language to be returned ! ! Return Value: ! ! True - We have a valid language object and a language element name. ! False - We don't have a language object and language element name ! !doc_begin ! ! ONE LINE DEFINITION: ! «TBS» ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! LOCAL prompt_str, no_value_str, type_keyword; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$prompt_lang_elem_param"); ENDON_ERROR; ! Determine the default prompt and no value message for various language ! element type ! lse$get_lang_elem_message(lang_elem_kwd,,, prompt_str, no_value_str,, type_keyword); ! Get out if we've been passed a real one ! if get_info( element_name, 'type' ) = type_keyword then the_element_name := get_info( element_name, 'name' ); the_lang_name := get_info( get_info( element_name, 'lse$language_type' ), 'name' ); return TRUE; endif; ! First get the language element name ! if lse$prompt_string( element_name, the_element_name, prompt_str, no_value_str, lse$get_curr_lang_element(lang_elem_kwd) ) then ! Now get the language name. If no language is specified, default to ! the current definition language is there is one. Otherwise, we will ! prompt for a language ! if (language_name = tpu$k_unspecified) then language_name := ""; endif; if lse$prompt_string( language_name, the_lang_name, lse$_langnamprompt, lse$_langnoval, lse$get_curr_lang_element(LSE$LANGUAGE) ) then ! We have a language name. Return true. ! return TRUE; endif; else endif; ! Something wrong with the prompting. Return false ! return FALSE; endprocedure; ! lse$prompt_lang_elem_param procedure lse$prompt_lang_pack_elem_param (element_name, lang_elem_kwd, lang_pack_name, lang_pack_kwd, the_element_name, the_lang_pack_name) ! FUNCTION: ! ! This function gets the language/package name and the language/package ! element name using the lse$prompt_lang_pack and lse$prompt_string routines. ! It then validates that the language/package exists. ! ! Parameters: ! ! element_name - Name of language element ! ! lang_elem_kwd - Keyword indicating type of language/package element to ! be checked. Keyword supported: ! Language: ! LSE$ALIAS ! LSE$ADJUSTMENT ! LSE$PLACEHOLDER ! LSE$TOKEN ! Package: ! LSE$ROUTINE ! ! lang_pack_name - Name of language or package ! ! lang_pack_kwd - Keyword indicating language or package type for the ! parameter lang_pack_name. Keyword supported: ! LSE$LANGUAGE ! LSE$PACKAGE ! ! the_element_name - Language/Package element name to be returned ! ! the_lang_pack_name - Language/Package name to be returned ! ! Return Value: ! ! True - We have a valid language object and a language element name. ! False - We don't have a language object and language element name ! !doc_begin ! ! ONE LINE DEFINITION: ! «TBS» ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! LOCAL find_type_str, lang_pack_type_kwd, lang_pack_prompt_str, lang_pack_notdef_msg, lang_pack_noval_msg, prompt_str, no_value_str, type_keyword; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$prompt_lang_pack_elem_param"); ENDON_ERROR; ! Determine the default prompt and no value message for ! various language/package element types ! lse$get_lang_elem_message(lang_elem_kwd,,, prompt_str, no_value_str,, type_keyword); ! Determine the "prompt string", "no value message" and "type keyword" ! for language or package type ! lse$get_lang_elem_message(lang_pack_kwd, find_type_str,, lang_pack_prompt_str, lang_pack_noval_msg, lang_pack_notdef_msg, lang_pack_type_kwd); ! If we've been passed a 'live' element, query it and return the name strings ! if get_info (element_name, 'type') = type_keyword then the_element_name := get_info (element_name, 'lse$name'); the_lang_pack_name := get_info (get_info (element_name, str (lang_pack_type_kwd)),'lse$name'); return TRUE; endif; ! First get the language/package element name. ! If the element_name is unspecified, prompt. ! if lse$prompt_string( element_name, the_element_name, prompt_str, no_value_str, lse$get_curr_lang_element(lang_elem_kwd)) then ! Now get the language/package name. If unspecified, ! default to 'current'. If 'current' is unspecified, prompt. ! if lang_pack_name = tpu$k_unspecified then lang_pack_name := ""; endif; if lse$prompt_string( lang_pack_name, the_lang_pack_name, lang_pack_prompt_str, lang_pack_noval_msg, lse$get_curr_lang_element(lang_pack_kwd)) then return TRUE; ! got a valid lang/pack name and an element name. endif; endif; return FALSE; ! Something wrong with the prompting. Return false endprocedure; ! lse$prompt_lang_pack_elem_param PROCEDURE lse$prompt_depth( value_in, value_out, prompt ;novalue_msg, default_value ) ! FUNCTION: ! ! Prompts for a depth ! ! PARAMETERS: ! ! value_in - String, Integer ! ! value_out - Integer ! ! prompt - String or message keyword, used as prompt ! ! novalue_msg - Optional, message to use if no value is entered ! ! default_value - Optional, value to use if there is ! no value entered ! ! RETURN VALUE: ! ! Values returned by LSE$PROMPT_STRING ! !doc_begin ! ! ONE LINE DEFINITION: ! «TBS» ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! local the_default_value, return_value; ON_ERROR [TPU$_NULLSTRING, TPU$_INVNUMSTR]: ! They might have entered "ALL" ! value_out := EDIT( value_out, UPPER ); IF INDEX( 'ALL', value_out ) = 1 THEN value_out := 9999; return true; ENDIF; eve$message( lse$_invdepth ); eve$learn_abort; return false; [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$prompt_depth"); ENDON_ERROR; ! ! If the input value is an integer, then return true or false without prompting. ! IF GET_INFO (value_in, 'type') = INTEGER THEN value_out := value_in; return TRUE; ENDIF; return_value := lse$prompt_string ( value_in, value_out, prompt, novalue_msg, default_value ); IF return_value = TRUE THEN value_out := INT( value_out ); ENDIF; RETURN return_value; ENDPROCEDURE; procedure lse$get_buffer (buffer_name, buffer_ptr_out) ! ! Function: returns a pointer to a buffer given the name of a buffer or ! a unique initial substring. ! ! Description: if a valid buffer name, or initial substring of a valid buffer ! name is given, buffer_ptr_out will point to a buffer. If ! the substring given was not unique the ambiguous error message ! lse$_ambigbufnam will be returned. If no buffers are found, ! lse$_buffnotexist will be returned. ! Parameters: ! buffer_name - string ! buffer_ptr_out - buffer ! ! Return values: ! true - buffer found, buffer_ptr_out is valid buffer_ptr ! lse$_buffnotexist - buffer not found ! lse$_ambigbufnam - buffer substring not unique; more than one buffer found ! !doc_begin ! ! ONE LINE DEFINITION: ! «TBS» ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! LOCAL the_upcase_name, how_many_wild_buffers, how_many_left_buffers, last_buffer, loop_buffer, loop_buffer_name, possible_left_buffer, possible_wild_buffer, temp_buffer_name, upcase_loop_name; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$get_buffer"); ENDON_ERROR; ! Exact match ! buffer_ptr_out := get_info (BUFFERS,"find_buffer",buffer_name); if buffer_ptr_out <> 0 then return true; endif; the_upcase_name := buffer_name; change_case(the_upcase_name, upper); ! Case insensitive exact match ! last_buffer := GET_INFO(BUFFERS, "last"); loop_buffer := GET_INFO(BUFFERS, "first"); LOOP loop_buffer_name := GET_INFO(loop_buffer, "name"); upcase_loop_name := loop_buffer_name; change_case (upcase_loop_name, upper); if upcase_loop_name = the_upcase_name THEN buffer_ptr_out := loop_buffer; return true; ENDIF; EXITIF loop_buffer = last_buffer; loop_buffer := GET_INFO(BUFFERS, "next"); ENDLOOP; ! Case insensitive wildcard match ! loop_buffer := GET_INFO(BUFFERS, "first"); LOOP temp_buffer_name := GET_INFO(loop_buffer, "name"); change_case(temp_buffer_name, upper); ! Wildcard match ! IF lse$$strmatch_wild( temp_buffer_name, the_upcase_name ) THEN possible_wild_buffer := loop_buffer; how_many_wild_buffers := how_many_wild_buffers + 1; ENDIF; ! Left match ! IF SUBSTR(temp_buffer_name, 1, LENGTH(the_upcase_name)) = the_upcase_name THEN possible_left_buffer := loop_buffer; how_many_left_buffers := how_many_left_buffers + 1; ENDIF; EXITIF loop_buffer = last_buffer; loop_buffer := GET_INFO(BUFFERS, "next"); ENDLOOP; ! One left ! IF how_many_left_buffers = 1 THEN buffer_ptr_out := possible_left_buffer; return true; endif; ! One wildcard ! IF how_many_wild_buffers = 1 THEN buffer_ptr_out := possible_wild_buffer; return true; endif; ! Ambigious ! if (how_many_wild_buffers > 1) OR (how_many_left_buffers > 1) then return lse$_ambigbufnam; endif; ! if we get to this point, there is no match ! return lse$_buffnotexist; endprocedure; ! ! PROCEDURE lse$$prompt_string( prompt_string, output_string ) LOCAL recursion_flag, recursion_window, current_buffer_key_map_list, current_key, current_window_key_map_list, prompt_display_offset, prompt_range, saved_contents, saved_cursor, saved_text_mode, saved_timer; ON_ERROR [TPU$_NODEFINITION]: [OTHERWISE, TPU$_CONTROLC]: IF GET_INFO( saved_cursor, 'type' ) = INTEGER THEN eve$x_bound_cursor := saved_cursor; ENDIF; IF saved_text_mode <> 0 THEN SET( saved_text_mode, CURRENT_BUFFER ); ENDIF; lse$$prompt_string_error_cleanup( saved_timer ); CASE ERROR [TPU$_READABORTED, TPU$_REQUIRESTERM, TPU$_CONTROLC]: eve$message( lse$_operationabort ); UPDATE(ALL); RETURN FALSE; [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$prompt_string"); ENDCASE; ENDON_ERROR; saved_cursor := tpu$k_unspecified; ! Save where we are ! saved_timer := SET( TIMER, off ); IF (CURRENT_WINDOW = lse$prompt_window) OR (CURRENT_WINDOW = lse$command_window) THEN recursion_flag := MARK( FREE_CURSOR ); recursion_window := CURRENT_WINDOW; ENDIF; ! Prepare te contents buffer ! POSITION( END_OF( lse$prompt_buffer ) ); SET (MODIFIABLE, lse$prompt_buffer, ON); SET (MODIFIABLE, lse$prompt_buffer_display, ON); SPLIT_LINE; MOVE_VERTICAL( -1 ); current_buffer_key_map_list := GET_INFO( current_buffer, 'key_map_list' ); ! Prepare the display buffer ! POSITION( BEGINNING_OF ( lse$prompt_buffer_display ) ); SPLIT_LINE; MOVE_VERTICAL( -1 ); MAP( lse$prompt_window, lse$prompt_buffer_display ); COPY_TEXT( prompt_string ); MOVE_HORIZONTAL( -1 ); prompt_range := CREATE_RANGE( LINE_BEGIN, MARK(NONE), REVERSE ); MOVE_HORIZONTAL( 1 ); current_window_key_map_list := GET_INFO( current_window, 'key_map_list' ); ! Read keys and protect the prompt ! LOOP ! Protect against unmodifiable buffers ! SET (MODIFIABLE, lse$prompt_buffer, ON); SET (MODIFIABLE, lse$prompt_buffer_display, ON); ! Prepare for input ! UPDATE( lse$prompt_window ); ! Get the next input ! current_key := read_key; ! Check the abort key, ! IF lse$$x_prompt_abort_keys{ current_key } = true THEN ABORT; ENDIF; ! We are done when we see a terminator ! IF lse$$x_prompt_terminator_keys{ current_key } = true THEN ERASE_LINE; ! Move the line chosen into the saved buffer ! POSITION( lse$prompt_buffer ); output_string := CURRENT_LINE; POSITION( END_OF( lse$prompt_buffer_saved ) ); COPY_TEXT( output_string ); ! No blank lines ! IF CURRENT_LINE = '' THEN ERASE_LINE; ENDIF; ! If there is a previous line we compare it to remove duplicates ! IF GET_INFO( CURRENT_BUFFER, 'record_number' ) > 1 THEN MOVE_VERTICAL( -1 ); IF CURRENT_LINE = output_string THEN ERASE_LINE; ENDIF; ENDIF; ! Move the saved buffer's contents into the contents buffer ! All this is so that recall lines are not modified by use ! actions. ! saved_contents := CREATE_RANGE( BUFFER_BEGIN, BUFFER_END, NONE ); POSITION( lse$prompt_buffer ); ERASE( lse$prompt_buffer ); COPY_TEXT( saved_contents ); ! A simple UNMAP is the right thing to do when dealing with ! user windows, It puts use where we came from, or where the ! user's key strokes want us to go. ! ! But when the prompt came from a key struck in the prompt window, ! an unmap will put us where the original prompt came from ! instead of at the prompt again. So we simple position to a ! saved mark when the prompt is recursive. ! IF recursion_flag <> 0 THEN IF recursion_window = lse$command_window THEN ! If we don't unmap the prompt window when we came from the ! command window, the command window exit will get and error ! because it will try to position to the prompt window ! while the command window is over the top of it. ! UNMAP( lse$prompt_window ); ENDIF; POSITION( recursion_flag ); ELSE UNMAP( lse$prompt_window ); ENDIF; SET( TIMER, saved_timer); ! Execute any alternate terminator keys ! IF lse$$x_prompt_alterminator_keys{ current_key } = true THEN IF eve$is_mouse( current_key ) THEN EXECUTE( current_key, GET_INFO( current_window, 'key_map_list' ) ); ELSE EXECUTE( current_key, GET_INFO( current_buffer, 'key_map_list' ) ); ENDIF; ENDIF; RETURN TRUE; ENDIF; ! Cursor must alway be bound because TPU builtins ! cursor_horizontal and cursor_vertical do nothing in buffers ! which aren't mapped to a window. I've poked the EVE variable ! directly instead of using set( lse$cursor_bound, lse$system, 1 ) ! for performance. ! saved_cursor := eve$x_bound_cursor; eve$x_bound_cursor := 1; ! Execute the key ! IF eve$is_mouse( current_key ) THEN ! Mouse actions are executed in the context of the ! and buffer display window ! EXECUTE( current_key, current_window_key_map_list ); IF (STR( prompt_range ) + GET_INFO( lse$prompt_buffer, 'line' )) <> GET_INFO( lse$prompt_buffer_display, 'line' ) THEN lse$$prompt_contents_display( lse$prompt_window, lse$prompt_buffer_display, END_OF( prompt_range ), lse$prompt_buffer ); ELSE ! The cursor position may have changed ! POSITION( lse$prompt_buffer_display ); IF prompt_string <> STR( prompt_range ) THEN ERASE( prompt_range ); prompt_range := COPY_TEXT( prompt_string ); prompt_range := CREATE_RANGE( BEGINNING_OF( prompt_range ), END_OF( prompt_range ), REVERSE ); ENDIF; prompt_display_offset := GET_INFO( CURRENT_BUFFER, 'offset' ); POSITION( lse$prompt_buffer ); IF GET_INFO( CURRENT_BUFFER, 'offset' ) <> prompt_display_offset - LENGTH( prompt_range ) THEN POSITION( LINE_BEGIN ); MOVE_HORIZONTAL( prompt_display_offset - LENGTH( prompt_range ) ); ENDIF; ENDIF; IF GET_INFO( lse$$x_last_mouse_window, 'type' ) = WINDOW THEN UPDATE( lse$$x_last_mouse_window ); ELSE UPDATE( ALL ); ENDIF; ELSE ! Key strokes are executed in the context of the contents buffer ! POSITION( lse$prompt_buffer ); EXECUTE( current_key, current_buffer_key_map_list ); eve$x_bound_cursor := saved_cursor; ENDIF; eve$x_bound_cursor := saved_cursor; lse$$prompt_display_contents( lse$prompt_window, lse$prompt_buffer_display, END_OF( prompt_range ), lse$prompt_buffer ); ENDLOOP; ENDPROCEDURE; procedure lse$$prompt_display_contents( prompt_window, prompt_buffer_display, prompt_mark, prompt_buffer ) LOCAL display_contents, display_contents_str, prompt_contents, prompt_contents_offset; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$prompt_display_contents"); ENDON_ERROR; ! Make sure there is at least on record in the buffer. The user might ! have deleted them all ! IF GET_INFO( CURRENT_BUFFER, 'record_count' ) = 0 THEN SPLIT_LINE; ENDIF; ! Correct for being beyond the last line ! POSITION( prompt_buffer ); IF GET_INFO( CURRENT_BUFFER, 'record_number' ) > GET_INFO( CURRENT_BUFFER, 'record_count' ) THEN MOVE_VERTICAL( -1 ); ENDIF; ! Get the contents ! prompt_contents := CURRENT_LINE; prompt_contents_offset := GET_INFO( CURRENT_BUFFER, 'offset' ); ! We force the user to stay in the prompt display buffer ! MAP( prompt_window, prompt_buffer_display ); ! Update the display ! POSITION( prompt_mark ); MOVE_HORIZONTAL( 1 ); display_contents := CREATE_RANGE( MARK(NONE), LINE_END, NONE ); display_contents_str := STR( display_contents ); IF display_contents_str <> prompt_contents THEN ! Update the display ! IF INDEX( prompt_contents, display_contents_str ) = 1 THEN ! Add to the end, avoids screen upating ! POSITION( LINE_END ); COPY_TEXT( SUBSTR( prompt_contents, LENGTH( display_contents_str ) + 1, LENGTH( prompt_contents ) - LENGTH( display_contents_str ) ) ); ELSE ! Change the contents ! ERASE( display_contents ); COPY_TEXT( prompt_contents ); SPLIT_LINE; MOVE_HORIZONTAL( -1 ); ENDIF; ENDIF; ! Position the cursor ! POSITION( prompt_mark ); MOVE_HORIZONTAL( prompt_contents_offset + 1); ENDPROCEDURE; procedure lse$$prompt_contents_display( prompt_window, prompt_buffer_display, prompt_mark, prompt_buffer ) LOCAL display_contents, display_contents_str, offset, prompt_contents, prompt_contents_offset, the_line; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$prompt_contents_display"); ENDON_ERROR; ! Get the display info ! offset := GET_INFO( prompt_buffer_display, 'offset' ); POSITION( prompt_mark ); MOVE_HORIZONTAL( 1 ); offset := offset - GET_INFO( CURRENT_BUFFER, 'offset' ); the_line := CREATE_RANGE( MARK( NONE ), LINE_END, NONE ); ! Copy to the contentx ! POSITION( prompt_buffer ); ERASE_LINE; COPY_TEXT( the_line ); MOVE_VERTICAL( -1 ); IF (offset < 0) THEN offset := 0; ENDIF; MOVE_HORIZONTAL( offset ); ENDPROCEDURE; PROCEDURE lse$$prompt_string_error_cleanup( saved_timer ) ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$prompt_string_error_cleanup"); ENDON_ERROR; SET( TIMER, saved_timer); ! On errors we throw away the line we inserted at the end ! POSITION( END_OF( lse$prompt_buffer ) ); IF GET_INFO( CURRENT_BUFFER, 'record_count' ) > 0 THEN MOVE_VERTICAL( -1 ); ERASE_LINE; ENDIF; IF GET_INFO( lse$prompt_window, 'visible' ) THEN UNMAP( lse$prompt_window ); ENDIF; ENDPROCEDURE; PROCEDURE lse$$prompt_string_jacket( prompt ) LOCAL output_string; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$prompt_string_jacket"); ENDON_ERROR; IF lse$prompt_string( , output_string, prompt, , '' ) THEN return output_string; ENDIF; return ascii(0); ENDPROCEDURE; ! ! PROCEDURE lse$prompt_list_buffer( prompt_buffer; relative_window ) LOCAL current_buffer_key_map_list, current_item, current_key, current_window_key_map_list, local_current_window, local_record_number, prompt_buffer_length, prompt_window, prompt_window_length, saved_balance, saved_buffer, saved_h_scroll_bar, saved_v_scroll_bar, saved_timer, saved_window, temp_buffer, temp_row, temp_status, window_length, window_index; ON_ERROR [TPU$_NOTMODIFIABLE]: eve$message( error_text ); [TPU$_NODEFINITION]: [OTHERWISE, TPU$_CONTROLC]: IF GET_INFO( saved_buffer, 'type' ) = BUFFER THEN IF eve$x_decwindows_active THEN ! Put scroll bars back if necessary ! IF saved_h_scroll_bar <> 0 THEN SET( SCROLL_BAR, prompt_window, HORIZONTAL, ON ); ENDIF; IF saved_v_scroll_bar <> 0 THEN SET( SCROLL_BAR, prompt_window, VERTICAL, ON ); ENDIF; ENDIF; lse$buffer_util( saved_buffer ); ELSE eve_delete_window; ENDIF; IF saved_balance <> 0 THEN lse_set_balance_windows( saved_balance ); ENDIF; SET( TIMER, saved_timer); SET( MODIFIABLE, lse$prompt_list_buff, ON ); CASE ERROR [TPU$_READABORTED, TPU$_REQUIRESTERM, TPU$_CONTROLC]: eve$message( lse$_operationabort ); UPDATE( ALL ); RETURN false; [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$prompt_list_buffer"); ENDCASE; ENDON_ERROR; ! Stop the timer ! saved_timer := SET( TIMER, off ); ! Put it into a buffer we know about so the key maps are right and ! we don't mess up the passed buffer ! IF GET_INFO( lse$prompt_list_buff, 'modifiable' ) = 0 THEN eve$message( lse$_recurplst ); RETURN FALSE; ENDIF; ! Calculate the window length. MIN( 1/4 screen length, buffer_length ) ! window_length := GET_INFO(eve$$x_windows{eve$x_number_of_windows},'bottom'); prompt_buffer_length := GET_INFO( prompt_buffer, 'record_count' ); prompt_window_length := window_length/4; IF prompt_window_length > prompt_buffer_length THEN prompt_window_length := prompt_buffer_length; ENDIF; ! Balanced windows must be off for the window magic ! saved_balance := set( lse$balance_windows, lse$window, OFF ); ! Are we in a user window ! window_index := 1; LOOP EXITIF current_window = eve$$x_windows{window_index}; EXITIF window_index >= eve$x_number_of_windows; window_index := window_index + 1; ENDLOOP; ! Put us in an appropriate window ! IF GET_INFO( relative_window, 'type' ) = WINDOW THEN local_current_window := relative_window; ELSE local_current_window := current_window; ENDIF; saved_window := current_window; IF local_current_window <> eve$$x_windows{window_index} THEN ! Not in a user window. Use the bottom window ! POSITION( eve$$x_windows{eve$x_number_of_windows} ); lse$$split_window_always( 2 ); IF GET_INFO( CURRENT_WINDOW, 'visible_length' ) > prompt_window_length THEN eve_shrink_window( GET_INFO( CURRENT_WINDOW, 'length' ) - prompt_window_length); ENDIF; ELSE ! In a user window ! IF eve$x_number_of_windows = 1 THEN ! One window ! UPDATE( current_window ); ! Required to make GET_INFO( SCREEN, 'current_row' ) work IF (window_length/2) < GET_INFO( SCREEN, 'current_row' ) THEN ! Put it at the top ! temp_buffer := GET_INFO( CURRENT_WINDOW, 'buffer' ); lse$$split_window_always( 2 );; lse$buffer_util( temp_buffer ); eve_previous_window; ELSE ! Put it at the bottom ! lse$$split_window_always( 2 );; ENDIF; eve_shrink_window( GET_INFO( CURRENT_WINDOW, 'length' ) - prompt_window_length); ELSE ! Multi_window ! UPDATE( current_window ); ! Required to make GET_INFO( SCREEN, 'current_row' ) work IF (window_length/2) < GET_INFO( SCREEN, 'current_row' ) THEN ! Put it above ! eve_previous_window; IF prompt_buffer_length < GET_INFO( CURRENT_WINDOW, 'length' ) THEN lse$$split_window_always( 2 ); ELSE saved_buffer := current_buffer; ENDIF; ELSE ! Put it below ! eve_next_window; IF prompt_buffer_length < GET_INFO( CURRENT_WINDOW, 'length' ) THEN temp_buffer := GET_INFO( CURRENT_WINDOW, 'buffer' ); lse$$split_window_always( 2 ); lse$buffer_util( temp_buffer ); eve_previous_window; ELSE saved_buffer := current_buffer; ENDIF; ENDIF; ENDIF; ENDIF; ! Move the data ! ERASE( lse$prompt_list_buff ); POSITION( lse$prompt_list_buff ); COPY_TEXT( prompt_buffer ); SET( MODIFIABLE, lse$prompt_list_buff, OFF ); POSITION( GET_INFO( prompt_buffer, 'record_number' ) ); ! Make it have the same language ! IF GET_INFO( prompt_buffer, 'lse$language' ) <> 0 THEN SET(lse$language, current_buffer, GET_INFO( prompt_buffer, 'lse$language' ) ); ELSE SET( lse$language, current_buffer, '' ); ENDIF; ! Init ! lse$buffer_util( lse$prompt_list_buff ); prompt_window := current_window; current_buffer_key_map_list := GET_INFO( current_buffer, 'key_map_list' ); current_window_key_map_list := GET_INFO( current_window, 'key_map_list' ); eve$set_fixed_status_line( lse$prompt_list_buff, COMPILE( 'RETURN "' + lse$get_message_text( lse$_menustatus ) + '"' ) ); IF eve$x_decwindows_active THEN saved_h_scroll_bar := GET_INFO(prompt_window, 'scroll_bar', HORIZONTAL); saved_v_scroll_bar := GET_INFO(prompt_window, 'scroll_bar', VERTICAL ); SET( SCROLL_BAR, prompt_window, VERTICAL, OFF ); SET( SCROLL_BAR, prompt_window, HORIZONTAL, OFF ); ENDIF; window_index := 1; LOOP UPDATE( eve$$x_windows{window_index} ); window_index := window_index + 1; EXITIF window_index >= eve$x_number_of_windows; ENDLOOP; ! Read keys and protect the prompt ! LOOP ! Prepare for input ! IF GET_INFO( CURRENT_BUFFER, 'record_number' ) > GET_INFO( CURRENT_BUFFER, 'record_count' ) THEN MOVE_VERTICAL( -1 ); ENDIF; current_item := CREATE_RANGE( LINE_BEGIN, LINE_END, REVERSE ); UPDATE( CURRENT_WINDOW ); ! Get the next input ! current_key := read_key; ! Check the abort key, ! IF lse$$x_prompt_abort_keys{ current_key } = true THEN ABORT; ENDIF; ! We are done when we see a terminator ! IF (lse$$x_prompt_terminator_keys{ current_key } = true) OR (current_key = M1CLICK2) THEN ! We do the following mumbo jumbo instead of ! POSITION( prompt_buffer ); ! POSITION( GET_INFO( CURRENT_BUFFER, 'record_number' ) ); ! because it doesn't work on the buffer built by the expand ! menu stuff written in BLISS ! local_record_number := GET_INFO( CURRENT_BUFFER, 'record_number' ); POSITION( BEGINNING_OF( prompt_buffer ) ); MOVE_VERTICAL( local_record_number - 1 ); ! Restore the screen ! IF GET_INFO( saved_buffer, 'type' ) = BUFFER THEN IF eve$x_decwindows_active THEN ! Put scroll bars back if necessary ! IF saved_h_scroll_bar <> 0 THEN SET( SCROLL_BAR, prompt_window, HORIZONTAL, ON ); ENDIF; IF saved_v_scroll_bar <> 0 THEN SET( SCROLL_BAR, prompt_window, VERTICAL, ON ); ENDIF; ENDIF; lse$buffer_util( saved_buffer ); ELSE eve_delete_window; ENDIF; IF saved_window <> TPU$K_UNSPECIFIED THEN POSITION( saved_window ); ENDIF; lse_set_balance_windows( saved_balance ); SET( TIMER, saved_timer); SET( MODIFIABLE, lse$prompt_list_buff, ON ); ! Execute any alternate terminator keys ! IF lse$$x_prompt_alterminator_keys{ current_key } = true THEN IF eve$is_mouse( current_key ) THEN EXECUTE( current_key, GET_INFO( current_window, 'key_map_list' ) ); ELSE EXECUTE( current_key, GET_INFO( current_buffer, 'key_map_list' ) ); ENDIF; ENDIF; RETURN TRUE; ENDIF; ! Execute the key ! IF eve$is_mouse( current_key ) THEN EXECUTE( current_key, current_window_key_map_list ); ELSE EXECUTE( current_key, current_buffer_key_map_list ); ENDIF; ! We force the user to stay in the prompt buffer ! MAP( prompt_window, lse$prompt_list_buff ); ENDLOOP; ENDPROCEDURE; PROCEDURE lse$$prompt_copy_command_prompt LOCAL saved_text_mode; ON_ERROR [OTHERWISE]: IF saved_text_mode <> 0 THEN SET( saved_text_mode, CURRENT_BUFFER ); ENDIF; lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$prompt_copy_command_prompt"); ENDON_ERROR; ! Get to the right place ! lse$$push_position; ! Take the prompt off the line if it is there ! IF GET_INFO( lse$command_prompt, 'type' ) = RANGE THEN ERASE( lse$command_prompt ); ENDIF; ! Put the prompt on this line ! POSITION( LINE_BEGIN ); saved_text_mode := SET( INSERT, CURRENT_BUFFER ); lse$command_prompt := COPY_TEXT( lse$$command_prompt_string ); SET( saved_text_mode, CURRENT_BUFFER ); lse$command_prompt := CREATE_RANGE( BEGINNING_OF( lse$command_prompt ), END_OF( lse$command_prompt ), REVERSE ); lse$$pop_position; ENDPROCEDURE; PROCEDURE lse$$prompt_exit_command_window ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$prompt_exit_command_window"); ENDON_ERROR; ! Unmap puts us where we came from, ! We push the place so we can map it back and know where to go ! IF GET_INFO( lse$command_window, 'visible' ) THEN UNMAP( lse$command_window ); ENDIF; lse$$push_position; ! We always leave at the end of the buffer with a blank line ! POSITION( lse$command_buffer ); IF GET_INFO( CURRENT_BUFFER, 'record_count' ) <= 0 THEN ! Empty buffer ! SPLIT_LINE; MOVE_HORIZONTAL( -1 ); ENDIF; POSITION( GET_INFO( CURRENT_BUFFER, 'record_count' ) ); IF CURRENT_LINE <> '' THEN ! Last line isn't blank ! POSITION( END_OF( lse$command_buffer ) ); SPLIT_LINE; MOVE_HORIZONTAL( -1 ); ENDIF; ! Cleanup the display ! MAP( lse$command_window, lse$command_buffer_display ); POSITION( lse$command_prompt ); ERASE_LINE; SPLIT_LINE; MOVE_HORIZONTAL( -1 ); ! DECwindows always has the prompt visible ! IF (eve$x_decwindows_active) OR get_info( SCREEN, 'mouse' ) THEN lse$$prompt_copy_command_prompt; lse$command_prompt := CREATE_RANGE( BEGINNING_OF( lse$command_prompt ), END_OF( lse$command_prompt ), NONE ); ENDIF; lse$$pop_position; ENDPROCEDURE; PROCEDURE lse$$command_post_execute( the_line ) LOCAL last_line; ON_ERROR [OTHERWISE]: lse$$prompt_exit_command_window; lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$command_post_execute"); ENDON_ERROR; ! Execute any alternate terminator keys ! IF lse$$x_prompt_alterminator_keys{ last_key } = true THEN IF eve$is_mouse( last_key ) THEN EXECUTE( last_key, GET_INFO( current_window, 'key_map_list' ) ); ELSE EXECUTE( last_key, GET_INFO( current_buffer, 'key_map_list' ) ); ENDIF; ENDIF; ! Clean up the buffer ! lse$$push_position; POSITION( lse$command_buffer ); ! Make sure there is at least on line in the buffer ! IF GET_INFO( CURRENT_BUFFER, 'record_count' ) <= 0 THEN SPLIT_LINE; MOVE_VERTICAL( -1 ); ENDIF; ! Copy the current line to the last line if necessary ! IF GET_INFO( CURRENT_BUFFER, 'record_count' ) <> GET_INFO( CURRENT_BUFFER, 'record_number' ) THEN ! We weren't on the last line so we need to copy it. ! POSITION( GET_INFO( CURRENT_BUFFER, 'record_count' ) ); IF CURRENT_LINE <> '' THEN !The last line wasn't blank ! MOVE_VERTICAL( 1 ); ENDIF; COPY_TEXT( the_line ); ENDIF; ! Erase duplicate lines ! last_line := CURRENT_LINE; IF GET_INFO( CURRENT_BUFFER, 'record_number' ) >= 2 THEN MOVE_VERTICAL( -1 ); IF CURRENT_LINE = last_line THEN ERASE_LINE; ENDIF; ENDIF; lse$$pop_position; ENDPROCEDURE; PROCEDURE lse$$command_undefined_key_proc LOCAL display_contents, display_contents_str, offset, parse_result, saved_contents, saved_cursor, the_line; ON_ERROR [TPU$_NODEFINITION]: eve$message (ERROR_TEXT); [OTHERWISE]: IF GET_INFO( saved_cursor, 'type' ) = INTEGER THEN eve$x_bound_cursor := saved_cursor; ENDIF; lse$$prompt_exit_command_window; lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$command_undefined_key_proc"); ENDON_ERROR; saved_cursor := tpu$k_unspecified; ! If the user positioned to the command buffer in a user window ! we simply go away, otherwise he is stuck here forever. ! IF CURRENT_WINDOW <> lse$command_window THEN lse$buffer_util( get_info( BUFFER, 'last' ) ); RETURN; ENDIF; ! If the command and display buffer's are not in sync, then something ! has changed the display without "telling us". Probably a mouse action. ! IF (GET_INFO( lse$command_buffer, 'record_number' ) > GET_INFO( lse$command_buffer, 'record_count' )) OR (GET_INFO( CURRENT_BUFFER, 'record_number' ) > GET_INFO( CURRENT_BUFFER, 'record_count' )) THEN ! No record, so CURRENT_LINE used below will return an error ! lse$$prompt_contents_display( lse$command_window, CURRENT_BUFFER, END_OF( lse$command_prompt ), lse$command_buffer ); ELSE IF (str( lse$command_prompt ) + GET_INFO( lse$command_buffer, 'line' ) <> CURRENT_LINE) OR (LENGTH(lse$command_prompt) + GET_INFO(lse$command_buffer, 'offset') <> GET_INFO( CURRENT_BUFFER, 'offset' ) ) THEN lse$$prompt_contents_display( lse$command_window, CURRENT_BUFFER, END_OF( lse$command_prompt ), lse$command_buffer ); ELSE POSITION( lse$command_buffer ); ENDIF; ENDIF; SET (MODIFIABLE, lse$command_buffer, ON); SET (MODIFIABLE, lse$command_buffer_display, ON); ! ! All done in the context of the contents buffer ! Abort keys get you out ! IF lse$$x_prompt_abort_keys{ last_key } = true THEN lse$$prompt_exit_command_window; RETURN; ENDIF; ! We are done when we see a terminator ! IF lse$$x_prompt_terminator_keys{ last_key } = true THEN IF NOT lse$is_continuation_line( CURRENT_LINE ) THEN ! Visual feedback that we heard the terminator ! POSITION( lse$command_window ); POSITION( LINE_BEGIN ); UPDATE( CURRENT_WINDOW ); POSITION( lse$command_buffer ); ! Exit on null command ! IF current_line = '' THEN lse$$prompt_exit_command_window; RETURN; ENDIF; ! Gather up any continutation lines above this one ! the_line := current_line; lse$$push_position; LOOP EXITIF GET_INFO( CURRENT_BUFFER, 'record_number' ) = 1; MOVE_VERTICAL( -1 ); EXITIF NOT lse$is_continuation_line( CURRENT_LINE ); the_line := SUBSTR( current_line, 1, LENGTH(current_line)-1) + the_line; ENDLOOP; ! Do the saved recall buffer magic ! POSITION( END_OF( lse$command_buffer_saved ) ); IF GET_INFO( CURRENT_BUFFER, 'record_count' ) > 0 THEN MOVE_VERTICAL( -1 ); IF CURRENT_LINE <> the_line THEN MOVE_VERTICAL( 1 ); COPY_TEXT( the_line ); ENDIF; ELSE COPY_TEXT( the_line ); ENDIF; ! Move the saved buffer's contents into the contents buffer ! All this is so that recall lines are not modified by use ! actions. ! saved_contents := CREATE_RANGE( BUFFER_BEGIN, BUFFER_END, NONE ); POSITION( lse$command_buffer ); ERASE( lse$command_buffer ); COPY_TEXT( saved_contents ); lse$$pop_position; ! Do the command, Unless the parse was ambigious ! UNMAP( lse$command_window ); IF get_info( lse$system, "lse$cli_parser" ) THEN ! V3.1 compatible ! lse$do_command( the_line ); lse$$command_post_execute( the_line ); ! Get out if it is one time only ! IF lse$$x_sticky_command_prompt = false THEN lse$$prompt_exit_command_window; RETURN; ENDIF; ELSE ! Portable parser ! lse$$x_last_parse_result := ''; parse_result := eve$$parse( the_line ); IF NOT eve$$x_state_array {eve$$k_ambiguous_parse} THEN ! Parse not ambigious ! IF parse_result <> '' THEN IF LENGTH( parse_result) > 256 THEN eve$message( 'Command too long' ); lse$$prompt_exit_command_window; RETURN; ENDIF; EXECUTE( parse_result ); lse$$command_post_execute( the_line ); ! Get out if it is one time only ! IF lse$$x_sticky_command_prompt = false THEN lse$$prompt_exit_command_window; RETURN; ENDIF; ENDIF; ENDIF; ! Ambigious parse, put the chosen result in the buffer for ! the user ! IF lse$$x_last_parse_result <> '' THEN POSITION( lse$command_buffer ); ERASE_LINE; COPY_TEXT( lse$$x_last_parse_result ); MAP( lse$command_window, lse$command_buffer_display ); POSITION( END_OF( lse$command_prompt ) ); MOVE_HORIZONTAL( 1 ); ERASE( CREATE_RANGE( MARK(NONE), LINE_END, NONE ) ); COPY_TEXT( lse$$x_last_parse_result ); RETURN; ENDIF; ENDIF; ELSE ! Continuation line ! IF GET_INFO( CURRENT_BUFFER, 'record_count' ) <> GET_INFO( CURRENT_BUFFER, 'record_number' ) THEN ! Gather up any continutation lines above this one ! POSITION( LINE_END ); the_line := MARK( NONE ); LOOP EXITIF GET_INFO( CURRENT_BUFFER, 'record_number' ) = 1; MOVE_VERTICAL( -1 ); EXITIF NOT lse$is_continuation_line( CURRENT_LINE ); ENDLOOP; POSITION( LINE_BEGIN ); the_line := CREATE_RANGE( the_line, MARK( NONE ), NONE ); ! Move the continuations lines to the end of the buffer ! POSITION( GET_INFO( CURRENT_BUFFER, 'record_count' ) ); IF CURRENT_LINE <> '' THEN MOVE_VERTICAL( 1 ); ENDIF; COPY_TEXT( the_line ); ENDIF; ENDIF; ! We always do it again at the end of the buffer with a blank line ! POSITION( lse$command_buffer ); IF GET_INFO( CURRENT_BUFFER, 'record_count' ) <= 0 THEN ! Empty buffer ! SPLIT_LINE; MOVE_HORIZONTAL( -1 ); ENDIF; POSITION( GET_INFO( CURRENT_BUFFER, 'record_count' ) ); IF CURRENT_LINE <> '' THEN ! Last line isn't blank ! POSITION( END_OF( lse$command_buffer ) ); SPLIT_LINE; MOVE_HORIZONTAL( -1 ); ENDIF; MAP( lse$command_window, lse$command_buffer_display ); POSITION( END_OF( lse$command_prompt ) ); MOVE_HORIZONTAL( 1 ); ERASE( CREATE_RANGE( MARK(NONE), LINE_END, NONE ) ); RETURN; ENDIF; ! Cursor must alway be bound because TPU builtins ! cursor_horizontal and cursor_vertical do nothing in buffers ! which aren't mapped to a window. I've poked the EVE variable ! directly instead of using set( lse$cursor_bound, lse$system, 1 ) ! for performance. ! saved_cursor := eve$x_bound_cursor; eve$x_bound_cursor := 1; ! Execute the key ! IF eve$is_mouse( last_key ) THEN EXECUTE( last_key, GET_INFO( current_window, 'key_map_list' ) ); ELSE EXECUTE( last_key, GET_INFO( current_buffer, 'key_map_list' ) ); ENDIF; eve$x_bound_cursor := saved_cursor; lse$$prompt_display_contents( lse$command_window, lse$command_buffer_display, END_OF( lse$command_prompt ), lse$command_buffer ); ENDPROCEDURE; PROCEDURE lse$$set_dialog_title (the_widget; dialog_title) LOCAL status, title_to_use, lse_title; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$set_dialog_title"); ENDON_ERROR; if dialog_title = tpu$k_unspecified then status := GET_INFO (the_widget, "widget_info", eve$x_resource_array {eve$k_ndialogtitle}, title_to_use); else title_to_use := dialog_title; endif; ! ! Set the title of the box. If the incoming dialog_title does not already ! contain an LSE: prefix, then add it. ! if index (title_to_use, eve$x_application_name + ": ") = 0 then lse_title := eve$x_application_name + ": " + title_to_use; else lse_title := title_to_use; endif; SET (WIDGET, the_widget, eve$x_resource_array {eve$k_ndialogtitle}, lse_title); return lse_title; ENDPROCEDURE; PROCEDURE lse$$prompt_boolean_jacket( prompt, default ) LOCAL output_boolean; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$prompt_boolean_jacket"); ENDON_ERROR; IF lse$prompt_boolean( , output_boolean, prompt, , default ) THEN return output_boolean; ENDIF; eve$learn_abort; ABORT; ENDPROCEDURE; PROCEDURE lse$$end_prompt( prompt_str, end_prompt ) ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$end_prompt"); ENDON_ERROR; CASE SUBSTR( prompt_str, LENGTH( prompt_str ), 1 ) [' ']: lse$$end_prompt := ''; ['?','>',':',";",']']: lse$$end_prompt := ' '; [OTHERWISE]: lse$$end_prompt := end_prompt; ENDCASE; ENDPROCEDURE; PROCEDURE lse$$prompt_save() ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$prompt_save"); ENDON_ERROR; ! If a prompt is in progress ! IF ((current_window = lse$command_window) OR (current_window = lse$prompt_window) OR (current_window = eve$prompt_window) OR (current_window = eve$command_window) OR (current_buffer = lse$prompt_list_buff)) THEN lse$$prompt_saved_buffer := current_buffer; lse$$prompt_saved_window := current_window; lse$$prompt_saved_position := mark(none); unmap( current_window ); ENDIF; ENDPROCEDURE; PROCEDURE lse$$prompt_restore() ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$prompt_restore"); ENDON_ERROR; ! If there's a saved state, restore it. ! IF lse$$prompt_saved_buffer <> tpu$k_unspecified THEN map (lse$$prompt_saved_window, lse$$prompt_saved_buffer); position(lse$$prompt_saved_position); ENDIF; lse$$prompt_saved_buffer := tpu$k_unspecified; lse$$prompt_saved_window := tpu$k_unspecified; lse$$prompt_saved_position := tpu$k_unspecified; update (all); ENDPROCEDURE; ! ! PROCEDURE lse$prompt_show_buffer( ;cur_buffer, response ) LOCAL buffer_ptr, status; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$prompt_show_buffer"); ENDON_ERROR; ! Make response a name ! IF GET_INFO( cur_buffer, 'type' ) = BUFFER THEN response := GET_INFO( cur_buffer, 'name' ); ELSE if not lse$prompt_string ( cur_buffer, response, '', '', current_buffer ) then RETURN false; endif; ENDIF; ! lse$shlst_process doesn't handle "foo" matching foo1 and foo2 ! So we figure out if it is ambigious and supply the "*" is necessary ! status := lse$get_buffer( response, buffer_ptr ); IF status = lse$_ambigbufnam THEN IF INDEX( response, '*' ) = 0 THEN response := response + '*'; ENDIF; ELSE IF buffer_ptr = 0 THEN EVE$MESSAGE (status, 0, response); RETURN false; ENDIF; response := GET_INFO( buffer_ptr, 'name' ); ENDIF; return true; endprocedure; procedure lse$$get_cli_buffer( buffer_name ) ! ! Function: returns full buffer name if it exists ! ! Description: if a valid buffer name, or initial substring of a valid buffer ! name is given, the return value will be the full buffer name. ! If the substring given was not unique the ambiguous error message ! lse$_ambigbufnam will be output. If no buffers are found, then ! the original string is returned to the caller. ! Parameters: ! buffer_name - string ! ! Return values: ! String, full buffer name or same buffer name ! String, '' error was output ! LOCAL the_upcase_name, how_many_buffers, last_buffer, loop_buffer, loop_buffer_name, possible_buffer, upcase_loop_name; ON_ERROR [OTHERWISE]: lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse$$get_cli_buffer "); ENDON_ERROR; ! first, check for an exact match ! possible_buffer := get_info (BUFFERS,"find_buffer",buffer_name); if possible_buffer <> 0 then return get_info( possible_buffer, 'name' ); endif; the_upcase_name := buffer_name; change_case(the_upcase_name, upper); ! now check for an exact match, case-insensitive ! last_buffer := GET_INFO(BUFFERS, "last"); loop_buffer := GET_INFO(BUFFERS, "first"); LOOP loop_buffer_name := GET_INFO(loop_buffer, "name"); upcase_loop_name := loop_buffer_name; change_case (upcase_loop_name, upper); if upcase_loop_name = the_upcase_name THEN return loop_buffer_name; ENDIF; EXITIF loop_buffer = last_buffer; loop_buffer := GET_INFO(BUFFERS, "next"); ENDLOOP; ! test for a partial match, case-sensitive ! loop_buffer := GET_INFO(BUFFERS, "first"); LOOP loop_buffer_name := GET_INFO(loop_buffer, "name"); IF buffer_name = SUBSTR(loop_buffer_name, 1, LENGTH(buffer_name)) THEN possible_buffer := loop_buffer; how_many_buffers := how_many_buffers + 1; ENDIF; EXITIF loop_buffer = last_buffer; loop_buffer := GET_INFO(BUFFERS, "next"); ENDLOOP; IF how_many_buffers = 1 THEN return get_info( possible_buffer, 'name' ); endif; if how_many_buffers > 1 then eve$message( lse$_ambigbufnam, 0, buffer_name ); return ''; endif; ! test for partial match, case-insensitive loop_buffer := GET_INFO(BUFFERS, "first"); LOOP loop_buffer_name := GET_INFO(loop_buffer, "name"); upcase_loop_name := loop_buffer_name; change_case(upcase_loop_name,upper); IF the_upcase_name = SUBSTR(upcase_loop_name, 1, LENGTH(the_upcase_name)) THEN possible_buffer := loop_buffer; how_many_buffers := how_many_buffers + 1; ENDIF; EXITIF loop_buffer = last_buffer; loop_buffer := GET_INFO(BUFFERS, "next"); ENDLOOP; IF how_many_buffers = 1 THEN return get_info( possible_buffer, 'name' ); endif; if how_many_buffers > 1 then eve$message( lse$_ambigbufnam, 0, buffer_name ); return ''; endif; ! if we get to this point, there is no match so return what was given to us. ! return buffer_name; endprocedure; variable lse$x_fao_command_array; variable lse$x_novalue_msg_array; variable lse$x_prompt_string_widget; variable lse$x_prompt_string_selection_widget; variable lse$x_prompt_boolean_widget; variable lse$x_prompt_boolean_value; variable lse$x_file_selection_dirmask; variable lse$x_file_selection_widget_array;