alloc big buffers on heap
This commit is contained in:
@@ -25,19 +25,19 @@ void tim_update_screen_size(void) {
|
||||
}
|
||||
i32 w = csbi.srWindow.Right - csbi.srWindow.Left + 1;
|
||||
i32 h = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
|
||||
tim.resized = (u32)(w * h) <= TIM_MAX_CELLS && (w != tim.w || h != tim.h);
|
||||
if (tim.resized) {
|
||||
tim.w = tim.scopes[0].w = w;
|
||||
tim.h = tim.scopes[0].h = h;
|
||||
tim.window = csbi.srWindow;
|
||||
tim->resized = (u32)(w * h) <= TIM_MAX_CELLS && (w != tim->w || h != tim->h);
|
||||
if (tim->resized) {
|
||||
tim->w = tim->scopes[0].w = w;
|
||||
tim->h = tim->scopes[0].h = h;
|
||||
tim->window = csbi.srWindow;
|
||||
}
|
||||
}
|
||||
|
||||
void tim_init_terminal(void) {
|
||||
DWORD mode = 0;
|
||||
HANDLE hin = GetStdHandle(STD_INPUT_HANDLE);
|
||||
GetConsoleMode(hin, &tim.mode_in); // get current input mode
|
||||
mode = tim.mode_in; //
|
||||
GetConsoleMode(hin, &tim->mode_in); // get current input mode
|
||||
mode = tim->mode_in; //
|
||||
mode &= ~ENABLE_ECHO_INPUT; // disable echo
|
||||
mode &= ~ENABLE_LINE_INPUT; // disable line buffer
|
||||
// TODO: enable ctrl-c again
|
||||
@@ -49,14 +49,14 @@ void tim_init_terminal(void) {
|
||||
SetConsoleMode(hin, mode); // set input mode
|
||||
//
|
||||
HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE); //
|
||||
GetConsoleMode(hout, &tim.mode_out); // get current output mode
|
||||
mode = tim.mode_out; //
|
||||
GetConsoleMode(hout, &tim->mode_out); // get current output mode
|
||||
mode = tim->mode_out; //
|
||||
mode |= ENABLE_PROCESSED_OUTPUT; // enable ascii sequences
|
||||
mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING; // enable vt sequences
|
||||
SetConsoleMode(hout, mode); // set output mode
|
||||
//
|
||||
tim.cp_in = GetConsoleCP(); // get current code page
|
||||
tim.cp_out = GetConsoleOutputCP(); //
|
||||
tim->cp_in = GetConsoleCP(); // get current code page
|
||||
tim->cp_out = GetConsoleOutputCP(); //
|
||||
SetConsoleCP(CP_UTF8); // set utf8 in/out code page
|
||||
SetConsoleOutputCP(CP_UTF8); //
|
||||
tim_write_str(S("\33[?1049h")); // use alternate buffer
|
||||
@@ -69,14 +69,14 @@ void tim_reset_terminal(void) {
|
||||
tim_write_str(S("\33[?1049l")); // exit alternate buffer
|
||||
HANDLE hin = GetStdHandle(STD_INPUT_HANDLE); //
|
||||
HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE); //
|
||||
SetConsoleMode(hin, tim.mode_in); // set original mode
|
||||
SetConsoleMode(hout, tim.mode_out); //
|
||||
SetConsoleCP(tim.cp_in); // set original code page
|
||||
SetConsoleOutputCP(tim.cp_out); //
|
||||
SetConsoleMode(hin, tim->mode_in); // set original mode
|
||||
SetConsoleMode(hout, tim->mode_out); //
|
||||
SetConsoleCP(tim->cp_in); // set original code page
|
||||
SetConsoleOutputCP(tim->cp_out); //
|
||||
}
|
||||
|
||||
void tim_read_event(i32 timeout_ms) {
|
||||
TimEvent* e = &tim.event;
|
||||
TimEvent* e = &tim->event;
|
||||
HANDLE h = GetStdHandle(STD_INPUT_HANDLE);
|
||||
|
||||
const i8 key_table[256] = {
|
||||
@@ -150,8 +150,8 @@ void tim_read_event(i32 timeout_ms) {
|
||||
tim_update_screen_size(); // workaround, see WINDOW_BUFFER_SIZE_EVENT
|
||||
e->type = TimEvent_Mouse;
|
||||
e->key = TimKey_MouseButtonLeft;
|
||||
e->x = rec.Event.MouseEvent.dwMousePosition.X - tim.window.Left;
|
||||
e->y = rec.Event.MouseEvent.dwMousePosition.Y - tim.window.Top;
|
||||
e->x = rec.Event.MouseEvent.dwMousePosition.X - tim->window.Left;
|
||||
e->y = rec.Event.MouseEvent.dwMousePosition.Y - tim->window.Top;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user