[incremental search] style patch for better highlights

This commit is contained in:
Robert Krahn 2013-03-10 19:56:16 -07:00
commit 5b0c216580

View file

@ -168,6 +168,32 @@ oop.inherits(IncrementalSearch, Search);
exports.IncrementalSearch = IncrementalSearch;
/**
*
* Config settings for enabling/disabling [[IncrementalSearch `IncrementalSearch`]].
*
**/
function patchHighlightMarkerStyling(options) {
options = options || {};
var id = 'incremental-search-highlight-style-patch',
style = document.getElementById(id);
if (style) {
if (options.enable) return;
style.parentNode.removeChild(style);
return;
}
if (!options.enable) return;
style = document.createElement('style');
style.setAttribute('id', id);
style.textContent = "div.ace_selected-word {\n"
+ " background-color: orange !important;\n"
+ " border: 0 !important;"
+ "}\n"
document.getElementsByTagName('head')[0].appendChild(style);
}
var Editor = require("./editor").Editor;
require("./config").defineOptions(Editor.prototype, "editor", {
useIncrementalSearch: {
@ -177,6 +203,7 @@ require("./config").defineOptions(Editor.prototype, "editor", {
if (val) {
// enable for whole editor
this.commands.addCommands(iSearchCommands);
patchHighlightMarkerStyling({enable: true});
if (kbd.isEmacs) { // adapt emacs key handler if used
kbd.oldSearchBindings = {
'c-s': kbd.commmandKeyBinding['c-s'],
@ -187,6 +214,7 @@ require("./config").defineOptions(Editor.prototype, "editor", {
}
} else {
this.commands.removeCommands(iSearchCommands);
patchHighlightMarkerStyling({enable: false});
if (kbd.isEmacs) {
kbd.bindKey('C-s', kbd.oldSearchBindings['c-s']);
kbd.bindKey('C-r', kbd.oldSearchBindings['c-r']);