FRACerqueira / PromptPlus

Interactive command-line toolkit for .Net core with powerful controls and commands to create professional console applications.
https://fracerqueira.github.io/PromptPlus/
MIT License
50 stars 5 forks source link

Separators in Select? #68

Closed ividyon closed 1 year ago

ividyon commented 1 year ago

Is it possible to have "separator" lines in Select elements?

2023-09-18_20-10-32__WindowsTerminal

In this example, I'd like to have, for example, a dash line between the "Toggle" options and the others, which cannot be selected (the select would just hop over it to the next one).

  Toggle option A
> Toggle option B
  Toggle option C
  ---------------
  Menu option A
  Menu option B
  Menu option C
FRACerqueira commented 1 year ago

@ividyon , here is this feature for multiselect. I'll mark it as an improvement and it will be very similar (same commands). An example of what it would look like:

selectnewfeature

FRACerqueira commented 1 year ago

@ividyon , Fixed scheduled for publication 4.0.6,

live Sample :


            PromptPlus.DoubleDash("Control:Select - basic usage with group and AppendGroupOnDescription");
            var selgrp = PromptPlus.Select<string>("Which cities would you like to visit?")
                 .AddItemsGrouped("North America", new[] { "Seattle", "Boston", "New York" })
                 .AddItemsGrouped("Asia", new[] { "Tokyo", "Singapore", "Shanghai" })
                 .AddItem("South America (Any)")
                 .AddItem("Europe (Any)")
                 .AppendGroupOnDescription()
                 .Run();

selectnewfeature

ividyon commented 1 year ago

Hm, this is useful, but isn't quite what I was looking for; is it possible to just have a simple separator line (dashes) and no nesting visuals in the list? Just like my example in my post.

The separator lines could be as long as the longest string in the select list, and the character the line is made of could be customizable.

ividyon commented 1 year ago
  Option 1
> Option 2
  Option 3
  ---------------
  Option 4
  Option 5
  Option 6

Just simple separating lines, no nesting

FRACerqueira commented 1 year ago

@ividyon done!, was maintaining a new item nesting option and adding the separation line option. Note: When using the sort option in conjunction with separation line, the separation lines will be deleted

live Sample :

           PromptPlus.Select<string>("Select")
                .AddItem("Seattle")
                .AddItem("New York")
                .AddSeparationline() //Default Separationline : SeparationLineType.SingleLine
                .AddItem("Tokyo")
                .AddItem("Singapore")
                .AddItem("Shanghai")
                .AddSeparationline(SeparationLineType.DoubleLine)
                .AddItem("London")
                .AddSeparationline(SeparationLineType.Char, '*')
                .AddItem("Other city")
                .Run();

selectnewfeature1

ividyon commented 1 year ago

Awesome, thank you!

FRACerqueira commented 1 year ago

@ividyon , No problem, change made to 'Separator' . I had already noticed that the item counter was taking into account separators and groupers, I just adjusted that too


            PromptPlus.DoubleDash("Control:Select - basic usage with Separationline");
            PromptPlus.Select<string>("Select")
                 .AddItem("Seattle")
                 .AddItem("New York")
                 .Separator() //Default SeparatorLine : SeparatorLine.SingleLine
                 .AddItem("Tokyo")
                 .AddItem("Singapore")
                 .AddItem("Shanghai")
                 .Separator(SeparatorLine.DoubleLine)
                 .AddItem("London")
                 .Separator(SeparatorLine.Char, '*')
                 .AddItem("Other city")
                 .Run();

output : Captura de tela 2023-09-19 172255

            PromptPlus.DoubleDash("Control:Select - basic usage with group and AppendGroupOnDescription");
            PromptPlus.Select<string>("Which cities would you like to visit?")
                 .AddItemsGrouped("North America", new[] { "Seattle", "Boston", "New York" })
                 .AddItemsGrouped("Asia", new[] { "Tokyo", "Singapore", "Shanghai" })
                 .AddItem("South America (Any)")
                 .AddItem("Europe (Any)")
                 .AppendGroupOnDescription()
                 .Run();

output : Captura de tela 2023-09-19 180022

Note: The 'Page Size' setting takes into account all items that are shown

ividyon commented 1 year ago

Perfect