Browse Source

This makes the insensitive search more effecient by not continuously invocating

tr///.
master
freesource 24 years ago
parent
commit
a43ab55b66
  1. 37
      BootRoot/YardBox.pm

37
BootRoot/YardBox.pm

@ -1173,6 +1173,8 @@ sub search {
# Search button # Search button
my ($keywords, $old_keywords, $offset); my ($keywords, $old_keywords, $offset);
my ($tmp_ct, $tmp_k);
my $submit_b = button(0,1,3,4,"Search",$table_search); my $submit_b = button(0,1,3,4,"Search",$table_search);
$search1->signal_connect("key_press_event", sub { $search1->signal_connect("key_press_event", sub {
my $event = pop @_; my $event = pop @_;
@ -1185,16 +1187,19 @@ sub search {
$submit_b->grab_default; $submit_b->grab_default;
$submit_b->signal_connect( "clicked", sub { $submit_b->signal_connect( "clicked", sub {
my $keywords = $search1->get_text(); my $keywords = $search1->get_text();
# rindex # rindex
if ($search_backwards->active) { if ($search_backwards->active) {
if (!$offset) { if (!$offset) {
if(!$case_sensitive->active) { if(!$case_sensitive->active) {
my ($tmp_ct, $tmp_k); if (!$tmp_ct && !$tmp_k) {
($tmp_ct = $changed_text_from_template) =~ tr/A-Z/a-z/; ($tmp_ct = $changed_text_from_template) =~
($tmp_k = $keywords) =~ tr/A-Z/a-z/; tr/A-Z/a-z/;
($tmp_k = $keywords) =~ tr/A-Z/a-z/;
}
$offset = rindex($tmp_ct, $tmp_k); $offset = rindex($tmp_ct, $tmp_k);
} }
else { else {
$offset = rindex($changed_text_from_template, $offset = rindex($changed_text_from_template,
@ -1212,9 +1217,11 @@ sub search {
$offset = $offset - 1; $offset = $offset - 1;
if(!$case_sensitive->active) { if(!$case_sensitive->active) {
my ($tmp_ct, $tmp_k); if (!$tmp_ct && !$tmp_k) {
($tmp_ct = $changed_text_from_template) =~ tr/A-Z/a-z/; ($tmp_ct = $changed_text_from_template) =~
($tmp_k = $keywords) =~ tr/A-Z/a-z/; tr/A-Z/a-z/;
($tmp_k = $keywords) =~ tr/A-Z/a-z/;
}
$offset = rindex($tmp_ct, $tmp_k, $offset); $offset = rindex($tmp_ct, $tmp_k, $offset);
} }
else { else {
@ -1240,9 +1247,11 @@ sub search {
else { else {
if (!$offset) { if (!$offset) {
if(!$case_sensitive->active) { if(!$case_sensitive->active) {
my ($tmp_ct, $tmp_k); if (!$tmp_ct && !$tmp_k) {
($tmp_ct = $changed_text_from_template) =~ tr/A-Z/a-z/; ($tmp_ct = $changed_text_from_template) =~
($tmp_k = $keywords) =~ tr/A-Z/a-z/; tr/A-Z/a-z/;
($tmp_k = $keywords) =~ tr/A-Z/a-z/;
}
$offset = index($tmp_ct, $tmp_k); $offset = index($tmp_ct, $tmp_k);
} }
else { else {
@ -1265,9 +1274,11 @@ sub search {
$offset = $offset + 1; $offset = $offset + 1;
if(!$case_sensitive->active) { if(!$case_sensitive->active) {
my ($tmp_ct, $tmp_k); if (!$tmp_ct && !$tmp_k) {
($tmp_ct = $changed_text_from_template) =~ tr/A-Z/a-z/; ($tmp_ct = $changed_text_from_template) =~
($tmp_k = $keywords) =~ tr/A-Z/a-z/; tr/A-Z/a-z/;
($tmp_k = $keywords) =~ tr/A-Z/a-z/;
}
$offset = index($tmp_ct, $tmp_k, $offset); $offset = index($tmp_ct, $tmp_k, $offset);
} }
else { else {

Loading…
Cancel
Save