UNPKG

2.32 kBtext/x-cView Raw
1#include <windows.h>
2#include <cassert>
3
4#include "TestUtil.cc"
5
6void dumpInfoToTrace() {
7 CONSOLE_SCREEN_BUFFER_INFO info;
8 assert(GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info));
9 trace("win=(%d,%d,%d,%d)",
10 (int)info.srWindow.Left,
11 (int)info.srWindow.Top,
12 (int)info.srWindow.Right,
13 (int)info.srWindow.Bottom);
14 trace("buf=(%d,%d)",
15 (int)info.dwSize.X,
16 (int)info.dwSize.Y);
17 trace("cur=(%d,%d)",
18 (int)info.dwCursorPosition.X,
19 (int)info.dwCursorPosition.Y);
20}
21
22int main(int argc, char *argv[]) {
23 if (argc == 1) {
24 startChildProcess(L"CHILD");
25 return 0;
26 }
27
28 setWindowPos(0, 0, 1, 1);
29
30 if (false) {
31 // Reducing the buffer height can move the window up.
32 setBufferSize(80, 25);
33 setWindowPos(0, 20, 80, 5);
34 Sleep(2000);
35 setBufferSize(80, 10);
36 }
37
38 if (false) {
39 // Reducing the buffer height moves the window up and the buffer
40 // contents up too.
41 setBufferSize(80, 25);
42 setWindowPos(0, 20, 80, 5);
43 setCursorPos(0, 20);
44 printf("TEST1\nTEST2\nTEST3\nTEST4\n");
45 fflush(stdout);
46 Sleep(2000);
47 setBufferSize(80, 10);
48 }
49
50 if (false) {
51 // Reducing the buffer width can move the window left.
52 setBufferSize(80, 25);
53 setWindowPos(40, 0, 40, 25);
54 Sleep(2000);
55 setBufferSize(60, 25);
56 }
57
58 if (false) {
59 // Sometimes the buffer contents are shifted up; sometimes they're
60 // shifted down. It seems to depend on the cursor position?
61
62 // setBufferSize(80, 25);
63 // setWindowPos(0, 20, 80, 5);
64 // setCursorPos(0, 20);
65 // printf("TESTa\nTESTb\nTESTc\nTESTd\nTESTe");
66 // fflush(stdout);
67 // setCursorPos(0, 0);
68 // printf("TEST1\nTEST2\nTEST3\nTEST4\nTEST5");
69 // fflush(stdout);
70 // setCursorPos(0, 24);
71 // Sleep(5000);
72 // setBufferSize(80, 24);
73
74 setBufferSize(80, 20);
75 setWindowPos(0, 10, 80, 10);
76 setCursorPos(0, 18);
77
78 printf("TEST1\nTEST2");
79 fflush(stdout);
80 setCursorPos(0, 18);
81
82 Sleep(2000);
83 setBufferSize(80, 18);
84 }
85
86 dumpInfoToTrace();
87 Sleep(30000);
88
89 return 0;
90}