Hightlight partial search results

This commit is contained in:
M66B
2024-06-30 18:24:39 +02:00
parent 0d2ebeb133
commit a0fa0b487c
5 changed files with 27 additions and 9 deletions

View File

@@ -3199,7 +3199,7 @@ public class HtmlHelper {
return ssb;
}
static void highlightSearched(Context context, Document document, String query) {
static void highlightSearched(Context context, Document document, String query, boolean partial) {
try {
int color = Helper.resolveColor(context, R.attr.colorHighlight);
@@ -3213,8 +3213,13 @@ public class HtmlHelper {
sb.append(Pattern.quote(w));
}
}
sb.insert(0, ".*?\\b(");
sb.append(")\\b.*?");
if (partial) {
sb.insert(0, ".*?(");
sb.append(").*?");
} else {
sb.insert(0, ".*?\\b(");
sb.append(")\\b.*?");
}
// TODO: match für for fur
Pattern p = Pattern.compile(sb.toString(), Pattern.DOTALL | Pattern.CASE_INSENSITIVE);