Skip to content

Commit

Permalink
Trying getting decent menu input display
Browse files Browse the repository at this point in the history
  • Loading branch information
stax76 committed Dec 12, 2023
1 parent 0d63fee commit 7cd5686
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/MpvNet/InputHelp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ public static Dictionary<string, Binding> GetActiveBindings(List<Binding> bindin
public static string GetBindingsForCommand(Dictionary<string, Binding> activeBindings, string command)
{
List<string> keys = new();
bool hasLongKeys = false;
int charCount = 0;

foreach (var it in activeBindings)
{
Expand All @@ -482,18 +482,13 @@ public static string GetBindingsForCommand(Dictionary<string, Binding> activeBin

Binding binding = it.Value;

if (binding.Input.Length > 8)
hasLongKeys = true;
else
if (!keys.Contains(binding.Input))
keys.Add(binding.Input);
if (!keys.Contains(binding.Input) && (charCount + binding.Input.Length) < 20)
{
keys.Add(binding.Input);
charCount += binding.Input.Length;
}
}

string ret = string.Join(", ", keys);

if (hasLongKeys && keys.Count > 0)
ret += ", ...";

return ret;
return string.Join(", ", keys);
}
}

0 comments on commit 7cd5686

Please sign in to comment.