Must enable ANSI in Windows terminal
Brought to you by:
kerravon86,
tcamp
Windows 10 does not support ANSI escape sequences by default, so terminal commands like LOCATE and CLS don't work in BWBASIC.
Microsoft has info here on how to enable it:
https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences
The relevant code seems to be this:
// Set output mode to handle virtual terminal sequences HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); if (hOut == INVALID_HANDLE_VALUE) { return GetLastError(); } DWORD dwMode = 0; if (!GetConsoleMode(hOut, &dwMode)) { return GetLastError(); } dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING; if (!SetConsoleMode(hOut, dwMode)) { return GetLastError(); }
There is also a workaround, but this affects the behavior of all command line programs. I created a batch file that makes a registry change and launches the bwbasic environment:
REG ADD HKCU\CONSOLE /f /v VirtualTerminalLevel /t REG_DWORD /d 1 bwbasic
I would suggest advising users of the registry workaround and incorporating the SetConsoleMode command in a future release.