From 6af1903d8c461a02cd94d461a756164d0a3bc888 Mon Sep 17 00:00:00 2001 From: Charlie Kindel Date: Wed, 11 Mar 2020 15:55:02 -0700 Subject: [PATCH 1/7] 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/7] 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/7] 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/7] 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/7] 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. From 25204bce067be424dc098550c5b4fa52b07ffa4b Mon Sep 17 00:00:00 2001 From: Tig Kindel Date: Wed, 3 Aug 2022 14:20:17 -0700 Subject: [PATCH 6/7] Upgrade to Terminal.Gui v1.7 --- .../Microsoft.PowerShell.ConsoleGuiTools.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.PowerShell.ConsoleGuiTools/Microsoft.PowerShell.ConsoleGuiTools.csproj b/src/Microsoft.PowerShell.ConsoleGuiTools/Microsoft.PowerShell.ConsoleGuiTools.csproj index 2bd6ac6..adeabd1 100644 --- a/src/Microsoft.PowerShell.ConsoleGuiTools/Microsoft.PowerShell.ConsoleGuiTools.csproj +++ b/src/Microsoft.PowerShell.ConsoleGuiTools/Microsoft.PowerShell.ConsoleGuiTools.csproj @@ -6,7 +6,7 @@ - + From c06641e18487d2a8c4514ac09f3c425103508391 Mon Sep 17 00:00:00 2001 From: Tig Kindel Date: Wed, 3 Aug 2022 16:54:38 -0700 Subject: [PATCH 7/7] improve VS code build and debug support --- .vscode/launch.json | 29 ++++++++++++----------------- .vscode/settings.json | 2 +- .vscode/tasks.json | 39 ++++++++++++++------------------------- README.md | 26 ++++++-------------------- 4 files changed, 33 insertions(+), 63 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 17f330a..fcc366c 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -6,25 +6,20 @@ "configurations": [ { "name": ".NET Core Launch (console)", + "preLaunchTask": "build ConsoleGuiTools", "type": "coreclr", "request": "launch", - "preLaunchTask": "build", - "program": "${workspaceFolder}/Cmdlet/bin/Debug/net6.0/win10-x64/OutGridViewCmdlet.dll", - "args": [], - "cwd": "${workspaceFolder}/Cmdlet", - "console": "internalConsole", - "stopAtEntry": false - }, - { - "name": ".NET Core Launch (application)", - "type": "coreclr", - "request": "launch", - "preLaunchTask": "build", - "program": "${workspaceFolder}/Application/bin/Debug/net6.0/win10-x64/OutGridViewApplication.dll", - "args": [], - "cwd": "${workspaceFolder}/Application", - "console": "internalConsole", - "stopAtEntry": false + "program": "pwsh", + "args": [ + "-NoExit", + "-NoProfile", + "-Command", + "Import-Module ${workspaceFolder}/module/Microsoft.PowerShell.ConsoleGuiTools" + ], + "cwd": "${workspaceFolder}", + "console": "integratedTerminal", + "stopAtEntry": false, + "justMyCode": false }, { "name": ".NET Core Attach", diff --git a/.vscode/settings.json b/.vscode/settings.json index 351aacc..d528a62 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,5 @@ { "files.associations": { - "**/.vsts-ci/**/*.yml":"azure-pipelines" + "**/.vsts-ci/**/*.yml":"azure-pipelines", } } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 0056896..e0a35c4 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,33 +1,22 @@ -{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + { "version": "2.0.0", "tasks": [ { - "label": "build", - "osx": { - "command": "/usr/local/bin/pwsh" - }, - "windows": { - "command": "pwsh.exe" - }, - "linux": { - "command": "/usr/local/bin/pwsh" - }, - "type": "process", + "label": "build ConsoleGuiTools", + "command": "Invoke-Build", + "type": "shell", "args": [ - "-c", - "Invoke-Build", - // Build both modules - //"Build -ModuleName Microsoft.PowerShell.GraphicalTools, Microsoft.PowerShell.ConsoleGuiTools", - // Build only Out-GridView - //"Build -ModuleName Microsoft.PowerShell.GraphicalTools", - // Build only Out-ConsoleGridView - "Build -ModuleName Microsoft.PowerShell.ConsoleGuiTools", + "Build", + "-Module", + "Microsoft.PowerShell.ConsoleGuiTools" ], - "problemMatcher": "$msCompile", - "group": { - "kind": "build", - "isDefault": true - } + "group": "build", + "presentation": { + "reveal": "silent" + }, + "problemMatcher": "$msCompile" } ] } \ No newline at end of file diff --git a/README.md b/README.md index d762d96..5a3fcd9 100644 --- a/README.md +++ b/README.md @@ -25,9 +25,9 @@ to view and filter objects graphically. ## Development -### 1. Install PowerShell 7.1+ +### 1. Install PowerShell 7.2+ -Install PowerShell 7.1+ with [these instructions](https://github.com/PowerShell/PowerShell#get-powershell). +Install PowerShell 7.2+ with [these instructions](https://github.com/PowerShell/PowerShell#get-powershell). ### 2. Clone the GitHub repository @@ -72,29 +72,15 @@ PS ./GraphicalTools> code . Build by hitting `Ctrl-Shift-B` in VS Code. -To debug: +Set a breakpoint and hit `F5` to start the debugger. -In a PowerShell session in the `./GraphicalTools` directory, run `pwsh` (thus -nesting PowerShell). - -Then do the folowing: +Click on the VS Code "TERMINAL" tab and type your command that starts `Out-ConsoleGridView`, e.g. ```powershell -Import-Module ./module/Microsoft.PowerShell.ConsoleGuiTools -$pid +ls | ocgv ``` -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. +Your breakpoint should be hit. ## Contributions Welcome