Skip to content

Commit 89191f0

Browse files
committed
refactor(panel): make shortcut labels optional in TaskBar and StartMenu
Add ShowShortcutLabels property to TaskBarElement and showShortcut parameter to StartMenuStyleHelper.FormatWindowItem, defaulting to hidden so shortcut labels are opt-in.
1 parent 1394415 commit 89191f0

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

SharpConsoleUI/Controls/StartMenu/StartMenuStyleHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ public static List<string> FormatInfoStripLines(string themeName, int windowCoun
4949
/// <summary>
5050
/// Formats a window list item with state indicator and optional keyboard shortcut.
5151
/// </summary>
52-
public static string FormatWindowItem(string title, int index, bool isMinimized, bool isActive)
52+
public static string FormatWindowItem(string title, int index, bool isMinimized, bool isActive, bool showShortcut = false)
5353
{
5454
var indicator = isMinimized
5555
? ControlDefaults.StartMenuMinimizedWindowIndicator
5656
: ControlDefaults.StartMenuActiveWindowIndicator;
57-
var shortcut = index < 9 ? $" Alt+{index + 1}" : "";
57+
var shortcut = showShortcut && index < 9 ? $" Alt+{index + 1}" : "";
5858
var dimStart = isMinimized ? "[dim]" : "";
5959
var dimEnd = isMinimized ? "[/]" : "";
6060
var activeStart = isActive ? "[bold]" : "";

SharpConsoleUI/Panel/Elements/TaskBarElement.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ public TaskBarElement(string? name = null)
4141
/// </summary>
4242
public bool MinimizedDim { get; set; } = true;
4343

44+
/// <summary>
45+
/// Gets or sets whether to show Alt-N keyboard shortcut labels next to window titles.
46+
/// </summary>
47+
public bool ShowShortcutLabels { get; set; } = false;
48+
4449
/// <inheritdoc/>
4550
public override int FlexGrow => 1;
4651

@@ -86,18 +91,19 @@ public override void Render(CharacterBuffer buffer, int x, int y, int width, Col
8691

8792
// Build entry markup
8893
string title = StringHelper.TrimWithEllipsis(w.Title, MaxTitleLength, TitleEllipsisLength);
94+
string shortcutPrefix = ShowShortcutLabels ? $"[bold]Alt-{i + 1}[/] " : "";
8995
string markup;
9096
if (isActive)
9197
{
92-
markup = $"[bold]Alt-{i + 1}[/] {title}";
98+
markup = $"{shortcutPrefix}{title}";
9399
}
94100
else if (isMinimized && MinimizedDim)
95101
{
96-
markup = $"[bold]Alt-{i + 1}[/] [dim]{title}[/]";
102+
markup = $"{shortcutPrefix}[dim]{title}[/]";
97103
}
98104
else
99105
{
100-
markup = $"[bold]Alt-{i + 1}[/] {title}";
106+
markup = $"{shortcutPrefix}{title}";
101107
}
102108

103109
// Add separator

0 commit comments

Comments
 (0)