bugfix...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-01-29 07:32:07 +03:00
parent 3e5c52b676
commit 3833545c55
2 changed files with 27 additions and 9 deletions

View File

@ -821,6 +821,7 @@ module.Keyboard = core.ImageGridFeatures.Feature({
//--------------------------------------------------------------------- //---------------------------------------------------------------------
// XXX make these usable for any keyboard handler, not just the builtin...
var KeyboardUIActions = actions.Actions({ var KeyboardUIActions = actions.Actions({
config: { config: {
// NOTE: this is defined in ui-dialogs feature... // NOTE: this is defined in ui-dialogs feature...
@ -828,6 +829,7 @@ var KeyboardUIActions = actions.Actions({
}, },
// XXX sub-group by path (???) // XXX sub-group by path (???)
// XXX make this usable for other other handlers...
browseKeyboardBindings: ['Help/Keyboard bindings...', browseKeyboardBindings: ['Help/Keyboard bindings...',
core.doc`Keyboard bindings viewer... core.doc`Keyboard bindings viewer...
@ -917,7 +919,7 @@ var KeyboardUIActions = actions.Actions({
var dialog = browse.makeLister(null, var dialog = browse.makeLister(null,
function(path, make){ function(path, make){
var keys = kb.keys('*') var keys = kb.keys('*')
var keybindings = that.keybindings var keybindings = kb.keyboard
Object.keys(keybindings) Object.keys(keybindings)
.forEach(function(mode){ .forEach(function(mode){
@ -1227,7 +1229,7 @@ var KeyboardUIActions = actions.Actions({
dialog.newKey = function(){ dialog.newKey = function(){
that.editKeyBinding(this.select('!').attr('mode') that.editKeyBinding(this.select('!').attr('mode')
|| Object.keys(that.keybindings)[0]) } || Object.keys(kb.keyboard)[0]) }
dialog.newMode = function(){ dialog.newMode = function(){
that.editKeyboardMode() } that.editKeyboardMode() }

View File

@ -1167,7 +1167,7 @@ var BrowserPrototype = {
holdSize: 20, holdSize: 20,
}, },
// XXX TEST: this should prevent event propagation... // XXX need a way to access buttons...
// XXX should we have things like ctrl-<number> for fast selection // XXX should we have things like ctrl-<number> for fast selection
// in filter mode??? // in filter mode???
keybindings: { keybindings: {
@ -1561,9 +1561,8 @@ var BrowserPrototype = {
// //
// item format: // item format:
// - str - item text // - str - item text
// NOTE: if text is '---' then a // NOTE: see: .options.elementShorthand
// separator item is created, it is // for shorthands for common elements
// not selectable (default: <hr>).
// //
// - [str/func, ... ] - item elements // - [str/func, ... ] - item elements
// Each of the elements is individually // Each of the elements is individually
@ -1582,6 +1581,16 @@ var BrowserPrototype = {
// Both traversable and disabled are optional and can take bool // Both traversable and disabled are optional and can take bool
// values. // values.
// //
// If item matches .options.itemShortcutMarker (default: /\$(\w)/)
// then the char after the '$' will be used as a keyboard shortcut
// for this item the char wrapped in a span (class: .keyboard-shortcut),
// and the marker (in this case '$') will be cleaned out.
// Also see: item.options.shortcut_key below.
//
// NOTE: only the first occurrence of key will get registered...
// NOTE: shortcuts can't override Browse shortcuts...
//
//
// options format: // options format:
// { // {
// // If true make the element traversable... // // If true make the element traversable...
@ -1942,10 +1951,13 @@ var BrowserPrototype = {
// text marker... // text marker...
if(item_shortcut_marker){ if(item_shortcut_marker){
var did_register = false
var _replace = function(){ var _replace = function(){
// get the last group... // get the last group...
var key = [].slice.call(arguments).slice(-3)[0] var key = [].slice.call(arguments).slice(-3)[0]
!item_shortcuts[key] !item_shortcuts[key]
// NOTE: this is a side-effect...
&& (did_register = true)
&& that.keyboard.handler( && that.keyboard.handler(
'ItemShortcuts', 'ItemShortcuts',
key, key,
@ -1960,9 +1972,13 @@ var BrowserPrototype = {
e = $(e) e = $(e)
e.html(e.html().replace(item_shortcut_marker, e.html(e.html().replace(item_shortcut_marker,
function(){ function(){
return '<span class="keyboard-shortcut">' did_register = false
+_replace.apply(this, arguments) var k = _replace.apply(this, arguments)
+'</span>' })) }) return !did_register ?
`<span class="keyboard-shortcut">${k}</span>`
: k
}))
})
} }
} }
//--------------------------------------------------------- //---------------------------------------------------------