I'm not much of a drawing/gui person, but it's hard not being able to search pages, so I gave it a try (attached). - If you hit ^Q on this window or the page source or page bugs windows, dillo will crash because it assumes it's closing a bw. - I didn't want a title bar, and I didn't want it to be able to outlive its bw, but I didn't know what to do about it. - If searching scrolls the window, highlighting isn't undone properly. (If you search for something like "a", the last instance on each line will remain highlighted) *plays with it a bit more* Maybe it's good to have a title bar after all. It's easier to move out of the way than the 0.8.x one was...
Very nice! I was text search a lot. What about incremental searching as you type? I don't mind the title bar... Cheers, Johannes On Fri, Nov 16, 2007 at 04:22:01AM +0000, place wrote:
I'm not much of a drawing/gui person, but it's hard not being able to search pages, so I gave it a try (attached).
- If you hit ^Q on this window or the page source or page bugs windows, dillo will crash because it assumes it's closing a bw.
- I didn't want a title bar, and I didn't want it to be able to outlive its bw, but I didn't know what to do about it.
- If searching scrolls the window, highlighting isn't undone properly. (If you search for something like "a", the last instance on each line will remain highlighted)
*plays with it a bit more*
Maybe it's good to have a title bar after all. It's easier to move out of the way than the 0.8.x one was...
diff -pur dillo2/src/dialog.cc dillo2-cur/src/dialog.cc --- dillo2/src/dialog.cc 2007-11-07 05:03:53.000000000 +0000 +++ dillo2-cur/src/dialog.cc 2007-11-16 03:30:20.000000000 +0000 @@ -11,22 +11,26 @@
// UI dialogs
+#include <fltk/events.h> // for the unfortunate (temporary?) event key testing #include <fltk/Window.h> #include <fltk/ask.h> #include <fltk/file_chooser.h> #include <fltk/TextBuffer.h> +#include <fltk/Input.h> +#include <fltk/CheckButton.h> #include <fltk/ReturnButton.h> #include <fltk/TextDisplay.h>
#include "dialog.hh" #include "misc.h" +#include "uicmd.hh"
using namespace fltk;
/* - * Callback for the text window dialog. + * Close dialog window. */ -void text_window_cb(Widget *, void *vwin) +static void window_close_cb(Widget *, void *vwin) { Window *window = (Window*)vwin;
@@ -107,10 +111,91 @@ void a_Dialog_text_window(const char *tx td->buffer(text_buf);
ReturnButton *b = new ReturnButton (0, wh-bh, ww, bh, "Close"); - b->callback(text_window_cb, window); + b->callback(window_close_cb, window);
window->resizable(window); window->end(); window->show(); }
+/* + * Dialog to find text in page. + */ +class TextFinder : public Window { +public: + TextFinder(int ww, int wh, BrowserWindow *bw); + BrowserWindow *bw; + Input *i; + CheckButton *cb; + ReturnButton *findb; + Button *clrb; + Button *clsb; +}; + +/* + * Find next occurrence of input key + */ +static void findtext_search_cb(Widget *, void *vtf) +{ + TextFinder *tf = (TextFinder *)vtf; + const char *key = tf->i->value(); + bool case_sens = tf->cb->value(); + + /* + * Somehow fltk even regards the first loss of focus for the + * window as a WHEN_ENTER_KEY_ALWAYS event. + */ + int e = event_key(); + if ((e != ReturnKey) && (e != LeftButton)) + return; + + if (key[0] != '\0') + a_UIcmd_findtext_search(tf->bw, key, case_sens); + +} + +/* + * Reset search state + */ +static void findtext_clear_cb(Widget *, void *vtf) +{ + TextFinder *tf = (TextFinder *)vtf; + tf->i->value(""); + a_UIcmd_findtext_reset(tf->bw); +} + +/* + * Construct text search window + */ +TextFinder::TextFinder(int ww, int wh, BrowserWindow *bw) : + Window(ww, wh, "unwanted title") +{ + int button_width = 70, ih = 35, bh = 30, gap = 10; + + this->bw = bw; + + begin(); + i = new Input(0, 0, ww, ih); + i->when(WHEN_ENTER_KEY_ALWAYS); + i->callback(findtext_search_cb, this); + + cb = new CheckButton(0, ih, ww, wh-ih-bh, "Case-sensitive"); + + findb = new ReturnButton(gap, wh-bh, button_width, bh, "Find"); + findb->callback(findtext_search_cb, this); + + clrb = new Button(button_width+2*gap, wh-bh, button_width, bh, "Clear"); + clrb->callback(findtext_clear_cb, this); + + clsb = new Button(2*button_width+3*gap, wh-bh, button_width, bh, "Close"); + clsb->callback(window_close_cb, this); + end(); + + hotspot(i); // place input widget beneath the cursor +} + +void a_Dialog_findtext(BrowserWindow *bw) +{ + TextFinder *tf = new TextFinder(250, 90, bw); + tf->show(); +} diff -pur dillo2/src/dialog.hh dillo2-cur/src/dialog.hh --- dillo2/src/dialog.hh 2007-11-08 19:50:20.000000000 +0000 +++ dillo2-cur/src/dialog.hh 2007-11-16 03:00:01.000000000 +0000 @@ -1,6 +1,8 @@ #ifndef __DIALOG_HH__ #define __DIALOG_HH__
+#include "bw.h" + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ @@ -14,7 +16,7 @@ const char *a_Dialog_save_file(const cha char *a_Dialog_open_file(const char *msg, const char *pattern, const char *fname); void a_Dialog_text_window(const char *txt, const char *title); - +void a_Dialog_findtext(BrowserWindow *bw);
#ifdef __cplusplus } diff -pur dillo2/src/menu.cc dillo2-cur/src/menu.cc --- dillo2/src/menu.cc 2007-11-14 22:07:49.000000000 +0000 +++ dillo2-cur/src/menu.cc 2007-11-16 02:09:24.000000000 +0000 @@ -115,7 +115,8 @@ static void Menu_add_bookmark_cb(Widget* */ static void Menu_find_text_cb(Widget* ) { - a_UIcmd_fullscreen_toggle(popup_bw); +// a_UIcmd_fullscreen_toggle(popup_bw); + a_UIcmd_findtext_dialog(popup_bw); }
/* diff -pur dillo2/src/uicmd.cc dillo2-cur/src/uicmd.cc --- dillo2/src/uicmd.cc 2007-11-14 22:07:49.000000000 +0000 +++ dillo2-cur/src/uicmd.cc 2007-11-16 03:03:19.000000000 +0000 @@ -696,3 +696,43 @@ void a_UIcmd_fullscreen_toggle(BrowserWi BW2UI(bw)->fullscreen_toggle(); }
+/* + * Open the text search dialog. + */ +void a_UIcmd_findtext_dialog(BrowserWindow *bw) +{ + a_Dialog_findtext(bw); +} + +/* + * Search for next occurrence of key. + */ +void a_UIcmd_findtext_search(BrowserWindow *bw, const char *key, int case_sens) +{ + Layout *l = (Layout *)bw->render_layout; + + switch (l->search(key, case_sens)) { + case FindtextState::RESTART: + a_UIcmd_set_msg(bw, "No further occurrences of \"%s\". " + "Restarting from the top.", key); + break; + case FindtextState::NOT_FOUND: + a_UIcmd_set_msg(bw, "\"%s\" not found.", key); + break; + case FindtextState::SUCCESS: + default: + a_UIcmd_set_msg(bw, ""); + } +} + +/* + * Reset text search state. + */ +void a_UIcmd_findtext_reset(BrowserWindow *bw) +{ + Layout *l = (Layout *)bw->render_layout; + l->resetSearch(); + + a_UIcmd_set_msg(bw, ""); +} + diff -pur dillo2/src/uicmd.hh dillo2-cur/src/uicmd.hh --- dillo2/src/uicmd.hh 2007-11-14 22:07:49.000000000 +0000 +++ dillo2-cur/src/uicmd.hh 2007-11-16 02:37:32.000000000 +0000 @@ -27,6 +27,9 @@ void a_UIcmd_search_dialog(void *vbw); 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_reset(BrowserWindow *bw); void a_UIcmd_page_popup(void *vbw, const DilloUrl *url, const char *bugs_txt, int prefs_load_images); void a_UIcmd_link_popup(void *vbw, const DilloUrl *url);
_______________________________________________ Dillo-dev mailing list Dillo-dev@dillo.org http://lists.auriga.wearlab.de/cgi-bin/mailman/listinfo/dillo-dev
Johannes wrote:
Very nice! I was text search a lot. What about incremental searching as you type? I don't mind the title bar...
Hmm... I'd have to modify findtext.cc some... I may get around to it at some point here, though I'm feeling the need to look into what's going on with redirection and gzip, so if anybody else gets there first, it'll be fine with me! :) If nothing else, it would be nice to change the behavior so that changing the search key doesn't restart the search from the top of the document.
On Fri, Nov 16, 2007 at 07:10:48PM +0000, place wrote:
Johannes wrote:
Very nice! I was text search a lot. What about incremental searching as you type? I don't mind the title bar...
Hmm... I'd have to modify findtext.cc some... I may get around to it at some point here, though I'm feeling the need to look into what's going on with redirection and gzip, so if anybody else gets there first, it'll be fine with me! :)
I was thinking about something like: diff -r f18e37a8e3ac src/dialog.cc --- a/src/dialog.cc Fri Nov 16 20:25:11 2007 +0100 +++ b/src/dialog.cc Fri Nov 16 20:27:18 2007 +0100 @@ -141,14 +141,6 @@ static void findtext_search_cb(Widget *, const char *key = tf->i->value(); bool case_sens = tf->cb->value(); - /* - * Somehow fltk even regards the first loss of focus for the - * window as a WHEN_ENTER_KEY_ALWAYS event. - */ - int e = event_key(); - if ((e != ReturnKey) && (e != LeftButton)) - return; - if (key[0] != '\0') a_UIcmd_findtext_search(tf->bw, key, case_sens); @@ -176,7 +168,7 @@ TextFinder::TextFinder(int ww, int wh, B begin(); i = new Input(0, 0, ww, ih); - i->when(WHEN_ENTER_KEY_ALWAYS); + i->when(WHEN_CHANGED); i->callback(findtext_search_cb, this); cb = new CheckButton(0, ih, ww, wh-ih-bh, "Case-sensitive"); on top of your patch of course. Works for me. Cheers, Johannes
Johannes wrote:
On Fri, Nov 16, 2007 at 07:10:48PM +0000, place wrote:
Johannes wrote:
Very nice! I was text search a lot. What about incremental searching as you type? I don't mind the title bar...
Hmm... I'd have to modify findtext.cc some... I may get around to it at some point here, though I'm feeling the need to look into what's going on with redirection and gzip, so if anybody else gets there first, it'll be fine with me! :)
I was thinking about something like:
diff -r f18e37a8e3ac src/dialog.cc --- a/src/dialog.cc Fri Nov 16 20:25:11 2007 +0100 +++ b/src/dialog.cc Fri Nov 16 20:27:18 2007 +0100 @@ -141,14 +141,6 @@ static void findtext_search_cb(Widget *, const char *key = tf->i->value(); bool case_sens = tf->cb->value();
- /* - * Somehow fltk even regards the first loss of focus for the - * window as a WHEN_ENTER_KEY_ALWAYS event. - */ - int e = event_key(); - if ((e != ReturnKey) && (e != LeftButton)) - return; - if (key[0] != '\0') a_UIcmd_findtext_search(tf->bw, key, case_sens);
@@ -176,7 +168,7 @@ TextFinder::TextFinder(int ww, int wh, B
begin(); i = new Input(0, 0, ww, ih); - i->when(WHEN_ENTER_KEY_ALWAYS); + i->when(WHEN_CHANGED); i->callback(findtext_search_cb, this);
cb = new CheckButton(0, ih, ww, wh-ih-bh, "Case-sensitive");
on top of your patch of course. Works for me.
I had tried that before replying earlier, and I was happy at first, but then after I hit Enter a few times on the final string, I was disappointed when I found backspace made the search go to the top of the page again. To me it felt like it should've been relative to where I found myself the last time I hit enter. I don't make much use of anything with incremental search, though, so I don't know what the standard behavior is.
On Fri, Nov 16, 2007 at 08:12:17PM +0000, place wrote:
Johannes wrote:
On Fri, Nov 16, 2007 at 07:10:48PM +0000, place wrote:
Johannes wrote:
Very nice! I was text search a lot. What about incremental searching as you type? I don't mind the title bar...
Hmm... I'd have to modify findtext.cc some... I may get around to it at some point here, though I'm feeling the need to look into what's going on with redirection and gzip, so if anybody else gets there first, it'll be fine with me! :)
I was thinking about something like:
diff -r f18e37a8e3ac src/dialog.cc --- a/src/dialog.cc Fri Nov 16 20:25:11 2007 +0100 +++ b/src/dialog.cc Fri Nov 16 20:27:18 2007 +0100 @@ -141,14 +141,6 @@ static void findtext_search_cb(Widget *, const char *key = tf->i->value(); bool case_sens = tf->cb->value();
- /* - * Somehow fltk even regards the first loss of focus for the - * window as a WHEN_ENTER_KEY_ALWAYS event. - */ - int e = event_key(); - if ((e != ReturnKey) && (e != LeftButton)) - return; - if (key[0] != '\0') a_UIcmd_findtext_search(tf->bw, key, case_sens);
@@ -176,7 +168,7 @@ TextFinder::TextFinder(int ww, int wh, B
begin(); i = new Input(0, 0, ww, ih); - i->when(WHEN_ENTER_KEY_ALWAYS); + i->when(WHEN_CHANGED); i->callback(findtext_search_cb, this);
cb = new CheckButton(0, ih, ww, wh-ih-bh, "Case-sensitive");
on top of your patch of course. Works for me.
I had tried that before replying earlier, and I was happy at first, but then after I hit Enter a few times on the final string, I was disappointed when I found backspace made the search go to the top of the page again. To me it felt like it should've been relative to where I found myself the last time I hit enter. I don't make much use of anything with incremental search, though, so I don't know what the standard behavior is.
Though I think the current behaviour is consistent, I understand your concern. Firefox never goes back when you shorten the search string even if you have not yet hit enter. But I think that's bad if you just mistyped the search string and want to correct it. Johannes
_______________________________________________ Dillo-dev mailing list Dillo-dev@dillo.org http://lists.auriga.wearlab.de/cgi-bin/mailman/listinfo/dillo-dev
On Fri, Nov 16, 2007 at 08:12:17PM +0000, place wrote:
Johannes wrote:
On Fri, Nov 16, 2007 at 07:10:48PM +0000, place wrote:
Johannes wrote:
Very nice! I was text search a lot. What about incremental searching as you type? I don't mind the title bar...
Hmm... I'd have to modify findtext.cc some... I may get around to it at some point here, though I'm feeling the need to look into what's going on with redirection and gzip, so if anybody else gets there first, it'll be fine with me! :)
I was thinking about something like:
diff -r f18e37a8e3ac src/dialog.cc --- a/src/dialog.cc Fri Nov 16 20:25:11 2007 +0100 +++ b/src/dialog.cc Fri Nov 16 20:27:18 2007 +0100 @@ -141,14 +141,6 @@ static void findtext_search_cb(Widget *, const char *key = tf->i->value(); bool case_sens = tf->cb->value();
- /* - * Somehow fltk even regards the first loss of focus for the - * window as a WHEN_ENTER_KEY_ALWAYS event. - */ - int e = event_key(); - if ((e != ReturnKey) && (e != LeftButton)) - return; - if (key[0] != '\0') a_UIcmd_findtext_search(tf->bw, key, case_sens);
@@ -176,7 +168,7 @@ TextFinder::TextFinder(int ww, int wh, B
begin(); i = new Input(0, 0, ww, ih); - i->when(WHEN_ENTER_KEY_ALWAYS); + i->when(WHEN_CHANGED); i->callback(findtext_search_cb, this);
cb = new CheckButton(0, ih, ww, wh-ih-bh, "Case-sensitive");
on top of your patch of course. Works for me.
I had tried that before replying earlier, and I was happy at first, but then after I hit Enter a few times on the final string, I was disappointed when I found backspace made the search go to the top of the page again. To me it felt like it should've been relative to where I found myself the last time I hit enter. I don't make much use of anything with incremental search, though, so I don't know what the standard behavior is.
Though I think the current behaviour is consistent, I understand your concern. Firefox never goes back when you shorten the search string even if you have not yet hit enter. But I think that's bad if you just mistyped the search string and want to correct it.
That's true. I guess it just caught me by surprise.
Hi, On Fri, Nov 16, 2007 at 04:22:01AM +0000, place wrote:
I'm not much of a drawing/gui person, but it's hard not being able to search pages, so I gave it a try (attached).
Good, I'm giving it a review.
- If you hit ^Q on this window or the page source or page bugs windows, dillo will crash because it assumes it's closing a bw.
Fixed in CVS. Funny how Ctrl+n from a search window produced a small dialog-sized bw!
- I didn't want a title bar, and I didn't want it to be able to outlive its bw, but I didn't know what to do about it.
- If searching scrolls the window, highlighting isn't undone properly. (If you search for something like "a", the last instance on each line will remain highlighted)
*plays with it a bit more*
Maybe it's good to have a title bar after all. It's easier to move out of the way than the 0.8.x one was...
Checking patch now... -- Cheers Jorge.-
Hi, On Fri, Nov 16, 2007 at 04:22:01AM +0000, place wrote:
I'm not much of a drawing/gui person, but it's hard not being able to search pages, so I gave it a try (attached).
- If you hit ^Q on this window or the page source or page bugs windows, dillo will crash because it assumes it's closing a bw.
Already fixed.
- I didn't want a title bar, and I didn't want it to be able to outlive its bw, but I didn't know what to do about it.
- If searching scrolls the window, highlighting isn't undone properly. (If you search for something like "a", the last instance on each line will remain highlighted)
Well, my idea was to make the Find-text widget similar to what Firefox has (a row above the status bar that appears on request). With Enter bound to "search next", Shift-Enter to "search prev" and a few buttons/widgets for the usual "case insensitive" option & friends. As it was taking too much time (and I didn't find a way to do it either with or without Johannes patch), I decided to commit the patch "as is", and not to delay anymore. The above-status-bar widget solves some problems, for instance: - the dialog window covering the highlighted word. - dependencies (as including uicmd.hh and bw.hh from dialog) It looks like the FltkViewport is not behaving as a native FLTK widget and that either some ad-hoc bindings are required, or to make it behave as native FLTK, at least for parent Group resizes. BTW, formerly "full screen" was bound to Ctrl-F (which is the shortcut for find text), now it's bound to Ctrl-Space. Why? Because I haven't found how to detect and handle the double-click event, cleanly from the UI. :-) Any help is appreciatted! :) -- Cheers Jorge.-
participants (3)
-
jcid@dillo.org
-
Johannes.Hofmann@gmx.de
-
place@gobigwest.com