[incremental search] moving emacs specific code to emacs.js
This commit is contained in:
parent
e5fc2ea853
commit
9f7cfde308
2 changed files with 22 additions and 28 deletions
|
|
@ -208,34 +208,17 @@ function patchHighlightMarkerStyling(options) {
|
|||
dom.importCssString(css, id);
|
||||
}
|
||||
|
||||
|
||||
// support for default keyboard handler
|
||||
require(["./commands/command_manager"], function(cmdMgr) {
|
||||
(function() {
|
||||
this.setupIncrementalSearch = function(editor, val) {
|
||||
if (this.usesIncrementalSearch == val) return;
|
||||
this.usesIncrementalSearch = val;
|
||||
var iSearchCommands = iSearchCommandModule.iSearchStartCommands,
|
||||
method = val ? 'addCommands' : 'removeCommands';
|
||||
this[method](iSearchCommands);
|
||||
};
|
||||
}).call(cmdMgr.CommandManager.prototype);
|
||||
});
|
||||
|
||||
// support for emacskeyboard handler
|
||||
require(["./keyboard/emacs"], function(emacs) {
|
||||
emacs.handler.setupIncrementalSearch = function(editor, val) {
|
||||
var commands = require("./commands/command_manager");
|
||||
(function() {
|
||||
this.setupIncrementalSearch = function(editor, val) {
|
||||
if (this.usesIncrementalSearch == val) return;
|
||||
this.usesIncrementalSearch = val;
|
||||
if (val) {
|
||||
this.bindKey('C-s', 'iSearch');
|
||||
this.bindKey('C-r', 'iSearchBackwards');
|
||||
} else {
|
||||
this.bindKey('C-s', "findnext");
|
||||
this.bindKey('C-r', "findprevious");
|
||||
}
|
||||
}
|
||||
});
|
||||
var iSearchCommands = iSearchCommandModule.iSearchStartCommands,
|
||||
method = val ? 'addCommands' : 'removeCommands';
|
||||
this[method](iSearchCommands);
|
||||
};
|
||||
}).call(commands.CommandManager.prototype);
|
||||
|
||||
// incremental search config option
|
||||
var Editor = require("./editor").Editor;
|
||||
|
|
|
|||
|
|
@ -108,9 +108,8 @@ exports.handler.attach = function(editor) {
|
|||
editor.commands.addCommands(commands);
|
||||
exports.handler.platform = editor.commands.platform;
|
||||
editor.$emacsModeHandler = this;
|
||||
require('../incremental_search');
|
||||
editor.setOption('useIncrementalSearch', true);
|
||||
this.setupIncrementalSearch(editor, true);
|
||||
if (!editor.getOption('useIncrementalSearch')) editor.setOption('useIncrementalSearch', true)
|
||||
else this.setupIncrementalSearch(editor, true);;
|
||||
};
|
||||
|
||||
exports.handler.detach = function(editor) {
|
||||
|
|
@ -487,5 +486,17 @@ exports.killRing = {
|
|||
}
|
||||
};
|
||||
|
||||
require('../incremental_search');
|
||||
exports.handler.setupIncrementalSearch = function(editor, val) {
|
||||
if (this.usesIncrementalSearch == val) return;
|
||||
this.usesIncrementalSearch = val;
|
||||
if (val) {
|
||||
this.bindKey('C-s', 'iSearch');
|
||||
this.bindKey('C-r', 'iSearchBackwards');
|
||||
} else {
|
||||
this.bindKey('C-s', "findnext");
|
||||
this.bindKey('C-r', "findprevious");
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue