Skip to content

Commit

Permalink
update for wsl
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlm committed Jan 9, 2025
1 parent 2d23c1e commit 407dc9d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -767,3 +767,4 @@ fabric.properties
*.sln.iml

/src/Tools/Consolonia.PreviewHost/Properties/launchSettings.json
src/.vscode/launch.json
33 changes: 25 additions & 8 deletions src/Consolonia.PlatformSupport/PlatformSupportExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,28 @@ public static AppBuilder UseAutoDectectedClipboard(this AppBuilder builder)
}
else if (OperatingSystem.IsLinux())
{
return builder.With<IClipboard>(new X11Clipboard());
if (IsWSLPlatform())
return builder.With<IClipboard>(new WSLClipboard());
else
return builder.With<IClipboard>(new XClipClipboard());
}
else
return builder.With<IClipboard>(new NaiveClipboard());
}

Check warning on line 70 in src/Consolonia.PlatformSupport/PlatformSupportExtensions.cs

View workflow job for this annotation

GitHub Actions / build

"[InconsistentNaming] Name 'IsWSLPlatform' does not match rule 'Methods'. Suggested name is 'IsWslPlatform'." on /home/runner/work/Consolonia/Consolonia/src/Consolonia.PlatformSupport/PlatformSupportExtensions.cs(70,29)

private static bool IsWSLPlatform()
{
// xclip does not work on WSL, so we need to use the Windows clipboard vis Powershell
(int exitCode, string result) = ClipboardProcessRunner.Bash("uname -a", waitForOutput: true);

Check warning on line 75 in src/Consolonia.PlatformSupport/PlatformSupportExtensions.cs

View workflow job for this annotation

GitHub Actions / build

"[CA1307] 'string.Contains(string)' has a method overload that takes a 'StringComparison' parameter. Replace this call in 'Consolonia.PlatformSupportExtensions.IsWSLPlatform()' with a call to 'string.Contains(string, System.StringComparison)' for clarity of intent." on /home/runner/work/Consolonia/Consolonia/src/Consolonia.PlatformSupport/PlatformSupportExtensions.cs(75,34)

Check warning on line 75 in src/Consolonia.PlatformSupport/PlatformSupportExtensions.cs

View workflow job for this annotation

GitHub Actions / build

"[CA1307] 'string.Contains(string)' has a method overload that takes a 'StringComparison' parameter. Replace this call in 'Consolonia.PlatformSupportExtensions.IsWSLPlatform()' with a call to 'string.Contains(string, System.StringComparison)' for clarity of intent." on /home/runner/work/Consolonia/Consolonia/src/Consolonia.PlatformSupport/PlatformSupportExtensions.cs(75,66)

if (exitCode == 0 && result.Contains("microsoft") && result.Contains("WSL"))

Check failure on line 77 in src/Consolonia.PlatformSupport/PlatformSupportExtensions.cs

View workflow job for this annotation

GitHub Actions / build

'string.Contains(string)' has a method overload that takes a 'StringComparison' parameter. Replace this call in 'Consolonia.PlatformSupportExtensions.IsWSLPlatform()' with a call to 'string.Contains(string, System.StringComparison)' for clarity of intent. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1307)

Check failure on line 77 in src/Consolonia.PlatformSupport/PlatformSupportExtensions.cs

View workflow job for this annotation

GitHub Actions / build

'string.Contains(string)' has a method overload that takes a 'StringComparison' parameter. Replace this call in 'Consolonia.PlatformSupportExtensions.IsWSLPlatform()' with a call to 'string.Contains(string, System.StringComparison)' for clarity of intent. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1307)
{
return true;
}

return false;
}


public static AppBuilder UseAutoDetectConsoleColorMode(this AppBuilder builder)
{
Expand All @@ -75,13 +92,13 @@ public static AppBuilder UseAutoDetectConsoleColorMode(this AppBuilder builder)
switch (Environment.OSVersion.Platform)
{
case PlatformID.Win32S or PlatformID.Win32Windows or PlatformID.Win32NT:
{
// if output is redirected, or we are a windows terminal we use the win32 ANSI based console.
if (Console.IsOutputRedirected || IsWindowsTerminal())
result = new RgbConsoleColorMode();
else
result = new EgaConsoleColorMode();
}
{
// if output is redirected, or we are a windows terminal we use the win32 ANSI based console.
if (Console.IsOutputRedirected || IsWindowsTerminal())
result = new RgbConsoleColorMode();
else
result = new EgaConsoleColorMode();
}
break;
case PlatformID.MacOSX:
result = new RgbConsoleColorMode();
Expand Down

0 comments on commit 407dc9d

Please sign in to comment.