Document revision date: 19 July 1999
[Compaq] [Go to the documentation home page] [How to order documentation] [Help on this site] [How to contact us]
[OpenVMS documentation]

DEC Text Processing Utility Reference Manual


Previous Contents Index


Appendix C
DECTPU Cursor Behavior

This appendix describes cursor behavior in DECTPU applications.

C.1 Cursor Position Compared to Editing Point

The cursor position is the location of the cursor in a window. Each window has an independent cursor position---the location of the cursor when that window becomes the current window.

The cursor position must be within the bounds of the visible window. To move the cursor position, use the CURSOR_HORIZONTAL or CURSOR_VERTICAL built-in. The cursor position is not necessarily bound to text.

DECTPU keeps the cursor position as close as possible to the editing point, which is the point in the buffer where text operations occur. However, the cursor position is not always exactly the same as the editing point. The editing point may be at a location in a buffer that is not visible in the current window, or the current buffer may not be mapped to a window at all. In either of these situations, text operations take place at a point different from the cursor position.

In this situation, the editing point is said to be detached. Being detached is not the same as being free. The editing point is free when it is in a location not occupied by a character. The editing point is detached when its location is not visible on the screen. Whenever possible, keep the cursor position synchronized with the editing point so that text operations are visible.

To move the editing point, use the MOVE_HORIZONTAL, MOVE_VERTICAL, or POSITION built-in.

The editing point is free if it is located before the beginning of a line, after the end of a line, in the middle of a tab, or beyond the end of a buffer.

Each buffer has its own editing point, which becomes active when that buffer becomes the current buffer.

Whenever the screen is updated, the cursor position in a window moves to the editing point of the buffer mapped to that window.

To move the editing point of a buffer to the cursor position of a window, use the POSITION built-in with a window variable as the parameter. The MAP and ADJUST_WINDOW built-ins position to the window implicitly and thus also move the editing point to the cursor position.

You can move the editing point without moving the cursor position and the reverse. However, to avoid confusion, the cursor position and the editing point should be synchronized when an operation manipulates the contents of a buffer. That is, both the cursor position and the editing point should point to the same place, or as close as possible. For example, using POSITION (buffer_variable) or POSITION (marker_variable) may reposition to another buffer without changing the current window. In this state, if you add self-inserting characters to a buffer, the cursor may not be visible in a window mapped to the buffer where the characters are inserted. Moreover, if the current buffer is not mapped to a visible window, there is no visual feedback of the input at all.

There are various ways to avoid this discrepancy between the cursor position and the editing point, depending on where a given text operation is to be carried out. If you use POSITION (buffer_variable) or POSITION (marker_variable) to implement user operations in a given buffer, either map the buffer to a visible window or position to a window to which the buffer is already mapped and then update the window. Remember, the screen manager may update the window automatically if you simply exit from your procedure.

If you position to a buffer or marker to perform some housekeeping operation and then want to restore the cursor position to its previous location, you should position to the current window (the window in which the visible cursor is located). This maps the current buffer to the current window and moves the editing point to the cursor position. Updating the screen at this point has no effect, because the positions are already synchronized.

C.2 Built-In Padding

The cursor position is not necessarily bound to text. You can move the cursor position to locations where there is no underlying text, such as left of the left margin, right of the end-of-line, in the middle of a tab, or on or below the end-of-buffer text.

However, some built-ins require an accurate offset into the current line. If you use such a built-in when the cursor position points to an area where there is no text, the screen manager inserts padding records and spaces to bind the current cursor position to a text offset.

The following built-ins cause this padding effect:
APPEND_LINE MOVE_HORIZONTAL
ATTACH MOVE_TEXT
COPY_TEXT MOVE_VERTICAL
CURRENT_CHARACTER READ_FILE
CURRENT_LINE SELECT
CURRENT_OFFSET SELECT_RANGE
ERASE_CHARACTER SPAWN
ERASE_LINE SPLIT_LINE
MARK  

The insertion of self-inserting characters also causes padding if the cursor is free.

To determine whether padding will occur if you use one of the built-ins previously listed, use the following call:


GET_INFO (window_variable, "bound"); 

If the cursor is to the left of the left margin, the margin is moved to the cursor position and spaces are inserted to fill the line from the cursor to where the text begins. If the cursor is to the left of the left margin on a blank line, the margin is moved to the cursor position and no spaces are inserted.

To find out if the cursor position is before the beginning of a line in a particular window, use the following call:


GET_INFO (window_variable,"before_bol"); 

If the cursor is to the right of the end of the line, spaces are inserted from the end of the line to the cursor position. To find out if the cursor is to the right of the end of a line in a particular window, use the following call:


GET_INFO (window_variable,"beyond_eol"); 

If the cursor is in the middle of a tab, spaces are inserted from the tab character to the current cursor position. The tab character is not deleted; it is simply moved to the left. To find out if the cursor is in the middle of a tab in a particular window, use the following call:


GET_INFO (window_variable, "middle_of_tab"); 

If the cursor is below the bottom of the buffer, blank lines are added from the end-of-buffer text to the line the cursor is on. To insert these blank lines, DECTPU uses the left margin set for the buffer. If necessary, the line the cursor is on is then padded, depending on whether the cursor is to the left or right of the left margin. To find out if the cursor is below the bottom of the buffer, use the following call:


GET_INFO (window_variable, "beyond_eol"); 


Index Contents

  [Go to the documentation home page] [How to order documentation] [Help on this site] [How to contact us]  
  privacy and legal statement  
6020PRO_041.HTML