!Last Modified: 13-DEC-1988 10:52:16.41, By: FLEMING !+ ! from WHAT.TPU - finds the current line number, returns it to caller !- ! procedure eve_return_line( this_position) ! What line am I on? local saved_mark, ! marker - current position text_mark, ! marker - after snapping to text this_line_position, ! marker - position at start of this_line total_lines, ! integer - total lines in buffer high_line, ! integer - high line limit for binary search low_line, ! integer - low line limit for binary search low_position, ! marker - beginning of low line this_line, ! integer - line number of current guess eob_flag, ! boolean - true if at eob percent; ! integer - percent of way through buffer on_error [TPU$_CONTROLC]: eve$$restore_position (saved_mark); ! restore free cursor position eve$learn_abort; abort; [OTHERWISE]: eve$$restore_position (saved_mark); endon_error; ! Initialization saved_mark := mark (FREE_CURSOR); position (search (ANCHOR, FORWARD)); ! snap the cursor (move_vertical pads) text_mark := mark (NONE); total_lines := get_info (current_buffer, "record_count"); high_line := total_lines + 1; if text_mark = end_of (current_buffer) then if text_mark = beginning_of (current_buffer) then eve$message (EVE$_BUFEMPTY); position (saved_mark); ! no learn_abort here return (FALSE); else eob_flag := TRUE; low_line := total_lines; low_position := end_of (current_buffer); endif; else low_line := 1; low_position := beginning_of (current_buffer); endif; ! Binary search loop exitif high_line - low_line <= 1; this_line := (high_line + low_line) / 2; position (low_position); move_vertical (this_line - low_line); if mark (FREE_CURSOR) > saved_mark then high_line := this_line; else low_line := this_line; low_position := mark (FREE_CURSOR); if mark (FREE_CURSOR) = saved_mark then high_line := this_line; endif; endif; endloop; eve_return_line := low_line; position (saved_mark); endprocedure