Setting the Amount of Scrollable Text

By default, the screen buffer associated with each QuickWin document window can store 2,048 characters. If this amount exceeds the display capacity of the window, QuickWin puts scroll bars on the window so the user can scroll through the window's contents.

The maximum buffer size for a new window can be set by specifying the size in the _wbufsize field of the _wopeninfo structure that you pass to the _fwopen function.

You can also limit the maximum buffer size at any other time with the _setscreenbuf function. This function takes two arguments: a file handle to the window and the desired upper limit on buffer size. The bufsiz argument can be a number or one of the following constants: _WINBUFDEF, which uses the default window screen buffer size, or _WINBUFINF, which places no limit on the buffer size. Unless you use _WINBUFINF, only the most recent characters, up to the buffer's capacity, are stored. In any case, the buffer is always allocated dynamically, so that it fits its contents.

To illustrate, the following code resizes a window's buffer to store 16,384 bytes:

#define BUFSIZE 16384

result = _wsetscreenbuf( fileno( fp ), BUFSIZE );

You can also use the _wgetscreenbuf function to examine the current size of a window's screen buffer.

The _wsetscreenbuf function returns 0 if successful or –1 if not. The _wgetscreenbuf function returns the current buffer size (in bytes) or _WINBUFINF if successful, or –1 if not.

See QWDEMO.C for further examples.