Terminal control/Preserve screen: Difference between revisions

Line 1:
{{task|Terminal control}}[[Terminal Control::task| ]]
The task is to clear the screen, output something on the display, and then restore the screen to the preserved state that it was in before the task was carried out. There is no requirement to change the font or kerning in this task, however character decorations and attributes are expected to be preserved. If the implementer decides to change the font or kerning during the display of the temporary screen, then these settings need to be restored prior to exit.
 
=={{header|C}}==
For Xterm. "Allow alternate screen buffer" must be enabled by the popup menu.<lang C>#include <stdio.h>
#include <unistd.h>
 
int main()
{
int i;
printf("\033[?1049h\033[H");
printf("Alternate screen buffer\n");
for (i = 5; i; i--) {
printf("\rgoing back in %d...", i);
fflush(stdout);
sleep(1);
}
printf("\033[?1049l");
 
return 0;
}</lang>
 
=={{header|JavaScript}}==
Anonymous user