diff --git a/src/visualizers/widgets/TextEditor/TextEditorWidget.js b/src/visualizers/widgets/TextEditor/TextEditorWidget.js
index e60ad0df3..058bb7fdc 100644
--- a/src/visualizers/widgets/TextEditor/TextEditorWidget.js
+++ b/src/visualizers/widgets/TextEditor/TextEditorWidget.js
@@ -18,6 +18,7 @@ define([
var TextEditorWidget,
WIDGET_CLASS = 'text-editor',
DEFAULT_SETTINGS = {
+ keybindings: 'default',
theme: 'solarized_dark',
fontSize: 12
};
@@ -118,7 +119,6 @@ define([
//
// maybe some of these should be under a "Settings" option...
- // TODO: get the component settings
var fontSizes = [8, 10, 11, 12, 14],
themes = [
'Solarized Light',
@@ -127,24 +127,15 @@ define([
'Eclipse',
'Monokai'
],
+ keybindings = [
+ 'default',
+ 'vim',
+ 'emacs'
+ ],
menuItems = {
setKeybindings: {
name: 'Keybindings...',
- items: {
- ace: {
- name: 'default',
- isHtmlName: true,
- callback: () => console.log('setting keybindings to def')
- },
- vim: {
- name: 'vim',
- callback: () => console.log('setting keybindings to vim')
- },
- emacs: {
- name: 'emacs',
- callback: () => console.log('setting keybindings to emacs')
- }
- }
+ items: {}
},
setFontSize: {
name: 'Font...',
@@ -194,6 +185,26 @@ define([
};
});
+ keybindings.forEach(name => {
+ var handler = name.toLowerCase().replace(/ /g, '_'),
+ isSet = handler === this.editorSettings.keybindings;
+
+ if (isSet) {
+ name = '' + name + '';
+ }
+
+ menuItems.setKeybindings.items[handler] = {
+ name: name,
+ isHtmlName: isSet,
+ callback: () => {
+ this.editorSettings.keybindings = handler;
+ this.editor.setKeyboardHandler(handler === 'default' ?
+ null : 'ace/keyboard/' + handler);
+ // TODO
+ }
+ };
+ });
+
return menuItems;
};