From dbee69230fb37763af7372d2f687d4129df61b6a Mon Sep 17 00:00:00 2001 From: freesource Date: Wed, 29 Aug 2001 03:50:31 +0000 Subject: [PATCH] Cool, that should cover it for the ssearch for now. It has netscape-like behavior with some konqueror-like enhancements. --- BootRoot/YardBox.pm | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/BootRoot/YardBox.pm b/BootRoot/YardBox.pm index b4a9cb5..db8667f 100644 --- a/BootRoot/YardBox.pm +++ b/BootRoot/YardBox.pm @@ -1181,7 +1181,7 @@ sub search { #_______________________________________ # Search button - my ($keywords, $old_keywords); + my ($keywords, $old_keywords, $before_offset); my ($tmp_ct, $tmp_k); my $submit_b = button(0,1,3,4,"Search",$table_search); @@ -1196,6 +1196,10 @@ sub search { $submit_b->grab_default; $submit_b->signal_connect( "clicked", sub { my $keywords = $search1->get_text(); + $before_offset = $offset if $offset != -1; + if ($old_keywords ne $keywords) { + undef $before_offset; + } # rindex if ($search_backwards->active) { @@ -1229,6 +1233,15 @@ sub search { $length = $length + $offset; $text->select_region($offset, $length); } + + # Here is an initial search and nothing is found + if (!$before_offset && $offset == -1) { + error_window("Search string \'$keywords\' not found."); + undef $offset; + undef $before_offset; + return; + } + } else { $offset = $offset - 1; @@ -1312,6 +1325,14 @@ sub search { $length = $length + $offset; $text->select_region($offset, $length); } + + # Here is an initial search and nothing is found + if (!$before_offset && $offset == -1) { + error_window("Search string \'$keywords\' not found."); + undef $offset; + undef $before_offset; + return; + } } else { $offset = $offset + 1; @@ -1343,7 +1364,26 @@ sub search { $length = $length + $offset; $text->select_region($offset,$length); } + elsif (!$before_offset && $offset == -1) { + # Here is a continued search and nothing is found + # We want the question_window to come up first + # Then pop this error box. + question_window("End of document reached;" + . " continue from beginning?", + $search_window,$submit_b, + length($changed_text_from_template)); + $before_offset = -100; + } + # The previous elsif continues. + elsif ($before_offset && $before_offset == -100) { + error_window("Search string \'$keywords\' not" . + " found."); + undef $offset; + undef $before_offset; + return; + } else { + question_window("End of document reached;" . " continue from beginning?", $search_window,$submit_b, @@ -1353,7 +1393,6 @@ sub search { } $old_keywords = $keywords; - print "$offset\n"; } );