winpty/misc/Win32Write1.cc

45 lines
1.3 KiB
C++
Raw Permalink Normal View History

/*
* A Win32 program that scrolls and writes to the console using the ioctl-like
* interface.
*/
#include <stdio.h>
#include <windows.h>
int main()
{
2012-04-01 08:40:30 +00:00
HANDLE conout = GetStdHandle(STD_OUTPUT_HANDLE);
2012-04-01 08:40:30 +00:00
for (int i = 0; i < 80; ++i) {
2012-04-01 08:40:30 +00:00
CONSOLE_SCREEN_BUFFER_INFO info;
GetConsoleScreenBufferInfo(conout, &info);
2012-04-01 08:40:30 +00:00
SMALL_RECT src = { 0, 1, info.dwSize.X - 1, info.dwSize.Y - 1 };
COORD destOrigin = { 0, 0 };
CHAR_INFO fillCharInfo = { 0 };
fillCharInfo.Char.AsciiChar = ' ';
fillCharInfo.Attributes = 7;
ScrollConsoleScreenBuffer(conout,
&src,
NULL,
destOrigin,
&fillCharInfo);
2012-04-01 08:40:30 +00:00
CHAR_INFO buffer = { 0 };
buffer.Char.AsciiChar = 'X';
buffer.Attributes = 7;
COORD bufferSize = { 1, 1 };
COORD bufferCoord = { 0, 0 };
SMALL_RECT writeRegion = { 0, 0, 0, 0 };
writeRegion.Left = writeRegion.Right = i;
writeRegion.Top = writeRegion.Bottom = 5;
WriteConsoleOutput(conout,
&buffer, bufferSize, bufferCoord,
&writeRegion);
2012-04-01 08:40:30 +00:00
Sleep(250);
}
return 0;
}