153 for (; cur; cur = nxt) {
173 if (!all && a != context->
current) {
181 if (add && !a->
sel) {
184 if (a->
sel != NULL) {
211 bool case_sensitive, forwards, showall;
219 if (context->
c == NULL) {
227 if (context->
string != NULL) {
234 context->
string = malloc(string_len + 1);
235 if (context->
string != NULL) {
236 memcpy(context->
string,
string, string_len);
237 context->
string[string_len] =
'\0';
265 }
else if (context->
current != NULL) {
299 if (context->
current == NULL) {
350 string_len = strlen(
string);
351 for (i = 0; i < string_len; i++) {
352 if (
string[i] !=
'#' &&
string[i] !=
'*')
356 if (i < string_len) {
441 if (context == NULL) {
445 search_head = malloc(
sizeof(
struct list_entry));
446 if (search_head == NULL) {
455 search_head->
sel = NULL;
456 search_head->
prev = NULL;
457 search_head->
next = NULL;
459 context->
found = search_head;
465 context->
gui_p = gui_data;
467 *textsearch_out = context;
482 struct {
const char *ss, *s, *p;
bool first; } context[16];
483 const char *ep = pattern + p_len;
484 const char *es =
string + s_len;
485 const char *p = pattern - 1;
486 const char *ss = string;
487 const char *s = string;
493 if (p < pattern || *p ==
'*') {
498 do p++;
while (p < ep && *p ==
'*');
526 context[top].ss = ss;
527 context[top].s = s + 1;
528 context[top].p = p - 1;
530 context[top].first = first;
551 matches = (*s == ch);
555 if (matches && first) {
571 ss = context[top].ss;
574 first = context[top].first;
579 *m_len =
max(s - ss, 1);
589 struct box *start_box,
595 entry = calloc(1,
sizeof(*entry));
624 unsigned start_offset,
631 for (cur = textsearch->
found->
next; cur != NULL; cur = cur->
next) {
649 assert(textsearch != NULL);
651 if (textsearch->
string != NULL) {
654 CONTENT_TEXTSEARCH_RECENT,
663 CONTENT_TEXTSEARCH_BACK,
669 CONTENT_TEXTSEARCH_FORWARD,
692 if (
string != NULL &&
699 }
else if (
string != NULL) {
Helpers for ASCII string handling.
static char ascii_to_upper(char c)
Convert a lower case character to upper case.
Content handling interface.
void content_broadcast(struct content *c, content_msg msg, const union content_msg_data *data)
Send a message to all users.
Protected interface to Content handling.
content_type
The type of a content.
@ CONTENT_MSG_TEXTSEARCH
A free text search action has occurred.
@ CONTENT_MSG_SCROLL
Request to scroll content.
@ SEARCH_FLAG_CASE_SENSITIVE
bool selection_highlighted(const struct selection *s, unsigned start, unsigned end, unsigned *start_idx, unsigned *end_idx)
Tests whether a text range lies partially within the selection, if there is a selection defined,...
struct selection * selection_create(struct content *c)
Creates a new selection object associated with a browser window.
void selection_init(struct selection *s)
Initialise the selection object to use the given box subtree as its root, ie.
void selection_set_position(struct selection *s, unsigned start, unsigned end)
Set the position of the current selection, updating the screen.
void selection_destroy(struct selection *s)
Destroys a selection object clearing it if nesessary.
Text selection within browser windows (interface).
nserror
Enumeration of error codes.
@ NSERROR_NOT_IMPLEMENTED
Functionality is not implemented.
@ NSERROR_NOMEM
Memory exhaustion.
#define NOF_ELEMENTS(array)
struct content * hlcache_handle_get_content(const hlcache_handle *handle)
Retrieve a content object from a cache handle.
High-level resource cache interface.
Interface to utility string handling.
nserror(* textsearch_find)(struct content *c, struct textsearch_context *context, const char *pattern, int p_len, bool case_sens)
content specific free text search find
nserror(* textsearch_bounds)(struct content *c, unsigned start_idx, unsigned end_idx, struct box *start_ptr, struct box *end_ptr, struct rect *bounds_out)
get bounds of free text search match
content_type(* type)(void)
Content which corresponds to a single URL.
const struct content_handler * handler
Handler for content.
struct content::@117 textsearch
Free text search state.
struct textsearch_context * context
struct list_entry * next
next match
struct selection * sel
content specific selection object
unsigned start_idx
start position of match
struct box * end_box
content opaque end pointer
struct list_entry * prev
previous match
unsigned end_idx
end of match
struct box * start_box
content opaque start pointer
The context for a free text search.
struct content * c
content search was performed upon
void * gui_p
opaque pointer passed to constructor.
struct list_entry * current
current selected match
struct list_entry * found
List of matches.
char * string
query string search results are for
static void textsearch_broadcast(struct textsearch_context *textsearch, int type, bool state, const char *string)
broadcast textsearch message
static void free_matches(struct textsearch_context *textsearch)
Release the memory used by the list of matches, deleting selection objects too.
static void search_show_all(bool all, struct textsearch_context *context)
Specifies whether all matches or just the current match should be highlighted in the search text.
static nserror search_text(struct textsearch_context *context, const char *string, int string_len, search_flags_t flags)
Search for a string in a content.
nserror content_textsearch_clear(struct hlcache_handle *h)
Clear a search.
nserror content_textsearch(struct hlcache_handle *h, void *context, search_flags_t flags, const char *string)
Free text search a content.
static nserror content_textsearch_step(struct textsearch_context *textsearch, search_flags_t flags, const char *string)
Begins/continues the search process.
nserror content_textsearch_destroy(struct textsearch_context *textsearch)
Ends the search process, invalidating all state freeing the list of found boxes.
static nserror content_textsearch__clear(struct content *c)
Terminate a search.
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.
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...
static nserror content_textsearch_create(struct content *c, void *gui_data, struct textsearch_context **textsearch_out)
create a search_context
nserror content_textsearch_add_match(struct textsearch_context *context, unsigned start_idx, unsigned end_idx, struct box *start_box, struct box *end_box)
Add a new entry to the list of matches.
Interface to HTML searching.
Extra data for some content_msg messages.
struct content_msg_data::@103 scroll
CONTENT_MSG_SCROLL - Part of content to scroll to show.
browser_window_console_flags flags
The flags of the logging.
@ CONTENT_TEXTSEARCH_FIND
Free text search find operation has started or finished.
struct content_msg_data::@111 textsearch
CONTENT_MSG_TEXTSEARCH - Free text search action.
@ CONTENT_TEXTSEARCH_MATCH
Free text search match state has changed.
@ CONTENT_TEXTSEARCH_BACK
Free text search back available state changed.
@ CONTENT_TEXTSEARCH_FORWARD
Free text search forward available state changed.
bool state
state for operation
const char * string
search string
enum content_msg_data::@104::@112 type
void * ctx
context passed to browser_window_search()
@ CONTENT_TEXTSEARCH_RECENT
add a search query string to the recent searches
Interface to a number of general purpose functionality.