Skip to content

Commit

Permalink
ENTER now moves to list if on filter (#98)
Browse files Browse the repository at this point in the history
* Fixed #58: Multi-line commands rendering wrong

* Fixed #58 - Newlines in commands render incorrectly

* Added debug instructions to readme

* Update src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs

Co-Authored-By: Tyler James Leonhardt <[email protected]>

* simplified stripping of newline/linefeed

* ENTER now moves to list if on filter

Co-authored-by: Tyler James Leonhardt <[email protected]>
  • Loading branch information
tig and TylerLeonhardt authored May 13, 2020
1 parent ad01f86 commit 6a06476
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ internal class ConsoleGui : IDisposable
private const string FILTER_LABEL = "Filter";
private bool _cancelled;
private GridViewDataSource _itemSource;
private TextField _filterField;
private ListView _listView;
private ApplicationData _applicationData;
private GridViewDetails _gridViewDetails;
Expand Down Expand Up @@ -100,7 +101,14 @@ private void AddStatusBar()
// Use Key.Unknown for SPACE with no delegate because ListView already
// handles SPACE
new StatusItem(Key.Unknown, "~SPACE~ Mark Item", null),
new StatusItem(Key.Enter, "~ENTER~ Accept", () => Accept()),
new StatusItem(Key.Enter, "~ENTER~ Accept", () => {
if (Application.Top.MostFocused == _listView){
Accept();
}
else if (Application.Top.MostFocused == _filterField){
Application.Top.SetFocus(_listView);
}
}),
new StatusItem(Key.Esc, "~ESC~ Close", () => Close())
}
: new StatusItem []
Expand Down Expand Up @@ -169,7 +177,7 @@ private void AddFilter(Window win)
X = 2
};

var filterField = new TextField(string.Empty)
_filterField = new TextField(string.Empty)
{
X = Pos.Right(filterLabel) + 1,
Y = Pos.Top(filterLabel),
Expand All @@ -185,7 +193,7 @@ private void AddFilter(Window win)
Width = Dim.Fill() - filterLabel.Text.Length
};

filterField.Changed += (object sender, ustring e) =>
_filterField.Changed += (object sender, ustring e) =>
{
// NOTE: `ustring e` seems to contain the text _before_ the added character...
// so we convert the `sender` into a TextField and grab the text from that.
Expand All @@ -208,7 +216,7 @@ private void AddFilter(Window win)
}
};

win.Add(filterLabel, filterField, filterErrorLabel);
win.Add(filterLabel, _filterField, filterErrorLabel);
}

private void AddHeaders(Window win, List<string> gridHeaders)
Expand Down

0 comments on commit 6a06476

Please sign in to comment.