Changing Buffer Contents
An Epsilon buffer contains text that you can edit. Most of the primitives in this section act on, or refer to, one of the buffers designated as the current buffer.
The insert( ) primitive inserts a single character into the current buffer. Its argument says what character to insert. The buffer's insertion point, or just point, refers to the particular position in each buffer where insertions occur.
The int variable named point stores this position. Its value denotes the number of characters from the beginning of the buffer to the spot at which insertions happen. For example, a value of zero for point means that insertions would occur at the beginning of the buffer. A value of one for point means that insertions would occur after the first character, etc.
To change the insertion point, you can assign a new value to point. For example, the statement
makes insertions occur after the third character in the buffer, assuming the buffer has at least 3 characters. If you set point to a value less than zero, point takes the value zero. Similarly, if you set point to a value greater than the size of the buffer, its value becomes the number of characters in the buffer.
When the current buffer changes, the value of the variable point automatically changes with it. We call variables with this behavior buffer-specific variables. See Buffer-specific Variables.
The variable point refers not to a character position, but rather to a character boundary, a place between characters (or at the beginning or end of a buffer). The legal values for point range from zero to size( ). We will refer to a value in this range, inclusive of the ends, as a position. A position is a place between characters in a buffer, or at the beginning of the buffer, or at the end. The value of a position is the number of characters before it in the buffer. In EEL, ints (integers) hold positions.
When Epsilon inserts a character, it goes before point, not after it. If Epsilon didn't work this way, inserting a, then b, then c would result in cba, not abc.
The delete( ) primitive doesn't save deleted text in a kill buffer. The kill commands themselves manage the kill buffers, and use the delete( ) primitive to actually remove the text.
Commands that insert text often begin by calling the
delete_if_highlighted( ) subroutine. If there's a
highlighted region, this subroutine deletes it and returns
The character( ) primitive returns the character after the
position specified by its argument,
The bprintf( ) function also inserts a string, but it takes a format string plus other arguments and builds the string to insert using the rules in Printf-style Format Strings. The buffer_printf( ) functions similarly, except that it takes the name of the buffer into which to insert the string. It creates the buffer if necessary. Similarly, buf_printf( ) takes a buffer number, and inserts the formatted string into that buffer. All of the primitives described in this paragraph return the number of characters they inserted into the buffer.