Movement Primitives

Summary
Movement Primitives
Macros
backspaceDelete character to the left of the cursor.
beginning_of_lineGoto beginning of line.
bookmark_listRetrieve existing bookmark list.
delete_bookmarkDelete a bookmark.
downMove position down one line.
drop_bookmarkCreate or update a bookmark.
end_of_bufferMove cursor to end of current buffer.
end_of_lineGoto end of line.
end_of_windowGoto end of the current window.
goto_lineMove to a particular line.
goto_old_lineMove to line before buffer modification.
leftMove position left one charcter.
move_absMove to an absolute location in the buffer.
move_relMove to a relative location in the buffer.
next_charMove to the next character.
page_downMove position down a page.
page_upMove position up a page.
parse_filenameParse a file into its components.
prev_charMove to the previous character.
swap_anchorSwaps the mark with the current position.
top_of_bufferMove cursor to start of current buffer.
top_of_windowGoto top of the current window.

Macros

backspace

void backspace([int num = 1])

Delete character to the left of the cursor.

Description

The backspace() primitive moves the cursor and deletes the character to the left of the cursor in the current buffer.

The actions of backspace are dependent on the current insert mode.

Insert Mode

If insert mode backspaces moves the cursor and deletes the previous character, all characters to the right move one character to the left.

If the cursor is at the beginning of the line then the current line is appended to the end of the previous line.

Overtype Mode

If overstrike mode backspaces moves the cursor and deletes the previous character, replacing it with a space.

If the previous character is a tab, it moves over virtual spaces between the current position and the tab character when moving back.

If the cursor is at the beginning of the line then the cursor is moved to end of the previous line.

Parameters

numOptional integer, if stated specifies the number of characters the cursor to be moved backwards, if omitted only a single character position is moved.

Returns

The backspace() primitive returns non-zero if successful impling the cursor moved, otherwise zero.

Portability

The num option is a GriefEdit extension.

See Also

delete_char, left

beginning_of_line

int beginning_of_line()

Goto beginning of line.

Description

The beginning_of_line() primitive moves the buffer cursor to the first character of the current line.

Parameters

none

Returns

The beginning_of_line() primitive returns non-zero on success denoting that the cursor moved, otherwise zero if the cursor remained unchanged.

Portability

n/a

See Also

end_of_line

bookmark_list

list bookmark_list()

Retrieve existing bookmark list.

Description

The bookmark_list() primitive creates a list containing all currently defined bookmarks.  For each definition the list shall contain a 4 integer record representing the bookmark as follows:

{ bookid, bufnum, line, column }
  • bookid - Bookmark identifier.
  • bufnum - buffer number.
  • line - buffer line number.
  • column - buffer column number.

If no bookmarks exist then a NULL list shall be returned.

Parameters

none

Returns

The bookmark_list() primitive returns a list containing the bookmark definitions otherwise NULL if no bookmarks exist.

Portability

n/a

See Also

delete_bookmark, drop_bookmark, goto_bookmark

delete_bookmark

void delete_bookmark(int bookid)

Delete a bookmark.

Description

The delete_bookmark() primitive deletes the bookmark bookid.

Upon successful completion, the REG_BOOKMARK event shall be triggered (See: register_macro).

Parameters

bookidBookmark identifier.

Returns

nothing

Portability

n/a

See Also

bookmark_list, drop_bookmark, goto_bookmark

down

int down([int lines = 1])

Move position down one line.

Description

The down() primitive moves the cursor down one line to the same column on the next line.

Parameters

linesOptional number of lines to move the cursor; may be negative in which case the cursor moves backwards behaving like up.

Returns

The down() primitive returns non-zero on success denoting that the cursor moved, otherwise zero if the cursor remained unchanged.

Portability

n/a

See Also

up, left, right

drop_bookmark

int drop_bookmark([int bookid],
[string yesno],
 [int bufnum],
[int line],
[int column],
[int local = FALSE])

Create or update a bookmark.

Description

The drop_bookmark() primitive either create a new or updates an existing bookmark.  A bookmark is a named place holder with a buffer, representing a specific physical location within that buffer.

bookid is the unique identifier to be associated with the bookmark; any valid integer may be used as the identifier.  The bookmark shall be associated with the buffer bufnum, line and column, if any are omitted the current buffer and location with that shall be used.

Upon there being an existing definition against the specified bookmark identifier, the user shall be prompted as follows, asking whether or not the bookmark should be replaced:

Overwrite existing bookmark [y/n]?

The yesno argument if given disables the user prompt.  If supplied with either “y” or “yes” the bookmark shall automatically be replaced, otherwise the bookmark is retained without change with the user informed as follows:

Bookmark already exists.

Upon successful completion, the user shall be informed as follows regardless of whether a new or updated definition resulted:

Bookmark dropped.

Parameters

bookidOptional bookmark identifier, if omitted a new unique book mark identifier shall be generated.
yesnoOptional string buffer containing the answer to be applied upon the bookmark pre-existing, if given as “y[es]” the bookmark shall be overridden otherwise is shall be related.  Otherwise if omitted upon a preexisting bookmark the user shall be prompted.
bufnumOptional buffer number, if omitted the current buffer shall be referenced.
lineOptional integer line number within the buffer, if omitted shall default to the top of the buffer (1).
columnOptional integer column number within the buffer, if omitted shall default to the left of the buffer (1).
localReserved for future use.

Returns

The drop_bookmark() primitive returns the associated book mark identifier, otherwise 0 on error.

Portability

n/a

TODO

Support buffer local bookmark identifiers; improves Vim compatibility.

See Also

bookmark_list, delete_bookmark, goto_bookmark

end_of_buffer

int end_of_buffer()

Move cursor to end of current buffer.

Description

The end_of_buffer() primitive moves the buffer cursor to the end of the last line of the current buffer.

Parameters

none

Returns

The end_of_buffer() primitive returns non-zero on success denoting that the cursor moved, otherwise zero if the cursor remained unchanged.

Portability

n/a

See Also

top_of_buffer, move_abs

end_of_line

int end_of_line()

Goto end of line.

Description

The end_of_line() primitive moves the buffer cursor to the last character of the current line.

Parameters

none

Returns

The end_of_line() primitive returns non-zero on success denoting that the cursor moved, otherwise zero if the cursor remained unchanged.

Portability

n/a

See Also

beginning_of_line

end_of_window

int end_of_window()

Goto end of the current window.

Description

The end_of_window() primitive moves the buffer cursor to the last line of the current window.

Parameters

none

Returns

Returns non-zero if the current cursor position moved, otherwise zero if already positioned at the end of the window.

Portability

n/a

See Also

top_of_window

goto_line

int goto_line([int lineno])

Move to a particular line.

Description

The goto_line() primitive repositions the cursor to tbe beginning of the specified line lineno.

Parameters

linenoSpecifies the line number which to relocate the cursor, if omitted the user is prompted.

Returns

The goto_line() primitive returns true if successful, otherwise zero or less if unsuccessful.

Portability

n/a

See Also

goto_old_line, move_abs

goto_old_line

int goto_old_line([int oldlineno])

Move to line before buffer modification.

Description

The goto_old_line() primitive repositions the cursor as close as possible to the beginning of the specified line oldlineno, representing the line prior to any buffer modifications.

For each buffer the previous line numbers are retained for any one edit session, that is they are maintained until the buffer is saved, at which point line references are reset to the resulting new image.

This primitive is provided for seeking lines within a buffer that are referred to in an external listing.  For example within a previous compiler error report yet since that time inserts and/or line deletes have occurred to the source, yet despite these edits the original line can still be addressed.

Parameters

oldlinenoSpecifies the old line number which to relocate the cursor, if omitted the user is prompted.

Returns

The goto_old_line() primitive returns true if successful, otherwise zero or less if unsuccessful.

Portability

n/a

See Also

goto_line, move_abs

left

int left([int columns = 1],
[int wrap = TRUE])

Move position left one charcter.

Description

The left() primitive moves the cursor left one column retaining the current line; unless at the beginning of the line, in which case the cursor moves to the end of the previous line.

Parameters

columnsOptional number of columns to move the cursor; negative in which case the cursor movement is reversed behaving like right.
wrapOptional boolean value controlling whether the cursor wraps when positioned at the beginning of line.  If FALSE line wrapping shall be disabled.

Returns

The left() primitive returns non-zero on success denoting that the cursor moved, otherwise zero if the cursor remained unchanged.

Portability

Unlike BRIEF, if the cursor is moved past the beginning of the current line, then the cursor wraps around to the end of the previous line.

wrap is a GriefEdit extension.

See Also

right, up, down

move_abs

int move_abs([int line = -1],
[int column = -1],
 [int bufnum],
[int clip = FALSE])

Move to an absolute location in the buffer.

Description

The move_abs() primitive moves the buffer cursor to an absolute location, with top of the buffer being position (1,1).

If a parameter is 0 or omitted, the corresponding line or column coordinate is unchanged; positive values set the line and/or column.

Parameters

lineOptional integer specifying the line number, if positive the cursor is set to the specified line.
columnOptional integer specifying the column number, if positive the cursor is set to the specified column.
bufnumOptional buffer number, if specified the associated buffer is affected, otherwise the current buffer.
clipOptional int flag, if non-zero the resulting buffer cursor shall be clipped to the buffer size.

Returns

The move_abs() primitive returns non-zero on success denoting that the cursor moved, otherwise zero if the cursor remained unchanged.

Portability

bufnum and clip are extensions.

See Also

move_rel

move_rel

int move_rel([int lines = 1],
[int cols = 1])

Move to a relative location in the buffer.

Description

The move_rel() primitive moves the buffer cursor to a new position relative to the current position.

If a parameter is 0 or omitted, the corresponding line or column coordinate is unchanged.  Positive values move the cursor towards the end of the line and/or column, likewise negative values move towards the beginning of the line and/or column.

Parameters

linesOptional integer specifying the line number, if positive the cursor moves forwards the end of the file, likewise a negative moves to backwards towards the top.
colsOptional integer specifying the column number, if positive the cursor moves forwards the front of the line, likewise a negative moves to backwards towards the beginning.

Returns

The mov_rel() primitive returns non-zero on success denoting that the cursor moved, otherwise zero if the cursor remained unchanged.

Portability

n/a

See Also

move_abs

next_char

int next_char([int characters = 1])

Move to the next character.

Description

The next_char() primitive moves the current buffer position forward to the next character, wrapping around line ends when encountered.

The primitive is similar to right except it moves physical characters as opposed to logic characters, as the result tabs and newlines are both treated as one character.

Within navigating binary files newlines are not implied, as such are not counted within the character count.

Parameters

charactersOptional number of characters to move forward in the buffer, which if omitted is 1.

Returns

The next_char() primitive returns non-zero on success denoting that the cursor moved, otherwise zero if the cursor remained unchanged.

Portability

n/a

See Also

prev_char, right

page_down

int page_down([int pages = 1])

Move position down a page.

Description

The page_down() primitive moves the buffer position down or forward one or more pages down, with a page being the current window size in lines.

Parameters

pagesIf supplied, states the number of pages to move the cursor forward, otherwise the cursor is moved 1 page.

Returns

The page_down() primitive returns non-zero on success denoting that the cursor moved, otherwise zero if the cursor remained unchanged.

Portability

pages is a GriefEdit extension.

See Also

page_up, down

page_up

int page_up([int pages = 1])

Move position up a page.

Description

The page_up() primitive moves the buffer position up or backwards one or more pages up, with a page being the current window size in lines.

Parameters

pagesIf supplied, states the number of pages to move the cursor backwards, otherwise the cursor is moved 1 page.

Returns

The page_up() primitive returns non-zero on success denoting that the cursor moved, otherwise zero if the cursor remained unchanged.

Portability

pages is a GriefEdit extension.

See Also

page_down, up

parse_filename

int parse_filename(string fullname,
 [string &drive],
  [string &path],
 [string &filename],
 [string &ext])

Parse a file into its components.

Description

The parse_filename() primitive parsing and brakes the file name fullname into it components.

Note:

Since this primitive is not portable outside of a DOS/Windows environment, its use is not adviced.

Parameters

fullnameA string containing the file-name to be parsed.
driveOptional string variable when supplied to be populated with the drive component, if any.
pathOptional string variable when supplied to be populated with the path component.
filenameOptional string variable when supplied to be populated with the file-name component.
extOptional string variable when supplied to be populated with the file extension.

Returns

The parse_filename() primitive returns non-zero on success denoted the fullname was parsed, otherwise zero was unsuccessful and -1 if an empty fullname was supplied.

Portability

Provided for BRIEF compatibility.

See Also

dirname, basename

prev_char

int prev_char([int characters = 1])

Move to the previous character.

Description

The prev_char() primitive moves the current buffer position backward to the previous character, wrapping around line ends when encountered.

The primitive is similar to left except it moves physical characters as opposed to logic characters, as the result tabs and newlines are both treated as one character.

Within navigating binary files newlines are not implied, as such are not counted within the character count.

Parameters

charactersOptional number of characters to move backward in the buffer, which if omitted is 1.

Returns

The prev_char() primitive returns non-zero on success denoting that the cursor moved, otherwise zero if the cursor remained unchanged.

Portability

n/a

See Also

next_char, left

swap_anchor

int swap_anchor()

Swaps the mark with the current position.

Description

The swap_anchor() primitive swaps the current cursor position with the start of the marked region, without changing the mark type.

Parameters

none

Returns

Returns true on success, otherwise false.

Portability

n/a

See Also

drop_anchor, mark

top_of_buffer

int top_of_buffer()

Move cursor to start of current buffer.

Description

The top_of_buffer() primitive moves the buffer cursor to the start of the first line of the current buffer; this is eqivalent to using move_abs as follows.

move_abs(1,1);

Parameters

none

Returns

The top_of_buffer() primitive returns non-zero on success denoting that the cursor moved, otherwise zero if the cursor remained unchanged.

Portability

n/a

See Also

end_of_buffer, inq_position, move_abs, move_rel

top_of_window

int top_of_window()

Goto top of the current window.

Description

The top_of_window() primitive moves the buffer cursor to the first line of the current window.

Parameters

none

Returns

Returns non-zero if the current cursor position moved, otherwise zero if already positioned at the top of the window.

Portability

n/a

See Also

end_of_buffer, inq_position, move_abs, move_rel

$Id: $

To send feedback on this topic email: grie.nosp@m.fedit@gmai.nosp@m.l.com

Copyright © Adam Young All Rights Reserved.

void backspace([int num = 1])
Delete character to the left of the cursor.
int beginning_of_line()
Goto beginning of line.
list bookmark_list()
Retrieve existing bookmark list.
void delete_bookmark(int bookid)
Delete a bookmark.
int down([int lines = 1])
Move position down one line.
int drop_bookmark([int bookid],
[string yesno],
 [int bufnum],
[int line],
[int column],
[int local = FALSE])
Create or update a bookmark.
int end_of_buffer()
Move cursor to end of current buffer.
int end_of_line()
Goto end of line.
int end_of_window()
Goto end of the current window.
int goto_line([int lineno])
Move to a particular line.
int goto_old_line([int oldlineno])
Move to line before buffer modification.
int left([int columns = 1],
[int wrap = TRUE])
Move position left one charcter.
int move_abs([int line = -1],
[int column = -1],
 [int bufnum],
[int clip = FALSE])
Move to an absolute location in the buffer.
int move_rel([int lines = 1],
[int cols = 1])
Move to a relative location in the buffer.
int next_char([int characters = 1])
Move to the next character.
int page_down([int pages = 1])
Move position down a page.
int page_up([int pages = 1])
Move position up a page.
int parse_filename(string fullname,
 [string &drive],
  [string &path],
 [string &filename],
 [string &ext])
Parse a file into its components.
int prev_char([int characters = 1])
Move to the previous character.
int swap_anchor()
Swaps the mark with the current position.
int top_of_buffer()
Move cursor to start of current buffer.
int top_of_window()
Goto top of the current window.
void delete_char([int num])
Delete character.
int goto_bookmark(int bookid =  NULL,
  [int &bufnum],  
 [int &line],  
 [int &column]  )
Seek a bookmark.
int register_macro(int type,
 string macro,
 [int local = FALSE])
Register a callback procedure.
int up([int lines = 1])
Move position up one line.
int right([int columns = 1],
[int wrap = TRUE])
Move position right one character.
int dirname(string path)
Report the parent directory name of a file pathname.
int basename(string pathname,
 [string suffix])
Return the last component of a pathname.
int drop_anchor([int type = MK_NORMAL])
Start marking a selection.
int mark([int type = MK_NORMAL])
Toggle the anchor status.
int inq_position([int &line],
[int &col])
Retrieve current buffer position.