Compare commits

...

3 Commits

Author SHA1 Message Date
df7ebd6973 ReadConsoleInput -> ReadConsoleInputW 2026-01-09 06:50:40 +01:00
Chu'vok
11589d4623 reduce code size by 5 bytes 2024-09-20 00:05:48 +02:00
Chu'vok
d3161b22bf workaround for cursor reappearing in cmd 2024-09-20 00:03:07 +02:00

9
tim.h
View File

@@ -765,7 +765,6 @@ static void init_terminal(void) {
SetConsoleCP(CP_UTF8); // set utf8 in/out code page SetConsoleCP(CP_UTF8); // set utf8 in/out code page
SetConsoleOutputCP(CP_UTF8); // SetConsoleOutputCP(CP_UTF8); //
write_str(S("\33[?1049h")); // use alternate buffer write_str(S("\33[?1049h")); // use alternate buffer
write_str(S("\33[?25l")); // disable cursor
update_screen_size(); // update_screen_size(); //
} }
@@ -804,8 +803,10 @@ static void read_event(int timeout_ms) {
while (true) { while (true) {
memset(e, 0, sizeof(*e)); memset(e, 0, sizeof(*e));
DWORD r = WaitForSingleObject(h, timeout_ms); // In cmd.exe the cursor somtimes reappears. This reliably hides it.
write_str(S("\33[?25l"));
DWORD r = WaitForSingleObject(h, timeout_ms);
if (r == WAIT_TIMEOUT) { if (r == WAIT_TIMEOUT) {
e->type = DRAW_EVENT; e->type = DRAW_EVENT;
update_screen_size(); // workaround, see WINDOW_BUFFER_SIZE_EVENT update_screen_size(); // workaround, see WINDOW_BUFFER_SIZE_EVENT
@@ -817,7 +818,7 @@ static void read_event(int timeout_ms) {
// received input // received input
INPUT_RECORD rec = {0}; INPUT_RECORD rec = {0};
DWORD n = 0; DWORD n = 0;
ReadConsoleInput(h, &rec, 1, &n); ReadConsoleInputW(h, &rec, 1, &n);
switch (rec.EventType) { switch (rec.EventType) {
case KEY_EVENT: { case KEY_EVENT: {
@@ -866,8 +867,6 @@ static void read_event(int timeout_ms) {
// terminal width changes and not for the height. As a workaround // terminal width changes and not for the height. As a workaround
// the screen size is updated every time an event is emitted. // the screen size is updated every time an event is emitted.
update_screen_size(); update_screen_size();
// For cmd.exe the cursor has to be hidden after each resize event.
write_str(S("\33[?25l"));
return; return;
} }
} // while } // while