summaryrefslogtreecommitdiff
path: root/content/handlers/html/search.c
diff options
context:
space:
mode:
Diffstat (limited to 'content/handlers/html/search.c')
-rw-r--r--content/handlers/html/search.c102
1 files changed, 55 insertions, 47 deletions
diff --git a/content/handlers/html/search.c b/content/handlers/html/search.c
index e26510e6e..3599951a7 100644
--- a/content/handlers/html/search.c
+++ b/content/handlers/html/search.c
@@ -422,6 +422,49 @@ static bool find_occurrences_text(const char *pattern, int p_len,
/**
+ * Specifies whether all matches or just the current match should
+ * be highlighted in the search text.
+ */
+static void search_show_all(bool all, struct search_context *context)
+{
+ struct list_entry *a;
+
+ for (a = context->found->next; a; a = a->next) {
+ bool add = true;
+ if (!all && a != context->current) {
+ add = false;
+ if (a->sel) {
+ selection_clear(a->sel, true);
+ selection_destroy(a->sel);
+ a->sel = NULL;
+ }
+ }
+ if (add && !a->sel) {
+
+ if (context->is_html == true) {
+ html_content *html = (html_content *)context->c;
+ a->sel = selection_create(context->c, true);
+ if (!a->sel)
+ continue;
+
+ selection_init(a->sel, html->layout,
+ &html->len_ctx);
+ } else {
+ a->sel = selection_create(context->c, false);
+ if (!a->sel)
+ continue;
+
+ selection_init(a->sel, NULL, NULL);
+ }
+
+ selection_set_start(a->sel, a->start_idx);
+ selection_set_end(a->sel, a->end_idx);
+ }
+ }
+}
+
+
+/**
* Search for a string in the box tree
*
* \param string the string to search for
@@ -429,8 +472,11 @@ static bool find_occurrences_text(const char *pattern, int p_len,
* \param context The search context to add the entry to.
* \param flags flags to control the search.
*/
-static void search_text(const char *string, int string_len,
- struct search_context *context, search_flags_t flags)
+static void
+search_text(const char *string,
+ int string_len,
+ struct search_context *context,
+ search_flags_t flags)
{
struct rect bounds;
struct box *box = NULL;
@@ -456,7 +502,8 @@ static void search_text(const char *string, int string_len,
/* check if we need to start a new search or continue an old one */
- if (context->newsearch) {
+ if ((context->newsearch) ||
+ (context->prev_case_sens != case_sensitive)) {
bool res;
if (context->string != NULL)
@@ -543,16 +590,15 @@ static void search_text(const char *string, int string_len,
/* Exported function documented in search.h */
-void search_step(struct search_context *context, search_flags_t flags,
- const char *string)
+void
+search_step(struct search_context *context,
+ search_flags_t flags,
+ const char *string)
{
int string_len;
int i = 0;
- if (context == NULL) {
- guit->misc->warning("SearchError", 0);
- return;
- }
+ assert(context != NULL);
guit->search->add_recent(string, context->gui_p);
@@ -598,44 +644,6 @@ bool search_term_highlighted(struct content *c,
}
-/* Exported function documented in search.h */
-void search_show_all(bool all, struct search_context *context)
-{
- struct list_entry *a;
-
- for (a = context->found->next; a; a = a->next) {
- bool add = true;
- if (!all && a != context->current) {
- add = false;
- if (a->sel) {
- selection_clear(a->sel, true);
- selection_destroy(a->sel);
- a->sel = NULL;
- }
- }
- if (add && !a->sel) {
-
- if (context->is_html == true) {
- html_content *html = (html_content *)context->c;
- a->sel = selection_create(context->c, true);
- if (!a->sel)
- continue;
-
- selection_init(a->sel, html->layout,
- &html->len_ctx);
- } else {
- a->sel = selection_create(context->c, false);
- if (!a->sel)
- continue;
-
- selection_init(a->sel, NULL, NULL);
- }
-
- selection_set_start(a->sel, a->start_idx);
- selection_set_end(a->sel, a->end_idx);
- }
- }
-}
/* Exported function documented in search.h */