#----------------------------Recherche-------------------------------------------------------------------------------- sub search_in_editor { $info="Recherche dans le fichier..."; &text_search($editortexte, $search_string, 'search'); if ($mw->depth > 1) { text_toggle($editortexte, ['configure', 'search', -background => 'SeaGreen4', -foreground => 'white'], 800, ['configure', 'search', -background => undef, -foreground => undef], 200); } else { text_toggle($editortexte, ['configure', 'search', -background => 'black', -foreground => 'white'], 800, ['configure', 'search', -background => undef, -foreground => undef], 200); } $info= "Recherche dans Fichier terminée."; } #-----------------------------Recherche ------------------------------------------------------------------- sub text_search { my($w, $string, $tag) = @_; print aaaaaa $string; if ($string) { $w->tag('remove', $tag, '0.0', 'end'); (my $num_lines) = $w->index('end') =~ /(\d*)\.\d*/; for($i = 1; $i <=$num_lines; $i++) { my $line = $w->get("${i}.0", "${i}.1000"); next if not defined $line or $line !~ /($string)/; my $l = length $1; $stringRegexp=$1; my $offset = 0; while (1) { my $tmpoffset=0; my $index = index $line, $stringRegexp, $tmpoffset; last if $index == -1; $offset += $index; $w->tag('add', $tag, sprintf("%d.%d", $i, $offset), sprintf("%d.%d", $i, $offset+$l)); $offset += $l; $line = substr $line, $index+$l; if ($line=~/($string)/) { $stringRegexp=$1; $l = length $1;} } } } } # end text_search