mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 00:42:51 +08:00
Enhance the style of the checkboxes for multi-selection (#1244)
* Enhance the checkboxes' style for multi-selection by applying the selected style, if available, to the checkboxes currently selected.
This commit is contained in:
parent
f8a4b2271d
commit
a55b80220d
@ -9,4 +9,15 @@ internal sealed class ListPromptConstants
|
|||||||
public const string InstructionsMarkup = "[grey](Press <space> to select, <enter> to accept)[/]";
|
public const string InstructionsMarkup = "[grey](Press <space> to select, <enter> to accept)[/]";
|
||||||
public const string MoreChoicesMarkup = "[grey](Move up and down to reveal more choices)[/]";
|
public const string MoreChoicesMarkup = "[grey](Move up and down to reveal more choices)[/]";
|
||||||
public const string SearchPlaceholderMarkup = "[grey](Type to search)[/]";
|
public const string SearchPlaceholderMarkup = "[grey](Type to search)[/]";
|
||||||
|
|
||||||
|
public static string GetSelectedCheckbox(bool isGroup, SelectionMode mode, Style? style = null)
|
||||||
|
{
|
||||||
|
if (style != null)
|
||||||
|
{
|
||||||
|
return "[[" + $"[{style.ToMarkup()}]X[/]" + "]]";
|
||||||
|
}
|
||||||
|
|
||||||
|
return isGroup && mode == SelectionMode.Leaf
|
||||||
|
? GroupSelectedCheckbox : SelectedCheckbox;
|
||||||
|
}
|
||||||
}
|
}
|
@ -257,8 +257,7 @@ public sealed class MultiSelectionPrompt<T> : IPrompt<List<T>>, IListPromptStrat
|
|||||||
}
|
}
|
||||||
|
|
||||||
var checkbox = item.Node.IsSelected
|
var checkbox = item.Node.IsSelected
|
||||||
? (item.Node.IsGroup && Mode == SelectionMode.Leaf
|
? ListPromptConstants.GetSelectedCheckbox(item.Node.IsGroup, Mode, HighlightStyle)
|
||||||
? ListPromptConstants.GroupSelectedCheckbox : ListPromptConstants.SelectedCheckbox)
|
|
||||||
: ListPromptConstants.Checkbox;
|
: ListPromptConstants.Checkbox;
|
||||||
|
|
||||||
grid.AddRow(new Markup(indent + prompt + " " + checkbox + " " + text, style));
|
grid.AddRow(new Markup(indent + prompt + " " + checkbox + " " + text, style));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user