Lugaru's Epsilon
Editor 14.04

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

Previous   Up    Next
Moving by Lines  Primitives and EEL Subroutines   Sorting Primitives

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

Other Movement Functions

int move_level(int dir, char *findch,
               char *otherch, int show, int stop_on_key)
buffer int (*mode_move_level)();
int c_move_level(int dir, int stop_on_key)
int html_move_level(int dir, int stop_on_key)
int default_move_level(int dir, char *findch,
                       char *otherch)

Several subroutines move through text counting and matching various sorts of delimiters. The move_level( ) subroutine takes a direction dir which may be 1 or -1, and two sets of delimiters. The routine searches for any one of the characters in findch. Upon finding one, it continues searching in the same direction for the character in the same position in otherch, skipping over matched pairs of these characters in its search.

For example, if findch was ">])" and dir was -1, move_level( ) would search backwards for one of these three characters. If it found a ")" first, it would then select the third character of otherch, which might be a "(". It would then continue searching for a "(". But if it found additional ")" characters before reaching that "(", it would need to find additional "(" characters before stopping.

The subroutine returns 1 to indicate that it found a match, and leaves point on the far side of the match (like commands such as forward-level). If no match can be found, the subroutine returns 0. Additionally, if its parameter show is nonzero, it displays an "Unmatched delimiter" message. When no characters in findch can be found in the specified direction, it sets point to the far end of the buffer and returns 1. If stop_on_key is nonzero, the subroutine will occasionally check for user key presses, and abort its search if the user has pressed a key. It returns -2 in this case and doesn't change point.

Certain modes define a replacement level matcher that understands more of the syntax of that mode's language. They do this by setting the buffer-specific function pointer variable mode_move_level to a function such as c_move_level( ). The move_level( ) subroutine will call this function instead of doing its normal processing when this variable is nonzero in the current buffer.

Any such function will receive only dir and stop_on_key parameters. (It should already know which delimiters are significant in its language.) It should return the buffer position it reached (but not actually move there), if it found a pair of matched delimiters, or if it reached one end of the buffer without finding any suitable delimiters. If should return -1 if it detected an unmatched delimiter, or -2 if a keypress made it abort.

The default_move_level( ) function is what move_level( ) calls when no mode-specific function is available. It takes parameters like move_level( ), and returns -1 or a buffer position like c_move_level( ). A mode-specific function may wish to call this function, specifying a set of delimiters suitable for that language. The html_move_level( ) subroutine, for example, does just that.

int give_position(int (*cmd)())

The give_position( ) subroutine runs the subroutine cmd, which (typically) moves to a new position in the buffer. The give_position( ) subroutine returns this new position, but restores point to its original value. For example, give_position(forward_word) returns the buffer position of the end of the current word. EEL requires that cmd be declared before you call it, via a line like int cmd();, unless it's defined in the same file, before the give_position( ) call.

Previous   Up    Next
Moving by Lines  Primitives and EEL Subroutines   Sorting Primitives

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