Because terminal-based operating systems communicate with video displays using relatively slow communications lines, optimizing screen output is much more important for such environments. You can increase the speed of output when a given location on the screen may have more than one change written, for example, when a window is set and text immediately written to it. Normally, each screen location which falls under the window is sent a character and painted to the appropriate attribute, and then the text is sent. Any position that contains text gets written to twice in this process. To optimize output under such circumstances, turn screen updating off before beginning your output calls, and turn it back on afterward and force a screen update. This ensures that each position will get written to only once.
Automatic screen updating of Vermont Views functions is controlled by a global variable, VID_ECHO. The Vermont Views output functions call the video update function only when VID_ECHO has a value of ON. Thus, automatic updating can be disabled simply by setting VID_ECHO to OFF.
To directly control screen updating in a part of your program, take the following steps:
Step 1: Save the value of VID_ECHO (so it can be restored at the end).
Step 2: Set VID_ECHO to OFF to disable automatic updating.
Step 3: Carry out the procedures for which screen updating is not desired.
Step 4: Restore the original value of VID_ECHO.
Step 5: Issue a screen update call, using vs_upd() or vs_updrgn(), if the restored value of VID_ECHO is ON.
vs_upd() updates the entire screen. vs_updrgn() updates the specified rectangular region on the screen. If you need to update the contents of a window, but not its border and margin area, you should specify the following:
|
The window structure members rb, cb, re, and ce give the beginning and ending row and column numbers for the interior of the window.
If you need to update the border and margin area of the window also, you should specify the following:
|
The window structure members rbf, cbf, ref, and cef give the beginning and ending row and column numbers for the entire window, including the border and margins.
If you are using windows with shadows, you may also need to update the part of the screen covered by the shadows. For example, if the shadows are one character wide and on the bottom and to the right of the window, the call to vs_updrgn() would be as follows:
|
Coding Example for Optimizing Screen Updating