NetSurf
textsearch.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_CONTENT_SEARCH_H
25#define NETSURF_CONTENT_SEARCH_H
26
27#include "desktop/search.h"
28
30struct content;
31struct hlcache_handle;
32struct box;
33
34/**
35 * Free text search a content
36 *
37 * \param[in] h Handle to content to search.
38 * \param[in] context The context passed to gui table search handlers
39 * \param[in] flags The flags that control the search
40 * \param[in] The string being searched for.
41 * \retun NSERROR_OK on success else error code on faliure
42 */
43nserror content_textsearch(struct hlcache_handle *h, void *context, search_flags_t flags, const char *string);
44
45/**
46 * Clear a search
47 *
48 * \param[in] h Handle to content to clear search from.
49 */
51
52/**
53 * Ends the search process, invalidating all state freeing the list of
54 * found boxes.
55 */
57
58/**
59 * Determines whether any portion of the given text box should be
60 * selected because it matches the current search string.
61 *
62 * \param textsearch The search context to hilight entries from.
63 * \param c The content to highlight within.
64 * \param start_offset byte offset within text of string to be checked
65 * \param end_offset byte offset within text
66 * \param start_idx byte offset within string of highlight start
67 * \param end_idx byte offset of highlight end
68 * \return true iff part of the box should be highlighted
69 */
71 unsigned start_offset,
72 unsigned end_offset,
73 unsigned *start_idx,
74 unsigned *end_idx);
75
76/**
77 * Find the first occurrence of 'match' in 'string' and return its index
78 *
79 * \param string the string to be searched (unterminated)
80 * \param s_len length of the string to be searched
81 * \param pattern the pattern for which we are searching (unterminated)
82 * \param p_len length of pattern
83 * \param case_sens true iff case sensitive match required
84 * \param m_len accepts length of match in bytes
85 * \return pointer to first match, NULL if none
86 */
87const char *content_textsearch_find_pattern(const char *string, int s_len, const char *pattern, int p_len, bool case_sens, unsigned int *m_len);
88
89/**
90 * Add a new entry to the list of matches
91 *
92 * \param context The search context to add the entry to.
93 * \param start_idx Offset of match start within textual representation
94 * \param end_idx Offset of match end
95 * \param start A pointer for the start
96 * \param end A pointer for the end
97 * \return NSERROR_OK on sucess else error code on faliure
98 */
99nserror content_textsearch_add_match(struct textsearch_context *context, unsigned start_idx, unsigned end_idx, struct box *start_ptr, struct box *end_ptr);
100
101#endif
Browseing window text search interface.
search_flags_t
Definition: search.h:29
nserror
Enumeration of error codes.
Definition: errors.h:29
Node in box tree.
Definition: box.h:177
box_flags flags
Box flags.
Definition: box.h:186
Content which corresponds to a single URL.
High-level cache handle.
Definition: hlcache.c:66
The context for a free text search.
Definition: textsearch.c:84
nserror content_textsearch_add_match(struct textsearch_context *context, unsigned start_idx, unsigned end_idx, struct box *start_ptr, struct box *end_ptr)
Add a new entry to the list of matches.
Definition: textsearch.c:586
nserror content_textsearch_clear(struct hlcache_handle *h)
Clear a search.
Definition: textsearch.c:734
nserror content_textsearch(struct hlcache_handle *h, void *context, search_flags_t flags, const char *string)
Free text search a content.
Definition: textsearch.c:682
nserror content_textsearch_destroy(struct textsearch_context *textsearch)
Ends the search process, invalidating all state freeing the list of found boxes.
Definition: textsearch.c:647
const char * content_textsearch_find_pattern(const char *string, int s_len, const char *pattern, int p_len, bool case_sens, unsigned int *m_len)
Find the first occurrence of 'match' in 'string' and return its index.
Definition: textsearch.c:475
bool content_textsearch_ishighlighted(struct textsearch_context *textsearch, unsigned start_offset, unsigned end_offset, unsigned *start_idx, unsigned *end_idx)
Determines whether any portion of the given text box should be selected because it matches the curren...
Definition: textsearch.c:623