App-tkispell
view release on metacpan or search on metacpan
-default_button => 'Yes',
);
$d->Subwidget('B_Yes')->configure(-font => $fn);
$d->Subwidget('B_No')->configure(-font => $fn);
if (($d->Show) =~ /Yes/) {
$cw->Busy;
move($ifname, "$ifname.bak");
open OUT, "+>>$ifname" or die "Couldn't overwrite old $ifname: $OS_ERROR\n";
print OUT ($cw->Subwidget('text')->get('1.0', 'end'));
close OUT;
$cw->Unbusy;
}
}
if ($#addlist >= 0) {
my $d = $cw->Dialog(
-title => 'Add Words',
-text => 'Save new words to your personal dictionary?',
-bitmap => 'question',
-font => $fn,
-buttons => [qw/Yes No/],
-default_button => 'Yes',
);
$d->Subwidget('B_Yes')->configure(-font => $fn);
$d->Subwidget('B_No')->configure(-font => $fn);
if (($d->Show) =~ /Yes/) {
$cw->Busy;
open OUT, ">>$hdict" or die "Couldn't add words to $hdict: $OS_ERROR\n";
foreach (@addlist) {
print OUT "$_\n";
}
close OUT;
$cw->Unbusy;
}
}
$cw->WmDeleteWindow;
}
sub filenotfound {
$cw->Dialog(
-title => 'File Not Found',
-text => "Could not open @_",
-bitmap => 'error',
my $replacement = $cw->Subwidget('replaceentry')->get;
while (1) {
my $mlength = 0;
$midx = ($cw->Subwidget('text')->search('-forwards', -count => \$mlength, $misspelled,$lastindex,'end'));
last unless length $midx;
$cw->Subwidget('text')->delete($midx, "$midx + $mlength chars");
$cw->Subwidget('text')->insert($midx, $replacement);
$lastindex = adjust_index ($midx,$replacement);
}
push @addlist, ($replacement);
$cw->Unbusy;
}
sub guesses {
$cw->Busy;
return if ! $ifname;
@guesslist = qx|"$ispell_prog" -a \<$ifname 2\>&1|;
shift @guesslist; # remove the ispell id
chomp foreach (@guesslist);
$cw->Unbusy;
}
sub show_guesses {
$cw->Subwidget('list')->delete (0, 'end');
my $misspelling = gettextselection();
my @wordguesses = grep /\& $misspelling/, @guesslist;
if ($wordguesses[0]) {
$wordguesses[0] =~ s/.*\: //;
$cw->Subwidget('list')->insert('end', $_)
foreach (split /, /, $wordguesses[0]);
}
}
sub get_misspellings {
return if ! $ifname;
$cw->Busy(-recurse => 1);
@misspelledlist = qx|"$ispell_prog" -l \<$ifname|;
if ($#misspelledlist >= 0) {
chomp foreach (@misspelledlist);
}
$cw->Unbusy(-recurse => 0);
}
mainwindow();
(($ifname=$ARGV[0]) && openfile()) if(defined $ARGV[0] and length $ARGV[0]);
$cw->MainLoop;
( run in 0.325 second using v1.01-cache-2.11-cpan-87723dcf8b7 )