!+ ! SORT.TPU !-! ! ! ! Sort the named buffer. Prompt for buffer name if not specified ! procedure eve_sort_by_col local sort_buffer ,key_size, end_select, end_column, start_column, first_row, last_row, sort_range, temp; IF eveplus_v_begin_select = 0 THEN MESSAGE("Rectangular select not active"); RETURN ENDIF; !+ ! Make sure there is a character at the corner of the box opposite ! the begin_select mark. If the end_select mark is before the ! begin_select mark, juggle the markers so that begin_select precedes ! end_select. !- IF MARK(reverse) >= eveplus_v_begin_select THEN end_select := MARK(NONE); ELSE end_select := eveplus_v_begin_select; eveplus_v_begin_select := MARK(NONE); ENDIF; !+ ! Figure out what column the box ends in and set END_COLUMN there. ! Then, clear out the video on EVEPLUS_V_BEGIN_SELECT. Figure out ! the start column. !- end_column := get_info(end_select,"offset"); start_column := get_info(eveplus_v_begin_select,"offset"); !+ ! We may have the upper right and lower left corners of the box ! selected. If so, START_COLUMN and END_COLUMN need to be reversed. !- IF start_column > end_column THEN temp := end_column; end_column := start_column; start_column := temp; ENDIF; !+ ! Create a buffer to sort in !- sort_buffer := create_buffer('sort_buffer'); !+ !+ ! mark the range that includes the area to sort and ! cut the entire range of rows to the sort buffer !- position(eveplus_v_begin_select); move_horizontal( - current_offset); first_row := mark(none); position(end_select); position (search (line_end, FORWARD)); last_row := mark(none); sort_range := create_range (first_row, last_row, reverse); position( sort_buffer ); move_text (sort_range); !+ ! Set up and call sort_by_col !- key_size := 1 + end_column - start_column; eveplus$$shell_sort_by_col (sort_buffer, 1 + start_column, key_size); !+ ! Put the contents of the sort buffer back into the original place !- position(first_row); move_text( sort_buffer ); delete(sort_buffer); eveplus_v_begin_select := 0; endprocedure