; ! Page 19 ! Insert (not overstrike) spaces from current position until given column. ! If current offset greater than column, do nothing. ! ! Parameters: ! ! which_column Column to go to - input procedure eve$to_column (which_column) local this_buffer, ! Current buffer this_mode, ! Keyword for current mode distance; ! Number of spaces needed this_buffer := current_buffer; this_mode := get_info (this_buffer, eve$kt_mode); set (insert, this_buffer); loop distance := which_column - get_info (this_buffer, eve$kt_offset_column); exitif distance <= 0; if distance > length (eve$kt_spaces) then copy_text (eve$kt_spaces); else copy_text (substr (eve$kt_spaces, 1, distance)); endif; endloop; set (this_mode, this_buffer); endprocedure ; ! move X columns to the right procedure eve$find_column(column_number,buffer_right_margin) local ok,i; ok := 0; loop !find the first column and select out status := eve_skip_white_space(buffer_right_margin); if (status = 0) then ! continue to unwind return(0); ! signal failure on first column endif; i:= i+1; exitif(i = column_number); ! on the correct column status := eve_skip_column(buffer_right_margin); endloop; return(1); endprocedure ; ! position to the end of a column if whitespace is null backup one procedure eve_skip_column(buffer_right_margin) local tab_character,this_character,ok; ok := 0; this_character := current_character; tab_character := ascii(9); !bug index function doesn't find tabs!! loop ! skip over the column to the blank space exitif(ok); this_character := current_character; if (index(eve$x_fill_separators,this_character)=0) and (this_character <> tab_character) and (this_character <> eve$kt_null) then move_horizontal(1); else ok := 1; endif; if (current_offset = buffer_right_margin) then message("EOLN this_position went past EOL"); return(0); endif; endloop; return(1); endprocedure !Last Modified: 8-JUN-1988 15:36:53.54 procedure eve_depad_column(len,selector) LOOP ! traverse column getting rid of blanks so new column will keep ! spacing. EXITIF MARK(NONE) > selector; erase_character(len); MOVE_VERTICAL(1); ENDLOOP; endprocedure ; ! create blanks so that inserted column doesn't overwrite its' neighbor ! beginning select marker will also be shifted so it will be replaced ! by a new one after the return procedure eve_pad_column(len,selector) local pad_chars; pad_chars := eveplus_blank_chars(len); ! create the padding SET(INSERT, current_buffer); LOOP EXITIF MARK(NONE) > selector; COPY_TEXT(pad_chars); ! add in blanks MOVE_HORIZONTAL(-len); MOVE_VERTICAL(1); ENDLOOP; endprocedure ; ! procedures to reverse columns. Prompts for two columns. EVE_MOVE_COLUMN ! selects out the two columns. A blank line is interpreted as the end of ! the columns. If left side of column is uneven data is lost. procedure eve_traverse_column(linecounter,start_column,tab_character, buffer_right_margin) local ok,this_char; ok := 0; loop ! select vertical this_char := current_character; exitif(ok); if (current_offset < start_column) then eve_move_up; ! cursor jumped to BOL ok := 1; else !jumped to a shorter line? linecounter := linecounter + 1; eve_move_down; if (index(eve$x_fill_separators,this_char) = 0) and (this_char <> tab_character) and (this_char <> eve$kt_null) then ok := eve_skip_column(buffer_right_margin); ok := 0; else if (current_offset = 0) and (index(current_line,eve$x_symbol_characters)=0) and (index(current_line,eve$x_not_alphabetic)=0) then ok:= 1; eve_move_up; linecounter := linecounter - 1; endif; endif; endif; endloop; endprocedure ; ! driver procedure eve_move_column local ok,prompt,first_col,second_col,this_position,this_char, first_select_start,second_select_start,len, second_select_end,first_select_end,buffer_right_margin,first_count, second_count,start_column,tab_character,first_column_length, second_column_length,first_column_end,second_column_start; tab_character := ascii(9); first_count := 0; ! counters to make sure columns are equal length second_count := 0; buffer_right_margin := get_info(current_buffer,"right_margin"); prompt := "Enter a column (number) to switch: "; first_col := int(read_line(prompt)); prompt := "Enter the column (number) to switch with: "; second_col := int(read_line(prompt)); if ((first_col = 0) or (second_col = 0)) then message("No column entered"); return; endif; if (first_col > second_col) then message("First column is greater than second column"); return; endif; ! once on first column advance x columns to second column second_col := second_col - first_col; position(beginning_of(current_buffer)); ok := 0; loop this_position := mark(none); if (this_position = end_of(current_buffer)) then message("Couldn't find a column"); return; endif; status := eve_skip_white_space(buffer_right_margin); if (status = 0) then ! continue to unwind return(0); ! signal failure on first column else ok := 1; endif; exitif (ok); endloop; ok := eve$find_column(first_col,buffer_right_margin); if (ok = 0) then return; endif; eve_rectangular_select; first_select_start := eveplus_v_begin_select;! select column start_column := current_offset; ok := eve_skip_column(buffer_right_margin);! move cursor across column if (ok = 0) then return; endif; first_column_end := current_offset; first_column_length := first_column_end - start_column; eve_traverse_column(first_count,start_column,tab_character, buffer_right_margin); first_select_end := mark(none); eve_rectangular_remove; ! remove first column eve$copy_buffer("insert here","store_buffer"); ! store it position(first_select_start); ! go back to where we started ok := eve_skip_white_space(buffer_right_margin);!skip to next column ok := eve$find_column(second_col,buffer_right_margin);! find second col if (ok = 0) then return; endif; second_column_start := current_offset; eve_rectangular_select;! select it second_select_start := eveplus_v_begin_select;! remember location ok := eve_skip_column(buffer_right_margin);! skip over it if (ok = 0) then return; endif; second_column_length := current_offset - second_column_start; eve_traverse_column(second_count,start_column,tab_character, buffer_right_margin); second_select_end := mark(none); eve_rectangular_remove;! remove second column if (first_count = second_count) then position(first_select_start);! goto where first column was if (second_column_length > first_column_length) then len := second_column_length - first_column_length; eve_pad_column(len,first_select_end);! make room for it position(first_select_start); delete(first_select_start);! select offset is bad move_horizontal(-len);! make a new one first_select_start := mark(none); eve_rectangular_insert_here;! insert second column eve$copy_buffer("store_buffer","insert here");!copy first back position(second_select_start);! goto where second was eve_depad_column(len,second_select_end);!shrink spaces position(second_select_start);! goto where second was eve_rectangular_insert_here;! insert old first column else if (second_column_length < first_column_length) then len := first_column_length-second_column_length ; eve_depad_column(len,first_select_end);! shrink spaces position(first_select_start); eve_rectangular_insert_here;! insert second column eve$copy_buffer("store_buffer","insert here");!copy first back position(second_select_start);! goto where second was eve_pad_column(len,second_select_end);! make room position(second_select_start); delete(second_select_start);! get rid of bad marker move_horizontal(-len); second_select_start := mark(none); eve_rectangular_insert_here; else ! else they are of equal length will fit nice&snug position(first_select_start); eve_rectangular_insert_here;! insert second column eve$copy_buffer("store_buffer","insert here");!copy first back position(second_select_start);! goto where second was eve_rectangular_insert_here; endif; endif; else message("Error columns unequal in length unable to switch"); position(second_select_start); eve_rectangular_insert_here;! insert second column eve$copy_buffer("store_buffer","insert here");!copy first back position(first_select_start); eve_rectangular_insert_here;! insert here endif; endprocedure