NetSurf
search.h
Go to the documentation of this file.
1 /*
2  * Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin@dfgh.net>
3  *
4  * This file is part of NetSurf, http://www.netsurf-browser.org/
5  *
6  * NetSurf is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; version 2 of the License.
9  *
10  * NetSurf is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 /**
20  * \file
21  * Interface to HTML searching.
22  */
23 
24 #ifndef NETSURF_HTML_SEARCH_H
25 #define NETSURF_HTML_SEARCH_H
26 
27 #include <ctype.h>
28 #include <string.h>
29 
30 #include "desktop/search.h"
31 
32 struct search_context;
33 
34 /**
35  * create a search_context
36  *
37  * \param c The content the search_context is connected to
38  * \param type The content type of c
39  * \param context A context pointer passed to the provider routines.
40  * \return A new search context or NULL on error.
41  */
43  content_type type, void *context);
44 
45 /**
46  * Ends the search process, invalidating all state
47  * freeing the list of found boxes
48  */
49 void search_destroy_context(struct search_context *context);
50 
51 /**
52  * Begins/continues the search process
53  *
54  * \note that this may be called many times for a single search.
55  *
56  * \param context The search context in use.
57  * \param flags The flags forward/back etc
58  * \param string The string to match
59  */
60 void search_step(struct search_context *context, search_flags_t flags,
61  const char * string);
62 
63 
64 /**
65  * Determines whether any portion of the given text box should be
66  * selected because it matches the current search string.
67  *
68  * \param c The content to hilight within.
69  * \param start_offset byte offset within text of string to be checked
70  * \param end_offset byte offset within text
71  * \param start_idx byte offset within string of highlight start
72  * \param end_idx byte offset of highlight end
73  * \param context The search context to hilight entries from.
74  * \return true iff part of the box should be highlighted
75  */
76 bool search_term_highlighted(struct content *c,
77  unsigned start_offset, unsigned end_offset,
78  unsigned *start_idx, unsigned *end_idx,
79  struct search_context *context);
80 
81 #endif
bool search_term_highlighted(struct content *c, unsigned start_offset, unsigned end_offset, unsigned *start_idx, unsigned *end_idx, struct search_context *context)
Determines whether any portion of the given text box should be selected because it matches the curren...
Definition: search.c:626
void search_destroy_context(struct search_context *context)
Ends the search process, invalidating all state freeing the list of found boxes.
Definition: search.c:648
Interface to utility string handling.
const char * type
Definition: filetype.cpp:44
Content which corresponds to a single URL.
content_type
The type of a content.
Definition: content_type.h:53
struct search_context * search_create_context(struct content *c, content_type type, void *context)
create a search_context
Definition: search.c:80
void search_step(struct search_context *context, search_flags_t flags, const char *string)
Begins/continues the search process.
Definition: search.c:592
struct content * c
Definition: search.c:68
search_flags_t
Definition: search.h:27