update
This commit is contained in:
1 parent
9779c4d1ca
commit
1b578c111a
719 files changed
+191593
-98
No files matched your search
+24
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Utilities for formatting keybinding hints in the UI.
|
||||
*/
|
||||
|
||||
import { getKeybindings, type Keybinding, type KeyId } from "@mariozechner/pi-tui";
|
||||
import { theme } from "../theme/theme.js";
|
||||
|
||||
function formatKeys(keys: KeyId[]): string {
|
||||
if (keys.length === 0) return "";
|
||||
if (keys.length === 1) return keys[0]!;
|
||||
return keys.join("/");
|
||||
}
|
||||
|
||||
export function keyText(keybinding: Keybinding): string {
|
||||
return formatKeys(getKeybindings().getKeys(keybinding));
|
||||
}
|
||||
|
||||
export function keyHint(keybinding: Keybinding, description: string): string {
|
||||
return theme.fg("dim", keyText(keybinding)) + theme.fg("muted", ` ${description}`);
|
||||
}
|
||||
|
||||
export function rawKeyHint(key: string, description: string): string {
|
||||
return theme.fg("dim", key) + theme.fg("muted", ` ${description}`);
|
||||
}
|
||||
Reference in new issue
Block a user