Functions

SaveScreen

Save a screen region for later display

Syntax

Signature
char *SaveScreen( int top, int left, int bottom, int right );

Arguments

top, left, bottom, right Inclusive, zero-based bounds. Use NIL for any edge to select the corresponding screen boundary.

Return value

An allocated buffer containing the saved cells. Release it with free().

Description

Capture the characters and attributes of an inclusive rectangle before drawing a temporary control. An edge set to `NIL` uses the corresponding edge of the current text window. `RestScreen()` can later draw the saved cells at the original location or a different location with the same dimensions.

The returned buffer contains binary screen data. Keep it until the last restore and then release it with `free()`.

Example

savescreen.c
#include "xdev-wtui.h"
#include "xdev-wtui-box.h"

#include <stdlib.h>

int main( void )
{
   SetPos( 2, 2 );
   DispOut( "Original screen", NULL );
   char *screen = SaveScreen( 1, 1, 5, 30 );

   DispBox( 1, 1, 5, 30, B_DOUBLE, "BG+/B" );
   SetPos( 2, 2 );
   DispOut( "Press a key to restore", NULL );
   Inkey( 0, NIL );

   RestScreen( 1, 1, 5, 30, screen );
   free( screen );

   Inkey( 0, NIL );

   return 0;
}