diff --git a/Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs b/Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs
index b5db7847b..a0837bf35 100644
--- a/Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs
+++ b/Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs
@@ -1500,6 +1500,7 @@ namespace Terminal.Gui {
}
}) {
powershell.Start ();
+ powershell.WaitForExit ();
if (!powershell.DoubleWaitForExit ()) {
var timeoutError = $@"Process timed out. Command line: bash {powershell.StartInfo.Arguments}.
Output: {powershell.StandardOutput.ReadToEnd ()}
diff --git a/Terminal.Gui/Core/Clipboard/ClipboardBase.cs b/Terminal.Gui/Core/Clipboard/ClipboardBase.cs
index db61af80f..9eb17e174 100644
--- a/Terminal.Gui/Core/Clipboard/ClipboardBase.cs
+++ b/Terminal.Gui/Core/Clipboard/ClipboardBase.cs
@@ -92,7 +92,8 @@ namespace Terminal.Gui {
try {
SetClipboardDataImpl (text);
return true;
- } catch (Exception) {
+ } catch (Exception ex) {
+ System.Diagnostics.Debug.WriteLine ($"TrySetClipboardData: {ex.Message}");
return false;
}
}
diff --git a/Terminal.Gui/Core/ConsoleDriver.cs b/Terminal.Gui/Core/ConsoleDriver.cs
index 873d8398b..cd180af1c 100644
--- a/Terminal.Gui/Core/ConsoleDriver.cs
+++ b/Terminal.Gui/Core/ConsoleDriver.cs
@@ -681,11 +681,13 @@ namespace Terminal.Gui {
/// Column to move the cursor to.
/// Row to move the cursor to.
public abstract void Move (int col, int row);
+
///
/// Adds the specified rune to the display at the current cursor position
///
/// Rune to add.
public abstract void AddRune (Rune rune);
+
///
/// Ensures a Rune is not a control character and can be displayed by translating characters below 0x20
/// to equivalent, printable, Unicode chars.
@@ -694,21 +696,14 @@ namespace Terminal.Gui {
///
public static Rune MakePrintable (Rune c)
{
- var controlChars = gethexaformat (c, 4);
- if (controlChars <= 0x1F || (controlChars >= 0X7F && controlChars <= 0x9F)) {
+ var controlChars = c & 0xFFFF;
+ if (controlChars <= 0x1F || controlChars >= 0X7F && controlChars <= 0x9F) {
// ASCII (C0) control characters.
// C1 control characters (https://www.aivosto.com/articles/control-characters.html#c1)
return new Rune (controlChars + 0x2400);
- } else {
- return c;
}
- }
- static uint gethexaformat (uint rune, int length)
- {
- var hex = rune.ToString ($"x{length}");
- var hexstr = hex.Substring (hex.Length - length, length);
- return (uint)int.Parse (hexstr, System.Globalization.NumberStyles.HexNumber);
+ return c;
}
///
diff --git a/Terminal.sln b/Terminal.sln
index 03b0011e9..29fac1e30 100644
--- a/Terminal.sln
+++ b/Terminal.sln
@@ -20,6 +20,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.github\workflows\dotnet-core.yml = .github\workflows\dotnet-core.yml
.github\workflows\publish.yml = .github\workflows\publish.yml
README.md = README.md
+ testenvironments.json = testenvironments.json
EndProjectSection
EndProject
Global
diff --git a/UnitTests/ConsoleDriverTests.cs b/UnitTests/ConsoleDriverTests.cs
index cb4bc1dcf..e9688c638 100644
--- a/UnitTests/ConsoleDriverTests.cs
+++ b/UnitTests/ConsoleDriverTests.cs
@@ -608,5 +608,29 @@ namespace Terminal.Gui.ConsoleDrivers {
Application.Run (win);
Application.Shutdown ();
}
+
+ [Theory]
+ [InlineData(0x0000001F, 0x241F)]
+ [InlineData(0x0000007F, 0x247F)]
+ [InlineData(0x0000009F, 0x249F)]
+ [InlineData(0x0001001A, 0x241A)]
+ public void MakePrintable_Converts_Control_Chars_To_Proper_Unicode (uint code, uint expected)
+ {
+ var actual = ConsoleDriver.MakePrintable(code);
+
+ Assert.Equal (expected, actual.Value);
+ }
+
+ [Theory]
+ [InlineData(0x20)]
+ [InlineData(0x7E)]
+ [InlineData(0xA0)]
+ [InlineData(0x010020)]
+ public void MakePrintable_Does_Not_Convert_Ansi_Chars_To_Unicode (uint code)
+ {
+ var actual = ConsoleDriver.MakePrintable(code);
+
+ Assert.Equal (code, actual.Value);
+ }
}
}
diff --git a/testenvironments.json b/testenvironments.json
new file mode 100644
index 000000000..898ac827d
--- /dev/null
+++ b/testenvironments.json
@@ -0,0 +1,19 @@
+{
+ // Remote Testing (experimental preview).
+ // Here is some documentation https://learn.microsoft.com/en-us/visualstudio/test/remote-testing?view=vs-2022.
+ // Here a screen shot of the VS2022 where are the Test Explorer https://user-images.githubusercontent.com/13117724/196798350-5a6f94d3-b6cd-424e-b4e8-a9b507dc057a.png.
+ // Ignore "Could not find 'mono' host" error because unit tests don't use the .NET Framework.
+ "version": "1",
+ "environments": [
+ {
+ "name": "WSL-Ubuntu",
+ "type": "wsl",
+ "wslDistribution": "Ubuntu"
+ },
+ {
+ "name": "WSL-Debian",
+ "type": "wsl",
+ "wslDistribution": "Debian"
+ }
+ ]
+}
\ No newline at end of file