Skip to content
Snippets Groups Projects
Commit 3706559b authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

The beginnings of ANSI console support on Windows

It kinda sorta works, but needs more love.
parent 6e2726e9
Branches
Tags
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #520 passed
...@@ -44,6 +44,16 @@ ...@@ -44,6 +44,16 @@
struct termios tio_default; /* Initial term settings */ struct termios tio_default; /* Initial term settings */
#endif #endif
#ifdef _WIN32
#ifndef ENABLE_VIRTUAL_TERMINAL_INPUT
#define ENABLE_VIRTUAL_TERMINAL_INPUT 0x0200
#endif
#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
#endif
#endif
#include "ciolib.h" #include "ciolib.h"
#include "ansi_cio.h" #include "ansi_cio.h"
...@@ -931,10 +941,12 @@ int ansi_initio_cb(void) ...@@ -931,10 +941,12 @@ int ansi_initio_cb(void)
{ {
#ifdef _WIN32 #ifdef _WIN32
if(isatty(fileno(stdin))) { if(isatty(fileno(stdin))) {
if(!SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), 0)) if(!SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), ENABLE_VIRTUAL_TERMINAL_INPUT))
return(0); return(0);
if(!SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), 0)) DWORD conmode = 0;
GetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), &conmode);
if(!SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), conmode | ENABLE_VIRTUAL_TERMINAL_PROCESSING))
return(0); return(0);
} }
setmode(fileno(stdout),_O_BINARY); setmode(fileno(stdout),_O_BINARY);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment