Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exiting Output-ConsoleGridView GUI is too hard #61

Closed
tig opened this issue Mar 11, 2020 · 21 comments
Closed

Exiting Output-ConsoleGridView GUI is too hard #61

tig opened this issue Mar 11, 2020 · 21 comments
Labels
enhancement New feature or request Module-ConsoleGuiTools This issue is about Microsoft.PowerShell.ConsoleGuiTools

Comments

@tig
Copy link
Collaborator

tig commented Mar 11, 2020

To exit the user has to press F9 then accept the confirmation.

Is there a reason this was made so multi-step?

Why not just have a keyboard shortcut (like ESC)?

@TylerLeonhardt
Copy link
Member

It's because I copied from an example 😅I'm not apposed to a single click button or single keyboard shortcut at all.

@potatoqualitee
Copy link

Escape would be great to escape and then perhaps a double enter to make a selection? Or let's see how suse does it. Accept down at the lower right similar to GUI with no confirmation.

@gwojan
Copy link

gwojan commented Mar 12, 2020

I think the default should be just like how Out-GridView works...

@tig
Copy link
Collaborator Author

tig commented Mar 12, 2020

Yeah. Out-GridView uses ESC to exit and ENTER to send selected items out.

Imma gonna look into doing it... Hold my beer.

@corbob
Copy link
Contributor

corbob commented Mar 12, 2020

The way I would expect it to work would be: ESC returns nothing. If you're selecting multiple items, you select them with Space, and finally Enter would return whatever is selected (or under the cursor if nothing is selected).

@tig
Copy link
Collaborator Author

tig commented Mar 12, 2020

Here's what I have working. I like it; seems very natural:

// Regardless of whether the item was already marked, if the user presses
// ENTER, mark that item. This feels the most intuitive. The alternatives are:
// (a) Assume the user means to choose the item that's selected and mark it
// (b) Act like ESC except Pass Through an marked items.
// (c) Toggle the selected item
//
// Option (c) violates the principle of least astonishment: If the user has an item marked, and selected
// and hits ENTER s/he would be surprised to see it not returned. Esp in the single choice (most common) case.
// Option (b) means in the most common case (a single item is wanted) ENTER does nothing. Again surprising.
// It seems a) is the most intuitive so that's what's implemented.
```

@potatoqualitee
Copy link

Boooooom so fast! Rad

@TylerLeonhardt TylerLeonhardt added enhancement New feature or request Module-ConsoleGuiTools This issue is about Microsoft.PowerShell.ConsoleGuiTools labels Mar 13, 2020
@TylerLeonhardt
Copy link
Member

TylerLeonhardt commented Mar 20, 2020

ESC is tough because it's typically used to close out of menus and whatnot. My ideal option would be:

These would be buttons you could click or use a keybinding to trigger that way we have both mouse and keyboard scenarios handled.

I would prefer that keybindings be at least 2 keys or a function key that way you can be absolutely sure you mean what you type.

Keep in mind, I'm doing some refactor work in #74 so we should hold off on implementations until that's done.

@TylerLeonhardt
Copy link
Member

TylerLeonhardt commented Mar 20, 2020

A good first step to shave off some keyboard strokes is to keep the menu we already have and just delete the Quit method code:

https://github.com/PowerShell/GraphicalTools/blob/0406f50c1ca2bdff80917cbf979cbb4f1e7f56de/src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs#L61

This would mean it would be:

F9 -> Enter

@gwojan
Copy link

gwojan commented Mar 20, 2020

Honestly, @TylerLeonhardt what's your objection to using the same keybindings as Out-GridView? It just seems so natural to me -- especially in passthru mode.

@tig
Copy link
Collaborator Author

tig commented Mar 20, 2020

Honestly, @TylerLeonhardt what's your objection to using the same keybindings as Out-GridView? It just seems so natural to me -- especially in passthru mode.

On Windows the keybinding to exit out-gridview is alt-F4. Not sure what it is on mac.

alt-F4 in a Windows Terminal session will close it, not the contained out-consolegridview.

On Mac and Windows, enter is the standard keyboard idiom for exiting (accepting) a modal dialog. A console Cmdlet is a modal dialog.

On Mac and Windows, esc is the standard keyboard idiom for cancelling a modal dialog. A console Cmdlet is a modal dialog.

Are there very many other Powershell cmdlets that are doing gui.c stuff? What norms are they following?

I choose ESC/ENTER because it matches what happens with other modal dialogs and is simple for the thing that out-consolegridview does. If -passthru were default it'd be even more natural:

  • As a user I want to select one item from a list in a console grid view with as few keystrokes as possible (without using the mouse). --> ENTER
  • As a user I want to select multiple items from a list in a console grid view with as few keystrokes as possible (without using the mouse) --> SPACE SPACE ENTER
  • As a user I want to abort a selection using console grid view with as few keystrokes as possible --> ESC

The menu is required only for mouse usage. There it shouldn't be a menu, but just 'buttons' like a modal dialog as @TylerLeonhardt suggesed with:

With PassThru (which will probably be the default behavior soon #71), two buttons at the bottom:

Accept (ENTER) & Close (ESC).

@TylerLeonhardt
Copy link
Member

Yeah ok that sounds good. The refactor work is done for now so feel free to send a new PR!

I'd say the PR should either:

  • Just add the keybindings and leave the menu as it is
    or
  • Add the keybindings and replace the menu with buttons

@TylerLeonhardt
Copy link
Member

The only problem I have with that proposal is that the -OutputMode parameter is suppose to control that single ENTER behavior:

#79

@tig
Copy link
Collaborator Author

tig commented Apr 13, 2020

I don't think #79 will be a problem.

I now have things working with your new code, however it depends on the new StatusBar that is now in gui.cs as of version 0.80.0.

https://github.com/migueldeicaza/gui.cs/blob/49cd29853f5de55547c9011996ed982040607b5c/Terminal.Gui/Views/StatusBar.cs

But version 0.80 .0 has not dropped to nuget yet.

StatusBar makes this all so much better:

PS> gci | Out-ConsoleGridView -PassThru

image

gci | Out-ConsoleGridView

image

Implementing -OutputMode Single (#79) will simply require the item selection code to only allow one item to be connected, I think. -OutputMode Multiple is identical to -PassThru.

Side note: In the above, I've disabled your filter code because it's exposing a bug in gui.cs 0.80.0 (I think), where Pos.Right(...) calls are causing an invalid cast exception deep in gui.cs. You'll see this as soon as you try to use 0.80.0.

@tig
Copy link
Collaborator Author

tig commented Apr 13, 2020

FWIW, I found where the bug in gui.cs is that was causing the filter code to crash:

gui-cs/Terminal.Gui#356

Looks nice!

image

Workaround is this:

            // Workaround for https://github.com/migueldeicaza/gui.cs/issues/356
            filterFieldWidth += 2;
            var filterApplyButton = new Button(APPLY_LABEL)
            {
                // Pos.Right(filterField) returns 0
                X = Pos.Right(filterLabel) + filterFieldWidth,
                Y = Pos.Top(filterLabel),
                Clicked = () =>
                {
                    filterChanged.Invoke(null, filterField.Text);
                }
            };

@TylerLeonhardt
Copy link
Member

looks a lot nicer in Windows Terminal too!

@TylerLeonhardt
Copy link
Member

Are Accept and Close clickable?

@TylerLeonhardt
Copy link
Member

My only concern is that Space to select is not very discoverable.

@tig
Copy link
Collaborator Author

tig commented Apr 13, 2020

Are Accept and Close clickable?

Not yet as StatusBar doesn't support that. I've added it as an issue to gui.cs: gui-cs/Terminal.Gui#360

@TylerLeonhardt
Copy link
Member

Seems like we should wait until StatusBar is a bit more stable (and released 😅) before moving to that.

We can keep the top menu for now - but support the keybindings you've suggested.
Or
we can wait on gui.cs to get StatusBar out but from experience, the project does take time to do releases.

This is awesome work @tig. I'm a big fan!

@tig tig changed the title Exiting OutGridView Console GUI is too hard Exiting Output-ConsoleGridView GUI is too hard Apr 17, 2020
@TylerLeonhardt
Copy link
Member

This is fixed now pending a new release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Module-ConsoleGuiTools This issue is about Microsoft.PowerShell.ConsoleGuiTools
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants