aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/findbar.cc31
-rw-r--r--src/findbar.hh3
-rw-r--r--src/uicmd.cc6
-rw-r--r--src/uicmd.hh3
4 files changed, 34 insertions, 9 deletions
diff --git a/src/findbar.cc b/src/findbar.cc
index 5d1c6245..ea1c80f1 100644
--- a/src/findbar.cc
+++ b/src/findbar.cc
@@ -63,7 +63,22 @@ void Findbar::search_cb(Widget *, void *vfb)
if (key[0] != '\0')
a_UIcmd_findtext_search(a_UIcmd_get_bw_by_widget(fb),
- key, case_sens);
+ key, case_sens, false);
+}
+
+/*
+ * Find previous occurrence of input key
+ */
+void Findbar::searchBackwards_cb(Widget *, void *vfb)
+{
+ Findbar *fb = (Findbar *)vfb;
+ const char *key = fb->i->text();
+ bool case_sens = fb->check_btn->value();
+
+ if (key[0] != '\0') {
+ a_UIcmd_findtext_search(a_UIcmd_get_bw_by_widget(fb),
+ key, case_sens, true);
+ }
}
/*
@@ -96,7 +111,7 @@ Findbar::Findbar(int width, int height) :
int button_width = 70;
int gap = 2;
int border = 2;
- int input_width = width - (2 * border + 3 * (button_width + gap));
+ int input_width = width - (2 * border + 4 * (button_width + gap));
int x = border;
height -= 2 * border;
@@ -121,15 +136,23 @@ Findbar::Findbar(int width, int height) :
i->clear_tab_to_focus();
i->set_click_to_focus();
- // TODO: search previous would be nice
next_btn = new HighlightButton(x, border, button_width, height, "Next");
x += button_width + gap;
- next_btn->tooltip("Find next occurrence of the search phrase");
+ next_btn->tooltip("Find next occurrence of the search phrase\n"
+ "shortcut: Enter");
next_btn->add_shortcut(ReturnKey);
next_btn->add_shortcut(KeypadEnter);
next_btn->callback(search_cb, this);
next_btn->clear_tab_to_focus();
+ prev_btn= new HighlightButton(x, border, button_width, height, "Previous");
+ prev_btn->tooltip("Find previous occurrence of the search phrase\n"
+ "shortcut: Shift+Enter");
+ prev_btn->add_shortcut(SHIFT+ReturnKey);
+ prev_btn->callback(searchBackwards_cb, this);
+ prev_btn->clear_tab_to_focus();
+ x += button_width + gap;
+
check_btn = new CheckButton(x, border, 2*button_width, height,
"Case-sensitive");
check_btn->clear_tab_to_focus();
diff --git a/src/findbar.hh b/src/findbar.hh
index 1e8c8d66..90982ffd 100644
--- a/src/findbar.hh
+++ b/src/findbar.hh
@@ -16,12 +16,13 @@ using namespace fltk;
*/
class Findbar : public Group {
Button *clrb;
- HighlightButton *hide_btn, *next_btn;
+ HighlightButton *hide_btn, *next_btn, *prev_btn;
CheckButton *check_btn;
xpmImage *hideImg;
Input *i;
static void search_cb (Widget *, void *);
+ static void searchBackwards_cb (Widget *, void *);
static void search_cb2 (Widget *, void *);
static void hide_cb (Widget *, void *);
diff --git a/src/uicmd.cc b/src/uicmd.cc
index 75d6336e..620669af 100644
--- a/src/uicmd.cc
+++ b/src/uicmd.cc
@@ -948,13 +948,13 @@ void a_UIcmd_fullscreen_toggle(BrowserWindow *bw)
}
/*
- * Search for next occurrence of key.
+ * Search for next/previous occurrence of key.
*/
-void a_UIcmd_findtext_search(BrowserWindow *bw, const char *key, int case_sens)
+void a_UIcmd_findtext_search(BrowserWindow *bw, const char *key, int case_sens, int backwards)
{
Layout *l = (Layout *)bw->render_layout;
- switch (l->search(key, case_sens)) {
+ switch (l->search(key, case_sens, backwards)) {
case FindtextState::RESTART:
a_UIcmd_set_msg(bw, "No further occurrences of \"%s\". "
"Restarting from the top.", key);
diff --git a/src/uicmd.hh b/src/uicmd.hh
index ca5b7cc5..b08b4f8d 100644
--- a/src/uicmd.hh
+++ b/src/uicmd.hh
@@ -34,7 +34,8 @@ void a_UIcmd_book(void *vbw);
void a_UIcmd_add_bookmark(BrowserWindow *bw, const DilloUrl *url);
void a_UIcmd_fullscreen_toggle(BrowserWindow *bw);
void a_UIcmd_findtext_dialog(BrowserWindow *bw);
-void a_UIcmd_findtext_search(BrowserWindow *bw,const char *key,int case_sens);
+void a_UIcmd_findtext_search(BrowserWindow *bw,const char *key,int case_sens,
+ int backwards);
void a_UIcmd_findtext_reset(BrowserWindow *bw);
void a_UIcmd_focus_main_area(BrowserWindow *bw);
void a_UIcmd_focus_location(void *vbw);