NetSurf
Functions
textsearch.h File Reference

Interface to HTML searching. More...

#include "desktop/search.h"
Include dependency graph for textsearch.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

nserror content_textsearch (struct hlcache_handle *h, void *context, search_flags_t flags, const char *string)
 Free text search a content. More...
 
nserror content_textsearch_clear (struct hlcache_handle *h)
 Clear a search. More...
 
nserror content_textsearch_destroy (struct textsearch_context *textsearch)
 Ends the search process, invalidating all state freeing the list of found boxes. More...
 
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 current search string. More...
 
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. More...
 
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. More...
 

Detailed Description

Interface to HTML searching.

Definition in file textsearch.h.

Function Documentation

◆ content_textsearch()

nserror content_textsearch ( struct hlcache_handle h,
void *  context,
search_flags_t  flags,
const char *  string 
)

Free text search a content.

Parameters
[in]hHandle to content to search.
[in]contextThe context passed to gui table search handlers
[in]flagsThe flags that control the search
[in]Thestring being searched for. \retun NSERROR_OK on success else error code on faliure

Definition at line 682 of file textsearch.c.

References content_textsearch__clear(), content_textsearch_create(), content_textsearch_destroy(), content_textsearch_step(), content::context, hlcache_handle_get_content(), NSERROR_NOMEM, NSERROR_OK, content::string, and content::textsearch.

Referenced by browser_window_search().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ content_textsearch_add_match()

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.

Parameters
contextThe search context to add the entry to.
start_idxOffset of match start within textual representation
end_idxOffset of match end
startA pointer for the start
endA pointer for the end
Returns
NSERROR_OK on sucess else error code on faliure

Definition at line 586 of file textsearch.c.

References list_entry::end_box, list_entry::end_idx, textsearch_context::found, list_entry::next, NSERROR_NOMEM, NSERROR_OK, list_entry::prev, list_entry::sel, list_entry::start_box, and list_entry::start_idx.

Referenced by find_occurrences_html_box(), and textplain_textsearch_find().

Here is the caller graph for this function:

◆ content_textsearch_clear()

nserror content_textsearch_clear ( struct hlcache_handle h)

Clear a search.

Parameters
[in]hHandle to content to clear search from.

Definition at line 734 of file textsearch.c.

References content_textsearch__clear(), and hlcache_handle_get_content().

Referenced by browser_window_search_clear().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ content_textsearch_destroy()

nserror content_textsearch_destroy ( struct textsearch_context textsearch)

Ends the search process, invalidating all state freeing the list of found boxes.

Definition at line 647 of file textsearch.c.

References free_matches(), NSERROR_OK, textsearch_context::string, and textsearch_broadcast().

Referenced by content_close(), content_textsearch(), and content_textsearch__clear().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ content_textsearch_find_pattern()

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.

Parameters
stringthe string to be searched (unterminated)
s_lenlength of the string to be searched
patternthe pattern for which we are searching (unterminated)
p_lenlength of pattern
case_senstrue iff case sensitive match required
m_lenaccepts length of match in bytes
Returns
pointer to first match, NULL if none

Definition at line 475 of file textsearch.c.

References ascii_to_upper(), max, and NOF_ELEMENTS.

Referenced by find_occurrences_html_box(), and textplain_textsearch_find().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ content_textsearch_ishighlighted()

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 current search string.

Parameters
textsearchThe search context to hilight entries from.
cThe content to highlight within.
start_offsetbyte offset within text of string to be checked
end_offsetbyte offset within text
start_idxbyte offset within string of highlight start
end_idxbyte offset of highlight end
Returns
true iff part of the box should be highlighted

Definition at line 623 of file textsearch.c.

References list_entry::end_idx, textsearch_context::found, list_entry::next, list_entry::sel, selection_highlighted(), and list_entry::start_idx.

Referenced by text_draw(), text_redraw(), and textplain_redraw().

Here is the call graph for this function:
Here is the caller graph for this function: