!Last Modified: 2-MAR-1987 09:39:14.23 ! EVEPLUS_KERNEL.TPU - Routines required by multiple modules ! ! Routine to insert text, even in overstrike mode ! procedure eveplus_insert_text(the_text) ! Copy_text in insert mode LOCAL old_mode; old_mode := get_info(current_buffer, "mode"); set(INSERT, current_buffer); copy_text(the_text); set(old_mode, current_buffer); endprocedure ; ! skip the space between columns and position at the begining of a column procedure eve_skip_white_space(buffer_right_margin) local ok,this_character,tab_character; ok := 0; tab_character := ascii(9); !bug index function doesn't find tabs!! loop ! skip whitespace this_character := current_character; ! call function once exitif(ok); if (index(eve$x_fill_separators,this_character) <> 0) or (tab_character = this_character) then move_horizontal(1); else ok := 1; endif; if (current_offset = buffer_right_margin) then message("EOLN marker went past EOL"); return(0); endif; endloop; return(1); endprocedure ! eveplus_set_mode PROCEDURE EVEPLUS_BLANK_CHARS(eveplus_v_blank_count) !+ ! This procedure returns a string of eveplus_v_blank_count blank chars. !- local eveplus_v_blank_chars, eveplus_v_oldlen, eveplus_v_blanks_so_far; ! Length of blank char string so far IF eveplus_v_blank_count = 0 THEN RETURN "" ENDIF; eveplus_v_blank_chars := " "; eveplus_v_blanks_so_far := 1; loop exitif eveplus_v_blanks_so_far >= eveplus_v_blank_count; eveplus_v_oldlen := LENGTH(eveplus_v_blank_chars); eveplus_v_blank_chars := eveplus_v_blank_chars + eveplus_v_blank_chars; eveplus_v_blanks_so_far := eveplus_v_blanks_so_far + eveplus_v_oldlen; endloop; IF eveplus_v_blanks_so_far > eveplus_v_blank_count THEN eveplus_v_blank_chars := SUBSTR(eveplus_v_blank_chars,1,eveplus_v_blank_count) ENDIF; RETURN eveplus_v_blank_chars endprocedure ! eve_rectangular_select PROCEDURE EVEPLUS_PAD_BLANK !+ ! This procedure drops a space at the current position if the current ! character is null so that any mark will be for an existing character. ! In EDD, we really want a mark in a particular screen column. In TPU, ! an EOL mark would move if the line were extended. Also in EDD, we ! want to highlight the select point so we need a character there. ! The cursor is returned to its original position after the space is ! copied to the current position in the current buffer. !- IF MARK(NONE) = END_OF(CURRENT_BUFFER) THEN copy_text(" "); move_horizontal(-1) ELSE if current_character = "" then copy_text(" "); move_horizontal(-1); endif ENDIF endprocedure ; ! Page 43 ! Backup over whitespace. Return number of spaces. procedure eve$backup_over_whitespace local temp_length; ! Number of characters backed up over if current_offset = 0 then return (0); endif; temp_length := 0; loop ! Back up past whitespace move_horizontal (-1); if index (eve$x_whitespace, current_character) <> 0 then temp_length := temp_length + 1; exitif current_offset = 0; else move_horizontal (1); exitif 1; endif; endloop; return (temp_length); endprocedure ; ! Page 41 ! Procedure bound to the space bar. Inserts a space and does word wrap ! based on the margin settings. procedure eve_space eve$fill_line (1); endprocedure ! eveplus_set_mode PROCEDURE EVEPLUS_BLANK_CHARS(eveplus_v_blank_count) !+ ! This procedure returns a string of eveplus_v_blank_count blank chars. !- local eveplus_v_blank_chars, eveplus_v_oldlen, eveplus_v_blanks_so_far; ! Length of blank char string so far IF eveplus_v_blank_count = 0 THEN RETURN "" ENDIF; eveplus_v_blank_chars := " "; eveplus_v_blanks_so_far := 1; loop exitif eveplus_v_blanks_so_far >= eveplus_v_blank_count; eveplus_v_oldlen := LENGTH(eveplus_v_blank_chars); eveplus_v_blank_chars := eveplus_v_blank_chars + eveplus_v_blank_chars; eveplus_v_blanks_so_far := eveplus_v_blanks_so_far + eveplus_v_oldlen; endloop; IF eveplus_v_blanks_so_far > eveplus_v_blank_count THEN eveplus_v_blank_chars := SUBSTR(eveplus_v_blank_chars,1,eveplus_v_blank_count) ENDIF; RETURN eveplus_v_blank_chars endprocedure !+ ! Procedure to replace TAB characters by the appropriate number of ! blanks on the current line, then pad the line out to a given length, if it ! is shorter. The routine assumes overstrike mode is in ! effect. It leave the current position at the beginning of the line. !- PROCEDURE edd_replace_tabs_with_blanks_and_pad(target_length) LOCAL i, col, cur_length, new_line, eight_blanks; !+ ! Make sure we're not on the EOB marker. !- IF MARK(NONE) <> END_OF(CURRENT_BUFFER) THEN IF INDEX(CURRENT_LINE, ASCII(9)) <> 0 THEN new_line := ''; eight_blanks := " "; i := 1; col := 0; LOOP EXITIF i > LENGTH(CURRENT_LINE); IF SUBSTR(CURRENT_LINE,i,1) = ASCII(9) THEN col := ((col + 8)/8)*8; new_line := new_line + SUBSTR(eight_blanks,1,col-LENGTH(new_line)) ELSE new_line := new_line + SUBSTR(CURRENT_LINE,i,1); col := col + 1 ENDIF; i := i + 1 ENDLOOP; MOVE_HORIZONTAL(-CURRENT_OFFSET); COPY_TEXT(new_line) ENDIF ENDIF; MOVE_HORIZONTAL(-CURRENT_OFFSET); !+ ! Now pad out the line if we have to !- IF MARK(NONE) = END_OF(CURRENT_BUFFER) THEN cur_length := 0 ELSE cur_length := LENGTH(CURRENT_LINE) ENDIF; IF cur_length < target_length THEN MOVE_HORIZONTAL(cur_length); COPY_TEXT(eveplus_blank_chars(target_length - cur_length)); ENDIF; MOVE_HORIZONTAL(-CURRENT_OFFSET) ENDPROCEDURE