App-Tk-Deparse
view release on metacpan or search on metacpan
lib/App/Tk/Deparse.pm view on Meta::CPAN
# 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;
}
my $pi = 3.14; # -d changes this to a string
my $answer = "42"; # single quote or no quote?
my @planets = ('Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn');
my %h = (
name => "Foo Bar",
age => 42,
fruits => qw(Apple Banana Peach),
);
my $gentlemen = "Some names";
my $me = 'Perl';
print "Hello, $pi, @ladies, \u$gentlemen\E, \u\L$me!";
# Trying to show -P without success
sub foo (\@) { 1 } foo @x
};
my $s = q{
};
# Removed l for now showing the temporary filename does not do much good.
my @flags = ('d', 'p', 'q', 'P');
sub new {
my ($class) = @_;
my $self = bless {}, $class;
$self->{top} = MainWindow->new(
-title => 'B::Deparse',
);
$self->create_menu;
$self->create_app;
$self->{incode}->insert("0.0", $sample);
$self->deparse;
return $self;
}
sub create_menu {
my ($self) = @_;
my $main_menu = $self->{top}->Menu();
my $file_menu = $main_menu->cascade(-label => 'File', -underline => 0);
#$file_menu->command(-label => 'Open Perl File', -command => sub { $self->show_open(); }, -underline => 0);
$file_menu->command(-label => 'Quit (Ctrl-q)', -command => sub { $self->exit_app(); }, -underline => 0);
my $about_menu = $main_menu->cascade(-label => 'Help', -underline => 0);
$about_menu->command(-label => 'About', -command => sub { $self->show_about; }, -underline => 0);
$self->{top}->configure(-menu => $main_menu);
}
sub show_about {
my ($self) = @_;
my $dialog = $self->{top}->DialogBox(
-title => 'About App::Deparse::Tk',
-popover => $self->{top},
-buttons => ['OK'],
);
my $html = $dialog->HyperText();
$html->pack;
$html->setHandler (Resource => \&onResource);
$html->loadString(qq{<html>
<head>
<title>About App::Deparse::Tk</title>
</head>
<body>
Version: $VERSION<br>
<a href="https://metacpan.org/pod/Tk">Perl Tk</a>: $Tk::VERSION<br>
<a href="https://metacpan.org/pod/B::Deparse">B::Deparse</a><br>
Perl $]<br>
<p>
Create by Gabor Szabo<br>
Source code on <a href="https://github.com/szabgab/App-Tk-Deparse">GitHub</a><br>
Thanks to my <a href="https://www.patreon.com/szabgab">Patreon</a> supporters<br>
<h2>Supporters</h2>
<ul>
<li><a href="https://www.activestate.com/">ActiveState</a></li>
<li><a href="https://www.chatterjee.net/">Anirvan Chatterjee</a></li>
<li>Brian Gaboury</li>
<li><a href="https://www.linkedin.com/in/chan-wilson-b867b3/">Chan Wilson</a></li>
<li><a href="https://www.linkedin.com/in/fins0ck/">Csaba Gaspar</a></li>
<li><a href="https://www.linkedin.com/in/dihnen/">David Ihnen</a></li>
<li><a href="https://www.preshweb.co.uk/about/">David Precious</a></li>
<li>Frank Kropp</li>
<li>John Andersen</li>
<li>Magnus Enger</li>
<li><a href="https://www.linkedin.com/in/mjgardner/">Mark Gardner</a></li>
<li>Markus Hechenberger</li>
<li>Matthew Mitchell</li>
<li>Matthew Persico</li>
<li>Meir Guttman</li>
<li>Mike Small</li>
<li><a href="https://www.linkedin.com/in/n8dgr8/">Nathan Schlehlein</a></li>
<li><a href="https://www.linkedin.com/in/pfmabry/">Paul Mabry</a></li>
<li><a href="https://perl.careers/">Perl Careers</a></li>
<li>Richard Leach</li>
<li>Robert Coursen</li>
<li><a href="https://www.linkedin.com/in/shajiindia/">Shaji Kalidasan</a></li>
<li><a href="https://www.linkedin.com/in/shanta-mcbain-7b644437/">Shanta McBain</a></li>
<li><a href="https://www.linkedin.com/in/slobodanmiskovic/">Slobodan MiÅ¡koviÄ</a></li>
<li><a href="https://www.linkedin.com/in/stephen-jarjoura-a684401/">Stephen A. Jarjoura</a></li>
<li>Tony Edwardson</li>
<li><a href="https://www.linkedin.com/in/tori-hunter-00009639/">Tori Hunter</a></li>
( run in 1.398 second using v1.01-cache-2.11-cpan-524268b4103 )