@@ -38,6 +38,7 @@ define(function (require, exports, module) {
3838 Dialogs = require ( "widgets/Dialogs" ) ,
3939 Metrics = require ( "utils/Metrics" ) ,
4040 WorkspaceManager = require ( "view/WorkspaceManager" ) ,
41+ StringUtils = require ( "utils/StringUtils" ) ,
4142 AppInit = require ( "utils/AppInit" ) ,
4243 DropdownButton = require ( "widgets/DropdownButton" ) . DropdownButton ,
4344 Strings = require ( "strings" ) ;
@@ -47,6 +48,7 @@ define(function (require, exports, module) {
4748 const panelHtml = require ( "text!./templates/bottom-panel.html" ) ,
4849 shortcutsHtml = require ( "text!./templates/shortcut-table.html" ) ,
4950 TOGGLE_SHORTCUTS_ID = Commands . HELP_TOGGLE_SHORTCUTS_PANEL ;
51+ const DEFAULT_PACK_PLACEHOLDER = "default" ;
5052 let keyList = [ ] ,
5153 panel ,
5254 $shortcutsPanel ,
@@ -111,7 +113,7 @@ define(function (require, exports, module) {
111113 // Core commands in Brackets use a simple command title as an id, for example "open.file".
112114 // Extensions should use the following format: "author.myextension.mycommandname".
113115 // For example, "lschmitt.csswizard.format.css".
114- const customOrigin = KeyBindingManager . getCustomShortcutOrigin ( keyBinding ) ;
116+ const customOrigin = KeyBindingManager . _getCustomShortcutOrigin ( keyBinding ) ;
115117 if ( customOrigin ) {
116118 return customOrigin ;
117119 }
@@ -337,6 +339,7 @@ define(function (require, exports, module) {
337339 }
338340
339341 function _showShortcuts ( ) {
342+ _updatePresets ( ) ;
340343 let $shortcuts = $ ( "#shortcuts-panel" ) ;
341344
342345 // Apply any active filter
@@ -391,6 +394,21 @@ define(function (require, exports, module) {
391394 keyList = [ ] ;
392395 }
393396
397+ function _updatePresets ( ) {
398+ if ( ! panel || ! panel . isVisible ( ) ) {
399+ return ;
400+ }
401+ const allPacks = KeyBindingManager . getAllCustomKeymapPacks ( ) ;
402+ const currentKeymapPack = KeyBindingManager . getCurrentCustomKeymapPack ( ) ;
403+ if ( currentKeymapPack ) {
404+ presetPicker . $button . text ( StringUtils . format (
405+ Strings . KEYBOARD_SHORTCUT_PRESET_USING , currentKeymapPack . packageName ) ) ;
406+ } else {
407+ presetPicker . $button . text ( Strings . KEYBOARD_SHORTCUT_PRESET_SELECT ) ;
408+ }
409+ presetPicker . items = [ DEFAULT_PACK_PLACEHOLDER , ...allPacks . map ( pack => pack . packID ) ] ;
410+ }
411+
394412 _updateKeyBindings = _ . debounce ( function ( ) {
395413 // Update keylist
396414 destroyKeyList ( ) ;
@@ -430,13 +448,17 @@ define(function (require, exports, module) {
430448 }
431449 }
432450
433- function _presetRenderer ( item ) {
434- var html = "<span class='stylesheet-name'>" + _ . escape ( item . name ) ;
435- if ( item . subDirStr ) {
436- html += "<span class='stylesheet-dir'> — " + _ . escape ( item . subDirStr ) + "</span>" ;
451+ function _presetRenderer ( packID ) {
452+ if ( packID === DEFAULT_PACK_PLACEHOLDER ) {
453+ return Strings . DEFAULT ;
437454 }
438- html += "</span>" ;
439- return html ;
455+ const allPacks = KeyBindingManager . getAllCustomKeymapPacks ( ) ;
456+ for ( let pack of allPacks ) {
457+ if ( pack . packID === packID ) {
458+ return pack . packageName ;
459+ }
460+ }
461+ return packID ;
440462 }
441463
442464 AppInit . appReady ( function ( ) {
@@ -461,10 +483,17 @@ define(function (require, exports, module) {
461483
462484 $shortcutsPanel = $ ( "#shortcuts-panel" ) ;
463485
464- presetPicker = new DropdownButton ( "Select Shortcut Presets" , [ ] , _presetRenderer , {
465- cssClasses : "presetPicker"
486+ presetPicker = new DropdownButton ( Strings . KEYBOARD_SHORTCUT_PRESET_SELECT , [ ] , _presetRenderer , {
487+ cssClasses : "presetPicker no-focus "
466488 } ) ;
467489 $shortcutsPanel . find ( ".presetPickerContainer" ) . append ( presetPicker . $button ) ;
490+ presetPicker . on ( "select" , function ( e , selectedPackID ) {
491+ if ( selectedPackID === DEFAULT_PACK_PLACEHOLDER ) {
492+ KeyBindingManager . _setCurrentCustomKeymapPack ( null ) ;
493+ }
494+ KeyBindingManager . _setCurrentCustomKeymapPack ( selectedPackID ) ;
495+ _updatePresets ( ) ;
496+ } ) ;
468497
469498 // Events
470499 $shortcutsPanel . on ( "dblclick" , function ( e ) {
@@ -510,5 +539,7 @@ define(function (require, exports, module) {
510539 } ) ;
511540 KeyBindingManager . on ( KeyBindingManager . EVENT_KEY_BINDING_ADDED , _updateKeyBindings ) ;
512541 KeyBindingManager . on ( KeyBindingManager . EVENT_KEY_BINDING_REMOVED , _updateKeyBindings ) ;
542+ KeyBindingManager . on ( KeyBindingManager . EVENT_NEW_PRESET , _updatePresets ) ;
543+ KeyBindingManager . on ( KeyBindingManager . EVENT_PRESET_CHANGED , _updatePresets ) ;
513544 } ) ;
514545} ) ;
0 commit comments