diff --git a/perl/Gnome-Tomboy/lib/Tomboy/TOC.pm b/perl/Gnome-Tomboy/lib/Tomboy/TOC.pm index 617ed3b3660cd41d66ce598689869fee5bd50240..cdf70781f94d56a147c92dce1301a975fcff0a81 100644 --- a/perl/Gnome-Tomboy/lib/Tomboy/TOC.pm +++ b/perl/Gnome-Tomboy/lib/Tomboy/TOC.pm @@ -25,17 +25,26 @@ sub set foreach my $par (keys %par) { $self->{$par}= $par{$par}; } } +=head2 $toc->find($pattern [, $where]) + +Search TOC for matching $pattern in field specified by $where; if $where is not defined, 'title' is used. + +Returns a list of matching TOC entries + +=cut + sub find { my $self= shift; my $pattern= shift; + my $where= shift || 'title'; -print "find: pattern=[$pattern]\n"; +print "find: where=[$where] pattern=[$pattern]\n"; my ($mode, $toc, $rows)= $self->load_toc(); my @res; foreach my $row (@$rows) { - next unless ($row->{'title'} =~ m#$pattern#i); + next unless ($row->{$where} =~ m#$pattern#i); # print "row: ", main::Dumper ($row); push (@res, $row); } diff --git a/perl/Gnome-Tomboy/tom b/perl/Gnome-Tomboy/tom index 61a36495e492230e96512677630e0d78cedc46a7..98ce7eeb340090141f63e4c41976e77d9cee96bc 100755 --- a/perl/Gnome-Tomboy/tom +++ b/perl/Gnome-Tomboy/tom @@ -88,9 +88,10 @@ print "op_code=[$op_code] par=[", join (';', @PAR), "]\n"; if ($op_code eq 'help') { usage(); } elsif ($op_code eq 'dump') { dump_note ($_) foreach (@PAR); } +elsif ($op_code eq 'show') { find_note ('uuid', $_) foreach (@PAR); } elsif ($op_code eq 'toc') { tom_toc(); } elsif ($op_code eq 'csv') { tom_csv(); } -elsif ($op_code eq 'find') { find_note(@PAR); } +elsif ($op_code eq 'find') { find_note('title', @PAR); } elsif ($op_code eq 'diff') { my $f1= shift (@PAR); @@ -130,12 +131,14 @@ sub tom_toc sub find_note { + my $where= shift; + setup_toc(); my %uuid; foreach my $pattern (@_) { - my @res= $toc->find ($pattern); + my @res= $toc->find ($pattern, $where); foreach my $res (@res) { $uuid{$res->{'uuid'}}= $res; } # TODO: count hits }