49 #define NOF_ELEMENTS(array) (sizeof(array)/sizeof(*(array))) 90 if (context == NULL) {
94 search_head = malloc(
sizeof(
struct list_entry));
95 if (search_head == NULL) {
104 search_head->
sel = NULL;
105 search_head->
prev = NULL;
106 search_head->
next = NULL;
108 context->
found = search_head;
115 context->
gui_p = gui_data;
164 const char *pattern,
int p_len,
bool case_sens,
167 struct {
const char *ss, *s, *p;
bool first; } context[16];
168 const char *ep = pattern + p_len;
169 const char *es =
string + s_len;
170 const char *p = pattern - 1;
171 const char *ss = string;
172 const char *s = string;
178 if (p < pattern || *p ==
'*') {
183 do p++;
while (p < ep && *p ==
'*');
197 if (!case_sens) ch = toupper(ch);
201 }
else if (toupper(*s) == ch)
211 context[top].ss = ss;
212 context[top].s = s + 1;
213 context[top].p = p - 1;
215 context[top].first = first;
236 matches = (*s == ch);
238 matches = (toupper(*s) == toupper(ch));
240 if (matches && first) {
256 ss = context[top].ss;
259 first = context[top].first;
264 *m_len =
max(s - ss, 1);
283 entry = calloc(1,
sizeof(*entry));
318 struct box *cur,
bool case_sens,
330 unsigned match_length;
331 unsigned match_offset;
332 const char *new_text;
334 pattern, p_len, case_sens,
340 match_offset = pos - cur->
text;
345 match_length, context);
352 new_text = pos + match_length;
353 length -= (new_text -
text);
381 struct content *c,
bool case_sens,
387 for(line = 0; line < nlines; line++) {
388 size_t offset, length;
394 unsigned match_length;
396 const char *new_text;
398 pattern, p_len, case_sens,
404 start_idx = offset + (pos -
text);
406 match_length, context);
410 new_text = pos + match_length;
411 offset += (new_text -
text);
412 length -= (new_text -
text);
432 if (!all && a != context->
current) {
440 if (add && !a->
sel) {
442 if (context->
is_html ==
true) {
482 bool case_sensitive, forwards, showall;
489 if (context->
c == NULL)
492 if (context->
is_html ==
true) {
507 if (context->
string != NULL)
513 context->
string = malloc(string_len + 1);
514 if (context->
string != NULL) {
515 memcpy(context->
string,
string, string_len);
516 context->
string[string_len] =
'\0';
521 if (context->
is_html ==
true) {
523 box, case_sensitive, context);
526 context->
c, case_sensitive, context);
542 }
else if (context->
current != NULL) {
567 if (context->
is_html ==
true) {
599 assert(context != NULL);
603 string_len = strlen(
string);
604 for (i = 0; i < string_len; i++)
605 if (
string[i] !=
'#' &&
string[i] !=
'*')
607 if (i >= string_len) {
627 unsigned start_offset,
unsigned end_offset,
631 if (c == context->
c) {
636 start_offset, end_offset,
650 assert(context != NULL);
652 if (context->
string != NULL) {
void selection_clear(struct selection *s, bool redraw)
Clears the current selection, optionally causing the screen to be updated.
void selection_destroy(struct selection *s)
Destroys a selection object, without updating the owning window (caller should call selection_clear()...
void search_destroy_context(struct search_context *context)
Ends the search process, invalidating all state freeing the list of found boxes.
Interface to utility string handling.
Interface to content handler for plain text.
Localised message support (interface).
static nserror line(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line)
Plots a line.
Interface to text/html content handler.
char * textplain_get_line(struct content *c, unsigned lineno, size_t *poffset, size_t *plen)
Return a pointer to the requested line of text.
void selection_set_end(struct selection *s, unsigned offset)
Set the end position of the current selection, updating the screen.
size_t byte_offset
Byte offset within a textual representation of this content.
#define selection_defined(s)
struct list_entry * found
Interface to platform-specific miscellaneous browser operation table.
void box_coords(struct box *box, int *x, int *y)
Find the absolute coordinates of a box.
struct search_context * search_create_context(struct content *c, content_type type, void *gui_data)
create a search_context
struct box * layout
Box tree, or NULL.
HTML Box tree inspection interface.
High-level resource cache interface.
struct selection * selection_create(struct content *c, bool is_html)
Creates a new selection object associated with a browser window.
void(* status)(bool found, void *p)
Change the displayed search status.
void(* hourglass)(bool active, void *p)
display hourglass while searching.
void(* add_recent)(const char *string, void *p)
add search string to recent searches list front has full liberty how to implement the bare notificati...
Private data for text/html content.
static void free_matches(struct search_context *context)
Release the memory used by the list of matches, deleting selection objects too.
size_t length
Length of text.
void selection_set_start(struct selection *s, unsigned offset)
Set the start position of the current selection, updating the screen.
Content which corresponds to a single URL.
content_type
The type of a content.
struct content_msg_data::@108 scroll
CONTENT_MSG_SCROLL - Part of content to scroll to show.
Request to scroll content.
static struct list_entry * add_entry(unsigned start_idx, unsigned end_idx, struct search_context *context)
Add a new entry to the list of matches.
Interface to platform-specific search operations.
Content handling interface.
void selection_init(struct selection *s, struct box *root, const nscss_len_ctx *len_ctx)
Initialise the selection object to use the given box subtree as its root, ie.
static void search_show_all(bool all, struct search_context *context)
Specifies whether all matches or just the current match should be highlighted in the search text...
void textplain_coords_from_range(struct content *c, unsigned start, unsigned end, struct rect *r)
Given a range of byte offsets within a UTF8 textplain content, return a box that fully encloses the t...
struct list_entry * current
static nserror text(const struct redraw_context *ctx, const struct plot_font_style *fstyle, int x, int y, const char *text, size_t length)
Text plotting.
void search_step(struct search_context *context, search_flags_t flags, const char *string)
Begins/continues the search process.
browser_window_console_flags flags
The flags of the logging.
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...
void content_broadcast(struct content *c, content_msg msg, const union content_msg_data *data)
Send a message to all users.
struct box * children
First child box, or NULL.
struct gui_search_table * search
Page search table.
int height
Height of content box (excluding padding etc.).
char * text
Text, or NULL if none.
int width
Width of content box (excluding padding etc.).
unsigned long textplain_line_count(struct content *c)
Retrieve number of lines in content.
struct hlcache_handle * object
Object in this box (usually an image), or NULL if none.
static bool find_occurrences_html(const char *pattern, int p_len, struct box *cur, bool case_sens, struct search_context *context)
Finds all occurrences of a given string in the html box tree.
Interface to HTML searching.
Interface to a number of general purpose functionality.
#define NOF_ELEMENTS(array)
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...
Text selection within browser windows (interface).
struct box * next
Next sibling box, or NULL.
nscss_len_ctx len_ctx
CSS length conversion context for document.
void(* forward_state)(bool active, void *p)
activate search forwards button in gui
void(* back_state)(bool active, void *p)
activate search back button in gui
Data specific to CONTENT_HTML.
static bool find_occurrences_text(const char *pattern, int p_len, struct content *c, bool case_sens, struct search_context *context)
Finds all occurrences of a given string in a textplain content.
Interface to core interface table.
struct netsurf_table * guit
The global interface table.
Extra data for some content_msg messages.
static void search_text(const char *string, int string_len, struct search_context *context, search_flags_t flags)
Search for a string in the box tree.
static const char * 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.