Pass KeyShortcutHandler consumers a printable prefixmap represention. Close #154.
This commit is contained in:
@@ -5,7 +5,7 @@ import kiss.Stream;
|
||||
import kiss.List;
|
||||
|
||||
typedef PrefixMap<T> = Map<String, ShortcutKey<T>>;
|
||||
typedef PrefixMapHandler<T> = (Map<String, ShortcutKey<T>>) -> Void;
|
||||
typedef PrefixMapHandler<T> = (Map<String, ShortcutKey<T>>, Map<String,String>) -> Void;
|
||||
typedef ItemHandler<T> = (T) -> Void;
|
||||
typedef FinishHandler = () -> Void;
|
||||
typedef BadKeyHandler<T> = (String, PrefixMap<T>) -> Void;
|
||||
|
@@ -21,7 +21,7 @@
|
||||
|
||||
(method _selectMap [m]
|
||||
(set currentMap m)
|
||||
(tryCall onSelectPrefixMap m))
|
||||
(tryCall onSelectPrefixMap m (prefixMapToStrings m)))
|
||||
|
||||
(method start []
|
||||
(_selectMap rootMap))
|
||||
@@ -100,3 +100,11 @@
|
||||
(method :Void registerItem [description :T item]
|
||||
(whenLet [keyboardShortcut (extractKeyboardShortcuts description)]
|
||||
(registerShortcut keyboardShortcut description item)))
|
||||
|
||||
(method :Map<String,String> prefixMapToStrings [:PrefixMap<T> map]
|
||||
(for =>key mapping map
|
||||
=>key (case mapping
|
||||
((Cancel _) "cancel")
|
||||
((Final thing) (Std.string thing))
|
||||
((Prefix map) (.join (collect (map.keys)) ", "))
|
||||
(never null))))
|
Reference in New Issue
Block a user