Skip to content

Commit 5bbb433

Browse files
committed
Fixes #250
Fixes #127 Add Focus and Search options to Out-ConsoleTableView Introduce Focus and Search parameters to control initial UI focus and cursor positioning. Update ApplicationData and OutTableViewWindow to support these features. Improve key bindings and add FocusTarget enum for focus selection.
1 parent 6cfc8ea commit 5bbb433

6 files changed

Lines changed: 403 additions & 5 deletions

File tree

README.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# ConsoleGuiTools - `Out-ConsoleGridView` and `Show-ObjectTree`
1+
# ConsoleGuiTools - `Out-ConsoleGridView`, `Out-ConsoleTableView`, and `Show-ObjectTree`
22

3-
This repo contains the `Out-ConsoleGridView`
4-
PowerShell Cmdlet providing console-based GUI experiences based on
3+
This repo contains the `Out-ConsoleGridView`, `Out-ConsoleTableView`, and `Show-ObjectTree`
4+
PowerShell Cmdlets providing console-based GUI experiences based on
55
[Terminal.Gui (gui.cs)](https://github.com/gui-cs/Terminal.Gui).
66

77
_Note:_ A module named `Microsoft.PowerShell.GraphicalTools` used to be built and published out of this repo, but per [#101](https://github.com/PowerShell/ConsoleGuiTools/issues/101) it is deprecated and unmaintained until such time that it can be rewritten on top of [.NET MAUI](https://devblogs.microsoft.com/dotnet/introducing-net-multi-platform-app-ui/).
@@ -15,6 +15,7 @@ Install-Module Microsoft.PowerShell.ConsoleGuiTools
1515
## Features
1616

1717
* [`Out-ConsoleGridview`](docs/Microsoft.PowerShell.ConsoleGuiTools/Out-ConsoleGridView.md) - Send objects to a grid view window for interactive filtering and sorting.
18+
* [`Out-ConsoleTableView`](docs/Microsoft.PowerShell.ConsoleGuiTools/Out-ConsoleTableView.md) - Send objects to a table view with column headers, horizontal scrolling, streaming, and native multi-selection.
1819
* [`Show-ObjectTree`](docs/Microsoft.PowerShell.ConsoleGuiTools/Show-ObjectTree.md) - Send objects to a tree view window for interactive filtering and sorting.
1920

2021
* Cross-platform - Works on any platform that supports PowerShell 7.2+.
@@ -129,6 +130,22 @@ This command gets the processes running on the local computer and sends them to
129130

130131
Use right arrow when a row has a `+` symbol to expand the tree. Left arrow will collapse the tree.
131132

133+
### Example 9: Output processes to a table view
134+
135+
```PowerShell
136+
Get-Process | Out-ConsoleTableView
137+
```
138+
139+
This command gets the processes running on the local computer and sends them to a table view with column headers. The table appears as soon as the first object arrives — rows stream in as the pipeline executes.
140+
141+
### Example 10: Search for a specific row in the table view
142+
143+
```PowerShell
144+
Get-Service | octv -Search "wuauserv" -Focus Filter
145+
```
146+
147+
This command displays all services in a table view, positions the cursor on the first row matching "wuauserv", and starts with focus in the filter field.
148+
132149
## Development
133150

134151
### 1. Install PowerShell 7.6+
@@ -203,7 +220,7 @@ to learn more.
203220

204221
`ConsoleGuiTools` consists of 2 .NET Projects:
205222

206-
* ConsoleGuiTools - Cmdlet implementation for Out-ConsoleGridView and Show-ObjectTree
223+
* ConsoleGuiTools - Cmdlet implementation for Out-ConsoleGridView, Out-ConsoleTableView, and Show-ObjectTree
207224
* OutGridView.Models - Contains data contracts between the GUI & Cmdlet
208225

209226
_Note:_ Previously, this repo included `Microsoft.PowerShell.GraphicalTools` which included the Avalonia-based `Out-GridView` (implemented in `.\Microsoft.PowerShell.GraphicalTools` and `.\OutGridView.Gui`). These components have been deprecated (see note above).
Lines changed: 293 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,293 @@
1+
---
2+
external help file: ConsoleGuiToolsModule.dll-Help.xml
3+
keywords: powershell,cmdlet
4+
locale: en-us
5+
Module Name: Microsoft.PowerShell.ConsoleGuiTools
6+
ms.date: 05/01/2026
7+
schema: 2.0.0
8+
title: Out-ConsoleTableView
9+
---
10+
11+
# Out-ConsoleTableView
12+
13+
## SYNOPSIS
14+
15+
Sends output to an interactive table view with column headers, horizontal scrolling, and native multi-selection.
16+
17+
## SYNTAX
18+
19+
```PowerShell
20+
Out-ConsoleTableView [-InputObject <psobject>] [-Title <string>] [-OutputMode {None | Single |
21+
Multiple}] [-Filter <string>] [-Search <string>] [-Focus {Table | Filter}] [-MinUI]
22+
[-FullScreen] [-ForceDriver <string>] [<CommonParameters>]
23+
```
24+
25+
## DESCRIPTION
26+
27+
The **Out-ConsoleTableView** cmdlet sends the output from a command to a table view window where the output is displayed in an interactive table with column headers, column sizing, and horizontal scrolling.
28+
29+
Use the Filter box at the top of the window to search the text in the table using regular expressions. Unlike the Filter, the `-Search` parameter positions the cursor on the first matching row without hiding non-matching rows.
30+
31+
Objects are streamed into the table as they arrive from the pipeline — the UI appears immediately and rows are added incrementally.
32+
33+
To send items from the interactive window down the pipeline, select rows (use arrow keys and `SPACE` or click with the mouse) and press `ENTER`. Press `ESC` to cancel without output. Use `Ctrl+A` to select all rows.
34+
35+
## EXAMPLES
36+
37+
### Example 1: Output processes to a table view
38+
39+
```PowerShell
40+
Get-Process | Out-ConsoleTableView
41+
```
42+
43+
This command gets the processes running on the local computer and sends them to a table view window with column headers for each property.
44+
45+
### Example 2: Select a single process using the table view
46+
47+
```PowerShell
48+
Get-Process | octv -OutputMode Single | Stop-Process
49+
```
50+
51+
This command displays processes in a table view restricted to single selection. The selected process is piped to `Stop-Process`.
52+
53+
### Example 3: Filter processes by name on the command line
54+
55+
```PowerShell
56+
Get-Process | octv -Filter "chrome"
57+
```
58+
59+
This command pre-populates the filter box with "chrome", showing only processes whose properties match that regex pattern.
60+
61+
### Example 4: Search for a row without filtering
62+
63+
```PowerShell
64+
Get-Service | octv -Search "wuauserv"
65+
```
66+
67+
This command displays all services but positions the cursor on the first row matching "wuauserv". Unlike `-Filter`, all rows remain visible.
68+
69+
### Example 5: Start with focus on the filter field
70+
71+
```PowerShell
72+
Get-ChildItem | octv -Focus Filter
73+
```
74+
75+
This command opens the table view with the cursor in the filter text field, ready to type a filter immediately. Pressing `ENTER` while in the filter field accepts the currently selected item(s).
76+
77+
### Example 6: Full screen mode with a custom title
78+
79+
```PowerShell
80+
Get-Process | octv -FullScreen -Title "Process Monitor"
81+
```
82+
83+
This command runs the table view in full-screen mode using the alternate screen buffer, with a custom window title.
84+
85+
### Example 7: Minimal UI for scripting
86+
87+
```PowerShell
88+
Get-Process | octv -MinUI -OutputMode Single
89+
```
90+
91+
This command shows the table view with no window frame, filter box, or status bar — just the table. Useful for quick selection in scripts.
92+
93+
### Example 8: Combine Filter and Search
94+
95+
```PowerShell
96+
Get-Process | octv -Filter "svc" -Search "host"
97+
```
98+
99+
This filters to rows matching "svc" and then positions the cursor on the first of those rows matching "host".
100+
101+
## PARAMETERS
102+
103+
### -Filter
104+
Pre-populates the Filter edit box, hiding rows that do not match the regular expression pattern.
105+
106+
```yaml
107+
Type: String
108+
Parameter Sets: (All)
109+
Aliases:
110+
111+
Required: False
112+
Position: Named
113+
Default value: None
114+
Accept pipeline input: False
115+
Accept wildcard characters: False
116+
```
117+
118+
### -Search
119+
Positions the cursor on the first row matching this regular expression pattern. Unlike `-Filter`, non-matching rows remain visible.
120+
121+
```yaml
122+
Type: String
123+
Parameter Sets: (All)
124+
Aliases:
125+
126+
Required: False
127+
Position: Named
128+
Default value: None
129+
Accept pipeline input: False
130+
Accept wildcard characters: False
131+
```
132+
133+
### -Focus
134+
Specifies which UI element receives initial focus.
135+
136+
- **Table** (default): The table view receives focus. Use arrow keys to navigate immediately.
137+
- **Filter**: The filter text field receives focus. Start typing to filter. Press `ENTER` to accept the selected item(s).
138+
139+
```yaml
140+
Type: FocusTarget
141+
Parameter Sets: (All)
142+
Aliases:
143+
Accepted values: Table, Filter
144+
145+
Required: False
146+
Position: Named
147+
Default value: Table
148+
Accept pipeline input: False
149+
Accept wildcard characters: False
150+
```
151+
152+
### -InputObject
153+
Specifies that the cmdlet accepts input for **Out-ConsoleTableView**.
154+
155+
When you use the **InputObject** parameter to send a collection of objects to **Out-ConsoleTableView**, **Out-ConsoleTableView** treats the collection as one collection object, and it displays one row that represents the collection.
156+
157+
To display each object in the collection, use a pipeline operator (|) to send objects to **Out-ConsoleTableView**.
158+
159+
```yaml
160+
Type: PSObject
161+
Parameter Sets: (All)
162+
Aliases:
163+
164+
Required: False
165+
Position: Named
166+
Default value: None
167+
Accept pipeline input: True (ByValue)
168+
Accept wildcard characters: False
169+
```
170+
171+
### -OutputMode
172+
Specifies the items that the interactive window sends down the pipeline as input to other commands.
173+
By default, this cmdlet generates zero, one, or many items.
174+
175+
To send items from the interactive window down the pipeline, select items and press `ENTER`. `ESC` cancels.
176+
177+
The values of this parameter determine how many items you can send down the pipeline.
178+
179+
- None. No items.
180+
- Single. Zero items or one item. Use this value when the next command can take only one input object.
181+
- Multiple. Zero, one, or many items. Use this value when the next command can take multiple input objects. This is the default value.
182+
183+
```yaml
184+
Type: OutputModeOption
185+
Parameter Sets: OutputMode
186+
Aliases:
187+
Accepted values: None, Single, Multiple
188+
189+
Required: False
190+
Position: Named
191+
Default value: Multiple
192+
Accept pipeline input: False
193+
Accept wildcard characters: False
194+
```
195+
196+
### -Title
197+
Specifies the text that appears in the title bar of the **Out-ConsoleTableView** window.
198+
199+
By default, the title bar displays "Out-ConsoleTableView".
200+
201+
```yaml
202+
Type: String
203+
Parameter Sets: (All)
204+
Aliases:
205+
206+
Required: False
207+
Position: Named
208+
Default value: Out-ConsoleTableView
209+
Accept pipeline input: False
210+
Accept wildcard characters: False
211+
```
212+
213+
### -MinUI
214+
If specified, no window frame, filter box, or status bar will be displayed. The table is shown without chrome.
215+
216+
```yaml
217+
Type: SwitchParameter
218+
Parameter Sets: (All)
219+
Aliases:
220+
221+
Required: False
222+
Position: Named
223+
Default value: None
224+
Accept pipeline input: False
225+
Accept wildcard characters: False
226+
```
227+
228+
### -FullScreen
229+
If specified, the application runs in full-screen mode using the alternate screen buffer. By default, the application renders inline in the current terminal.
230+
231+
```yaml
232+
Type: SwitchParameter
233+
Parameter Sets: (All)
234+
Aliases:
235+
236+
Required: False
237+
Position: Named
238+
Default value: None
239+
Accept pipeline input: False
240+
Accept wildcard characters: False
241+
```
242+
243+
### -ForceDriver
244+
Forces the Terminal.Gui driver to use. Valid values are `ansi`, `windows`, or `unix`.
245+
246+
```yaml
247+
Type: String
248+
Parameter Sets: (All)
249+
Aliases:
250+
251+
Required: False
252+
Position: Named
253+
Default value: None
254+
Accept pipeline input: False
255+
Accept wildcard characters: False
256+
```
257+
258+
### CommonParameters
259+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
260+
261+
## INPUTS
262+
263+
### System.Management.Automation.PSObject
264+
265+
You can send any object to this cmdlet. Objects are streamed — the UI appears as soon as the first object arrives.
266+
267+
## OUTPUTS
268+
269+
### System.Object
270+
271+
By default **Out-ConsoleTableView** returns objects representing the selected rows to the pipeline. Use `-OutputMode` to change this behavior.
272+
273+
## NOTES
274+
275+
* **Out-ConsoleTableView** uses Terminal.Gui's `TableView` control which provides column headers, column sizing, horizontal scrolling, and native multi-row selection.
276+
277+
* The alias for **Out-ConsoleTableView** is `octv`.
278+
279+
* Objects are streamed into the table as they arrive from the pipeline. The UI appears immediately on the first object and rows are added incrementally. A spinner in the status bar indicates loading is in progress.
280+
281+
* The command output that you send to **Out-ConsoleTableView** should not be formatted, such as by using the Format-Table or Format-Wide cmdlets. To select properties, use the Select-Object cmdlet.
282+
283+
* Keyboard shortcuts:
284+
- `ENTER` — Accept selection and close
285+
- `ESC` — Cancel and close
286+
- `Ctrl+A` — Select all rows (when OutputMode is Multiple)
287+
- `Home`/`End` — Jump to first/last row
288+
- Arrow keys — Navigate rows and columns
289+
- `Tab` — Move focus between filter and table
290+
291+
## RELATED LINKS
292+
293+
[Out-ConsoleGridView](Out-ConsoleGridView.md)

src/Microsoft.PowerShell.ConsoleGuiTools/OutConsoleTableViewCmdletCommand.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ public class OutConsoleTableViewCmdletCommand : PSCmdlet, IDisposable
7373
[Parameter(HelpMessage = "If specified the TUI will run in full screen mode instead of inline.")]
7474
public SwitchParameter FullScreen { set; get; }
7575

76+
/// <summary>
77+
/// Gets or sets which UI element should receive initial focus (Table or Filter).
78+
/// </summary>
79+
[Parameter(HelpMessage = "Specifies which UI element receives initial focus. Valid values are 'Table' (default) and 'Filter'.")]
80+
public FocusTarget Focus { set; get; } = FocusTarget.Table;
81+
82+
/// <summary>
83+
/// Gets or sets a search string that positions the cursor on the first matching row.
84+
/// </summary>
85+
[Parameter(HelpMessage = "Positions the cursor on the first row matching this regex pattern. Unlike -Filter, non-matching rows remain visible.")]
86+
public string? Search { set; get; }
87+
7688
/// <summary>
7789
/// Gets or sets the Terminal.Gui driver to use.
7890
/// </summary>
@@ -153,6 +165,8 @@ baseObject is PSReference ||
153165
Filter = Filter,
154166
MinUI = MinUI,
155167
FullScreen = FullScreen,
168+
Focus = Focus,
169+
Search = Search,
156170
Driver = ForceDriver,
157171
Verbose = Verbose,
158172
Debug = Debug,

0 commit comments

Comments
 (0)