| 1 |
|
| 2 |
|
| 3 |
=head1 NAME |
| 4 |
|
| 5 |
Tk::TextUndoQuiet - TextUndo widget sans progress popup in the Save method |
| 6 |
|
| 7 |
=for pm Tk/TextUndoQuiet.pm |
| 8 |
|
| 9 |
=for category Derived Widgets |
| 10 |
|
| 11 |
=head1 SYNOPSIS |
| 12 |
|
| 13 |
use Tk::TextUndoQuiet; |
| 14 |
... |
| 15 |
$tuq = $mw->TextUndoQuiet(?options,...?); |
| 16 |
|
| 17 |
=head1 DESCRIPTION |
| 18 |
|
| 19 |
This "I<IS A>" widget with everything identical to the normal TextUndo |
| 20 |
widget, except that the progress popup is disabled when saving a file. |
| 21 |
|
| 22 |
=head1 KEYS |
| 23 |
|
| 24 |
widget, text, undo |
| 25 |
|
| 26 |
=head1 SEE ALSO |
| 27 |
|
| 28 |
L<Tk::TextUndo> |
| 29 |
|
| 30 |
=cut |
| 31 |
|
| 32 |
|
| 33 |
package Tk::TextUndoQuiet; |
| 34 |
|
| 35 |
use Tk::TextUndo; |
| 36 |
use base qw(Tk::TextUndo); |
| 37 |
|
| 38 |
Construct Tk::Widget 'TextUndoQuiet'; |
| 39 |
|
| 40 |
sub Save |
| 41 |
{ |
| 42 |
my ($w,$filename) = @_; |
| 43 |
$filename = $w->FileName unless defined $filename; |
| 44 |
return $w->FileSaveAsPopup unless defined $filename; |
| 45 |
local *FILE; |
| 46 |
if (open(FILE,">$filename")) |
| 47 |
{ |
| 48 |
my $status; |
| 49 |
my $count=0; |
| 50 |
my $index = '1.0'; |
| 51 |
my $progress; |
| 52 |
my ($lines) = $w->index('end') =~ /^(\d+)\./; |
| 53 |
while ($w->compare($index,'<','end')) |
| 54 |
{ |
| 55 |
# my $end = $w->index("$index + 1024 chars"); |
| 56 |
my $end = $w->index("$index lineend +1c"); |
| 57 |
print FILE $w->get($index,$end); |
| 58 |
$index = $end; |
| 59 |
## if (($count++%1000) == 0) |
| 60 |
## { |
| 61 |
## $progress = $w->TextUndoFileProgress (Saving => $filename,$count,$count,$ |
| 62 |
## lines); |
| 63 |
## } |
| 64 |
} |
| 65 |
## $progress->withdraw if defined $progress; |
| 66 |
if (close(FILE)) |
| 67 |
{ |
| 68 |
$w->ResetUndo; |
| 69 |
$w->FileName($filename); |
| 70 |
return 1; |
| 71 |
} |
| 72 |
} |
| 73 |
else |
| 74 |
{ |
| 75 |
$w->BackTrace("Cannot open $filename:$!"); |
| 76 |
} |
| 77 |
return 0; |
| 78 |
} |
| 79 |
|
| 80 |
1; |