NetSurf
Data Structures | Macros | Functions | Variables
search.c File Reference

Free text search implementation. More...

#include "utils/config.h"
#include <ctype.h>
#include <string.h>
#include "oslib/hourglass.h"
#include "oslib/wimp.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "netsurf/browser_window.h"
#include "netsurf/search.h"
#include "netsurf/content.h"
#include "desktop/search.h"
#include "riscos/gui.h"
#include "riscos/dialog.h"
#include "riscos/menus.h"
#include "riscos/wimp.h"
#include "riscos/wimp_event.h"
Include dependency graph for search.c:

Go to the source code of this file.

Data Structures

struct  search_static_data
 

Macros

#define RECENT_SEARCHES   8
 
#define DEFAULT_FLAGS
 

Functions

static wimp_MENU (RECENT_SEARCHES)
 
void ro_gui_search_init (void)
 
bool ro_gui_search_next (wimp_w w)
 Wrapper for the pressing of an OK button for wimp_event. More...
 
bool ro_gui_search_menu_prepare (wimp_w w, wimp_i i, wimp_menu *menu, wimp_pointer *pointer)
 Callback to prepare menus in the Search dialog. More...
 
bool ro_gui_search_click (wimp_pointer *pointer)
 
void ro_gui_search_add_recent (const char *search, void *p)
 add search string to recent searches list More...
 
bool ro_gui_search_prepare_menu (void)
 
static bool ro_gui_search_bw_searchable (struct browser_window *bw)
 Determine of the browser window is searchable. More...
 
void ro_gui_search_prepare (struct browser_window *bw)
 Open the search dialog. More...
 
bool ro_gui_search_keypress (wimp_key *key)
 Handle keypresses in the search dialog. More...
 
void ro_gui_search_end (wimp_w w)
 Ends the search. More...
 
void ro_gui_search_set_status (bool found, void *p)
 Change the displayed search status. More...
 
void ro_gui_search_set_hourglass (bool active, void *p)
 display hourglass while searching More...
 
void ro_gui_search_set_forward_state (bool active, void *p)
 activate search forwards button in gui More...
 
void ro_gui_search_set_back_state (bool active, void *p)
 activate search forwards button in gui More...
 
search_flags_t ro_gui_search_update_flags (void)
 retrieve state of 'case sensitive', 'show all' checks in gui More...
 

Variables

static struct search_static_data search_data
 
struct gui_search_tableriscos_search_table = &search_table
 

Detailed Description

Free text search implementation.

Definition in file search.c.

Macro Definition Documentation

◆ DEFAULT_FLAGS

#define DEFAULT_FLAGS
Value:
(wimp_ICON_TEXT | wimp_ICON_FILLED | \
(wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT) | \
(wimp_COLOUR_WHITE << wimp_ICON_BG_COLOUR_SHIFT))

◆ RECENT_SEARCHES

#define RECENT_SEARCHES   8

Definition at line 45 of file search.c.

Function Documentation

◆ ro_gui_search_add_recent()

void ro_gui_search_add_recent ( const char *  search,
void *  p 
)

add search string to recent searches list

front is at liberty how to implement the bare notification should normally store a strdup() of the string in search_global_data.recent[]; core gives no guarantee of the integrity of the const char *

Parameters
searchstring search pattern
pthe pointer sent to search_verify_new()

Definition at line 205 of file search.c.

References dialog_search, ICON_SEARCH_MENU, RECENT_SEARCHES, search_static_data::recent_searches, ro_gui_search_prepare_menu(), ro_gui_set_icon_shaded_state(), ro_warn_user(), search_data, and search_static_data::search_insert.

Here is the call graph for this function:

◆ ro_gui_search_bw_searchable()

static bool ro_gui_search_bw_searchable ( struct browser_window bw)
static

Determine of the browser window is searchable.

Parameters
bwThe browser window to check.
Todo:
Should have content_is_searchable() api

Definition at line 269 of file search.c.

References browser_window_get_content(), content_get_type(), CONTENT_HTML, and CONTENT_TEXTPLAIN.

Referenced by ro_gui_search_prepare().

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

◆ ro_gui_search_click()

bool ro_gui_search_click ( wimp_pointer *  pointer)

Definition at line 157 of file search.c.

References browser_window_search(), browser_window_search_clear(), dialog_search, ICON_SEARCH_CASE_SENSITIVE, ICON_SEARCH_FIND_PREV, ICON_SEARCH_SHOW_ALL, ICON_SEARCH_TEXT, ro_gui_get_icon_selected_state(), ro_gui_get_icon_string(), ro_gui_search_update_flags(), search_data, SEARCH_FLAG_FORWARDS, SEARCH_FLAG_NONE, SEARCH_FLAG_SHOWALL, search_static_data::search_insert, and search_static_data::search_window.

Referenced by ro_gui_search_init().

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

◆ ro_gui_search_end()

void ro_gui_search_end ( wimp_w  w)

Ends the search.

Parameters
wthe search window handle (not used)

Definition at line 404 of file search.c.

References browser_window_search_clear(), search_data, and search_static_data::search_window.

Referenced by ro_gui_search_init().

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

◆ ro_gui_search_init()

void ro_gui_search_init ( void  )

◆ ro_gui_search_keypress()

bool ro_gui_search_keypress ( wimp_key *  key)

Handle keypresses in the search dialog.

Parameters
keywimp_key block
Returns
true if keypress handled, false otherwise

Definition at line 323 of file search.c.

References browser_window_search(), browser_window_search_clear(), dialog_search, ICON_SEARCH_CASE_SENSITIVE, ICON_SEARCH_TEXT, IS_WIMP_KEY, ro_gui_get_icon_selected_state(), ro_gui_get_icon_string(), ro_gui_search_set_back_state(), ro_gui_search_set_forward_state(), ro_gui_search_update_flags(), ro_gui_set_icon_selected_state(), search_data, SEARCH_FLAG_FORWARDS, SEARCH_FLAG_SHOWALL, search_static_data::search_insert, and search_static_data::search_window.

Referenced by ro_gui_search_init().

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

◆ ro_gui_search_menu_prepare()

bool ro_gui_search_menu_prepare ( wimp_w  w,
wimp_i  i,
wimp_menu *  menu,
wimp_pointer *  pointer 
)

Callback to prepare menus in the Search dialog.

At present, this only has to handle the previous search pop-up.

Parameters
wThe window handle owning the menu.
iThe icon handle owning the menu.
*menuThe menu to be prepared.
*pointerThe associated mouse click event block, or NULL on an Adjust-click re-opening.
Returns
true if the event was handled; false if not.

Definition at line 144 of file search.c.

References ICON_SEARCH_MENU, recent_search_menu, and ro_gui_search_prepare_menu().

Referenced by ro_gui_search_init().

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

◆ ro_gui_search_next()

bool ro_gui_search_next ( wimp_w  w)

Wrapper for the pressing of an OK button for wimp_event.

Returns
false, to indicate the window should not be closed

Definition at line 120 of file search.c.

References browser_window_search(), dialog_search, ICON_SEARCH_TEXT, ro_gui_get_icon_string(), ro_gui_search_update_flags(), search_data, SEARCH_FLAG_FORWARDS, search_static_data::search_insert, and search_static_data::search_window.

Referenced by ro_gui_search_init().

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

◆ ro_gui_search_prepare()

void ro_gui_search_prepare ( struct browser_window bw)

Open the search dialog.

Parameters
bwthe browser window to search

Definition at line 292 of file search.c.

References dialog_search, ICON_SEARCH_CASE_SENSITIVE, ICON_SEARCH_SHOW_ALL, ICON_SEARCH_TEXT, ro_gui_search_bw_searchable(), ro_gui_search_set_back_state(), ro_gui_search_set_forward_state(), ro_gui_search_set_status(), ro_gui_set_icon_selected_state(), ro_gui_set_icon_string(), ro_gui_wimp_event_memorise(), search_data, search_static_data::search_insert, and search_static_data::search_window.

Referenced by ro_gui_window_action_search(), and ro_gui_window_menu_warning().

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

◆ ro_gui_search_prepare_menu()

bool ro_gui_search_prepare_menu ( void  )

Definition at line 239 of file search.c.

References recent_search_menu, RECENT_SEARCHES, search_static_data::recent_searches, and search_data.

Referenced by ro_gui_search_add_recent(), and ro_gui_search_menu_prepare().

Here is the caller graph for this function:

◆ ro_gui_search_set_back_state()

void ro_gui_search_set_back_state ( bool  active,
void *  p 
)

activate search forwards button in gui

Parameters
activeactivate/inactivate
pthe pointer sent to search_verify_new() / search_create_context()

Definition at line 454 of file search.c.

References dialog_search, ICON_SEARCH_FIND_PREV, and ro_gui_set_icon_shaded_state().

Referenced by ro_gui_search_keypress(), and ro_gui_search_prepare().

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

◆ ro_gui_search_set_forward_state()

void ro_gui_search_set_forward_state ( bool  active,
void *  p 
)

activate search forwards button in gui

Parameters
activeactivate/inactivate
pthe pointer sent to search_verify_new() / search_create_context()

Definition at line 442 of file search.c.

References dialog_search, ICON_SEARCH_FIND_NEXT, and ro_gui_set_icon_shaded_state().

Referenced by ro_gui_search_keypress(), and ro_gui_search_prepare().

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

◆ ro_gui_search_set_hourglass()

void ro_gui_search_set_hourglass ( bool  active,
void *  p 
)

display hourglass while searching

Parameters
activestart/stop indicator
pthe pointer sent to search_verify_new() / search_create_context()

Definition at line 427 of file search.c.

◆ ro_gui_search_set_status()

void ro_gui_search_set_status ( bool  found,
void *  p 
)

Change the displayed search status.

Parameters
foundsearch pattern matched in text
pthe pointer sent to search_verify_new() / search_create_context()

Definition at line 415 of file search.c.

References dialog_search, ICON_SEARCH_STATUS, messages_get(), and ro_gui_set_icon_string().

Referenced by ro_gui_search_prepare().

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

◆ ro_gui_search_update_flags()

search_flags_t ro_gui_search_update_flags ( void  )

retrieve state of 'case sensitive', 'show all' checks in gui

Definition at line 463 of file search.c.

References dialog_search, ICON_SEARCH_CASE_SENSITIVE, ICON_SEARCH_SHOW_ALL, ro_gui_get_icon_selected_state(), SEARCH_FLAG_CASE_SENSITIVE, and SEARCH_FLAG_SHOWALL.

Referenced by ro_gui_search_click(), ro_gui_search_keypress(), and ro_gui_search_next().

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

◆ wimp_MENU()

static wimp_MENU ( RECENT_SEARCHES  )
static

Definition at line 56 of file search.c.

Variable Documentation

◆ riscos_search_table

struct gui_search_table* riscos_search_table = &search_table

Definition at line 85 of file search.c.

Referenced by main().

◆ search_data

struct search_static_data search_data
static