2004-08-06 00:32:00 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2004 John M Bell <jmb202@ecs.soton.ac.uk>
|
2006-07-14 01:57:35 +04:00
|
|
|
* Copyright 2005 Adrian Lees <adrianl@users.sourceforge.net>
|
2007-08-08 20:16:03 +04:00
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2004-08-06 00:32:00 +04:00
|
|
|
*/
|
|
|
|
|
2004-08-06 02:03:56 +04:00
|
|
|
/** \file
|
|
|
|
* Free text search (implementation)
|
|
|
|
*/
|
|
|
|
|
2008-07-27 03:42:24 +04:00
|
|
|
#include "utils/config.h"
|
|
|
|
|
2005-03-25 17:25:25 +03:00
|
|
|
#include <ctype.h>
|
2004-08-06 00:32:00 +04:00
|
|
|
#include <string.h>
|
2005-07-19 07:56:17 +04:00
|
|
|
#include "oslib/hourglass.h"
|
2004-08-06 00:32:00 +04:00
|
|
|
#include "oslib/wimp.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "utils/config.h"
|
|
|
|
#include "content/content.h"
|
2010-04-07 21:33:58 +04:00
|
|
|
#include "content/hlcache.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "desktop/browser.h"
|
|
|
|
#include "desktop/gui.h"
|
2012-08-22 15:22:58 +04:00
|
|
|
#include "desktop/browser_private.h"
|
2009-12-18 02:55:02 +03:00
|
|
|
#include "desktop/search.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "riscos/dialog.h"
|
|
|
|
#include "riscos/menus.h"
|
|
|
|
#include "riscos/wimp.h"
|
|
|
|
#include "riscos/wimp_event.h"
|
|
|
|
#include "utils/log.h"
|
|
|
|
#include "utils/messages.h"
|
|
|
|
#include "utils/utils.h"
|
2004-08-06 00:32:00 +04:00
|
|
|
|
2009-12-18 02:55:02 +03:00
|
|
|
#define RECENT_SEARCHES 8
|
2006-02-13 00:23:22 +03:00
|
|
|
|
2009-12-18 02:55:02 +03:00
|
|
|
struct search_static_data {
|
|
|
|
char *recent_searches[RECENT_SEARCHES];
|
|
|
|
bool search_insert;
|
|
|
|
struct browser_window *search_window;
|
2004-08-06 00:32:00 +04:00
|
|
|
};
|
|
|
|
|
2009-12-18 02:55:02 +03:00
|
|
|
static struct search_static_data search_data =
|
2014-05-31 01:52:22 +04:00
|
|
|
{ { NULL }, false, NULL };
|
2004-08-06 02:03:56 +04:00
|
|
|
|
2005-12-31 07:42:17 +03:00
|
|
|
static wimp_MENU(RECENT_SEARCHES) menu_recent;
|
|
|
|
wimp_menu *recent_search_menu = (wimp_menu *)&menu_recent;
|
|
|
|
#define DEFAULT_FLAGS (wimp_ICON_TEXT | wimp_ICON_FILLED | \
|
|
|
|
(wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT) | \
|
|
|
|
(wimp_COLOUR_WHITE << wimp_ICON_BG_COLOUR_SHIFT))
|
|
|
|
|
|
|
|
|
2007-03-27 01:09:25 +04:00
|
|
|
static void ro_gui_search_end(wimp_w w);
|
2005-12-31 07:42:17 +03:00
|
|
|
static bool ro_gui_search_next(wimp_w w);
|
2011-02-21 02:16:33 +03:00
|
|
|
static bool ro_gui_search_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
|
|
|
|
wimp_pointer *pointer);
|
|
|
|
static bool ro_gui_search_prepare_menu(void);
|
2005-12-31 07:42:17 +03:00
|
|
|
static bool ro_gui_search_click(wimp_pointer *pointer);
|
|
|
|
static bool ro_gui_search_keypress(wimp_key *key);
|
2009-12-18 02:55:02 +03:00
|
|
|
static search_flags_t ro_gui_search_update_flags(void);
|
|
|
|
static void ro_gui_search_set_forward_state(bool active, void *p);
|
|
|
|
static void ro_gui_search_set_back_state(bool active, void *p);
|
|
|
|
static void ro_gui_search_set_status(bool found, void *p);
|
|
|
|
static void ro_gui_search_set_hourglass(bool active, void *p);
|
|
|
|
static void ro_gui_search_add_recent(const char *string, void *p);
|
|
|
|
|
2014-03-19 02:32:52 +04:00
|
|
|
static struct gui_search_table search_table = {
|
2009-12-18 02:55:02 +03:00
|
|
|
ro_gui_search_set_status,
|
|
|
|
ro_gui_search_set_hourglass,
|
2014-03-19 02:32:52 +04:00
|
|
|
ro_gui_search_add_recent,
|
|
|
|
ro_gui_search_set_forward_state,
|
|
|
|
ro_gui_search_set_back_state,
|
2009-12-18 02:55:02 +03:00
|
|
|
};
|
2005-12-31 07:42:17 +03:00
|
|
|
|
2014-03-19 02:32:52 +04:00
|
|
|
struct gui_search_table *riscos_search_table = &search_table;
|
|
|
|
|
2007-03-27 01:09:25 +04:00
|
|
|
void ro_gui_search_init(void)
|
|
|
|
{
|
2005-12-31 07:42:17 +03:00
|
|
|
dialog_search = ro_gui_dialog_create("search");
|
|
|
|
ro_gui_wimp_event_register_keypress(dialog_search,
|
|
|
|
ro_gui_search_keypress);
|
|
|
|
ro_gui_wimp_event_register_close_window(dialog_search,
|
|
|
|
ro_gui_search_end);
|
2011-02-21 02:16:33 +03:00
|
|
|
ro_gui_wimp_event_register_menu_prepare(dialog_search,
|
|
|
|
ro_gui_search_menu_prepare);
|
2007-03-27 01:09:25 +04:00
|
|
|
ro_gui_wimp_event_register_menu_gright(dialog_search,
|
|
|
|
ICON_SEARCH_TEXT, ICON_SEARCH_MENU,
|
|
|
|
recent_search_menu);
|
|
|
|
ro_gui_wimp_event_register_text_field(dialog_search,
|
|
|
|
ICON_SEARCH_STATUS);
|
|
|
|
ro_gui_wimp_event_register_checkbox(dialog_search,
|
|
|
|
ICON_SEARCH_CASE_SENSITIVE);
|
2005-12-31 07:42:17 +03:00
|
|
|
ro_gui_wimp_event_register_mouse_click(dialog_search,
|
|
|
|
ro_gui_search_click);
|
|
|
|
ro_gui_wimp_event_register_ok(dialog_search, ICON_SEARCH_FIND_NEXT,
|
|
|
|
ro_gui_search_next);
|
|
|
|
ro_gui_wimp_event_register_cancel(dialog_search, ICON_SEARCH_CANCEL);
|
|
|
|
ro_gui_wimp_event_set_help_prefix(dialog_search, "HelpSearch");
|
|
|
|
|
|
|
|
recent_search_menu->title_data.indirected_text.text =
|
|
|
|
(char*)messages_get("Search");
|
|
|
|
ro_gui_menu_init_structure(recent_search_menu, RECENT_SEARCHES);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Wrapper for the pressing of an OK button for wimp_event.
|
|
|
|
*
|
|
|
|
* \return false, to indicate the window should not be closed
|
|
|
|
*/
|
2007-03-27 01:09:25 +04:00
|
|
|
bool ro_gui_search_next(wimp_w w)
|
|
|
|
{
|
2009-12-18 02:55:02 +03:00
|
|
|
search_data.search_insert = true;
|
2011-02-21 02:16:33 +03:00
|
|
|
search_flags_t flags = SEARCH_FLAG_FORWARDS |
|
2009-12-18 02:55:02 +03:00
|
|
|
ro_gui_search_update_flags();
|
2014-03-19 02:32:52 +04:00
|
|
|
browser_window_search(search_data.search_window, NULL, flags,
|
2013-05-07 17:41:40 +04:00
|
|
|
ro_gui_get_icon_string(dialog_search,
|
|
|
|
ICON_SEARCH_TEXT));
|
2005-12-31 07:42:17 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-02-21 02:16:33 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback to prepare menus in the Search dialog. At present, this
|
|
|
|
* only has to handle the previous search pop-up.
|
|
|
|
*
|
|
|
|
* \param w The window handle owning the menu.
|
|
|
|
* \param i The icon handle owning the menu.
|
|
|
|
* \param *menu The menu to be prepared.
|
|
|
|
* \param *pointer The associated mouse click event block, or NULL
|
|
|
|
* on an Adjust-click re-opening.
|
|
|
|
* \return true if the event was handled; false if not.
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool ro_gui_search_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
|
|
|
|
wimp_pointer *pointer)
|
|
|
|
{
|
|
|
|
if (menu != recent_search_menu || i != ICON_SEARCH_MENU)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (pointer != NULL)
|
|
|
|
return ro_gui_search_prepare_menu();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-27 01:09:25 +04:00
|
|
|
bool ro_gui_search_click(wimp_pointer *pointer)
|
|
|
|
{
|
2009-12-18 02:55:02 +03:00
|
|
|
search_flags_t flags;
|
2005-12-31 07:42:17 +03:00
|
|
|
switch (pointer->i) {
|
2007-03-27 01:09:25 +04:00
|
|
|
case ICON_SEARCH_FIND_PREV:
|
2009-12-18 02:55:02 +03:00
|
|
|
search_data.search_insert = true;
|
2011-02-21 02:16:33 +03:00
|
|
|
flags = ~SEARCH_FLAG_FORWARDS &
|
2009-12-18 02:55:02 +03:00
|
|
|
ro_gui_search_update_flags();
|
2014-03-19 02:32:52 +04:00
|
|
|
browser_window_search(search_data.search_window, NULL,
|
2013-05-07 17:41:40 +04:00
|
|
|
flags,
|
|
|
|
ro_gui_get_icon_string(dialog_search,
|
|
|
|
ICON_SEARCH_TEXT));
|
2005-12-31 07:42:17 +03:00
|
|
|
return true;
|
|
|
|
case ICON_SEARCH_CASE_SENSITIVE:
|
2011-02-21 02:16:33 +03:00
|
|
|
flags = SEARCH_FLAG_FORWARDS |
|
2009-12-18 02:55:02 +03:00
|
|
|
ro_gui_search_update_flags();
|
2014-03-19 02:32:52 +04:00
|
|
|
browser_window_search(search_data.search_window, NULL,
|
2013-05-07 17:41:40 +04:00
|
|
|
flags,
|
|
|
|
ro_gui_get_icon_string(dialog_search,
|
|
|
|
ICON_SEARCH_TEXT));
|
2005-12-31 07:42:17 +03:00
|
|
|
return true;
|
2006-02-13 00:23:22 +03:00
|
|
|
case ICON_SEARCH_SHOW_ALL:
|
2013-05-07 17:41:40 +04:00
|
|
|
flags = ro_gui_get_icon_selected_state(
|
|
|
|
pointer->w, pointer->i) ?
|
|
|
|
SEARCH_FLAG_SHOWALL : SEARCH_FLAG_NONE;
|
2014-03-19 02:32:52 +04:00
|
|
|
browser_window_search(search_data.search_window, NULL,
|
2013-05-07 17:41:40 +04:00
|
|
|
flags,
|
|
|
|
ro_gui_get_icon_string(dialog_search,
|
|
|
|
ICON_SEARCH_TEXT));
|
2006-02-13 00:23:22 +03:00
|
|
|
return true;
|
2005-12-31 07:42:17 +03:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-12-18 02:55:02 +03:00
|
|
|
/**
|
|
|
|
* 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 *
|
|
|
|
* \param string search pattern
|
|
|
|
* \param p the pointer sent to search_verify_new()
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_search_add_recent(const char *search, void *p)
|
2007-03-27 01:09:25 +04:00
|
|
|
{
|
2006-02-16 02:14:51 +03:00
|
|
|
char *tmp;
|
|
|
|
int i;
|
2005-12-31 07:42:17 +03:00
|
|
|
|
|
|
|
if ((search == NULL) || (search[0] == '\0'))
|
|
|
|
return;
|
|
|
|
|
2009-12-18 02:55:02 +03:00
|
|
|
if (!search_data.search_insert) {
|
|
|
|
free(search_data.recent_searches[0]);
|
|
|
|
search_data.recent_searches[0] = strdup(search);
|
2005-12-31 07:42:17 +03:00
|
|
|
ro_gui_search_prepare_menu();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-12-18 02:55:02 +03:00
|
|
|
if ((search_data.recent_searches[0] != NULL) &&
|
|
|
|
(!strcmp(search_data.recent_searches[0], search)))
|
2006-07-14 01:57:35 +04:00
|
|
|
return;
|
2005-12-31 07:42:17 +03:00
|
|
|
|
|
|
|
tmp = strdup(search);
|
|
|
|
if (!tmp) {
|
2007-03-27 01:09:25 +04:00
|
|
|
warn_user("NoMemory", 0);
|
|
|
|
return;
|
2005-12-31 07:42:17 +03:00
|
|
|
}
|
2009-12-18 02:55:02 +03:00
|
|
|
free(search_data.recent_searches[RECENT_SEARCHES - 1]);
|
2005-12-31 07:42:17 +03:00
|
|
|
for (i = RECENT_SEARCHES - 1; i > 0; i--)
|
2009-12-18 02:55:02 +03:00
|
|
|
search_data.recent_searches[i] = search_data.recent_searches[i - 1];
|
|
|
|
search_data.recent_searches[0] = tmp;
|
|
|
|
search_data.search_insert = false;
|
2006-07-14 01:57:35 +04:00
|
|
|
|
2005-12-31 07:42:17 +03:00
|
|
|
ro_gui_set_icon_shaded_state(dialog_search, ICON_SEARCH_MENU, false);
|
|
|
|
ro_gui_search_prepare_menu();
|
|
|
|
}
|
|
|
|
|
2007-03-27 01:09:25 +04:00
|
|
|
bool ro_gui_search_prepare_menu(void)
|
|
|
|
{
|
2005-12-31 07:42:17 +03:00
|
|
|
int i;
|
|
|
|
int suggestions = 0;
|
2006-07-14 01:57:35 +04:00
|
|
|
|
2005-12-31 07:42:17 +03:00
|
|
|
for (i = 0; i < RECENT_SEARCHES; i++)
|
2009-12-18 02:55:02 +03:00
|
|
|
if (search_data.recent_searches[i] != NULL)
|
2005-12-31 07:42:17 +03:00
|
|
|
suggestions++;
|
|
|
|
|
|
|
|
if (suggestions == 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for (i = 0; i < suggestions; i++) {
|
2005-12-31 08:17:44 +03:00
|
|
|
recent_search_menu->entries[i].menu_flags &= ~wimp_MENU_LAST;
|
2005-12-31 07:42:17 +03:00
|
|
|
recent_search_menu->entries[i].data.indirected_text.text =
|
2009-12-18 02:55:02 +03:00
|
|
|
search_data.recent_searches[i];
|
2005-12-31 07:42:17 +03:00
|
|
|
recent_search_menu->entries[i].data.indirected_text.size =
|
2009-12-18 02:55:02 +03:00
|
|
|
strlen(search_data.recent_searches[i]) + 1;
|
2005-12-31 07:42:17 +03:00
|
|
|
}
|
2007-03-27 01:09:25 +04:00
|
|
|
recent_search_menu->entries[suggestions - 1].menu_flags |=
|
|
|
|
wimp_MENU_LAST;
|
2005-12-31 07:42:17 +03:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2004-08-06 00:32:00 +04:00
|
|
|
|
2004-08-06 02:03:56 +04:00
|
|
|
/**
|
|
|
|
* Open the search dialog
|
|
|
|
*
|
2009-12-18 02:55:02 +03:00
|
|
|
* \param bw the browser window to search
|
2004-08-06 02:03:56 +04:00
|
|
|
*/
|
2009-12-18 02:55:02 +03:00
|
|
|
void ro_gui_search_prepare(struct browser_window *bw)
|
2004-08-06 02:03:56 +04:00
|
|
|
{
|
2010-04-07 21:33:58 +04:00
|
|
|
hlcache_handle *h;
|
2005-04-17 07:30:35 +04:00
|
|
|
|
2009-12-18 02:55:02 +03:00
|
|
|
assert(bw != NULL);
|
2004-08-06 02:03:56 +04:00
|
|
|
|
2010-04-07 21:33:58 +04:00
|
|
|
h = bw->current_content;
|
2006-02-16 02:14:51 +03:00
|
|
|
|
|
|
|
/* only handle html/textplain contents */
|
2010-04-07 21:33:58 +04:00
|
|
|
if ((!h) || (content_get_type(h) != CONTENT_HTML &&
|
|
|
|
content_get_type(h) != CONTENT_TEXTPLAIN))
|
2006-02-16 02:14:51 +03:00
|
|
|
return;
|
|
|
|
|
2009-12-18 02:55:02 +03:00
|
|
|
/* if the search dialogue is reopened over a new window, we may
|
2005-07-21 03:27:28 +04:00
|
|
|
need to cancel the previous search */
|
2009-12-18 02:55:02 +03:00
|
|
|
ro_gui_search_set_forward_state(true, bw);
|
|
|
|
ro_gui_search_set_back_state(true, bw);
|
|
|
|
|
|
|
|
search_data.search_window = bw;
|
2004-08-06 02:03:56 +04:00
|
|
|
|
2008-08-05 05:23:04 +04:00
|
|
|
ro_gui_set_icon_string(dialog_search, ICON_SEARCH_TEXT, "", true);
|
2004-08-06 02:03:56 +04:00
|
|
|
ro_gui_set_icon_selected_state(dialog_search,
|
|
|
|
ICON_SEARCH_CASE_SENSITIVE, false);
|
2006-02-16 02:14:51 +03:00
|
|
|
ro_gui_set_icon_selected_state(dialog_search,
|
|
|
|
ICON_SEARCH_SHOW_ALL, false);
|
2005-04-17 07:30:35 +04:00
|
|
|
|
2009-12-18 02:55:02 +03:00
|
|
|
ro_gui_search_set_status(true, NULL);
|
2005-07-19 07:56:17 +04:00
|
|
|
|
2005-12-31 07:42:17 +03:00
|
|
|
ro_gui_wimp_event_memorise(dialog_search);
|
2009-12-18 02:55:02 +03:00
|
|
|
search_data.search_insert = true;
|
2004-08-06 00:32:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2004-08-06 02:03:56 +04:00
|
|
|
* Handle keypresses in the search dialog
|
|
|
|
*
|
|
|
|
* \param key wimp_key block
|
|
|
|
* \return true if keypress handled, false otherwise
|
2004-08-06 00:32:00 +04:00
|
|
|
*/
|
2004-08-06 02:03:56 +04:00
|
|
|
bool ro_gui_search_keypress(wimp_key *key)
|
2004-08-06 00:32:00 +04:00
|
|
|
{
|
2004-08-06 02:03:56 +04:00
|
|
|
bool state;
|
2009-12-18 02:55:02 +03:00
|
|
|
search_flags_t flags;
|
2004-08-06 02:03:56 +04:00
|
|
|
|
|
|
|
switch (key->c) {
|
2013-05-07 17:41:40 +04:00
|
|
|
case 1: {
|
|
|
|
flags = ro_gui_search_update_flags()
|
|
|
|
^ SEARCH_FLAG_SHOWALL;
|
2014-03-19 02:32:52 +04:00
|
|
|
browser_window_search(search_data.search_window, NULL,
|
2013-05-07 17:41:40 +04:00
|
|
|
flags,
|
|
|
|
ro_gui_get_icon_string(dialog_search,
|
|
|
|
ICON_SEARCH_TEXT));
|
2006-02-13 00:23:22 +03:00
|
|
|
}
|
|
|
|
break;
|
2004-08-06 02:03:56 +04:00
|
|
|
case 9: /* ctrl i */
|
2007-03-27 01:09:25 +04:00
|
|
|
state = ro_gui_get_icon_selected_state(dialog_search,
|
|
|
|
ICON_SEARCH_CASE_SENSITIVE);
|
|
|
|
ro_gui_set_icon_selected_state(dialog_search,
|
|
|
|
ICON_SEARCH_CASE_SENSITIVE, !state);
|
2011-02-21 02:16:33 +03:00
|
|
|
flags = SEARCH_FLAG_FORWARDS |
|
2009-12-18 02:55:02 +03:00
|
|
|
ro_gui_search_update_flags();
|
2014-03-19 02:32:52 +04:00
|
|
|
browser_window_search(search_data.search_window, NULL,
|
2013-05-07 17:41:40 +04:00
|
|
|
flags,
|
|
|
|
ro_gui_get_icon_string(dialog_search,
|
|
|
|
ICON_SEARCH_TEXT));
|
2004-08-06 02:03:56 +04:00
|
|
|
return true;
|
2006-07-14 01:57:35 +04:00
|
|
|
case IS_WIMP_KEY | wimp_KEY_UP:
|
2009-12-18 02:55:02 +03:00
|
|
|
search_data.search_insert = true;
|
2011-02-21 02:16:33 +03:00
|
|
|
flags = ~SEARCH_FLAG_FORWARDS &
|
2009-12-18 02:55:02 +03:00
|
|
|
ro_gui_search_update_flags();
|
2014-03-19 02:32:52 +04:00
|
|
|
browser_window_search(search_data.search_window, NULL,
|
2013-05-07 17:41:40 +04:00
|
|
|
flags,
|
|
|
|
ro_gui_get_icon_string(dialog_search,
|
|
|
|
ICON_SEARCH_TEXT));
|
2005-04-18 03:32:09 +04:00
|
|
|
return true;
|
2006-07-14 01:57:35 +04:00
|
|
|
case IS_WIMP_KEY | wimp_KEY_DOWN:
|
2009-12-18 02:55:02 +03:00
|
|
|
search_data.search_insert = true;
|
2011-02-21 02:16:33 +03:00
|
|
|
flags = SEARCH_FLAG_FORWARDS |
|
2009-12-18 02:55:02 +03:00
|
|
|
ro_gui_search_update_flags();
|
2014-03-19 02:32:52 +04:00
|
|
|
browser_window_search(search_data.search_window, NULL,
|
2013-05-07 17:41:40 +04:00
|
|
|
flags,
|
|
|
|
ro_gui_get_icon_string(dialog_search,
|
|
|
|
ICON_SEARCH_TEXT));
|
2005-04-18 03:32:09 +04:00
|
|
|
return true;
|
2005-07-19 07:56:17 +04:00
|
|
|
|
|
|
|
default:
|
2007-03-27 01:09:25 +04:00
|
|
|
if (key->c == 21) {
|
|
|
|
/* ctrl+u means the user's starting
|
|
|
|
* a new search */
|
2013-05-07 17:41:40 +04:00
|
|
|
browser_window_search_clear(
|
2011-08-24 17:14:16 +04:00
|
|
|
search_data.search_window);
|
2009-12-18 02:55:02 +03:00
|
|
|
search_data.search_insert = true;
|
2007-03-27 01:09:25 +04:00
|
|
|
}
|
2005-07-19 07:56:17 +04:00
|
|
|
if (key->c == 8 || /* backspace */
|
|
|
|
key->c == 21 || /* ctrl u */
|
|
|
|
(key->c >= 0x20 && key->c <= 0x7f)) {
|
2011-02-21 02:16:33 +03:00
|
|
|
flags = SEARCH_FLAG_FORWARDS |
|
2009-12-18 02:55:02 +03:00
|
|
|
ro_gui_search_update_flags();
|
2011-02-21 02:16:33 +03:00
|
|
|
ro_gui_search_set_forward_state(true,
|
2009-12-18 02:55:02 +03:00
|
|
|
search_data.search_window);
|
|
|
|
ro_gui_search_set_back_state(true,
|
|
|
|
search_data.search_window);
|
2013-05-07 17:41:40 +04:00
|
|
|
browser_window_search(search_data.search_window,
|
2014-03-19 02:32:52 +04:00
|
|
|
NULL,
|
2013-05-07 17:41:40 +04:00
|
|
|
flags,
|
|
|
|
ro_gui_get_icon_string(
|
2009-12-18 02:55:02 +03:00
|
|
|
dialog_search,
|
|
|
|
ICON_SEARCH_TEXT));
|
2005-07-19 07:56:17 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
2004-08-06 02:03:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-12-18 02:55:02 +03:00
|
|
|
* Ends the search
|
|
|
|
* \param w the search window handle (not used)
|
2004-08-06 02:03:56 +04:00
|
|
|
*/
|
2005-12-31 07:42:17 +03:00
|
|
|
void ro_gui_search_end(wimp_w w)
|
2004-08-06 02:03:56 +04:00
|
|
|
{
|
2013-05-07 17:41:40 +04:00
|
|
|
browser_window_search_clear(search_data.search_window);
|
2005-03-25 17:25:25 +03:00
|
|
|
}
|
|
|
|
|
2004-08-06 00:32:00 +04:00
|
|
|
/**
|
2009-12-18 02:55:02 +03:00
|
|
|
* Change the displayed search status.
|
|
|
|
* \param found search pattern matched in text
|
|
|
|
* \param p the pointer sent to search_verify_new() / search_create_context()
|
|
|
|
*/
|
2004-08-06 00:32:00 +04:00
|
|
|
|
2009-12-18 02:55:02 +03:00
|
|
|
void ro_gui_search_set_status(bool found, void *p)
|
2006-02-16 02:14:51 +03:00
|
|
|
{
|
2009-12-18 02:55:02 +03:00
|
|
|
ro_gui_set_icon_string(dialog_search, ICON_SEARCH_STATUS, found ? "" :
|
|
|
|
messages_get("NotFound"), true);
|
2006-02-16 02:14:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-12-18 02:55:02 +03:00
|
|
|
* display hourglass while searching
|
|
|
|
* \param active start/stop indicator
|
|
|
|
* \param p the pointer sent to search_verify_new() / search_create_context()
|
|
|
|
*/
|
2006-02-16 02:14:51 +03:00
|
|
|
|
2009-12-18 02:55:02 +03:00
|
|
|
void ro_gui_search_set_hourglass(bool active, void *p)
|
2006-02-16 02:14:51 +03:00
|
|
|
{
|
2009-12-18 02:55:02 +03:00
|
|
|
if (active)
|
|
|
|
xhourglass_on();
|
2006-02-16 02:14:51 +03:00
|
|
|
|
|
|
|
else
|
2009-12-18 02:55:02 +03:00
|
|
|
xhourglass_off();
|
2006-02-16 02:14:51 +03:00
|
|
|
}
|
|
|
|
|
2005-04-17 07:30:35 +04:00
|
|
|
/**
|
2009-12-18 02:55:02 +03:00
|
|
|
* activate search forwards button in gui
|
|
|
|
* \param active activate/inactivate
|
|
|
|
* \param p the pointer sent to search_verify_new() / search_create_context()
|
|
|
|
*/
|
2005-04-17 07:30:35 +04:00
|
|
|
|
2009-12-18 02:55:02 +03:00
|
|
|
void ro_gui_search_set_forward_state(bool active, void *p)
|
2005-04-17 07:30:35 +04:00
|
|
|
{
|
2011-02-21 02:16:33 +03:00
|
|
|
ro_gui_set_icon_shaded_state(dialog_search, ICON_SEARCH_FIND_NEXT,
|
2009-12-18 02:55:02 +03:00
|
|
|
!active);
|
2005-04-17 07:30:35 +04:00
|
|
|
}
|
|
|
|
|
2006-02-13 00:23:22 +03:00
|
|
|
/**
|
2009-12-18 02:55:02 +03:00
|
|
|
* activate search forwards button in gui
|
|
|
|
* \param active activate/inactivate
|
|
|
|
* \param p the pointer sent to search_verify_new() / search_create_context()
|
|
|
|
*/
|
2006-02-13 00:23:22 +03:00
|
|
|
|
2009-12-18 02:55:02 +03:00
|
|
|
void ro_gui_search_set_back_state(bool active, void *p)
|
2006-02-13 00:23:22 +03:00
|
|
|
{
|
2009-12-18 02:55:02 +03:00
|
|
|
ro_gui_set_icon_shaded_state(dialog_search, ICON_SEARCH_FIND_PREV,
|
|
|
|
!active);
|
2006-02-13 00:23:22 +03:00
|
|
|
}
|
|
|
|
|
2005-04-18 03:32:09 +04:00
|
|
|
/**
|
2009-12-18 02:55:02 +03:00
|
|
|
* retrieve state of 'case sensitive', 'show all' checks in gui
|
|
|
|
*/
|
|
|
|
search_flags_t ro_gui_search_update_flags(void)
|
2005-04-18 03:32:09 +04:00
|
|
|
{
|
2009-12-18 02:55:02 +03:00
|
|
|
search_flags_t flags;
|
|
|
|
flags = 0 | (ro_gui_get_icon_selected_state(dialog_search,
|
|
|
|
ICON_SEARCH_CASE_SENSITIVE) ?
|
|
|
|
SEARCH_FLAG_CASE_SENSITIVE : 0) |
|
|
|
|
(ro_gui_get_icon_selected_state(dialog_search,
|
|
|
|
ICON_SEARCH_SHOW_ALL) ? SEARCH_FLAG_SHOWALL : 0);
|
|
|
|
return flags;
|
2005-04-18 03:32:09 +04:00
|
|
|
}
|
|
|
|
|