Skip to content
Snippets Groups Projects
Commit c3689792 authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

ignore case for search in the Pd Console window

parent 6b524493
No related branches found
No related tags found
No related merge requests found
...@@ -98,12 +98,18 @@ function console_unwrap_tag(console_elem, tag_name) { ...@@ -98,12 +98,18 @@ function console_unwrap_tag(console_elem, tag_name) {
} }
} }
// We need to use a regular expression to search without regard to case
function escapeRegExp(string){
// $& means the whole matched string
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
function console_find_text(evt, callback) { function console_find_text(evt, callback) {
var console_text = document.getElementById("p1"), var console_text = document.getElementById("p1"),
wrap_tag = "mark", wrap_tag = "mark",
wrapper_count, wrapper_count,
elem = evt.target; elem = evt.target;
window.setTimeout(function () { window.setTimeout(function () {
var find_text = new RegExp(escapeRegExp(elem.value), "gi");
console_unwrap_tag(console_text, wrap_tag); console_unwrap_tag(console_text, wrap_tag);
// Check after the event if the value is empty // Check after the event if the value is empty
if (elem.value === undefined || elem.value === "") { if (elem.value === undefined || elem.value === "") {
...@@ -112,7 +118,7 @@ function console_find_text(evt, callback) { ...@@ -112,7 +118,7 @@ function console_find_text(evt, callback) {
} else { } else {
window.findAndReplaceDOMText(console_text, { window.findAndReplaceDOMText(console_text, {
//preset: "prose", //preset: "prose",
find: elem.value.toLowerCase(), find: find_text,
wrap: wrap_tag wrap: wrap_tag
}); });
// The searchAndReplace API is so bad you can't even know how // The searchAndReplace API is so bad you can't even know how
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment