mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-21 04:10:17 +08:00
canonicalize -> normalize in keyboard manager.
This commit is contained in:
parent
c888f9d3e4
commit
c54f48278d
@ -455,18 +455,18 @@ var IPython = (function (IPython) {
|
|||||||
return help;
|
return help;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShortcutManager.prototype.canonicalize_key = function (key) {
|
ShortcutManager.prototype.normalize_key = function (key) {
|
||||||
return inv_keycodes[keycodes[key]];
|
return inv_keycodes[keycodes[key]];
|
||||||
}
|
}
|
||||||
|
|
||||||
ShortcutManager.prototype.canonicalize_shortcut = function (shortcut) {
|
ShortcutManager.prototype.normalize_shortcut = function (shortcut) {
|
||||||
// Sort a sequence of + separated modifiers into the order alt+ctrl+meta+shift
|
// Sort a sequence of + separated modifiers into the order alt+ctrl+meta+shift
|
||||||
var values = shortcut.split("+");
|
var values = shortcut.split("+");
|
||||||
if (values.length === 1) {
|
if (values.length === 1) {
|
||||||
return this.canonicalize_key(values[0])
|
return this.normalize_key(values[0])
|
||||||
} else {
|
} else {
|
||||||
var modifiers = values.slice(0,-1);
|
var modifiers = values.slice(0,-1);
|
||||||
var key = this.canonicalize_key(values[values.length-1]);
|
var key = this.normalize_key(values[values.length-1]);
|
||||||
modifiers.sort();
|
modifiers.sort();
|
||||||
return modifiers.join('+') + '+' + key;
|
return modifiers.join('+') + '+' + key;
|
||||||
}
|
}
|
||||||
@ -489,7 +489,7 @@ var IPython = (function (IPython) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ShortcutManager.prototype.add_shortcut = function (shortcut, data) {
|
ShortcutManager.prototype.add_shortcut = function (shortcut, data) {
|
||||||
shortcut = this.canonicalize_shortcut(shortcut);
|
shortcut = this.normalize_shortcut(shortcut);
|
||||||
this._shortcuts[shortcut] = data;
|
this._shortcuts[shortcut] = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -500,7 +500,7 @@ var IPython = (function (IPython) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ShortcutManager.prototype.remove_shortcut = function (shortcut) {
|
ShortcutManager.prototype.remove_shortcut = function (shortcut) {
|
||||||
shortcut = this.canonicalize_shortcut(shortcut);
|
shortcut = this.normalize_shortcut(shortcut);
|
||||||
delete this._shortcuts[shortcut];
|
delete this._shortcuts[shortcut];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user