ConsoleGuiTools icon indicating copy to clipboard operation
ConsoleGuiTools copied to clipboard

OCGV: Feature-Request: Out-ConsoleGridView Skip to next element on select

Open MrFly72 opened this issue 3 years ago • 6 comments
trafficstars

It would be great if Out-ConsoleGridView could have a parameter somehow like -skiptonextelementonselect Or whatever makes sense as parameter name. Basically with this set after a selection of an element, the cursor will move to the next line instead of staying at the same.

MrFly72 avatar Apr 20 '22 20:04 MrFly72

@andschwa maybe this one is easy to implement? and it would be a huge comfort improvement, especially as Out-ConsoleGridView might be used a lot with keyboard.

MrFly72 avatar Apr 29 '22 19:04 MrFly72

Why not have what you suggest be the default behavior?

I'm not a fan of adding more and more options.

tig avatar Aug 03 '22 21:08 tig

In my eyes it can also be the default. I was just curious because changing a current because is also not nice sometimes as others might complain.

MrFly72 avatar Aug 04 '22 04:08 MrFly72

No idea if it's easy or not, try it!

andyleejordan avatar Aug 04 '22 20:08 andyleejordan

@andschwa please edit this title to prefix with "OCGV: ". Gracias.

tig avatar Aug 24 '22 12:08 tig

The reason I didn't push to get this in quickly is it's more complicated than I originally thought.

I now believe this functionality should be optional and propose -MoveToNextOnSelect:

    -MoveToNextOnSelect
        If specified, pressing SPACE to select an item (when '-OutputMode Multiple' is enabled) will toggle the state of the item and move the selection to the next item in the list.

        Required?                    false
        Position?                    Named
        Accept pipeline input?       false
        Parameter set name           (All)
        Aliases                      None
        Dynamic?                     false
        Accept wildcard characters?  false

Without resorting to some hackery, the right way to implement this is by implementing a new feature in Terminal.Gui's ListView that turns on off/this behavior.

The code in ocgv would thus, be


// in OutConsoleGridviewCmdletCommand.cs:

        /// <summary>
        /// If specified, pressing SPACE to select an item (when '-OutputMode Multiple' is enabled) will toggle the state of the item and move the selection to the next item in the list.
        /// </summary>
        [Parameter(HelpMessage = "If specified, pressing SPACE to select an item (when '-OutputMode Multiple' is enabled) will toggle the state of the item and move the selection to the next item in the list.")]
        public SwitchParameter MoveToNextOnSelect { set; get; }

// In ConsoleGui.cs @ line 387, before the call to win.Add(_listView):

      _listView.MoveToNextOnToggleKey

The reason this is tricky is ListView doesn't currently distinguish between a toggle happening via keypress (SPACE) or some other means.

I've created an issue in Terminal.Gui for this new feature: https://github.com/gui-cs/Terminal.Gui/issues/1962

tig avatar Aug 25 '22 00:08 tig