[fpc-devel] Compiler message colour scheme
Tomas Hajny
XHajT03 at hajny.biz
Wed Nov 25 13:30:56 CET 2020
On 2020-11-25 10:31, Nikolai Zhubr via fpc-devel wrote:
> 25.11.2020 1:52, Tomas Hajny via fpc-devel:
Hi Nikolai,
>> No problem, thanks for testing. Unfortunately, it doesn't work for me
>> under Windows (Win 10 Pro 64-bit) either with the original version or
>
> Have you also checked with this registry trick for win10:
>
> [HKEY_CURRENT_USER\Console]
> "VirtualTerminalLevel"=dword:00000001
>
> (As per https://superuser.com/a/1300251/109090)
.
.
If I read the article correctly, it says that an application may enable
this processing explicitly using SetConsoleMode, or that it may be
enabled for all applications / consoles using the mentioned registry
key. The code added to the compiler contains the mentioned
SetConsoleMode setting, thus it should be sufficient according to the
article. However, the call fails (here) with error 87 (invalid
parameter). And btw, changing the registry key doesn't help (i.e. I
still get the same error). The same call (SetConsoleMode) performed
without setting the respective flag (ENABLE_VIRTUAL_TERMINAL_PROCESSING)
succeeds. I'm willing to have a look at additional hints, but I won't
perform additional research myself for this.
For anybody interested, the following test program reproduces the
functionality in the compiler (and provides debug information):
-----------------------------
{$MODE OBJFPC}
uses
Windows;
const
ENABLE_VIRTUAL_TERMINAL_PROCESSING = $0004;
CachedIsATTY : Boolean = false;
IsATTYValue : Boolean = false;
function IsATTY(var t : text) : Boolean;
const dwMode: dword = 0;
begin
if not(CachedIsATTY) then
begin
IsATTYValue := false;
if GetConsoleMode(TextRec(t).handle, dwMode) then
begin
WriteLn ('dwMode = ', dwMode);
if not (SetConsoleMode(TextRec(t).handle, dwMode)) then
WriteLn ('SCM0: ', GetLastError);
dwMode := dwMode or ENABLE_VIRTUAL_TERMINAL_PROCESSING;
if SetConsoleMode(TextRec(t).handle, dwMode) then
IsATTYValue := true
else
WriteLn ('SCM: ', GetLastError);
end
else
WriteLn ('GCM: ', GetLastError);
CachedIsATTY:=true;
end;
Result:=IsATTYValue;
end;
begin
WriteLn (IsATTY (Output));
end.
======================================
I get the following result (regardless from the registry setting):
dwMode = 3
SCM: 87
FALSE
Tomas
More information about the fpc-devel
mailing list