diff --git a/ui/lib/keyboard.js b/ui/lib/keyboard.js index 92a5bcc3..f675c52c 100755 --- a/ui/lib/keyboard.js +++ b/ui/lib/keyboard.js @@ -590,6 +590,31 @@ function buildKeybindingsHelp(keybindings, shifted_keys){ } +// Get a list of keys associated with a given doc... +// +// The second argument must be a structure formated as returned by +// buildKeybindingsHelp(...) +// +// Returned format: +// { +// : +// ... +// } +// +// NOTE: is the same as generated by buildKeybindingsHelp(..) +function getKeysByDoc(doc, help){ + var res = {} + for(var mode in help){ + var name = mode + var section = help[mode] + if(doc in section){ + res[mode] = section[doc] + } + } + return res +} + + // Build a basic HTML table with keyboard help... // // The table will look like this: @@ -646,6 +671,36 @@ function buildKeybindingsHelpHTML(keybindings){ } +// Build HTML for a single key definition... +// +// XXX not yet sure if we are handling the sections correctly... +function getKeysByDocHTML(doc, help, combine_sections){ + var spec = getKeysByDoc(doc, help) + var res = '' + + var keys = [] + + for(var section in spec){ + if(!combine_sections){ + keys = spec[section].join(', ') + res += '' + +''+ section +'' + +''+ keys +'' + +'' + } else { + keys = keys.concat(spec[section]) + } + } + + if(combine_sections){ + res += ''+ doc +'' + +''+ keys.join(', ') +'' + } + + return res + '' +} + + /********************************************************************** * Key binding editor...