! EVE$EDIT.TPU 11-SEP-1988 12:14 Page 1 ! EVE - { Extensible | Easy | Efficient } Vax Editor ! !************************************************************************* ! * ! © Copyright 2005 Hewlett-Packard Development Company, L.P. * ! * ! Confidential computer software. Valid license from HP required for * ! possession, use or copying. Consistent with FAR 12.211 and 12.212, * ! Commercial Computer Software, Computer Software Documentation, and * ! Technical Data for Commercial Items are licensed to the U.S. * ! Government under vendor's standard commercial license. * ! * !************************************************************************* ! !++ ! FACILITY: ! VAX Language-Sensitive Editor ! ! ABSTRACT: ! This file contains TPU procedures for LSE that relate to the contents ! of the EVE$EXTRAS.TPU file. ! ! ENVIRONMENT: ! ! VAX/VMS ! ! Author: Paul B. Patrick, Technical Languages and Environments ! ! CREATION DATE: 13-Jul-1989 ! ! MODIFIED BY: ! ! X3.0-0 PBP 13-Jul-89 Created this file ! X3.1 DAS 28-Mar-90 Use CREATE/TERM if on DECwindows V2 ! X3.1-1 DAS 13-Apr-90 Use nested if and not AND on decwindows_v1 ! X3.1-2 DAS 24-Apr-90 Change SCREEN_UPDATE ON/OFF to SUCCESS ! ON/OFF to fix cursor position on SPELL. ! X3.1-3 DAS 25-Apr-90 Changed how original success is saved ! X3.2 NMC 13-Jul-90 Remove lse$$decwindows_v1 support in ! eve_spell ! X3.3 LRH 10-Dec-91 Copied in TPU's eve_spell, eve$$spell ! and added decwindows and overview support ! X4.0 SHE 02-Jun-92 Modified eve$$spell to use LSE's prompting ! X4.0-1 SHE 16-Sep-92 Merge in EVE's fix for eve$$spell not ! releasing the scratch buffer if DEC Spell ! is not installed. ! ! EVE$EXTRAS.TPU Page 2 procedure lse$eve_extras_module_ident return "X4.0-1"; endprocedure; ! EVE$EXTRAS.TPU Page 4 procedure eve_spell ! Run SPELLing corrector over text (;spell_args) ! VMS qualifiers (Ultrix options) for spell command local ok_to_ask, ok_to_write, text_ptr, start_mark, end_mark, range_ptr, filespec; on_error [OTHERWISE]: endon_error; if current_window = eve$command_window then eve$message (EVE$_CANTCMDWINDOW); eve$learn_abort; return (FALSE); endif; if not eve$declare_intention (eve$k_action_spell) then return (FALSE); endif; text_ptr := eve$selection (FALSE,,, eve$x_select_remove_flag,, TRUE); if text_ptr = 0 then text_ptr := current_buffer; endif; if get_info (text_ptr, "type") <> RANGE then text_ptr := current_buffer; ! ! ### LSE CHANGE: check overview records ! start_mark := beginning_of (current_buffer); end_mark := end_of (current_buffer); range_ptr := create_range(start_mark, end_mark, NONE); else range_ptr := text_ptr; ! ! ### END OF LSE CHANGE ! endif; ! ! ### LSE CHANGE: check overview records ! IF NOT lse$source_only(range_ptr) then MESSAGE(lse$_cantdobuffer,tpu$k_message_text,"SPELL", "- buffer contains overview records"); eve$learn_abort; return (false); endif; ! ! ### END OF LSE CHANGE ! eve$x_spell_flag description ! -------------------- ----------- ! unspecified (default) ask if want to write modified buffer ! true don't ask, write out modified buffer ! false don't ask, don't write modified buffer if get_info (current_buffer, "modified") and (not eve$x_ultrix_active) then if eve$x_spell_flag = tpu$k_unspecified then ok_to_ask := TRUE; ok_to_write := TRUE; else if eve$x_spell_flag then ok_to_write := TRUE; endif; endif; if ok_to_ask then if not lse$prompt_boolean( tpu$k_unspecified, ok_to_write, FAO (lse$get_message_text (EVE$_SPELLPROMPT), get_info (current_buffer, "name")), '', 'Y') then return (false); endif; endif; if ok_to_write then lse_save_file; endif; endif; eve$message (EVE$_INVOKINGSPELL); if get_info(spell_args, "type") = UNSPECIFIED then spell_args := " " endif; if eve$$spell (text_ptr, spell_args) then if eve$x_ultrix_active then eve$message (EVE$_SPELLDONEULT); else eve$message (EVE$_SPELLDONE, eve$k_success, get_info (eve$$x_spell_save_buffer, "name")); endif; return (TRUE); else return (FALSE); ! already did learn_abort endif; endprocedure; ! eve_spell ! ! Supercede EVE$$SPELL in order to use the CREATE/TERMINAL on DECwindows EVE. ! This only works on DECwindows V2 and later systems. ! procedure eve$$spell ! Actually invoke spell checker (text_ptr, ! range or buffer to be spelled spell_args) ! VMS qualifiers (Ultrix options) for spell command local local_text, text_buffer, is_empty, the_file, the_file1, the_position, is_range, is_box, is_offset, original_success, status, saved_box_flag, this_buffer, this_window, spell_window, saved_window, saved_mark, start_mark, end_mark; on_error [TPU$_CONTROLC]: eve$$restore_position (saved_window, saved_mark); eve$x_box_select_flag := saved_box_flag; eve$$release_scratch_buffer; set (SUCCESS, original_success); eve$learn_abort; abort; [TPU$_CREATEFAIL]: set (SCREEN_UPDATE, ON); %if eve$x_option_decwindows %then eve$popup_message (message_text (EVE$_CANTCREASPELL, 1)); %else eve$message (EVE$_CANTCREASPELL); %endif set (SUCCESS, original_success); eve$learn_abort; return (FALSE); [OTHERWISE]: eve$$restore_position (saved_window, saved_mark); eve$x_box_select_flag := saved_box_flag; eve$$release_scratch_buffer; set (SUCCESS, original_success); endon_error; saved_window := current_window; saved_mark := mark (FREE_CURSOR); saved_box_flag := eve$x_box_select_flag; original_success := SET (SUCCESS, OFF); local_text := text_ptr; if not eve$$reserve_scratch_buffer then eve$message (EVE$_ILLSCRATCHRES); eve$learn_abort; return (FALSE); endif; status := FALSE; if not eve$x_ultrix_active then ! first see if DECspell is installed (assume SYS$SYSTEM:LNGSPLCOR.EXE) eve$reset_file_search; ! Negate earlier file_search with same name. if file_search ("LNGSPLCOR", "SYS$SYSTEM:.EXE") = "" then eve$message (EVE$_NODECSPELL); eve$learn_abort; eve$$release_scratch_buffer; set (SUCCESS, original_success); return (status); endif; endif; ! See if it's a buffer or range or box selection if get_info (local_text, "type") = BUFFER then ! entire buffer text_buffer := local_text; else if get_info (local_text, "type") = ARRAY then ! box selection is_box := TRUE; text_buffer := get_info (local_text {0}, "buffer"); else ! standard selection if get_info (local_text, "type") = RANGE then ! box selection is_range := TRUE; text_buffer := get_info (local_text, "buffer"); else ! bad selection? eve$message (EVE$_EVEINTERROR); eve$learn_abort; return (status); endif; endif; endif; if not eve$x_ultrix_active then ! Don't spell an unmodifable buffer on VMS where correction is done. if not get_info (text_buffer, "modifiable") then eve$message (EVE$_BUFUNMODIFIABLE, 0, get_info (current_buffer, "name")); eve$learn_abort; return (status); endif; endif; ! Create spell buffer and process if get_info (eve$$x_spell_save_buffer, "type") <> BUFFER then if eve$$x_buf_str_spell_save = tpu$k_unspecified then eve$$x_buf_str_spell_save := "$SPELL$"; endif; eve$$x_spell_save_buffer := eve$init_buffer (eve$$x_buf_str_spell_save, ""); endif; if (get_info (eve$$x_spell_process, "type") = UNSPECIFIED) or (eve$$x_spell_process = 0) then if eve$x_ultrix_active then eve$$x_spell_process := create_process (eve$$spell_buffer); else eve$$x_spell_process := create_process (eve$$spell_buffer, "$ set noon"); ! disregard user symbol send ("$ delete:==delete", eve$$x_spell_process); endif; endif; the_file := str (get_info (eve$$x_spell_process, "pid")) + ".tmp"; if eve$x_ultrix_active then ! Ultrix: write to the_file, redirect spell output to the_file1. the_file1 := the_file + ".1"; else the_file := "sys$scratch:" + the_file; endif; ! insure we do complete lines (otherwise single words selected in the middle of ! a line get read_file'd onto previous line, too nasty to prevent) if is_range then start_mark := beginning_of (local_text); end_mark := end_of (local_text); if get_info (start_mark, "offset") > 0 then position (start_mark); position (LINE_BEGIN); start_mark := mark (NONE); endif; if get_info (end_mark, "offset") > 0 then position (end_mark); position (LINE_END); end_mark := mark (NONE); endif; local_text := create_range (start_mark, end_mark, NONE); endif; erase (eve$$x_scratch_buffer); erase (eve$$x_spell_save_buffer); ! Copy the text to the $SPELL$ buffer. (saves text on VMS) if is_box then ! A box selection. eve$x_box_select_flag := TRUE; eve$$store_remove (eve$$x_spell_save_buffer, ! buffer to copy to FALSE, ! don't delete it FALSE, ! no messages local_text); ! text to copy eve$x_box_select_flag := saved_box_flag; the_position := beginning_of (local_text {1}); else ! An entire buffer or a standard selection. the_position := beginning_of (local_text); position (eve$$x_spell_save_buffer); copy_text (local_text); endif; ! write out temp file, then check it, then read in results position (eve$$x_scratch_buffer); write_file (eve$$x_spell_save_buffer, the_file); if eve$x_ultrix_active then ! % spell -d hlist infile > outfile send ("/usr/bin/spell " + spell_args + " " + the_file + " > " + the_file1, eve$$x_spell_process); read_file (the_file1); else ! ! Invoke differently under DECwindows. We will specifically state that the ! number of lines is 24, since the default is whatever the user DECterm ! customizations are and SPELL will only use 24 lines. ! ! Note that the DECterm title should not be changed to have a string with the ! word EVE in it. This would cause LSE to supercede the procedure. ! ! Note that this command comes very close to TPU's limit on the mailbox length, ! so caution must be taken in enhancing this command. ! if eve$x_decwindows_active then send ('CREA/TERM/WAIT/WIND=(TITL="Spell Window",ICON="Spell",ROW=24)' + ' SPELL '+ the_file + '/OUTP=' + the_file, eve$$x_spell_process); else spawn ("spell " + spell_args + " " + the_file + "/output=" + the_file); endif; read_file (the_file); endif; position (the_position); if get_info (eve$$x_scratch_buffer, "record_count") = 0 then ! something went wrong if eve$x_ultrix_active then eve$message (EVE$_NOSPELLTEXTULT); erase (eve$$x_spell_save_buffer); ! show no text if it's mapped else eve$message (EVE$_NOSPELLTEXT); endif; else if eve$x_ultrix_active then ! Split windows like SHELL command, show mispellings in other window. this_buffer := current_buffer; if this_buffer = eve$$x_spell_save_buffer then spell_window := current_window; else if eve$x_number_of_windows = 1 then eve_split_window (2); this_window := eve$top_window; spell_window := current_window; map (spell_window, eve$$x_spell_save_buffer); else this_window := current_window; spell_window := eve$get_mapped_window (eve$$x_spell_save_buffer); if spell_window = 0 then ! insure the spell_window is opposite the current_window spell_window := eve$bottom_window; if spell_window = this_window then spell_window := eve$top_window; endif; endif; map (spell_window, eve$$x_spell_save_buffer); endif; endif; eve$set_status_line (spell_window); erase (eve$$x_spell_save_buffer); position (eve$$x_spell_save_buffer); copy_text (eve$$x_scratch_buffer); position (BUFFER_BEGIN); if this_buffer <> eve$$x_spell_save_buffer then position (this_window); endif; status := TRUE; else if is_box then ! Cut the box (using eve$x_box_pad_flag + buffer mode) erase (eve$$x_spell_save_buffer); eve$$box_cut (local_text, eve$$x_spell_save_buffer, TRUE, ! delete the box FALSE); ! no messages ! Paste the corrected text (using eve$x_box_pad_flag + buffer mode) eve$$box_paste (eve$$x_scratch_buffer); status := TRUE; else erase (local_text); if get_info (current_buffer, "record_count") = 0 then ! either spell'd w/no range, or range covered entire buffer is_empty := TRUE; split_line; else if (the_position <> beginning_of (current_buffer)) then ! put marker @eol before line where corrected text is put move_horizontal (-1); the_position := mark (NONE); move_horizontal (1); is_offset := 1; endif; endif; eve$insert_text (eve$$x_scratch_buffer); position (the_position); if is_offset ! position to start of corrected text then move_horizontal (1); else position (beginning_of (current_buffer)); if is_empty then ! erase temporary modification erase_line; endif; endif; status := TRUE; endif; endif; endif; eve$$release_scratch_buffer; if eve$x_ultrix_active then send ("/bin/rm " + the_file + " " + the_file1, eve$$x_spell_process); else send ("$ delete " + the_file + ";*", eve$$x_spell_process); endif; set (SUCCESS, original_success); if not status then eve$learn_abort; endif; return (status); endprocedure ! eve$$spell