[GUI] Disable ANSI codes support for console logger in Wine

This commit is contained in:
VaDiM
2026-01-27 00:07:31 +03:00
parent bb10ea4ebe
commit ac7644621f
+14 -4
View File
@@ -1,5 +1,6 @@
// Based on code by tomzorz (https://gist.github.com/tomzorz/6142d69852f831fb5393654c90a1f22e) // Based on code by tomzorz (https://gist.github.com/tomzorz/6142d69852f831fb5393654c90a1f22e)
using System; using System;
using System.Diagnostics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace AssetStudio namespace AssetStudio
@@ -20,15 +21,19 @@ namespace AssetStudio
private static extern IntPtr GetStdHandle(int nStdHandle); private static extern IntPtr GetStdHandle(int nStdHandle);
static ColorConsoleHelper() static ColorConsoleHelper()
{ {
var isWin = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); var isWin = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
if (isWin) if (isWin)
{ {
isAnsiCodesSupported = TryEnableVTMode(); isAnsiCodesSupported = TryEnableVTMode();
if (!isAnsiCodesSupported)
if (!isAnsiCodesSupported && IsTerminal)
{ {
//Check for bash terminal emulator. E.g., Git Bash, Cmder isAnsiCodesSupported = true;
isAnsiCodesSupported = Environment.GetEnvironmentVariable("TERM") != null; }
else if (IsWine)
{
isAnsiCodesSupported = false;
} }
} }
else else
@@ -53,5 +58,10 @@ namespace AssetStudio
return SetConsoleMode(iStdOut, outConsoleMode); return SetConsoleMode(iStdOut, outConsoleMode);
} }
//Check for bash terminal emulator. E.g., Git Bash, Cmder
private static bool IsTerminal => Environment.GetEnvironmentVariable("TERM") != null;
private static bool IsWine => Process.GetProcessesByName("winlogon").Length == 0;
} }
} }