in reply to A little edit decision list in Perl
#!/usr/bin/perl use Tk; use Tk::TextUndo; use Tk::Adjuster; use strict; my $file = shift || $0; my $buf; open (FH,"< $file"); read( FH, $buf, -s FH ); close FH; my $mw = tkinit(-title=>'Some Title'); my $TextTOP = $mw->Scrolled("TextUndo")->pack(-expand=>1, -fill=>'both +'); my $adj = $mw->Adjuster->packAfter($TextTOP); my $TextBOTTOM = $mw->Scrolled("Text")->pack(-expand=>1, -fill =>'both +'), $mw->bind('<Control-s>', sub { print "saving...\n" }); $mw->bind('Tk::Text', '<Control-s>', \&save_file); $mw->Button(-text=>'Exit', -command=> sub{Tk::exit})->pack(); $TextTOP->insert('end',"$buf"); MainLoop; sub save_file{ open(FH,">> $0.txt") or warn "$!\n"; my $current_text = $TextBOTTOM->get('1.0', 'end'); print FH $current_text,"\n"; close FH; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: A little edit decision list in Perl
by brian_d_foy (Abbot) on Sep 30, 2004 at 17:22 UTC |