display emmet shortcuts in keybindings menu
This commit is contained in:
parent
563a38700d
commit
db4bd7ffd1
3 changed files with 44 additions and 21 deletions
|
|
@ -60,8 +60,9 @@ define(function(require, exports, module) {
|
||||||
var kb = getEditorKeybordShortcuts(editor);
|
var kb = getEditorKeybordShortcuts(editor);
|
||||||
var el = document.createElement('div');
|
var el = document.createElement('div');
|
||||||
var commands = kb.reduce(function(previous, current) {
|
var commands = kb.reduce(function(previous, current) {
|
||||||
return previous + '<div class="ace_optionsMenuEntry"><b>' + current.command + '</b> : ' +
|
return previous + '<div class="ace_optionsMenuEntry"><span class="ace_optionsMenuCommand">'
|
||||||
current.key + '</div>';
|
+ current.command + '</span> : '
|
||||||
|
+ '<span class="ace_optionsMenuKey">' + current.key + '</span></div>';
|
||||||
}, '');
|
}, '');
|
||||||
|
|
||||||
el.id = 'kbshortcutmenu';
|
el.id = 'kbshortcutmenu';
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,8 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
var keys = require("../../lib/keys");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a map of keyboard shortcuts to command names for the current platform.
|
* Gets a map of keyboard shortcuts to command names for the current platform.
|
||||||
* @author <a href="mailto:matthewkastor@gmail.com">
|
* @author <a href="mailto:matthewkastor@gmail.com">
|
||||||
|
|
@ -60,27 +62,39 @@ define(function(require, exports, module) {
|
||||||
* // {'command' : aCommand, 'key' : 'Control-d'}
|
* // {'command' : aCommand, 'key' : 'Control-d'}
|
||||||
* // ]
|
* // ]
|
||||||
*/
|
*/
|
||||||
module.exports.getEditorKeybordShortcuts = function getEditorKeybordShortcuts (editor) {
|
module.exports.getEditorKeybordShortcuts = function(editor) {
|
||||||
var commands = editor.commands.byName;
|
var KEY_MODS = keys.KEY_MODS;
|
||||||
var commandName;
|
var keybindings = [];
|
||||||
var key;
|
var commandMap = {};
|
||||||
var platform = editor.commands.platform;
|
editor.keyBinding.$handlers.forEach(function(handler) {
|
||||||
var kb = [];
|
var ckb = handler.commmandKeyBinding;
|
||||||
for (commandName in commands) {
|
for (var i in ckb) {
|
||||||
try {
|
var modifier = parseInt(i);
|
||||||
key = commands[commandName].bindKey[platform];
|
if (modifier == -1) {
|
||||||
if (key) {
|
modifier = "";
|
||||||
kb.push({
|
} else if(isNaN(modifier)) {
|
||||||
'command' : commandName,
|
modifier = i;
|
||||||
'key' : key
|
} else {
|
||||||
});
|
modifier = "" +
|
||||||
|
(modifier & KEY_MODS.command ? "Cmd-" : "") +
|
||||||
|
(modifier & KEY_MODS.ctrl ? "Ctrl-" : "") +
|
||||||
|
(modifier & KEY_MODS.alt ? "Alt-" : "") +
|
||||||
|
(modifier & KEY_MODS.shift ? "Shift-" : "");
|
||||||
|
}
|
||||||
|
for (var key in ckb[i]) {
|
||||||
|
var command = ckb[i][key]
|
||||||
|
if (typeof command != "string")
|
||||||
|
command = command.name
|
||||||
|
if (commandMap[command]) {
|
||||||
|
commandMap[command].key += "|" + modifier + key;
|
||||||
|
} else {
|
||||||
|
commandMap[command] = {key: modifier+key, command: command};
|
||||||
|
keybindings.push(commandMap[command]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
|
||||||
// errors on properties without bindKey we don't want them
|
|
||||||
// so the errors don't need handling.
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
return kb;
|
return keybindings;
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -38,3 +38,11 @@
|
||||||
.ace_closeButton{
|
.ace_closeButton{
|
||||||
background: rgba(245, 146, 146, 0.9);
|
background: rgba(245, 146, 146, 0.9);
|
||||||
}
|
}
|
||||||
|
.ace_optionsMenuKey {
|
||||||
|
color: darkslateblue;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.ace_optionsMenuCommand {
|
||||||
|
color: darkcyan;
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue