! EVE$FORMAT.TPU 31-DEC-1992 10:29 Page 1 module eve$format ident "V03-014" ! ! COPYRIGHT © 1986,1992 BY ! DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASSACHUSETTS ! ALL RIGHTS RESERVED ! ! THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED ! ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND WITH THE ! INCLUSION OF THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE OR ANY OTHER ! COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY ! OTHER PERSON. NO TITLE TO AND OWNERSHIP OF THE SOFTWARE IS HEREBY ! TRANSFERRED. ! ! THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE ! AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT ! CORPORATION. ! ! DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY OF ITS ! SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DIGITAL. ! !++ ! FACILITY: ! DECTPU - Text Processing Utility ! EVE - Extensible Versatile Editor ! ! ABSTRACT: ! This is the source program for the EVE interface text formatting ! features. This file was obtained from the old evesecini.tpu file. ! ! ENVIRONMENT: ! OpenVMS VAX, OpenVMS AXP, RISC/ULTRIX ! !Author: Bill Robinson ! ! CREATION DATE: 10-Oct-1986 ! ! MODIFIED BY: ! !-- ! EVE$FORMAT.TPU Page 2 !++ ! Table of Contents ! ! EVE$FORMAT.TPU ! 31-DEC-1992 10:29 ! ! Procedure name Page Description ! -------------- ---- ------------ ! ! eve$format_declare_synonym 3 Declare Synonyms for tab args ! eve$current_word 4 Make range for current word ! eve$$indent_line_to 5 Indent line to a column ! eve_set_wrap 6 Set right margin action ! eve_set_nowrap 6 Disable right margin action ! eve_capitalize_word 7 Capitalize word (or select/find ranges) ! eve$capitalize_range 8 Capitalize a range ! eve_center_line 9 Center line between margins using spaces ! eve_fill_paragraph 10 Fill paragraph between margins using spaces ! eve_fill_range 11 Fill the selected text range ! eve$fill_range 12 Fill a range ! eve_fill 13 Fill select range or paragraph ! eve$paragraph_break 14 Test if cursor is on paragraph break ! eve_lowercase_word 15 Lowercase current word ! eve_uppercase_word 15 Uppercase current word ! eve_set_left_margin 16 Set the left margin ! eve_set_right_margin 17 Set the right margin ! eve_set_tabs 18 Set tabs ! eve_set_paragraph_indent 19 Set paragraph indent ! eve$$word_wrap 20 Word wrap at right margin ! eve$$word_wrap_insert 21 Insert a char in wordwrapping ! eve$expand_to_choices 22 Put choices on separate lines ! eve$get_choice 23 Find match in choice buffer ! eve$strip_choices 24 Remove first n characters from choices ! eve$display_choices 25 Prepare choices for display ! eve$$letter_wrap 26 Letter wrap the current line ! eve$capitalize_string 27 Capitalize a string ! eve$add_choice 28 Add a choice ! eve$format_choices 29 Format the choice buffer ! eve$$reserve_scratch_buffer 30 Reserve scratch buffer for use ! eve$$release_scratch_buffer 30 Release scratch buffer from use ! eve_convert_tabs 31 Replace Tabs with spaces ! eve$convert_tabs 31 Convert tabs subprocedure ! eve_set_fill_tags 32 ! eve_set_fill_notags 32 ! eve$set_para_breaks 32 Assign paragraph break patterns !-- ! EVE$FORMAT.TPU Page 3 procedure eve$format_declare_synonym ! Declare Synonyms for tab args ! Declare synonyms for Set Tabs arguments eve$build_synonym ("at",, 2); eve$build_synonym ("every",, 2); eve$build_synonym ("spaces",, 2); eve$build_synonym ("movement",, 2); eve$build_synonym ("insert",, 2); eve$build_synonym ("invisible",, 2); eve$build_synonym ("visible",, 2); endprocedure; ! eve$format_declare_synonym ! EVE$FORMAT.TPU Page 4 procedure eve$current_word ! Make range for current word ! Returns a range for the current word (the next word if between words). ! Cursor moves to end of the word. Returns 0 if no current word. ! Used by change-case commands and others. local start_current_word, ! Marker for start of range end_current_word, ! Marker for end of range saved_mark; ! Marker for current cursor position position (TEXT); ! snap cursor saved_mark := mark (FREE_CURSOR); if saved_mark = end_of (current_buffer) then return (0); endif; if current_character = "" then move_horizontal (1); return (create_range (saved_mark, saved_mark, NONE)); endif; if eve$x_word_is_on_left then ! If on whitespace, current word is word to left. Desired behavior. if not eve$at_start_of_word then eve$start_of_word; endif; start_current_word := mark (FREE_CURSOR); eve$end_of_word; move_horizontal (-1); end_current_word := mark (FREE_CURSOR); move_horizontal (1); else ! If on whitespace, current word is word on right. EVE behavior since V1.0. ! If on a word separator, go to next word. if index (eve$$x_word_separators, current_character) <> 0 then eve$end_of_word; endif; ! Go to end of word first - eve$start_of_word goes back a word ! when current cursor is at the start of a word eve$end_of_word; move_horizontal (-1); end_current_word := mark (FREE_CURSOR); move_horizontal (1); eve$start_of_word; start_current_word := mark (FREE_CURSOR); eve$end_of_word; endif; return (create_range (start_current_word, end_current_word, NONE)); endprocedure; ! eve$current_word ! EVE$FORMAT.TPU Page 5 procedure eve$$indent_line_to ! Indent line to a column (which_column) ! Column to indent to - input ! Indent this line to the specified column, making using of existing whitespace ! Leave cursor at the specified column. local this_buffer; ! Current buffer on_error [OTHERWISE]: endon_error; this_buffer := current_buffer; move_horizontal (-current_offset); loop exitif get_info (this_buffer, "offset_column") >= which_column; if (current_character = " ") or (current_character = ascii (9)) then move_horizontal (1); else exitif 1; endif; endloop; eve$to_column (which_column); endprocedure; ! eve$$indent_line_to ! EVE$FORMAT.TPU Page 6 procedure eve_set_wrap ! Set right margin action on_error [OTHERWISE]: endon_error; set (RIGHT_MARGIN_ACTION, current_buffer, eve$kt_word_wrap_routine); eve$message (EVE$_WRAPON); return (TRUE); endprocedure; ! eve_set_wrap procedure eve_set_nowrap ! Disable right margin action on_error [OTHERWISE]: endon_error; set (RIGHT_MARGIN_ACTION, current_buffer); eve$message (EVE$_WRAPOFF); return (TRUE); endprocedure; ! eve_set_nowrap ! EVE$FORMAT.TPU Page 7 procedure eve_capitalize_word ! Capitalize word (or select/find ranges) local the_range, a_range, the_index, ! Index for box selection array start_word, word_range, ! Range for current word word_string, ! String for current word saved_mark, ! Original location first_word; ! Boolean for first word in range if not eve$test_if_modifiable (current_buffer) then eve$learn_abort; return (FALSE); endif; if not eve$declare_intention (eve$k_action_change_case) then return (FALSE); endif; position (TEXT); ! no padding blank lines saved_mark := mark (NONE); the_range := eve$selection (FALSE,,, eve$x_select_remove_flag,, TRUE); if the_range <> 0 then if get_info (the_range, "type") = ARRAY then ! box selection the_index := 1; loop a_range := the_range {the_index}; exitif a_range = tpu$k_unspecified; if not eve$capitalize_range (a_range) then eve$learn_abort; return (FALSE); endif; the_index := the_index + 1; endloop; return (TRUE); endif; ! standard selection return (eve$capitalize_range (the_range)); endif; ! no selection word_range := eve$current_word; if (word_range <> 0) and (current_offset > 0) then word_string := erase_character (-length (word_range)); eve$capitalize_string (word_string); eve$insert_text (word_string); ! leaves cursor after inserted text endif; return (TRUE); endprocedure; ! eve_capitalize_word ! EVE$FORMAT.TPU Page 8 procedure eve$capitalize_range ! Capitalize a range (the_range) ! Capitalize all words in the_range. Does not cap entire word at start of ! the_range, just from start of the_range. Caps entire word at end of ! the_range. local start_word, the_begin, ! Start of the_range the_end, ! Ent of the_range word_range, ! Range for current word word_string, ! String for current word saved_mark, ! Original location first_word; ! Boolean for first word in range the_begin := beginning_of (the_range); the_end := end_of (the_range); position (the_begin); first_word := TRUE; loop exitif mark (NONE) > the_end; if first_word then ! capitalize current character of the 1st word (skipping ! punctuation), don't go back to start of word start_word := mark (NONE); eve$end_of_word; move_horizontal (-1); word_range := create_range (start_word, mark (NONE), NONE); move_horizontal (1); else word_range := eve$current_word; endif; ! don't go past select range if end_of (word_range) > the_end then word_range := create_range (beginning_of (word_range), the_end, NONE); position (end_of (word_range)); move_horizontal (1); endif; if (word_range <> 0) and (current_offset > 0) then if (first_word) or ((not first_word) and (beginning_of (word_range) >= the_begin)) then word_string := substr (word_range, 1, length (word_range)); ! insure leading punctuation is skipped over eve$capitalize_string (word_string); eve$insert_text (word_string); erase (word_range); endif; endif; first_word := FALSE; endloop; return (TRUE); endprocedure; ! eve$capitalize_range ! EVE$FORMAT.TPU Page 9 procedure eve_center_line ! Center line between margins using spaces ! Center the current line between the margins local saved_mark, ! Marker for current cursor position count, ! Number of spaces to erase at start of line the_left_margin, ! Left margin for current buffer the_right_margin, ! Right margin for current buffer start_column, ! Start offset column of centerable text text_length; ! Length of centerable text if not eve$test_if_modifiable (current_buffer) then eve$learn_abort; return (FALSE); endif; if not eve$declare_intention (eve$k_action_format) then return (FALSE); endif; saved_mark := mark (NONE); if saved_mark = end_of (current_buffer) then eve$learn_abort; return (FALSE); endif; position (LINE_BEGIN); position (search_quietly (notany (eve$x_whitespace) | line_end, forward, exact)); count := current_offset; erase_character (-count); start_column := get_info (current_buffer, "offset_column"); position (LINE_END); count := current_offset; position (search_quietly (notany (eve$x_whitespace) | line_begin, reverse, exact)); if index (eve$x_whitespace, current_character) = 0 then move_horizontal (1); endif; erase_character (count - current_offset); the_left_margin := get_info (current_buffer, "left_margin"); the_right_margin := get_info (current_buffer, "right_margin"); ! How much whitespace to insert text_length := get_info (current_buffer, "offset_column"); if start_column <> 1 ! adjust for length of left margin (= start_column) then text_length := text_length - start_column + 1; endif; count := (((the_right_margin - the_left_margin) - text_length) / 2) + the_left_margin; eve$$indent_line_to (count); position (saved_mark); return (TRUE); endprocedure; ! eve_center_line ! EVE$FORMAT.TPU Page 10 procedure eve_fill_paragraph ! Fill paragraph between margins using spaces local saved_mark, ! Marker for current cursor position start_paragraph, ! Marker for start of current paragraph stop_paragraph, ! Marker for end of current paragraph the_right_margin, the_left_margin, the_indent, fill_range; ! Range for current paragraph on_error [OTHERWISE]: endon_error; ! Can't fill an empty buffer - avoid additional checks later on if beginning_of (current_buffer) = end_of (current_buffer) then eve$message (EVE$_NOFILL); eve$learn_abort; return (FALSE); endif; if not eve$declare_intention (eve$k_action_format) then return (FALSE); endif; position (TEXT); saved_mark := mark (NONE); ! First insure para break patterns are current. if eve$x_save_fill_tags <> eve$x_fill_tags then eve$set_para_breaks (eve$x_fill_tags); endif; ! Find beginning of paragraph. Paragraph breaks are blank lines, DOCUMENT tags, ! runoff commands, FF (hard FF), or FF+NL (soft FF). If on a paragraph break ! other than a DOCUMENT tag or runoff command line, then do preceding paragraph. position (LINE_BEGIN); if (not eve$x_save_fill_tags) and (search_quietly (eve$pattern_tag_break, FORWARD) <> 0) then ! on DOCUMENT tag or runoff command line, go to next line position (LINE_END); move_horizontal (1); start_paragraph := mark (NONE); else loop ! stop at top of buffer exitif mark (NONE) = beginning_of (current_buffer); move_vertical (-1); position (LINE_BEGIN); ! incase set(column_move_vertical,on) ! stop at a break and move to start of next line if eve$paragraph_break then position (LINE_END); move_horizontal (1); exitif; endif; endloop; start_paragraph := mark (NONE); position (saved_mark); endif; ! find end of paragraph loop position (LINE_BEGIN); exitif mark (NONE) = end_of (current_buffer); exitif eve$paragraph_break; move_vertical (1); endloop; if start_paragraph = mark (NONE) then eve$message (EVE$_NOFILL); position (saved_mark); eve$learn_abort; return (FALSE); else move_horizontal (-1); stop_paragraph := mark (NONE); ! Now fill the paragraph the_right_margin := get_info (current_buffer, "right_margin"); if eve$$x_word_wrap_indent {current_buffer} <> tpu$k_unspecified then the_left_margin := eve$$x_word_wrap_indent {current_buffer}; else the_left_margin := get_info (current_buffer, "left_margin"); endif; if eve$$x_paragraph_indent {current_buffer} <> tpu$k_unspecified then the_indent := eve$$x_paragraph_indent {current_buffer} - the_left_margin; else the_indent := get_info (current_buffer, "left_margin") - the_left_margin; endif; fill_range := create_range (start_paragraph, stop_paragraph, NONE); edit (fill_range, TRIM_LEADING, OFF); fill (fill_range, eve$x_fill_separators, the_left_margin, the_right_margin, the_indent); position (stop_paragraph); eve$show_first_line; endif; return (TRUE); endprocedure; ! eve_fill_paragraph ! EVE$FORMAT.TPU Page 11 procedure eve_fill_range ! Fill the selected text range on_error [OTHERWISE]: endon_error; return (eve$fill_range (eve$selection (FALSE,,, eve$x_select_remove_flag,, TRUE))); endprocedure; ! eve_fill_range ! EVE$FORMAT.TPU Page 12 procedure eve$fill_range ! Fill a range (range_arg) local the_range, start_mark, ! Start of the range to fill the_right_margin, the_left_margin, the_indent, tmp, status, old_right_margin, end_mark, ! Marker for end of range saved_pad_flag; on_error [TPU$_CONTROLC]: eve$$release_scratch_buffer; if old_right_margin <> 0 then set (RIGHT_MARGIN, eve$$x_scratch_buffer, old_right_margin); endif; eve$x_box_pad_flag := saved_pad_flag; eve$learn_abort; abort; [OTHERWISE]: eve$$release_scratch_buffer; if old_right_margin <> 0 then set (RIGHT_MARGIN, eve$$x_scratch_buffer, old_right_margin); endif; eve$x_box_pad_flag := saved_pad_flag; endon_error; saved_pad_flag := eve$x_box_pad_flag; if not eve$declare_intention (eve$k_action_format) then return (FALSE); endif; the_range := range_arg; if the_range <> 0 then if get_info (the_range, "type") = ARRAY then ! box selection if not eve$$reserve_scratch_buffer then eve$message (EVE$_ILLSCRATCHRES); return (FALSE); endif; erase (eve$$x_scratch_buffer); position (the_range {1}); ! cut box to scratch buffer eve$x_box_pad_flag := true; ! force overstrike behavior eve$$box_cut (the_range, eve$$x_scratch_buffer, TRUE, ! delete the box FALSE); ! no messages eve$x_box_pad_flag := saved_pad_flag; ! set up the scratch buffer to be filled to box's width old_right_margin := get_info (eve$$x_scratch_buffer, "right_margin"); if length (the_range {1}) = 1 then ! avoid left=right=1 set (RIGHT_MARGIN, eve$$x_scratch_buffer, 2); else set (RIGHT_MARGIN, eve$$x_scratch_buffer, length (the_range {1})); endif; eve$trim_buffer (eve$$x_scratch_buffer); position (eve$$x_scratch_buffer); if eve$fill_range (create_range (BUFFER_BEGIN, BUFFER_END)) then ! Now overstrike the filled scratch buffer over original box. ! This can't add more lines since no text that exceeds the ! box right side is ever wrapped down. position (beginning_of (the_range {1})); eve$$box_overstrike (eve$$x_scratch_buffer); eve$clear_message; status := TRUE; else status := FALSE; endif; eve$$release_scratch_buffer; set (RIGHT_MARGIN, eve$$x_scratch_buffer, old_right_margin); return (status); endif; ! standard selection if beginning_of (the_range) <= end_of (the_range) then start_mark := beginning_of (the_range); end_mark := end_of (the_range); else end_mark := beginning_of (the_range); start_mark := end_of (the_range); endif; the_range := 0; position (start_mark); ! Move start_mark if on an DOCUMENT tag or runoff command line ! (first insure para break patterns are current) if eve$x_save_fill_tags <> eve$x_fill_tags then eve$set_para_breaks (eve$x_fill_tags); endif; loop exitif search_quietly (eve$pattern_skip_paragraph_break, FORWARD) = 0; ! skip past DOCUMENT tag, runoff command line, ff's position (LINE_END); move_horizontal (1); start_mark := mark (NONE); if (mark (NONE) > end_mark) or (mark (NONE) = end_of (current_buffer)) then return (TRUE); ! nothing to fill endif; endloop; loop ! Find the paragraph bounds for all paragraphs loop position (LINE_END); exitif mark (NONE) = end_of (current_buffer); move_horizontal (1); exitif mark (NONE) > end_mark; exitif eve$paragraph_break; endloop; move_horizontal (-1); if mark (NONE) > end_mark then position (end_mark); endif; the_right_margin := get_info (current_buffer, "right_margin"); if eve$$x_word_wrap_indent {current_buffer} <> tpu$k_unspecified then the_left_margin := eve$$x_word_wrap_indent {current_buffer}; else the_left_margin := get_info (current_buffer, "left_margin"); endif; if eve$$x_paragraph_indent {current_buffer} <> tpu$k_unspecified then the_indent := eve$$x_paragraph_indent {current_buffer} - the_left_margin; else the_indent := get_info (current_buffer, "left_margin") - the_left_margin; endif; the_range := create_range (start_mark, mark (NONE), NONE); edit (the_range, TRIM_LEADING, OFF); ! Indents are allowed only if the range begins at the left margin. if the_indent <> 0 then tmp := beginning_of (the_range); if get_info (tmp, "offset_column") <> get_info (tmp, "left_margin") then eve$message (EVE$_NOFILLINDENT); return (FALSE); endif; endif; fill (the_range, eve$x_fill_separators, the_left_margin, the_right_margin, the_indent); loop ! Skip the inter-paragraph break; position (LINE_END); move_horizontal (1); exitif not eve$paragraph_break; endloop; start_mark := mark (NONE); exitif start_mark >= end_mark; endloop; position (end_mark); !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!! screen manager issue !!!!!!!!!!!!!!!!!!!!!!!!!! update (current_window); !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! else eve$message (EVE$_SELFIRST); eve$learn_abort; return (FALSE); endif; eve$clear_message; return (TRUE); endprocedure; ! eve$fill_range ! EVE$FORMAT.TPU Page 13 procedure eve_fill ! Fill select range or paragraph local the_selection; the_selection := eve$selection (FALSE,,, eve$x_select_remove_flag,, TRUE); if the_selection <> 0 then return (eve$fill_range (the_selection)); else return (eve_fill_paragraph); endif; endprocedure; ! eve_fill ! EVE$FORMAT.TPU Page 14 procedure eve$paragraph_break ! Test if cursor is on paragraph break ! Returns true if current line looks like a runoff command (starts with ! a period followed by an alphabetic character) or a blank line, ! else returns false. Assumes cursor was at start of line. on_error [OTHERWISE]: endon_error; ! insure para break patterns are current if eve$x_save_fill_tags <> eve$x_fill_tags then eve$set_para_breaks (eve$x_fill_tags); endif; if search_quietly (eve$pattern_paragraph_break, FORWARD) <> 0 then return (TRUE); endif; endprocedure; ! eve$paragraph_break ! EVE$FORMAT.TPU Page 15 procedure eve_lowercase_word ! Lowercase current word ! Put word in all lowercase letters local the_range, a_range, the_index; position (TEXT); ! snap to text if not eve$test_if_modifiable (current_buffer) then eve$learn_abort; return (FALSE); endif; if not eve$declare_intention (eve$k_action_change_case) then return (FALSE); endif; the_range := eve$selection (FALSE,,, eve$x_select_remove_flag,, TRUE); if the_range = 0 then the_range := eve$current_word; endif; if the_range <> 0 then if get_info (the_range, "type") = ARRAY then ! a box selection the_index := 1; loop a_range := the_range {the_index}; exitif a_range = tpu$k_unspecified; change_case (a_range, LOWER); position (end_of (a_range)); move_horizontal (1); if a_range = eve$x_found_range then eve$$remove_found_range; endif; the_index := the_index + 1; endloop; return (TRUE); endif; ! a standard selection or word change_case (the_range, LOWER); position (end_of (the_range)); move_horizontal (1); if the_range = eve$x_found_range then eve$$remove_found_range; endif; endif; return (TRUE); endprocedure; ! eve_lowercase_word procedure eve_uppercase_word ! Uppercase current word ! Put word in all uppercase letters local the_range, a_range, the_index; position (TEXT); ! snap to text if not eve$test_if_modifiable (current_buffer) then eve$learn_abort; return (FALSE); endif; if not eve$declare_intention (eve$k_action_change_case) then return (FALSE); endif; the_range := eve$selection (FALSE,,, eve$x_select_remove_flag,, TRUE); if the_range = 0 then the_range := eve$current_word; endif; if the_range <> 0 then if get_info (the_range, "type") = ARRAY then ! a box selection the_index := 1; loop a_range := the_range {the_index}; exitif a_range = tpu$k_unspecified; change_case (a_range, UPPER); position (end_of (a_range)); move_horizontal (1); if a_range = eve$x_found_range then eve$$remove_found_range; endif; the_index := the_index + 1; endloop; return (TRUE); endif; ! a standard selection or word change_case (the_range, UPPER); position (end_of (the_range)); move_horizontal (1); if the_range = eve$x_found_range then eve$$remove_found_range; endif; endif; return (TRUE); endprocedure; ! eve_uppercase_word ! EVE$FORMAT.TPU Page 16 procedure eve_set_left_margin ! Set the left margin (set_parameter) ! New left margin - input ! Set left margin without changing right margin local new_left_margin, ! Local copy of set_parameter relative_indent, ! Current paragraph indent setting current_right_margin; ! Right margin for current buffer on_error [OTHERWISE]: endon_error; if not (eve$prompt_number (set_parameter, new_left_margin, message_text (EVE$_LEFTPROMPT, 1), message_text (EVE$_LEFTNOTCHNG, 0))) then eve$learn_abort; return (FALSE); endif; if new_left_margin <= 0 then eve$message (EVE$_LEFTGTONE); else current_right_margin := get_info (current_buffer, "right_margin"); if eve$$x_paragraph_indent {current_buffer} <> tpu$k_unspecified then ! get the relative value of the indent relative_indent := eve$$x_paragraph_indent {current_buffer} - get_info (current_buffer, "left_margin"); if (relative_indent + new_left_margin) >= current_right_margin then eve$message (EVE$_PINDENTTOOBIG, 0, get_info (current_buffer, "right_margin")); eve$learn_abort; return (FALSE); endif; if (relative_indent + new_left_margin) <= 0 then eve$message (EVE$_BADLEFTPINDENT, eve$k_warning, new_left_margin, relative_indent); eve$learn_abort; return (FALSE); endif; eve$$x_paragraph_indent {current_buffer} := relative_indent + new_left_margin; endif; if new_left_margin >= current_right_margin then eve$message (EVE$_LEFTLESSRIGHT, 0, current_right_margin); else set (LEFT_MARGIN, current_buffer, new_left_margin); if get_info (current_buffer, "bound") then if mark (NONE) <> end_of (current_buffer) then if (current_character = "") and (length (current_line) = 0) then if mark (NONE) = beginning_of (current_buffer) then erase_line; split_line; move_horizontal (-1); else append_line; split_line; endif; endif; endif; endif; eve$message (EVE$_LEFTSETTO, 0, get_info (current_buffer, "left_margin")); return (TRUE); endif; endif; eve$learn_abort; return (FALSE); endprocedure; ! eve_set_left_margin ! EVE$FORMAT.TPU Page 17 procedure eve_set_right_margin ! Set the right margin (set_parameter) ! New right margin - input ! Set right margin without changing left margin local new_right_margin, ! Local copy of set_parameter current_left_margin; ! Left margin of current buffer on_error [OTHERWISE]: endon_error; if not (eve$prompt_number (set_parameter, new_right_margin, message_text (EVE$_RIGHTPROMPT, 1), message_text (EVE$_RIGHTNOTCHNG, 0))) then eve$learn_abort; return (FALSE); endif; current_left_margin := get_info (current_buffer, "left_margin"); if eve$$x_paragraph_indent {current_buffer} <> tpu$k_unspecified then if eve$$x_paragraph_indent {current_buffer} >= new_right_margin then eve$message (EVE$_PINDENTTOOBIG, 0, get_info (current_buffer, "right_margin")); eve$learn_abort; return (FALSE); endif; endif; if new_right_margin <= current_left_margin then eve$message (EVE$_RIGHTGTLEFT, 0, current_left_margin); eve$learn_abort; return (FALSE); else set (RIGHT_MARGIN, current_buffer, new_right_margin); eve$message (EVE$_RIGHTSETTO, 0, get_info (current_buffer, "right_margin")); endif; return (TRUE); endprocedure; ! eve_set_right_margin ! EVE$FORMAT.TPU Page 18 procedure eve_set_tabs ! Set tabs (the_argument) ! string (input) composed of a required first ! token and an optional second token. ! The required first tokens are: ! = AT = set tabs at the specified positions - input ! = EVERY = set tabs every n columns ! = INSERT = insert a tab character - ascii(9) ! = SPACES = insert equivalent number of spaces ! = MOVEMENT= move cursor to the next (forward) tab stop ! = VISIBLE = make tabs visible ! = INVISIBLE = make tabs invisible ! The optional second token is a string that contains the AT/EVERY ! tab settings. local local_argument, ! Local copy of the_argument the_function, ! Local copy of 1st token the_settings, ! Local copy of 2nd token temp, ! For case changes the_column, ! Current column tab_increment, ! Copy of the_settings for EVERY matched_string, ! String returned from test_synonym for choices the_result, ! Copy of current Set Tabs parameter saved_mark, ! Current position in buffer resulting_message, ! success msg.text (0 if errors in validation) attribute_type, ! Attribute identifier: parm. to define attr. the_command, ! "Set tabs" string or synonym for choices tab_settings; ! Copy of the_settings for AT on_error [TPU$_CONTROLC]: eve$$restore_position (saved_mark); eve$learn_abort; abort; [OTHERWISE]: eve$$restore_position (saved_mark); eve$message (EVE$_CANTCHNGTABS); endon_error; local_argument := the_argument; if local_argument = "" then if not eve$prompt_string (the_argument, local_argument, message_text (EVE$_SETTABPROMPT, 1), message_text (EVE$_NOSETTAB, 0)) then eve$learn_abort; return (FALSE); endif; endif; the_function := eve$$get_next_word (local_argument, " "); the_settings := local_argument; ! the rest is the_argument change_case (the_function, LOWER); saved_mark := mark (FREE_CURSOR); position (TEXT); ! snap cursor !** How do we get the synonym for this command? the_command := "set tabs "; erase (eve$choice_buffer); ! function can't be ambiguous in English, but could be in other languages, so ! we test for all possible input functions & build choices buffer just in case. if eve$test_synonym ("at", the_function, 1, matched_string) then the_result := 1; eve$add_choice (matched_string); endif; if eve$test_synonym ("every", the_function, 1, matched_string) then the_result := 2; eve$add_choice (matched_string); endif; if eve$test_synonym ("spaces", the_function, 1, matched_string) then the_result := 3; eve$add_choice (matched_string); endif; if eve$test_synonym ("movement", the_function, 1, matched_string) then the_result := 4; eve$add_choice (matched_string); endif; if eve$test_synonym ("insert", the_function, 1, matched_string) then the_result := 5; eve$add_choice (matched_string); endif; if eve$test_synonym ("invisible", the_function, 1, matched_string) then the_result := 6; eve$add_choice (matched_string); endif; if eve$test_synonym ("visible", the_function, 1, matched_string) then the_result := 7; eve$add_choice (matched_string); endif; if get_info (eve$choice_buffer, "record_count") > 1 then ! display choices if eve$$x_state_array {eve$$k_help_active} <> 4 then ! messages enabled if eve$$x_state_array {eve$$k_in_init_file} then eve$$x_state_array {eve$$k_ambiguous_parse} := TRUE; eve$message (EVE$_AMBCMDINIT, 0, eve$$x_current_init_cmd); position (saved_mark); else eve$display_choices (message_text (EVE$_AMBCMD, 0, the_command + the_function), the_command, the_function); endif; endif; eve$learn_abort; return (FALSE); endif; resulting_message := 0; ! resulting_message holds a message to display on successful validation ! if an error occurs, it wont' be changed from its initial 0 value, and ! we'll abort. attribute_type := ""; ! attribute_type holds a string which is the type of attribute we should ! be maintaining for this command, or the null string, in which case we won't ! be setting any attribute case the_result from 1 to 7 [1]: ! AT if eve$prompt_string (the_settings, tab_settings, message_text (EVE$_TABATPROMPT, 1), message_text (EVE$_TABNOTCHNG, 0)) then set (TAB_STOPS, current_buffer, tab_settings); resulting_message := message_text (EVE$_SHOW_TABSETAT, 0, the_argument); endif; [2]: ! EVERY if eve$prompt_number (the_settings, tab_increment, message_text (EVE$_TABEVERYPROMPT, 1), message_text (EVE$_TABNOTCHNG, 0)) then if tab_increment <= 0 then eve$message (EVE$_TABSNOTEQ); else set (TAB_STOPS, current_buffer, tab_increment); resulting_message := message_text (EVE$_SHOW_TABEVERY, 0, tab_increment); endif; endif; [3]: ! SPACES eve$x_tab_mode := 1; resulting_message := message_text (EVE$_TABSPACES); attribute_type := "eve_set_tabs_spaces/movement/insert"; [4]: ! MOVEMENT eve$x_tab_mode := 2; resulting_message := message_text (EVE$_TABMOVE); attribute_type := "eve_set_tabs_spaces/movement/insert"; [5]: ! INSERT eve$x_tab_mode := 0; resulting_message := message_text (EVE$_TABINSERT); attribute_type := "eve_set_tabs_spaces/movement/insert"; [6]: ! INVISIBLE eve$set_all_windows (TEXT, BLANK_TABS); attribute_type := "eve_set_tabs_visible"; resulting_message := message_text (EVE$_TABINVISIBLE); [7]: ! VISIBLE eve$set_all_windows (TEXT, GRAPHIC_TABS); attribute_type := "eve_set_tabs_visible"; resulting_message := message_text (EVE$_TABVISIBLE); [OUTRANGE]: ! INVALID TAB COMMAND eve$message (EVE$_BADTABFUNC, 0, the_function); endcase; position (saved_mark); ! Restore position prior to return if resulting_message <> 0 ! Parse was successful, set attribute and exit then eve$message (resulting_message); if attribute_type <> "" then return (eve$define_attr (attribute_type, "eve_set_tabs ('" + the_argument + "');", resulting_message)); endif; return TRUE; endif; eve$learn_abort; ! Either parse or attribute call was bad - abort with error return (FALSE); endprocedure; ! eve_set_tabs ! EVE$FORMAT.TPU Page 19 procedure eve_set_paragraph_indent ! Set paragraph indent (set_parameter) local new_paragraph_indent, ! Local copy of set_parameter absolute_indent, current_left_margin; on_error [OTHERWISE]: endon_error; if not (eve$prompt_number (set_parameter, new_paragraph_indent, "Enter Paragraph Indent:", "No paragraph indent set")) then eve$learn_abort; return (FALSE); endif; current_left_margin := get_info (current_buffer, "left_margin"); absolute_indent := new_paragraph_indent + current_left_margin; if absolute_indent >= get_info (current_buffer, "right_margin") then eve$message (EVE$_PINDENTTOOBIG, 0, get_info (current_buffer, "right_margin")); eve$learn_abort; return (FALSE); endif; if absolute_indent <= 0 then eve$message (EVE$_PINDENTSMALL); eve$learn_abort; return (FALSE); else if (absolute_indent = current_left_margin) or (absolute_indent = 0) then eve$$x_paragraph_indent {current_buffer} := tpu$k_unspecified; eve$message (EVE$_NOPINDENT); else eve$$x_paragraph_indent {current_buffer} := absolute_indent; eve$message (message_text (EVE$_PINDENTSETTO, 0, new_paragraph_indent)); endif; endif; return (TRUE); endprocedure; ! eve_set_paragraph_indent ! EVE$FORMAT.TPU Page 20 procedure eve$$word_wrap ! Word wrap at right margin ! Procedure to do word-wrapping when typing occurs beyond the right margin eve$$word_wrap_insert (eve$alphabetic (last_key)); endprocedure; ! eve$$word_wrap ! EVE$FORMAT.TPU Page 21 procedure eve$$word_wrap_insert ! Insert a char in wordwrapping (the_char) ! Procedure to insert a character with word-wrapping. local the_start, the_end, fill_range, the_right_margin, the_left_margin, the_indent, here; on_error [OTHERWISE]: endon_error; copy_text (the_char); here := mark (NONE); position (LINE_BEGIN); ! skip over leading whitespace in the line stopping at the eol position (search_quietly (notany (eve$x_whitespace) | line_end, forward, exact)); the_start := mark (NONE); move_horizontal (length (current_line) - (current_offset + 1)); the_end := mark (NONE); the_right_margin := get_info (current_buffer, "right_margin"); if eve$$x_word_wrap_indent {current_buffer} <> tpu$k_unspecified then the_left_margin := eve$$x_word_wrap_indent {current_buffer}; else the_left_margin := get_info (current_buffer, "left_margin"); endif; position (the_start); if current_offset <> 0 then the_indent := 0; else the_indent := get_info (the_start, "left_margin") - the_left_margin; endif; fill_range := create_range (the_start, the_end, NONE); fill (fill_range, eve$x_fill_separators, the_left_margin, the_right_margin, the_indent); position (here); endprocedure; ! eve$$word_wrap_insert ! EVE$FORMAT.TPU Page 22 procedure eve$expand_to_choices ! Put choices on separate lines (expanded_string) ! Result of expand_name - input ! Take the result of an expand_name command, and put each of the choices on ! a separate line in the choice buffer. Erase any previous choices in the ! choice buffer. Cursor is left at beginning of choice buffer. local temp_string, temp_index, saved_mark; on_error [TPU$_CONTROLC]: eve$$restore_position (saved_mark); eve$learn_abort; abort; [OTHERWISE]: eve$$restore_position (saved_mark); endon_error; saved_mark := mark (FREE_CURSOR); ! only needed for error returns position (eve$choice_buffer); erase (eve$choice_buffer); if expanded_string = "" then position (saved_mark); return; endif; temp_string := expanded_string; loop temp_index := index (temp_string, " "); exitif (temp_index = 0); copy_text (substr (temp_string, 1, temp_index - 1)); split_line; temp_string := substr (temp_string, temp_index + 1, length (temp_string)); endloop; copy_text (temp_string); position (beginning_of (eve$choice_buffer)); endprocedure; ! eve$expand_to_choices ! EVE$FORMAT.TPU Page 23 procedure eve$get_choice ! Find match in choice buffer (choice_string) ! String to find in the choice buffer - input ! Combines two tests: if there is only one item in the choice buffer, ! return that string as the choice. Otherwise, if the input string is ! an exact choice in the choice buffer, return the input string ! as the choice. If neither test is true, return the null string. ! Assume that cursor is at beginning of choice buffer (procedure should ! called after eve$expand_to_choices). on_error [TPU$_STRNOTFOUND]: return (""); [OTHERWISE]: endon_error; if get_info (eve$choice_buffer, "record_count") <> 1 then position (search (LINE_BEGIN + choice_string + LINE_END, FORWARD, NO_EXACT)); endif; return (current_line); endprocedure; ! eve$get_choice ! EVE$FORMAT.TPU Page 24 procedure eve$strip_choices !Remove first n characters from choices (how_much_to_strip; ! Number of characters to strip - input the_buffer) ! Buffer to strip (default=choices) - optional input ! Procedure to strip the first n characters off of the name of each ! choice in the choice buffer. Used for mark and command names. ! Leaves cursor at end of choice buffer. local saved_mark, a_buffer; on_error [TPU$_CONTROLC]: eve$$restore_position (saved_mark); eve$learn_abort; abort; [OTHERWISE]: eve$$restore_position (saved_mark); endon_error; if the_buffer = tpu$k_unspecified then a_buffer := eve$choice_buffer; else a_buffer := the_buffer; endif; saved_mark := mark (FREE_CURSOR); ! only needed for error returns position (beginning_of (a_buffer)); loop exitif mark (NONE) = end_of (a_buffer); erase_character (how_much_to_strip); move_vertical (1); endloop; endprocedure; ! eve$strip_choices ! EVE$FORMAT.TPU Page 25 procedure eve$display_choices ! Prepare choices for display (message_to_display, ! Error message for message window. command_name; ! The EVE command that has ambiguous arguments, along ! with any arguments before the ambiguous one. ! For example, "line 2 " if the LINE command were ! called with an ambiguous procedure name. Note that ! no underscores are allowed in the command name. the_argument) ! The ambiguous argument. For example if the user ! typed LINE 2 EVE_ where EVE_ is an ambiguous ! procedure name, then the command_name would be ! "line 2 ", and the_argument would be "EVE_". ! Procedure to enable displaying of choices. Leaves cursor in command window. local last_reply, ! Last reply of prompt string last_command, ! Command invoked by a key saved_window, saved_mark; on_error [TPU$_CONTROLC]: eve$$restore_position (saved_window, saved_mark); eve$learn_abort; abort; [OTHERWISE]: eve$$restore_position (saved_window, saved_mark); endon_error; saved_window := current_window; saved_mark := mark (FREE_CURSOR); eve$message (message_to_display); ! If no default buffer exists, then we're most likely executing ! an ambiguous command from a /COMMAND file. Just abort. if get_info (eve$default_buffer, "type") <> BUFFER then eve$learn_abort; return (FALSE); endif; position (end_of (eve$choice_buffer)); eve$format_choices; eve$$x_state_array {eve$$k_ambiguous_parse} := TRUE; position (beginning_of (eve$choice_buffer)); last_reply := ""; if eve$$x_state_array {eve$$k_prompt_flag} then position (end_of (eve$recall_line_buffer)); if mark (NONE) <> beginning_of (eve$recall_line_buffer) then move_vertical (-1); last_reply := current_line; endif; eve$$x_state_array {eve$$k_prompt_flag} := 0; endif; if eve$$x_state_array {eve$$k_command_line_flag} then ! Command has been written in command buffer ! And EVE$PROCESS_COMMAND will map CHOICE_WINDOWS if last_reply <> "" then ! Command prompted for an argument position (end_of (eve$command_buffer)); move_horizontal (-1); ! command buffer is unmodifiable after eve$$exit_command_window set (RECORD_ATTRIBUTE, mark (NONE), MODIFIABLE, ON); erase_line; copy_text (eve$x_command_prompt + eve$x_do_line + " "); eve$$x_choice_range := copy_text (last_reply); else ! Command was complete on command line if command_name <> "" then ! Unamibiguous command with amiguous argument if (get_info (eve$$x_choice_range, "type") = RANGE) then if (get_info (the_argument, "type") = STRING) then ! Point the range at the ambiguous arg position (eve$$x_choice_range); ! command buffer=unmodifiable after eve$$exit_command_window set (RECORD_ATTRIBUTE, mark (NONE), MODIFIABLE, ON); erase (eve$$x_choice_range); copy_text (command_name); eve$$x_choice_range := copy_text (the_argument); endif; endif; ! else ! EVE$$X_CHOICE_RANGE was set in EVE$$EXIT_COMMAND_WINDOW endif; endif; else ! Not a command -- from help or a key if eve$$x_state_array {eve$$k_help_active} = 0 ! Let HELP handle ambiguous topics then ! Otherwise, we need a command name. ! A key was defined to a command, and either the command or one of its ! arguments is ambiguous eve$map_choices; if command_name <> "" then ! the EVE command finding the ambiguity last_command := command_name; if the_argument = tpu$k_unspecified then last_reply := ""; else last_reply := the_argument; endif; else ! the last key's definition = ambiguous last_command := eve$$lookup_comment (last_key, eve$x_key_map_list); translate (last_command, " ", "_"); ! probably no args here endif; position (saved_window); ! so pre_command_window is set correctly eve$$enter_command_window; ! by eve$$enter_c_w copy_text (last_command); eve$$x_choice_range := copy_text (last_reply); eve$$set_command_line; endif; endif; endprocedure; ! eve$display_choices ! EVE$FORMAT.TPU Page 26 procedure eve$$letter_wrap ! Letter wrap the current line (; left_indent) ! Number of spaces at start of continued line, ! NOT USED - input ! Letter-wrap the current line. local wrap_width, ! Screen width this_position, ! Marker for current cursor position what_column; ! Current column wrap_width := get_info (current_window, "width"); this_position := mark (NONE); loop position (LINE_END); what_column := get_info (current_buffer, "offset_column"); exitif what_column <= wrap_width; move_horizontal (wrap_width - what_column); split_line; endloop; position (this_position); endprocedure; ! eve$$letter_wrap ! EVE$FORMAT.TPU Page 27 procedure eve$capitalize_string ! Capitalize a string (cap_string) ! String to be capitalized - input/output ! Capitalize a string - like CHANGE_CASE (string, capital) would be. ! Ignore leading punctuation, so things like "Hi" and (foo) can be ! capitalized. local initial_letter, ! Initial substring ending at first letter initial_index, ! Loop index used in search for first letter cap_string_length, ! Length of cap_string parameter rest_of_string; ! Remainder of cap_string after initial_letter on_error [OTHERWISE]: endon_error; initial_index := 1; cap_string_length := length (cap_string); loop initial_letter := substr (cap_string, 1, initial_index); exitif initial_index = cap_string_length; exitif index (eve$x_not_alphabetic, substr (cap_string, initial_index, 1)) = 0; initial_index := initial_index + 1; endloop; rest_of_string := substr (cap_string, initial_index + 1, cap_string_length); change_case (initial_letter, UPPER); change_case (rest_of_string, LOWER); cap_string := initial_letter + rest_of_string; endprocedure; ! eve$capitalize_string ! EVE$FORMAT.TPU Page 28 procedure eve$add_choice ! Add a choice (choice_string) ! String to add to choice buffer - input ! Add a string on a new line in the choice buffer local saved_mark; on_error [TPU$_CONTROLC]: eve$$restore_position (saved_mark); eve$learn_abort; abort; [OTHERWISE]: eve$$restore_position (saved_mark); endon_error; saved_mark := mark (FREE_CURSOR); position (end_of (eve$choice_buffer)); copy_text (choice_string); position (saved_mark); endprocedure; ! eve$add_choice ! EVE$FORMAT.TPU Page 29 procedure eve$format_choices ! Format the choice buffer ! Format the choice buffer (which has one choice per line) into multiple ! choices per line, capitalize each choice (on VMS), and add leading space ! to each line. Leaves cursor in the choice buffer. local total_width, ! Screen width how_many_columns, ! Number of columns in display which_column, ! Column index used during formatting leftover, ! Used in computation of column width string_position, ! Index into expanded_string which_item, ! String for current column entry how_many_items, ! How many items need to be formatted saved_mark; on_error [TPU$_CONTROLC]: eve$$restore_position (saved_mark); eve$learn_abort; abort; [OTHERWISE]: eve$$restore_position (saved_mark); endon_error; saved_mark := mark (FREE_CURSOR); ! only needed for error returns position (end_of (eve$choice_buffer)); loop exitif mark (NONE) = beginning_of (eve$choice_buffer); move_vertical (-1); exitif current_line <> ""; erase_line; endloop; position (beginning_of (eve$choice_buffer)); how_many_items := get_info (eve$choice_buffer, "record_count"); if how_many_items = 0 then position (saved_mark); return; endif; ! get the length of the longest line in the buffer eve$$x_choices_column_width := 0; loop exitif mark (NONE) = end_of (eve$choice_buffer); if eve$$x_choices_column_width < length (current_line) then eve$$x_choices_column_width := length (current_line); endif; move_vertical (1); endloop; total_width := get_info (SCREEN, "width"); ! determine the number of columns (items) that can be on a line eve$$x_choices_column_width := eve$$x_choices_column_width + 2; how_many_columns := (total_width - 1) / eve$$x_choices_column_width; if (how_many_columns * eve$$x_choices_column_width) > total_width then ! rounded up how_many_columns := how_many_columns - 1; endif; if how_many_columns = 0 then how_many_columns := 1; else if how_many_items < how_many_columns then ! adjust for number of items < number that would fit on a line how_many_columns := how_many_items; eve$$x_choices_column_width := (total_width - 1) / how_many_items; if (how_many_columns * eve$$x_choices_column_width) > total_width then ! rounded up eve$$x_choices_column_width := eve$$x_choices_column_width - 1; endif; else ! adjust for number of items > number that would fit on a line loop leftover := (total_width - 1) - (how_many_columns * eve$$x_choices_column_width); exitif leftover < how_many_columns; eve$$x_choices_column_width := eve$$x_choices_column_width + 1; endloop; endif; endif; which_column := 1; string_position := 1; position (beginning_of (eve$choice_buffer)); split_line; loop exitif mark (NONE) = end_of (eve$choice_buffer); which_item := erase_line; move_horizontal (-1); if not eve$x_ultrix_active ! Capitalize only on VMS then eve$capitalize_string (which_item); endif; if (which_column = 1) and (eve$$x_choices_column_width <= total_width) then copy_text (" "); endif; copy_text (which_item); if which_column = how_many_columns then if how_many_columns = 1 then eve$$letter_wrap (0); endif; split_line; which_column := 1; else copy_text (substr (eve$kt_spaces, 1, eve$$x_choices_column_width - length (which_item))); which_column := which_column + 1; endif; move_horizontal (1); endloop; append_line; endprocedure; ! eve$format_choices ! EVE$FORMAT.TPU Page 30 procedure eve$$reserve_scratch_buffer ! Reserve scratch buffer for use ! Reserve the scratch buffer for special use, create it if needed if not eve$$x_scratch_buffer_reserved then if get_info (eve$$x_scratch_buffer, "type") <> BUFFER then if eve$x_buf_str_scratch = tpu$k_unspecified then eve$x_buf_str_scratch := "$SCRATCH$"; endif; eve$$x_scratch_buffer := eve$init_buffer (eve$x_buf_str_scratch, ""); endif; eve$$x_scratch_buffer_reserved := TRUE; return (TRUE); endif; eve$message (EVE$_ILLSCRATCHRES); return (FALSE); endprocedure; ! eve$$reserve_scratch_buffer procedure eve$$release_scratch_buffer ! Release scratch buffer from use ! Release the scratch buffer from special use eve$$x_scratch_buffer_reserved := FALSE; return (TRUE); endprocedure; ! eve$$release_scratch_buffer ! EVE$FORMAT.TPU Page 31 procedure eve_convert_tabs ! Replace Tabs with spaces ! Convert tabs to spaces in the select range or, if none, in current_buffer. ! Side effect: if current position is on a Tab in the range or buffer, the ! position will slip to the right as the Tab is erased and replaced with spaces. local the_selection, the_index, the_range; if not eve$test_if_modifiable (current_buffer) then eve$learn_abort; return (FALSE); endif; position (TEXT); ! snap to text the_selection := eve$selection (FALSE,,, eve$x_select_remove_flag,, TRUE); if the_selection = 0 then ! no selection, do the buffer the_selection := create_range (beginning_of (current_buffer), end_of (current_buffer), NONE); else if get_info (the_selection, "type") = ARRAY then the_index := 1; loop the_range := the_selection {the_index}; exitif the_range = tpu$k_unspecified; eve$convert_tabs (the_range, TRUE, ! stay on this line get_info (end_of (the_range), ! don't exceed "offset_column")); ! this column the_index := the_index + 1; endloop; return (TRUE); endif; endif; return (eve$convert_tabs (the_selection)); ! buffer or standard selection endprocedure; ! eve_convert_tabs procedure eve$convert_tabs ! Convert tabs subprocedure (the_range; ! range to be converted one_line, ! stay on 1st line of range col_limit) ! column limit to not exceed local tab_pattern, tab_range, saved_position, single_line, max_col; on_error [OTHERWISE]: eve$$restore_position (saved_position); endon_error; if get_info (one_line, "type") = INTEGER then single_line := one_line; ! else false endif; if get_info (col_limit, "type") = INTEGER then max_col := col_limit; ! else false endif; saved_position := mark (FREE_CURSOR); position (beginning_of (the_range)); if single_line then ! ANCHOR stays on this line tab_pattern := ANCHOR + match (ascii (9)); else tab_pattern := match (ascii (9)); endif; loop tab_range := search_quietly (tab_pattern, FORWARD, EXACT); exitif tab_range = 0; ! no tabs position (end_of (tab_range)); ! lands on the tab if max_col <> 0 ! don't go past max_col if specified then exitif get_info (mark (FREE_CURSOR), "offset_column") > max_col; endif; exitif mark (FREE_CURSOR) > end_of (the_range); ! don't exceed the_range erase_character (1); ! erase the tab eve$insert_text (" " * eve$spaces_to_tab (get_info (mark (FREE_CURSOR), "offset_column") - 1)); endloop; position (saved_position); return (TRUE); endprocedure; ! eve$convert_tabs ! EVE$FORMAT.TPU Page 32 procedure eve_set_fill_tags eve$x_fill_tags := TRUE; eve$message (EVE$_FILLTAGS); return (TRUE); endprocedure; ! eve_set_fill_tags procedure eve_set_fill_notags eve$x_fill_tags := FALSE; eve$message (EVE$_NOFILLTAGS); return (TRUE); endprocedure; ! eve_set_fill_notags procedure eve$set_para_breaks ! Assign paragraph break patterns (on_or_off) ! boolean: 0 = don't fill tags, 1 = fill tags ! This procedure assigns pattern variables for FILL operations. It must ! be called during startup and before each FILL to insure we pick up any ! user change to variable eve$x_fill_tags. eve$x_save_fill_tags := on_or_off; if eve$x_save_fill_tags then ! Characters used to begin Runoff commands eve$x_runoff_characters := ""; ! Para breaks from only Runoff or Document tags eve$pattern_tag_break := ANCHOR + LINE_BEGIN + (("." | "<") + any (eve$x_runoff_characters)); ! Para breaks eve$pattern_paragraph_break := ANCHOR + LINE_BEGIN + ((("" | span (eve$x_whitespace)) + LINE_END) | (ascii (12) + LINE_END) | ! hard FF (ascii (12) + ascii (0) + LINE_END)); ! soft FF ! Para breaks not filled by FILL RANGE at start of range eve$pattern_skip_paragraph_break := ANCHOR + LINE_BEGIN + ((ascii (12) + LINE_END) | (ascii (12) + ascii (0) + LINE_END)); else eve$x_runoff_characters := "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ!;"; ! Para breaks from only Runoff or Document tags eve$pattern_tag_break := ANCHOR + LINE_BEGIN + (("." | "<") + any (eve$x_runoff_characters)); eve$pattern_paragraph_break := ANCHOR + LINE_BEGIN + ((("." | "<") + any (eve$x_runoff_characters)) | (("" | span (eve$x_whitespace)) + LINE_END) | (ascii (12) + LINE_END) | ! hard FF (ascii (12) + ascii (0) + LINE_END)); ! soft FF eve$pattern_skip_paragraph_break := ANCHOR + LINE_BEGIN + ((("." | "<") + any (eve$x_runoff_characters)) | (ascii (12) + LINE_END) | (ascii (12) + ascii (0) + LINE_END)); endif; endprocedure; ! eve$set_para_breaks ! EVE$FORMAT.TPU Page 33 ! Module initialization code eve$x_word_is_on_left := FALSE; ! 0 = CAP/LOW/UPPER use word to right of ! inter-word whitespace for pre-V3.1 compatibility, ! 1 = use word to left of whitespace eve$arg1_set_left_margin := "integer"; eve$arg1_set_right_margin := "integer"; eve$$x_scratch_buffer_reserved := FALSE; eve$x_fill_tags := FALSE; ! Dont' fill runoff/document tags - user ! settable without issuing a command. eve$set_para_breaks (eve$x_fill_tags); ! assign pattern variables ! Set default user attributes eve$define_attr ("eve_set_tabs_spaces/movement/insert", "eve_set_tabs ('INSERT');", message_text (EVE$_TABINSERT)); eve$define_attr ("eve_set_tabs_visible", "eve_set_tabs ('INVISIBLE');", message_text (EVE$_TABINVISIBLE)); endmodule; ! EVE$FORMAT.TPU Page 34 ! ! EVE$BUILD time executable code !