From 6af1903d8c461a02cd94d461a756164d0a3bc888 Mon Sep 17 00:00:00 2001 From: Charlie Kindel Date: Wed, 11 Mar 2020 15:55:02 -0700 Subject: [PATCH 1/5] Fixed #58: Multi-line commands rendering wrong --- src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs b/src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs index e0e27cd..07eb4bd 100644 --- a/src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs +++ b/src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Text.RegularExpressions; using OutGridView.Models; using Terminal.Gui; @@ -164,6 +165,11 @@ private static string GetPaddedString(List strings, int[] colWidths, int builder.Append(' '); } + // Replace any newlines with encoded newline (`n) + // Note we can't use Environment.Newline because we don't know that the + // Command honors that. + strings[i] = strings[i].Replace("\n", "`n"); + // If the string won't fit in the column, append an ellipsis. if (strings[i].Length > colWidths[i]) { From a69373eae9534aaf1a771f372982b5ea03ecc6de Mon Sep 17 00:00:00 2001 From: Charlie Kindel Date: Wed, 11 Mar 2020 16:00:25 -0700 Subject: [PATCH 2/5] Fixed #58 - Newlines in commands render incorrectly --- src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs b/src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs index 07eb4bd..19deced 100644 --- a/src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs +++ b/src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using System.Text.RegularExpressions; using OutGridView.Models; using Terminal.Gui; From f155262ca88adaab5c49c16fd232b789d6c32abe Mon Sep 17 00:00:00 2001 From: Charlie Kindel Date: Wed, 11 Mar 2020 16:30:01 -0700 Subject: [PATCH 3/5] Added debug instructions to readme --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/README.md b/README.md index 073a375..5672e70 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,35 @@ Get-Process | Out-ConsoleGridView > NOTE: If you change the code and rebuild the project, you'll need to launch a > _new_ PowerShell process since the dll is already loaded and can't be unloaded. +### Debugging in Visual Studio Code + + +```powershell +PS C:\path\to\GraphicalTools> code . +``` + +Build by hitting `Ctrl-Shift-b` in VS Code. + +To debug: + +In a Powershell session in the `c:\path\to\GraphicalTools` directory, run `pwsh` (thus nesting powershell). + +Then do the folowing: + +```powershell +Import-Module .\module\Microsoft.PowerShell.ConsoleGuiTools +$pid +``` + +This will import the latest built DLL and output the process ID you'll need for debugging. Copy this ID to the clipboard. + +In VScode, set your breakpoints, etc... Then hit `F5`. In the VScode search box, paste the value printed by `$pid`. You'll see something like `pwsh.exe 18328`. Click that and the debug session will start. + +In the Powershell session run your commands; breakpoints will be hit, etc... + +When done, run `exit` to exit the nested PowerShell and run `pwsh` again. This unloads the DLL. Repeat. + + ## Contributions Welcome! We would love to incorporate community contributions into this project. If you would like to From 440833ea33563e47efbb1c2558be67fd125291ef Mon Sep 17 00:00:00 2001 From: Charlie Kindel Date: Wed, 11 Mar 2020 16:31:28 -0700 Subject: [PATCH 4/5] Update src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs Co-Authored-By: Tyler James Leonhardt --- src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs b/src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs index 19deced..e784836 100644 --- a/src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs +++ b/src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs @@ -167,6 +167,7 @@ private static string GetPaddedString(List strings, int[] colWidths, int // Replace any newlines with encoded newline (`n) // Note we can't use Environment.Newline because we don't know that the // Command honors that. + strings[i] = strings[i].Replace("\r\n", "`r`n"); strings[i] = strings[i].Replace("\n", "`n"); // If the string won't fit in the column, append an ellipsis. From dd2e765f705d9914aee7ad1b4e6cde2eeafcc432 Mon Sep 17 00:00:00 2001 From: Charlie Kindel Date: Wed, 11 Mar 2020 19:45:23 -0700 Subject: [PATCH 5/5] simplified stripping of newline/linefeed --- src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs b/src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs index e784836..2692d5b 100644 --- a/src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs +++ b/src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs @@ -164,10 +164,10 @@ private static string GetPaddedString(List strings, int[] colWidths, int builder.Append(' '); } - // Replace any newlines with encoded newline (`n) + // Replace any newlines with encoded newline/linefeed (`n or `r) // Note we can't use Environment.Newline because we don't know that the // Command honors that. - strings[i] = strings[i].Replace("\r\n", "`r`n"); + strings[i] = strings[i].Replace("\r", "`r"); strings[i] = strings[i].Replace("\n", "`n"); // If the string won't fit in the column, append an ellipsis.