Files
terminal_tetris/c-src/terminal_windows.c
2026-03-02 08:09:02 +13:00

52 lines
976 B
C

#include "../include/terminal.h"
#include <Windows.h>
#include <consoleapi.h>
#include <minwindef.h>
#include <processenv.h>
#include <winbase.h>
#define DEFAULT_CONSOLE_MODE (\
ENABLE_ECHO_INPUT |\
ENABLE_LINE_INPUT |\
ENABLE_MOUSE_INPUT |\
ENABLE_PROCESSED_INPUT |\
ENABLE_QUICK_EDIT_MODE |\
ENABLE_WINDOW_INPUT |\
ENABLE_PROCESSED_OUTPUT |\
ENABLE_WRAP_AT_EOL_OUTPUT |\
ENABLE_VIRTUAL_TERMINAL_PROCESSING |\
DISABLE_NEWLINE_AUTO_RETURN |\
ENABLE_LVB_GRID_WORLDWIDE)
#define RAW_CONSOLE_MODE \
ENABLE_WINDOW_INPUT |\
ENABLE_VIRTUAL_TERMINAL_INPUT
// ENABLE_PROCESSED_INPUT |\
static DWORD mode = 0;
void enter_raw_mode() {
GetConsoleMode(
GetStdHandle(STD_INPUT_HANDLE),
&mode
);
SetConsoleMode(
GetStdHandle(STD_INPUT_HANDLE),
RAW_CONSOLE_MODE
);
}
void exit_raw_mode() {
SetConsoleMode(
GetStdHandle(STD_INPUT_HANDLE),
mode
);
}