/* Exported function documented in search.h */ bool search_term_highlighted(struct content *c, unsigned start_offset, unsigned end_offset, unsigned *start_idx, unsigned *end_idx, struct search_context *context) { if (c == context->c) { struct list_entry *a; for (a = context->found->next; a; a = a->next) if (a->sel && selection_defined(a->sel) && selection_highlighted(a->sel, start_offset, end_offset, start_idx, end_idx)) return true; } return false; }
/** * Handle key presses in a browser window. * * \param bw The root browser window * \param key The UCS4 character codepoint * \return true if key handled, false otherwise */ bool browser_window_key_press(struct browser_window *bw, uint32_t key) { struct browser_window *focus = bw->focus; assert(bw->window != NULL); /* keys that take effect wherever the caret is positioned */ switch (key) { case KEY_SELECT_ALL: selection_select_all(bw->cur_sel); return true; case KEY_COPY_SELECTION: gui_copy_to_clipboard(bw->cur_sel); return true; case KEY_CLEAR_SELECTION: selection_clear(bw->cur_sel, true); return true; case KEY_ESCAPE: if (bw->cur_sel && selection_defined(bw->cur_sel)) { selection_clear(bw->cur_sel, true); return true; } /* if there's no selection, * leave Escape for the caller */ return false; } /* pass on to the appropriate field */ if (!focus->caret_callback) return false; return focus->caret_callback(focus, key, focus->caret_p1, focus->caret_p2); }