muta...@gmail.com
2020-10-20 20:37:34 UTC
I (believe I) have figured out the behavior of GetConsoleScreenBufferInfo
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hConsoleOutput, &csbi);
printf("size char_info is %d\n", sizeof(CHAR_INFO));
printf("%d %d\n", (int)csbi.dwSize.X, (int)csbi.dwSize.Y);
printf("%d %d\n", (int)csbi.dwMaximumWindowSize.X, (int)csbi.dwMaximumWindowSize.Y);
printf("%d %d\n", (int)csbi.srWindow.Right, (int)csbi.srWindow.Bottom);
The window sizes (rows) include the size of the
scrollback buffer. Except for the "Maximum" -
that reflects the actual screen size.
Regardless, when I attempt to write to row 16
like this:
sz.X = 16;
sz.Y = 1;
coord.X = 0;
coord.Y = 0;
rect.Left = 1;
rect.Top = 10; /* was 10 */
rect.Right = 17; /* was 17 */
rect.Bottom = 10; /* was 10 */
ret = WriteConsoleOutput(hConsoleOutput,
mybuf,
sz,
coord,
&rect);
it does actually write to row 16, but it is row 16
of the scrollback buffer, so it's not actually
visible on my screen.
If I run "cls" first, then everything is reset and
everything works as I want.
My question is - is there a call to clear the
screen? Or some other approach?
Besides system("cls");
Thanks. Paul.
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hConsoleOutput, &csbi);
printf("size char_info is %d\n", sizeof(CHAR_INFO));
printf("%d %d\n", (int)csbi.dwSize.X, (int)csbi.dwSize.Y);
printf("%d %d\n", (int)csbi.dwMaximumWindowSize.X, (int)csbi.dwMaximumWindowSize.Y);
printf("%d %d\n", (int)csbi.srWindow.Right, (int)csbi.srWindow.Bottom);
The window sizes (rows) include the size of the
scrollback buffer. Except for the "Maximum" -
that reflects the actual screen size.
Regardless, when I attempt to write to row 16
like this:
sz.X = 16;
sz.Y = 1;
coord.X = 0;
coord.Y = 0;
rect.Left = 1;
rect.Top = 10; /* was 10 */
rect.Right = 17; /* was 17 */
rect.Bottom = 10; /* was 10 */
ret = WriteConsoleOutput(hConsoleOutput,
mybuf,
sz,
coord,
&rect);
it does actually write to row 16, but it is row 16
of the scrollback buffer, so it's not actually
visible on my screen.
If I run "cls" first, then everything is reset and
everything works as I want.
My question is - is there a call to clear the
screen? Or some other approach?
Besides system("cls");
Thanks. Paul.