diff --git a/lib/ace/ext/keybinding_menu.js b/lib/ace/ext/keybinding_menu.js index 1fa267c6..bf8189a5 100644 --- a/lib/ace/ext/keybinding_menu.js +++ b/lib/ace/ext/keybinding_menu.js @@ -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 + '
' + current.command + ' : ' + - current.key + '
'; + return previous + '
' + + current.command + ' : ' + + '' + current.key + '
'; }, ''); el.id = 'kbshortcutmenu'; diff --git a/lib/ace/ext/menu_tools/get_editor_keyboard_shortcuts.js b/lib/ace/ext/menu_tools/get_editor_keyboard_shortcuts.js index 44a24cd7..e62d931a 100644 --- a/lib/ace/ext/menu_tools/get_editor_keyboard_shortcuts.js +++ b/lib/ace/ext/menu_tools/get_editor_keyboard_shortcuts.js @@ -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 @@ -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; }; }); \ No newline at end of file diff --git a/lib/ace/ext/menu_tools/settings_menu.css b/lib/ace/ext/menu_tools/settings_menu.css index 8e14a903..f8b761ce 100644 --- a/lib/ace/ext/menu_tools/settings_menu.css +++ b/lib/ace/ext/menu_tools/settings_menu.css @@ -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; } \ No newline at end of file