Lugaru's Epsilon
Programmer's
Editor

Context:
Epsilon User's Manual and Reference
   Primitives and EEL Subroutines
      Buffer Primitives
         Changing Buffer Contents
         Moving Text Between Buffers
         Getting Text from a Buffer
         . . .
         Listing Buffers
      Display Primitives
         . . .
         Pop-up Window Subroutines
         Window Attributes
         Buffer Text in Windows
         Window Titles and Mode Lines
         Normal Buffer Display
         . . .
      File Primitives
         File Reading Primitives
         File Writing Primitives
         Line Translation Primitives
         . . .
         Tagging Internals
      . . .

Previous   Up    Next
Window Attributes  Primitives and EEL Subroutines   Window Titles and Mode Lines


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

Buffer Text in Windows

to_buffer(char *buf)          /* buffer.e */
to_buffer_num(int bnum)     /* buffer.e */
window short window_bufnum;
switch_to_buffer(int bnum)
int give_prev_buf()         /* buffer.e */
prev_forget_buf(int buf)    /* buffer.e */
to_another_buffer(char *buf)
tiled_only()            /* window.e */
int in_bufed()              /* bufed.e */
quit_bufed()            /* bufed.e */

The to_buffer( ) subroutine defined in buffer.e connects the current window to the named buffer, while to_buffer_num( ) does the same, but takes a buffer number. Both work by setting the window_bufnum variable, first remembering the previous buffer displayed in the window so the user can easily return to it. The window_bufnum variable stores the buffer number of the buffer displayed in the current window.

Both of these functions check the file date of the new buffer and warn the user if the buffer's file has been modified on disk. The switch_to_buffer( ) subroutine skips this checking.

The give_prev_buf( ) subroutine retrieves the saved buffer number of the previous buffer displayed in the current window. If the previous buffer has been deleted, or there is no previous buffer for this window, it returns the number of another recently-used buffer. If it can't find any suitable buffer, it returns 0. The prev_forget_buf( ) subroutine says that the indicated buffer should be removed from the list of previous buffers.

The to_another_buffer( ) subroutine makes sure that buf is not the current buffer. If it is, the subroutine switches the current window to a different buffer. This subroutine is useful when you're about to delete a buffer.

Sometimes the user may issue a command that switches buffers, while in a bufed pop-up window, or some other type of pop-up window. Issuing to_buffer( ) would switch the pop-up window to the new buffer, rather than the underlying window. Such commands should call the tiled_only( ) subroutine before switching buffers. This subroutine removes any bufed windows or other unwanted windows, and returns to the original tiled window. It calls the quit_bufed( ) subroutine to remove bufed windows. If it can't remove some pop-up windows, it tries to abort the command that created them. The quit_bufed( ) subroutine uses the in_bufed( ) subroutine to determine if the current window is a bufed window.

user window int window_start;
user window int window_end;
fix_window_start()      /* window.e */

The window_start variable provides the buffer position of the first character displayed in the current window. Epsilon's redisplay sets this variable, but you can also set it manually to change what part of the buffer appears in the window. When Epsilon updates the window after a command, it makes sure that point is still somewhere on the screen, using the new value for window_start. If not, it alters window_start so point is visible.

The window_end variable provides the buffer position of the last character displayed in the window. Epsilon's redisplay sets this variable. Setting it does nothing.

The fix_window_start( ) subroutine adjusts window_start, if necessary, so that it occurs at the beginning of a line.

int get_window_pos(int pos, int *row, int *col)
int window_line_to_position(int row)

The get_window_pos( ) function takes a buffer position and finds the window row and column that displays the character at that position. It puts the row and column in the locations that row and col point to. It returns 0 if it could find the position in the window, or a code saying why it could not.

A return value of 1 means that the position you gave doesn't appear in the window because it precedes the first position displayed in the window. If the given position doesn't appear in the window because it follows the last position displayed in the window, the function returns 2. A return value of 3 means that the position "appears" before the left edge of the screen (due to horizontal scrolling), and 4 means that the position "appears" too far to the right. It doesn't change the locations that row and col refer to when it returns 1 or 2.

The window_line_to_position( ) primitive takes the number of a row in the current window, and returns the buffer position of the first character displayed on that row. It returns -1 if the row number provided is negative or greater than the number of rows in the window.

user int line_in_window;
user int column_in_window;

The line_in_window and column_in_window primitives give you the position of point in the current window, as set by the last refresh( ). Both variables start counting from 0. If you switch windows, Epsilon will not update these variables until the next refresh( ).

int window_extra_lines()
build_window()
window_to_fit(int max)      /* window.e */
popup_near_window(int new, int old)

When buffer text doesn't reach to the bottom of a window, Epsilon blanks the rest of the window. The window_extra_lines( ) primitive gives the number of blank lines at the bottom of the window that don't correspond to any lines in the buffer.

Some of the functions that return information about the text displayed in a window only provide information as of the last redisplay. Due to buffer changes, their information may now be outdated. The build_window( ) primitive reconstructs the current window internally, updating Epsilon's idea of which lines of text go where in the window, how much will fit, and so forth. This primitive updates the value of window_end. It may also modify the display_column and window_start variables if displaying the window as they indicate doesn't get to point. The build_window( ) function also updates the values returned by the window_line_to_position(), get_window_pos( ), and window_extra_lines( ) functions.

Use the window_to_fit( ) subroutine to ensure that a pop-up window is no taller than it needs to be. It sets the window's height so that it's just big enough to hold the buffer's text, but never more than max lines tall. The subroutine has no effect on windows that form part of a dialog.

The popup_near_window( ) subroutine tries to move a pop-up window on the screen so it's near another window. It also adjusts the height of the pop-up window based on its contents, by calling window_to_fit( ). The bufed command uses this to position its pop-up buffer list near the tiled window from which you invoked it.

window_scroll(int lines)

The window_scroll( ) primitive scrolls the text of the current window up or down. It takes an argument saying how many lines up to scroll the current window. With a negative argument, this primitive scrolls the window down. (See Normal Buffer Display for information on scrolling text left or right.)



Previous   Up    Next
Window Attributes  Primitives and EEL Subroutines   Window Titles and Mode Lines


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