[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);
|
dom.importCssString(css, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// support for default keyboard handler
|
// support for default keyboard handler
|
||||||
require(["./commands/command_manager"], function(cmdMgr) {
|
var commands = require("./commands/command_manager");
|
||||||
(function() {
|
(function() {
|
||||||
this.setupIncrementalSearch = function(editor, val) {
|
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) {
|
|
||||||
if (this.usesIncrementalSearch == val) return;
|
if (this.usesIncrementalSearch == val) return;
|
||||||
this.usesIncrementalSearch = val;
|
this.usesIncrementalSearch = val;
|
||||||
if (val) {
|
var iSearchCommands = iSearchCommandModule.iSearchStartCommands,
|
||||||
this.bindKey('C-s', 'iSearch');
|
method = val ? 'addCommands' : 'removeCommands';
|
||||||
this.bindKey('C-r', 'iSearchBackwards');
|
this[method](iSearchCommands);
|
||||||
} else {
|
};
|
||||||
this.bindKey('C-s', "findnext");
|
}).call(commands.CommandManager.prototype);
|
||||||
this.bindKey('C-r', "findprevious");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// incremental search config option
|
// incremental search config option
|
||||||
var Editor = require("./editor").Editor;
|
var Editor = require("./editor").Editor;
|
||||||
|
|
|
||||||
|
|
@ -108,9 +108,8 @@ exports.handler.attach = function(editor) {
|
||||||
editor.commands.addCommands(commands);
|
editor.commands.addCommands(commands);
|
||||||
exports.handler.platform = editor.commands.platform;
|
exports.handler.platform = editor.commands.platform;
|
||||||
editor.$emacsModeHandler = this;
|
editor.$emacsModeHandler = this;
|
||||||
require('../incremental_search');
|
if (!editor.getOption('useIncrementalSearch')) editor.setOption('useIncrementalSearch', true)
|
||||||
editor.setOption('useIncrementalSearch', true);
|
else this.setupIncrementalSearch(editor, true);;
|
||||||
this.setupIncrementalSearch(editor, true);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler.detach = function(editor) {
|
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