App-Tk-Deparse
view release on metacpan or search on metacpan
lib/App/Tk/Deparse.pm view on Meta::CPAN
use Path::Tiny qw(path);
use Capture::Tiny qw(capture);
use Tk;
use Tk::Dialog;
use Tk::HyperText;
use Tk::BrowseEntry;
our $VERSION = '0.02';
# TODO: make fonts more readable
# TODO: Clear the output when we change the input (or maybe rerun the deparse process?)
# TODO: use nice temporary filename as we can see the name of the file with the -l flags
# TODO: Save window size upon exit; restore window size upon start
# TODO: If there is a syntax error in the code B::Deparse will fail. We sould display this.
my $sample = q{
# Paste your code in the top window and click the Deparse button to see what B::Deparse thinks about it
for (my $j=0, $j<3, ++$j) {
print $j;
lib/App/Tk/Deparse.pm view on Meta::CPAN
my ($self, $event) = @_;
# TODO can we delay this and only run the deparse process if there were no changes for some time (e.g. 1 sec)
$self->deparse;
#print("changed\n");
}
sub create_app {
my ($self) = @_;
$self->{incode} = $self->{top}->Text(
-state => 'normal',
-font => ['fixed', 12],
-bg => 'white',
);
$self->{incode}->bindtags([$self->{incode}, 'Tk::Text', $self->{top}, 'all']);
#$self->{incode}->bind('<<Modified>>' => sub { I could not get this working
$self->{incode}->bind('<Any-KeyPress>' => sub { $self->changed(shift); });
$self->{incode}->pack(-fill => 'both', -expand => 1);
$self->{flags} = $self->{top}->Frame();
$self->{flags}->pack(-side => 'top');
for my $flag (@flags) {
$self->{"${flag}_flag"} = 0;
$self->{"${flag}_flag_checkbox"} = $self->{flags}->Checkbutton(
-text => "-$flag",
-variable => \$self->{"${flag}_flag"},
-font => ['fixed', 10],
-command => sub { $self->deparse },
);
$self->{"${flag}_flag_checkbox"}->pack(-side => 'left');
}
# $self->{"s_flag"} = '';
# my @s_values = qw(C i T);
# $self->{"s_flag_widget"} = $self->{flags}->BrowseEntry(
# -label => "-s",
# -width => 3,
# -variable => \$self->{"s_flag"},
# );
# for my $s (@s_values) {
# $self->{"s_flag_widget"}->insert("end", $s);
# }
# $self->{"s_flag_widget"}->pack;
$self->{outcode} = $self->{top}->Text(
-state => 'disabled',
-font => ['fixed', 12],
);
$self->{outcode}->pack(-fill => 'both', -expand => 1);
$self->{deparse} = $self->{top}->Button(
-text => 'Deparse',
-command => sub { $self->deparse },
);
$self->{deparse}->pack()
( run in 0.650 second using v1.01-cache-2.11-cpan-ceb78f64989 )