Lugaru's Epsilon
Programmer's
Editor 14.04

Context:
Epsilon User's Manual and Reference
   Primitives and EEL Subroutines
      Buffer Primitives
         . . .
         Undo Primitives
         Searching Primitives
         Moving by Lines
         Other Movement Functions
         Sorting Primitives
         . . .
      Display Primitives
         Creating & Destroying Windows
         Window Resizing Primitives
         Preserving Window Arrangements
         . . .
         Colors
      . . .

Previous   Up    Next
Searching Subroutines  Primitives and EEL Subroutines   Other Movement Functions


Epsilon User's Manual and Reference > Primitives and EEL Subroutines > Buffer Primitives >

Moving by Lines

int nl_forward()
int nl_reverse()
int move_by_lines(int cnt)

The nl_forward( ) and nl_reverse( ) primitives quickly search for newline characters in the direction you specify. The nl_forward( ) primitive is the same as search(1, "\n"), while nl_reverse( ) is the same as search(-1, "\n"), where \n means the newline character (see Character Constants). These primitives do not set matchstart or matchend, but otherwise work the same as the previous searching primitives, returning 1 if they find a newline and 0 if they don't.

The move_by_lines( ) primitive moves forward over cnt lines, like calling nl_forward( ) that many times. If cnt is negative, it moves backward, like calling nl_reverse( ). It returns 0, unless it hit the end of the buffer (or narrowing) before moving the full amount; in that case it returns the number of lines still to go when it stopped. For example, if there are two newlines in the buffer before point, calling move_by_lines(-10) moves to the start of the buffer and returns -8.

to_begin_line()         /* eel.h macro */
to_end_line()           /* eel.h macro */
int give_begin_line()       /* basic.e */
int give_end_line()         /* basic.e */

The eel.h file defines textual macros named to_begin_line() and to_end_line() that make it easy to go to the beginning or end of the current line. They simply search in the appropriate direction for a newline character and back up over it if the search succeeds.

The give_begin_line( ) subroutine returns the buffer position of the beginning of the current line, and the give_end_line( ) subroutine returns the position of its end. Neither moves point.

go_line(int num)            /* basic.e */
buf_go_line(int buf, int num)
int lines_between(int from, int to, ?int abort_ok)
int count_lines_in_buf(int buf, int abortok)
int buf_position_to_line_number(int buf, int pos)
int all_blanks(int from, int to)    /* indent.e */

The EEL subroutine go_line( ) defined in basic.e uses the move_by_lines( ) primitive to go to a certain line in the buffer, counting from 1. go_line(2), for example, goes to the beginning of the second line in the buffer. The similar buf_go_line( ) subroutine does the same in the specified buffer.

The lines_between( ) primitive returns the number of newline characters in the part of the buffer between from and to. If abort_ok is nonzero, the user can abort from this primitive, otherwise Epsilon ignores the abort key.

The buf_position_to_line_number( ) subroutine returns the line number, counting from 1, of a particular position in the specified buffer.

The count_lines_in_buf( ) subroutine returns the number of newline characters in the buffer buf. If abortok is nonzero and the user press the abort key, the subroutine uses the check_abort( ) primitive to abort.

The all_blanks( ) subroutine returns 1 if the characters between from and to are all whitespace characters (space, tab, or newline), 0 otherwise.



Previous   Up    Next
Searching Subroutines  Primitives and EEL Subroutines   Other Movement Functions


Lugaru Epsilon Programmer's Editor 14.04 manual. Copyright (C) 1984, 2021 by Lugaru Software Ltd. All rights reserved.