! [LOMASKY.EVE]BSPELL.TPU$COMMAND ! ! Teradyne-created TPU procedures used for extending EVE's spell checker ! ! <<<<< Modification History >>>>>> ! 01/06/92 Brian Lomasky Chged to BSPELL cuz new SPELL interface ! 11/12/91 Brian Lomasky Added new output file create and check ! 11/04/91 Brian Lomasky Original ! module eve$extras ident "V02-036" procedure eve_bspell ! Run SPELLing corrector over text local text_ptr; on_error [OTHERWISE]: endon_error; %if eve$x_option_decwindows %then if eve$x_decwindows_active then eve$message (EVE$_NODECWCMD, 0, message_text (EVE$_SPELL)); return (FALSE); endif; %endif 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); if get_info (text_ptr, "type") <> RANGE then text_ptr := current_buffer; endif; eve$message (EVE$_INVOKINGSPELL); if eve$$spell (text_ptr) then eve$message (EVE$_SPELLDONE); return (TRUE); else return (FALSE); ! already did learn_abort endif; endprocedure; ! eve_bspell procedure eve$$spell (text_ptr) ! Actually invoke SPELL_DIR:SPELL.EXE local local_text, text_buffer, start_mark, end_mark, the_file, the_file2, the_position, is_offset; on_error [TPU$_CONTROLC]: set (SCREEN_UPDATE, ON); 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 eve$learn_abort; return (FALSE); [OTHERWISE]: set (SCREEN_UPDATE, ON); endon_error; local_text := text_ptr; ! first see if SPELL_DIR:SPELL.EXE is installed eve$reset_file_search; ! Negate earlier file_search with same name. if file_search ("SPELL", "SPELL_DIR:.EXE") = "" then eve$message (EVE$_NODECSPELL); eve$learn_abort; return (0); endif; if get_info (text_ptr, "type") = BUFFER ! Don't spell an unmodifable buffer then text_buffer := text_ptr; else text_buffer := get_info (text_ptr, "buffer"); endif; if not get_info (text_buffer, "modifiable") then eve$message (EVE$_BUFUNMODIFIABLE, 0, get_info (current_buffer, "name")); eve$learn_abort; return (FALSE); endif; if get_info (eve$$spell_buffer, "type") <> BUFFER then if eve$$x_buf_str_spell = tpu$k_unspecified then eve$$x_buf_str_spell := "SPELL"; endif; eve$$spell_buffer := eve$init_buffer (eve$$x_buf_str_spell, ""); endif; if (get_info (eve$$x_spell_process, "type") = UNSPECIFIED) or (eve$$x_spell_process = 0) then eve$$x_spell_process := create_process (eve$$spell_buffer, "$ set noon"); send ("$ delete:==delete", eve$$x_spell_process); ! disregard user symbols endif; the_file := "sys$scratch:" + str (get_info (eve$$x_spell_process, "pid")) + ".tmp"; the_file2 := "sys$scratch:" + str (get_info (eve$$x_spell_process, "pid")) + ".SPL"; set (SCREEN_UPDATE, OFF); ! 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 get_info (local_text, "type") = 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; ! write out temp file to be checked by SPELL_DIR:SPELL.EXE write_file (local_text, the_file); ! should on_error return false? spawn ("SPELL " + the_file + "/EVE"); send ("$ delete " + the_file + ";*", eve$$x_spell_process); ! see if the .SPL file was correctly created by SPELL if file_search (the_file2) = "" then eve$learn_abort; set (SCREEN_UPDATE, ON); refresh; eve$message ("Error from Spelling-Checker - No changes have been made."); return (FALSE); endif; the_position := beginning_of (local_text); erase (local_text); if (the_position <> beginning_of (current_buffer)) then move_horizontal (-1); the_position := mark (NONE); move_horizontal (1); is_offset := 1; endif; read_file (the_file2); ! get corrected text position (the_position); if is_offset then move_horizontal (1); else position (beginning_of (current_buffer)); endif; send ("$ delete " + the_file2 + ";*", eve$$x_spell_process); set (SCREEN_UPDATE, ON); refresh; return (TRUE); endprocedure ! eve$$spell ! Module initialization code ! Global process varibles eve$$x_spell_process := 0; ! DCL subprocess used by SPELL command endmodule; eve$$require ("eve$core"); ! Build dependencies