! ABEL_EDIT.TPU ! ! Table of Contents as of 27-Mar-1988 ! ! Procedure name Page Description ! -------------- ---- ----------- ! ! eve_erase_character 1 Delete current character ! eve_erase_previous_word 2 Erase a word ! eve_erase_whitespace 3 Erase whitespace at current cursor ! eve_erase_word 4 Erase current or next word ! eve_erase_line 5 Erase a line or a portion of a line ! eve$erase_line 6 Erase cursor to end of line, inc eol ! eve_erase_start_of_line 7 Erase from cursor to start of line ! eve_unerase_character 8 Restores last erased character ! eve_unerase_word 9 Restores last erased word ! eve_unerase_line 10 Restores last erased line ! eve_open_line 11 Open a blank line at the cursor ! eve_delete 12 Delete previous character ! eve_ascii 13 Put ascii character in buffer ! eve_center_line 14 Center line(s) between margins ! Page 1 procedure eve_erase_character ! Delete current character ! Delete current character; mode-sensitive; saves erasure ! ! Globals: ! abl$erased_character string last erased character ! ! Source: ! Eve local this_position; ! Marker for current cursor position this_position := mark (none); if this_position = end_of (current_buffer) then return; else abl$erased_character:=current_character; if current_character = eve$kt_null then move_horizontal (1); if mark (none) = end_of (current_buffer) then move_horizontal (-1); else eve$append_line; endif; else if get_info (current_buffer, "mode") = overstrike then copy_text (" "); else erase_character (1); endif; endif; endif; endprocedure ! Page 2 procedure eve_erase_previous_word ! Erase a word ! Erase a word. If at start of word (or preceding character is blank) then ! erase preceding word, else erase current word; saves erasure; mode-sensitive ! ! Globals: ! abl$erased_word string last erased word ! ! Source: ! Eve local this_buffer, ! Current buffer this_mode, ! Keyword for current mode temp_string, ! String used to check for start of line start_erase_word, ! Marker for beginning of previous word end_erase_word, ! Marker for end of previous word erase_word_range; ! Range for previous word this_buffer := current_buffer; if current_window = eve$command_window then if get_info (this_buffer, "offset_column") <= (eve$x_command_prompt_length + 1) then return; endif; endif; if get_info (this_buffer, "offset_column") <= get_info (this_buffer, "left_margin") then if mark (none) <> beginning_of (this_buffer) then if (eve$append_line) then if current_offset = 0 then temp_string := ascii (10); else move_horizontal (-1); temp_string := current_character; move_horizontal (1); endif; if index (eve$x_word_separators, temp_string) = 0 then this_mode := get_info (this_buffer, "mode"); set (insert, this_buffer); copy_text (" "); set (this_mode, this_buffer); endif; eve$x_restoring_line := 1; eve$x_restore_text := eve$x_null; return; endif; else return; endif; endif; eve$start_of_word; start_erase_word := mark (none); eve$end_of_word; move_horizontal (-1); ! don't want first character of next word end_erase_word := mark (none); erase_word_range := create_range (start_erase_word, end_erase_word, none); position (start_erase_word); eve$x_restore_text := erase_character (length (erase_word_range)); if get_info(current_buffer,"mode")=overstrike then set(insert,current_buffer); copy_text(substr(eve$x_spaces,1,length(eve$x_restore_text))); set(overstrike,current_buffer); endif; eve$x_restoring_line := 0; abl$erased_word:=eve$x_restore_text; endprocedure ! Page 3 procedure eve_erase_whitespace ! Erase whitespace at current cursor ! Erase tabs and spaces at current cursor location. If between words, leaves ! a space. ! ! Source: ! Eve eve$compress_whitespace endprocedure ! Page 4 procedure eve_erase_word ! Erase current or next word ! Erase the whole current word; erasure saved; mode-sensitive ! ! Globals: ! abl$erased_word string last erased word ! ! Source: ! Eve local this_buffer, ! Current buffer this_mode, ! Keyword for current mode temp_string, ! String used to check for start of line start_erase_word, ! Marker for beginning of previous word end_erase_word, ! Marker for end of previous word spaces_to_erase, ! Number of between-word spaces to erase x, erase_word_range; ! Range for previous word if current_window = eve$command_window then eve_erase_previous_word; return; endif; this_buffer := current_buffer; if mark (none) = end_of (this_buffer) then return; endif; ! Are we on a space between words? If so, compress whitespace and ! move to start of next word. if index (eve$x_whitespace, current_character) <> 0 then eve$compress_whitespace; endif; ! Check for end of line if current_character = eve$x_null then if current_offset = 0 then temp_string := ascii (10); else move_horizontal (-1); temp_string := current_character; move_horizontal (1); endif; move_horizontal (1); eve$append_line; if mark (none) <> end_of (this_buffer) then if index (eve$x_word_separators, temp_string) = 0 then this_mode := get_info (this_buffer, "mode"); set (insert, this_buffer); copy_text (" "); set (this_mode, this_buffer); endif; endif; eve$x_restoring_line := 1; eve$x_restore_text := eve$x_null; else if not eve$at_start_of_word then eve$start_of_word; endif; start_erase_word := mark (none); eve$end_of_word; move_horizontal (-1); end_erase_word := mark (none); erase_word_range := create_range (start_erase_word, end_erase_word, none); position (start_erase_word); if get_info(current_buffer,"mode")=overstrike then x:=length(erase_word_range); loop exitif x=0; exitif index(eve$x_whitespace,substr(erase_word_range,x,1))=0; x:=x-1; endloop; eve$x_restore_text := erase_character(x); set(insert,current_buffer); copy_text(substr(eve$x_spaces,1,length(eve$x_restore_text))); set(overstrike,current_buffer); position(end_erase_word); else eve$x_restore_text := erase_character (length (erase_word_range)); endif; eve$x_restoring_line := 0; endif; abl$erased_word:=eve$x_restore_text; endprocedure ! Page 5 procedure eve_erase_line ! Erase a line or a portion of a line ! Erases a line or a portion of a line depending on qualifiers used ! ! Qualifiers: ! /start boolean erase from cursor to start of line ! /end boolean erase from cursor to end of line ! ! Both /start and /end cannot be specified together. If both are omitted then ! the whole line is erased. ! ! Source: ! Eva2 if abl$q_start and abl$q_end then message("Conflicting qualifiers: can't specify both /START and /END"); return 0; endif; if abl$q_start then abl$do("eve_erase_start_of_line",""); return 1 endif; if abl$q_end then eve$erase_line; if get_info(current_buffer,'mode')=insert then move_horizontal(1); if mark(none)<>end_of(current_buffer) then move_horizontal(-1); split_line; endif; move_horizontal(-1); endif; return 1; endif; move_horizontal(-current_offset); eve$erase_line; return endprocedure ! Page 6 procedure eve$erase_line ! Erase cursor to end of line, inc eol ! Erase from cursor to end of line, including the end of line; erasure saved; ! mode-sensitive ! ! Globals: ! abl$erased_line string last erased line ! ! Source: ! Eve's eve_erase_line local cur_buf; cur_buf:=current_buffer; eve$x_restoring_line := 1; if get_info(cur_buf,"mode")=insert then if current_offset = 0 then eve$x_restore_text := erase_line; else ! Erase_character stops deleting at the end of the line eve$x_restore_text := erase_character (length (current_line)); move_horizontal (- current_offset); move_vertical (1); if mark (none) = end_of (current_buffer) then move_horizontal (-1); else eve$append_line; endif; endif; else if current_line="" then append_line; move_horizontal(1); else eve$x_restore_text:=erase_character(length(current_line)); move_horizontal(-current_offset); move_vertical(1); move_horizontal(-1); endif; endif; abl$erased_line := eve$x_restore_text; endprocedure ! Page 7 procedure eve_erase_start_of_line ! Erase from cursor to start of line ! Erase from cursor to start of line; erasure saved in abl$erased_line; ! mode-sensitive ! ! Globals: ! abl$erased_line string last erased line ! ! Source: ! Eve local erase_length; ! How much of current line to erase if mark (none) = end_of (current_buffer) then return; endif; erase_length := current_offset; if current_buffer = eve$command_buffer then if substr (current_line, 1, eve$x_command_prompt_length) = eve$x_command_prompt then erase_length := current_offset - eve$x_command_prompt_length; endif; if erase_length > 0 then eve$x_restore_text := erase_character (- erase_length); eve$x_restoring_line := 0; endif; else eve$x_restore_text := erase_character (- erase_length); if get_info(current_buffer,"mode")=overstrike then set(insert,current_buffer); copy_text(substr(eve$x_spaces,1,length(eve$x_restore_text))); set(overstrike,current_buffer); endif; eve$x_restoring_line := 0; eve$indent_line_to (get_info (current_buffer, "left_margin")); endif; abl$erased_line := eve$x_restore_text; endprocedure ! Page 8 procedure eve_unerase_character ! Restores last erased character ! Restore last erased or deleted character ! ! Globals: ! abl$erased_character string last erased character ! ! Source: ! Eva2 copy_text (abl$erased_character); endprocedure ! Page 9 procedure eve_unerase_word ! Restores last erased word ! Restore last erased word ! ! Globals: ! abl$erased_word string last erased word ! ! Source: ! Eva local this_buffer, ! Marker for current cursor position this_mode, ! Keyword for current mode temp_position; ! Used to check for end of buffer this_buffer := current_buffer; temp_position := mark (none); ! check for end of buffer copy_text (abl$erased_word); endprocedure ! Page 10 procedure eve_unerase_line ! Restores last erased line ! Restore last erased line (includes "to start of" or "to end of" erasures) ! ! Globals: ! abl$erased_line string last erased line ! ! Source: ! Eva local this_buffer, ! Marker for current cursor position this_mode, ! Keyword for current mode temp_position; ! Used to check for end of buffer this_buffer := current_buffer; this_mode := get_info (this_buffer, "mode"); temp_position := mark (none); ! check for end of buffer copy_text (abl$erased_line); if this_mode=insert then if (temp_position <> end_of (this_buffer)) then split_line; else position(end_of(this_buffer)) endif; else move_horizontal(-current_offset+length(current_line)); endif; endprocedure ! Page 11 procedure eve_open_line ! Open a blank line at the cursor ! Open a blank line at the current cursor position ! ! Source: ! Eva split_line; move_horizontal(-1); endprocedure ! Page 12 procedure eve_delete ! Delete previous character ! Deletes the previous character; saved in abl$erased_character ! ! Globals: ! abl$erased_character string last erased character ! ! Source: ! Eve local this_position; ! Marker for current cursor position ! If we don't mark this position now we'll get funny results later ! if cursor is beyond end of line this_position := mark (none); if current_window = eve$command_window then if get_info (current_buffer, "offset_column") <= (eve$x_command_prompt_length + 1) then return; endif; endif; if get_info (current_buffer, "offset_column") <= get_info (current_buffer, "left_margin") then eve$append_line; abl$erased_character := ""; else if get_info (current_buffer, "mode") = insert then move_horizontal(-1); abl$erased_character:=current_character; erase_character (1); else !overstrike mode if current_character = eve$x_null then move_horizontal(-1); abl$erased_character:=current_character; erase_character (1); else move_horizontal (-1); if current_character <> ascii (9) then abl$erased_character:=current_character; copy_text (" "); move_horizontal (-1); else abl$erased_character:=ascii(9); erase_character (1); endif; endif; endif; endif; endprocedure ! Page 13 procedure eve_ascii($ascii_values) ! Put ascii character in buffer ! Put specified ascii character in buffer; this allows you to get to charcters ! that you can't get to with eve_quote ! ! Parameters: ! $ascii_values string list of numbers that represent ascii values ! ! Qualifiers: ! /previous boolean use previous values ! ! Globals: ! abl$ascii_values string list of numbers representing ascii chars ! abl$ascii_text string ascii characters ! ! Source: ! Eva local previous_value_text, ascii_text, ascii_values; if abl$q_previous then if abl$ascii_text = "" then message("No previous value; aborted..."); return 0; else message("Using previous value(s): "+ abl$ascii_values); endif; else if not eve$prompt_string($ascii_values,ascii_values,"Ascii value(s): ", "Aborted...") then return 0; endif; if not abl$ascii(ascii_values,ascii_text) then message("Numbers must be between 0 and 255, separated by spaces"); return 0; else abl$ascii_values := ascii_values; abl$ascii_text := ascii_text; endif; endif; copy_text(abl$ascii_text); endprocedure ! Page 14 procedure eve_center_line ! Center line(s) between margins ! Centers text on the current line or text with in a select range, if active. ! Text can be centered between the current margin settings, between margins ! specified in qualifiers, or by positioning the cursor where the center of ! text should be. See the qualifiers below. ! ! Qualifiers: ! /left_margin integer overrides current left margin setting ! /right_margin integer overrides current right margin setting ! /here boolean center text at cursor; ignores margins ! /check_width boolean use screen width if > right margin; to maintain ! functionality with Eve ! /reset boolean if centering range, reset range when done ! ! Source: ! Eve local this_position, ! Marker for current cursor position count, ! Number of spaces to erase at start of line left_margin, ! Left margin for current buffer right_margin, ! Right margin for current buffer width_of_screen, ! Screen width center_range, ! Select range if active line_starting, ! Select range starting line number line_ending, ! Select range ending line number lines_to_center, ! How many lines to center if select range starting_column, ! Column where user left the cursor this_column; ! Current column on_error endon_error; ! ! Check qualifiers ! if ((abl$q_left_margin <> -1) or (abl$q_right_margin <> -1)) and abl$q_here then message("Conflicting qualifiers: cannot specify margins and /HERE"); return 0; endif; ! ! Inits ! this_position := mark(none); center_range:=0; ! ! Find the starting column ! if abl$q_here then if not abl$notab_offset(starting_column) then message ("Can't operate on a buffer with irregularly spaced tabs, aborted"); return 0; endif; starting_column := starting_column + 1; endif; ! ! If select range active, determine if we can use it, and how many lines ! to center ! if eve$x_select_position<>0 then if get_info (eve$x_select_position, "buffer") <> current_buffer then message("Select range active but not in this buffer; not performing "+ "centering on range"); else center_range := select_range; position(end_of(center_range)); line_ending := eve$what_line; position(beginning_of(center_range)); line_starting := eve$what_line; lines_to_center := line_ending - line_starting + 1; endif; endif; loop exitif mark(none) = end_of (current_buffer); exitif (center_range <> 0) and (lines_to_center = 0); lines_to_center := lines_to_center - 1; ! ! Erase whitespace before and after line of text ! move_horizontal (- current_offset); eve$compress_whitespace; position (search (line_end, forward)); eve$compress_whitespace; ! ! Determine left and right margins to use ! if abl$q_here then left_margin := starting_column; right_margin := starting_column; else if abl$q_left_margin<>-1 then left_margin := abl$q_left_margin else left_margin := get_info (current_buffer, "left_margin") endif; if abl$q_right_margin<>-1 then right_margin := abl$q_right_margin else right_margin := get_info (current_buffer, "right_margin") endif; if abl$q_right_margin width_of_screen then right_margin := width_of_screen; message("Right margin wider than screen, using screen width"); endif; endif; endif; ! ! Determine how much whitespace to insert ! this_column := get_info (current_buffer, "offset_column"); count := (((right_margin - left_margin) - this_column) / 2) + left_margin; eve$indent_line_to (count); ! ! If we weren't centering a range then exit ! else go to next line and do it again ! exitif center_range=0; move_vertical(1); endloop; position (this_position); if abl$q_reset then eve$x_select_position:=0; endif; endprocedure