The virtual screen manager consists of a set of C library functions that lets you easily direct output in your C programs, to multiple virtual overlapping screens which are mapped to a physical screen.
Each virtual screen is completely scrollable within itself and is capable of displaying one or more combination of the following video attributes:
Reverse
Underline
Blink
Dim
Bold
The ability to display a combination of vide attributes depends on the physical terminal. The Wyse 60 terminal, which has one of the most flexible and powerful operating mode, is capable of displaying all the video attributes combination. While on lesser terminal emulation mode such as VT100, the combination video attribute is not available.
The Virtual Screen Manager was designed on a Wyse 60, so if your installation is using Wyse 60's you are in luck. A full wyse60 termcap definition is included with this release.
All of my Unix based programs are written to take full advantage of the Wyse 60.
The virtual screen manager features an optimized screen update alogrithm which tries its best to send the least number of escape sequences to position the cursor based on it's previous position.
A Virtual screen can overlap other virtual screens, your C program need not be concerned about this, the library takes care of the display automatically. All your program has to do is just direct the output data to the correct virtual screen.
Data manipulation functions for the virtual screens include:
Cursor positioning
Insert Character
Delete Character
Add Line
Delete Line
Clear till end of line
Clear till end of virtual screen
Virtual screens can be moved around and their order from rear to front changed by the user, all of which are completely transparent to the application program.
Each virtual screen can be set to automatically display any of the four different frame box types:
single box,
double box,
single horizontal double vertial box, or
double horizontal single vertical box.
Each virtual screen has a cursor position where the next print will be display and the cursor can be turned on or off and can have any one of four different types:
Blinking Line
Blinking Block
Steady Block
Steady Line
The redraw function is taken care of by the library. Any part of a virtual screen that was previously covered by another virtual screen and became visible will be redrawn by the library automatically without the program knowing. This is sort of like a "fire and forget" missile: your C program just display the output on the virtual screen, and can forget what was displayed. Refresh and Print-Screen functions are all handled by the library. This is different than programming in the MacOS environment. The MacOS has to tell the application that a region of it's window needs to be redrawn. Your Mac application has to draw the part of the window that just became visible.
Virtual screens can be bigger than the physical screen. The library takes care of the display automatically, anything to be printed off the screen will be truncated.
On the fly shifting from 80-column to 132-column screen.
The library also includes functions for reading terminal input in raw mode, a function to check if a key has been pressed, an extended getchar function which is able to recognize terminal function keys, signal management functions.
Using Virtual Screens
It's very easy to use virtual screens in your C programs. Just initialize the virtual screen library by calling
initvscr();
at the beginning of your C program. Then instead of printing to the screen using printf() and putchar(), you would use vsprint() and vsputc(). The library will direct all output to the default screen, which is a virtual screen the same size as the terminal screen.
To create a second virtual screen, just define a pointer to a virtual screen structure as in:
struct vscr_st *myvscr;
then call:
newvscr( "MY SCREEN",&myvscr,60,20,10,2,1);
This creates a virtual screen on top of the default screen, named 'MY SCREEN' with 60 columns and 20 lines at the 10th column and 2nd line of the screen, and having a single line box enclosing the virtual screen. The next output using vsprint() and vsputc() will go only into the second virtual screen. If the output goes past the last column and line of the virtual screen, it will automatically scroll. You don't have to worry about it scrolling it. It is that simple!
Implementation Note
The programming style is pre-ANSI because I started programming in C in 1983 and all the C programs I write up to this day use this style for consistency and hopefully downward compatibility with older, obsolete, slow systems. The best feature I found on ANSI C compilers is function prototyping. I find that this feature help me catch a lot of argument passing mistakes. So I've included in the header files the prototypes of all functions if the ANSI flag is set. If you are going to compile in a non-ANSI C compiler, just undefine this flag in the Makefile.
To access the terminal control sequences, I chose the obsolete Termcap database instead of terminfo because at the time I started programming in C, back in the dark ages of 16-Mhz 68000 processor powered Unix systems, termcap was the standard and terminfo was relatively new, bulky and slow. And all Unix systems at that time where shipped with the termcap library. When termcap became obsolete and the termcap library was no longer being distributed in new Unix systems, I was force to my own quick and dirty termcap functions so that my programs will run on these newer systems.