mirror of
https://github.com/aelurum/AssetStudio.git
synced 2026-11-15 19:28:48 -05:00
[GUI] Disable ANSI codes support for console logger in Wine
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user