[incremental search] style patch for better highlights
This commit is contained in:
parent
8a62ad8be0
commit
5b0c216580
1 changed files with 28 additions and 0 deletions
|
|
@ -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']);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue