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 el = document.createElement('div');
|
||||
var commands = kb.reduce(function(previous, current) {
|
||||
return previous + '<div class="ace_optionsMenuEntry"><b>' + current.command + '</b> : ' +
|
||||
current.key + '</div>';
|
||||
return previous + '<div class="ace_optionsMenuEntry"><span class="ace_optionsMenuCommand">'
|
||||
+ current.command + '</span> : '
|
||||
+ '<span class="ace_optionsMenuKey">' + current.key + '</span></div>';
|
||||
}, '');
|
||||
|
||||
el.id = 'kbshortcutmenu';
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
var keys = require("../../lib/keys");
|
||||
|
||||
/**
|
||||
* Gets a map of keyboard shortcuts to command names for the current platform.
|
||||
* @author <a href="mailto:matthewkastor@gmail.com">
|
||||
|
|
@ -60,27 +62,39 @@ define(function(require, exports, module) {
|
|||
* // {'command' : aCommand, 'key' : 'Control-d'}
|
||||
* // ]
|
||||
*/
|
||||
module.exports.getEditorKeybordShortcuts = function getEditorKeybordShortcuts (editor) {
|
||||
var commands = editor.commands.byName;
|
||||
var commandName;
|
||||
var key;
|
||||
var platform = editor.commands.platform;
|
||||
var kb = [];
|
||||
for (commandName in commands) {
|
||||
try {
|
||||
key = commands[commandName].bindKey[platform];
|
||||
if (key) {
|
||||
kb.push({
|
||||
'command' : commandName,
|
||||
'key' : key
|
||||
});
|
||||
module.exports.getEditorKeybordShortcuts = function(editor) {
|
||||
var KEY_MODS = keys.KEY_MODS;
|
||||
var keybindings = [];
|
||||
var commandMap = {};
|
||||
editor.keyBinding.$handlers.forEach(function(handler) {
|
||||
var ckb = handler.commmandKeyBinding;
|
||||
for (var i in ckb) {
|
||||
var modifier = parseInt(i);
|
||||
if (modifier == -1) {
|
||||
modifier = "";
|
||||
} else if(isNaN(modifier)) {
|
||||
modifier = i;
|
||||
} 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;
|
||||
};
|
||||
|
||||
});
|
||||
|
|
@ -37,4 +37,12 @@
|
|||
}
|
||||
.ace_closeButton{
|
||||
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