Lugaru's Epsilon
Programmer's
Editor

Context:
Epsilon User's Manual and Reference
   Primitives and EEL Subroutines
      Buffer Primitives
         . . .
         Other Formatting Functions
         Comparing Primitives
         Managing Buffers
         Catching Buffer Changes
         Listing Buffers
      Display Primitives
         Creating & Destroying Windows
         Window Resizing Primitives
         Preserving Window Arrangements
         . . .
         Colors
      . . .

Previous   Up    Next
Comparing Primitives  Primitives and EEL Subroutines   Catching Buffer Changes


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

Managing Buffers

int create(char *buf)
char *bufnum_to_name(int bnum)
int name_to_bufnum(char *bname)
int zap(char *buf)
buf_zap(int bnum)
int change_buffer_name(char *newname)

The create( ) primitive makes a new buffer. It takes the name of the buffer to create. If the buffer already exists, nothing happens. In either case, it returns the buffer number of the buffer.

Some primitives let you specify a buffer by name; others let you specify a buffer by number. Epsilon tries never to reuse buffer numbers, so EEL functions can look a buffer up by its buffer number to see if a particular buffer still exists. Functions that accept a buffer number generally start with buf_.

Use the bufnum_to_name( ) primitive to convert from a buffer number to the buffer's name. If no such buffer exists, it returns a null pointer. The name_to_bufnum( ) primitive takes a buffer name, and gives you the corresponding buffer number. If no such buffer exists, it returns zero.

The zap( ) primitive creates a buffer if necessary, but empties it of all characters if the buffer already exists. So calling zap( ) always results in an empty buffer. The zap( ) primitive returns the buffer number of the buffer, whether or not it needed to create the buffer. The buf_zap( ) primitive works like zap( ), except the former takes a buffer number instead of a buffer name, and signals an error if no buffer with that number exists. Unlike zap( ), buf_zap( ) cannot create a buffer. Neither primitive switches to the emptied buffer.

The change_buffer_name( ) primitive renames the current buffer to the indicated name. If there is already a buffer with the new name, the primitive returns 0, otherwise the buffer is renamed and the primitive returns 1.

int exist(char *buf)
int buf_exist(int bnum)
delete_buffer(char *buf)
delete_user_buffer(char *buf)
buf_delete(int bnum)
drop_buffer(char *buf)        /* buffer.e */
char *temp_buf()        /* basic.e */
int tmp_buf()       /* basic.e */

The exist( ) primitive tells whether a buffer with a particular name exists. It returns 1 if the buffer exists, 0 if not. The buf_exist( ) does the same thing, but takes a buffer number instead of a buffer name.

The delete_buffer( ) primitive removes a buffer with a given name. It also removes all windows associated with the buffer. The buf_delete( ) primitive does the same thing, but takes a buffer number. Epsilon signals an error if the buffer does not exist, if it contains a running process, or if one of the buffer's windows could not be deleted. If the buffer might have syntax highlighting in it, use the delete_user_buffer( ) subroutine instead; it cleans up some data needed by syntax highlighting.

The drop_buffer( ) subroutine deletes the buffer, but queries the user first like the kill-buffer command if the buffer contains unsaved changes.

The EEL subroutine temp_buf( ), defined in basic.e, uses the exist( ) primitive to create an unused name for a temporary buffer. It returns the name of the empty buffer it creates. The tmp_buf( ) subroutine creates a temporary buffer like temp_buf( ), but returns its number instead of its name.

buffer char *bufname;
buffer int bufnum;

The bufname variable returns the name of the current buffer, and the bufnum variable gives its number. Setting either switches to a different buffer. If the indicated buffer does not exist, nothing happens. Use this method of switching buffers only to temporarily switch to a new buffer; use the to_buffer( ) or to_buffer_num( ) subroutines described in Buffer Text in Windows to change the buffer a window will display.

To set the bufname variable, use the syntax bufname = new value;. Don't use strcpy( ), for example, to modify it.

int buffer_size(char *buf)
int buf_size(int bnum)
int get_buf_point(int buf)
set_buf_point(int buf, int pos)

The buffer_size( ) and buf_size( ) subroutines returns the size in characters of the indicated buffer (specified by its name or number). The get_buf_point( ) subroutine returns the value of point in the indicated buffer. The set_buf_point( ) subroutine sets point in the specified buffer to the value pos. These are all defined in buffer.e.



Previous   Up    Next
Comparing Primitives  Primitives and EEL Subroutines   Catching Buffer Changes


Lugaru Copyright (C) 1984, 2012 Lugaru Software Ltd. All Rights Reserved.