allow selecting codemirror keymap in menu

This commit is contained in:
Min RK 2014-12-02 12:15:04 -08:00
parent 9a504dd7c3
commit 85b6b280b2
2 changed files with 33 additions and 0 deletions

View File

@ -54,6 +54,30 @@ define([
this.element.find('#menu-replace').click(function () {
editor.codemirror.execCommand("replace");
});
this.element.find('#menu-keymap-default').click(function () {
editor.update_codemirror_options({
vimMode: false,
keyMap: null
});
});
this.element.find('#menu-keymap-sublime').click(function () {
editor.update_codemirror_options({
vimMode: false,
keyMap: 'sublime'
});
});
this.element.find('#menu-keymap-emacs').click(function () {
editor.update_codemirror_options({
vimMode: false,
keyMap: 'emacs'
});
});
this.element.find('#menu-keymap-vim').click(function () {
editor.update_codemirror_options({
vimMode: true,
keyMap: 'vim'
});
});
// View
this.element.find('#menu-line-numbers').click(function () {
@ -67,6 +91,9 @@ define([
var text = lineNumbers ? "Hide" : "Show";
text = text + " Line Numbers";
that.element.find('#menu-line-numbers').find("a").text(text);
var keyMap = editor.codemirror.getOption('keyMap') || "default";
that.element.find(".selected-keymap").removeClass("selected-keymap");
that.element.find("#menu-keymap-" + keyMap).addClass("selected-keymap");
});
};

View File

@ -46,6 +46,12 @@ data-file-path="{{file_path}}"
<ul id="edit-menu" class="dropdown-menu">
<li id="menu-find"><a href="#">Find</a></li>
<li id="menu-replace"><a href="#">Find &amp; Replace</a></li>
<li class="divider"></li>
<li>Key Map</li>
<li id="menu-keymap-default"><a href="#">Default<i class="fa"></i></a></li>
<li id="menu-keymap-sublime"><a href="#">Sublime Text<i class="fa"></i></a></li>
<li id="menu-keymap-vim"><a href="#">Vim<i class="fa"></i></a></li>
<li id="menu-keymap-emacs"><a href="#">emacs<i class="fa"></i></a></li>
</ul>
</li>
<li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">View</a>