App-PerlTidy-Tk

 view release on metacpan or  search on metacpan

lib/App/PerlTidy/Tk.pm  view on Meta::CPAN

package App::PerlTidy::Tk;
use strict;
use warnings;
use 5.008;

use Browser::Open qw(open_browser open_browser_cmd);
use Cwd qw(getcwd);
use Cpanel::JSON::XS qw(encode_json decode_json);
use Data::Dumper qw(Dumper);
use File::HomeDir ();
use File::Spec ();
use Path::Tiny qw(path);
use Getopt::Long qw(GetOptions);
use Perl::Tidy;

use Tk;
use Tk::Dialog;
use Tk::FileSelect;
use Tk::HyperText;
use Tk::Table;

our $VERSION = '0.03';

my $zoom = 3;
my %skip = map { $_ => 1 } qw(nocheck-syntax perl-syntax-check-flags);
my $home = File::HomeDir->my_home;
my $config_file = File::Spec->catfile($home, '.perltidy-tk.json');
my @options = ('indent-columns', 'paren-tightness', 'brace-tightness', 'block-brace-tightness');

sub usage {
    die "Usage: $0 [--help] [--perl somefile.pl]\n";
}

sub new {
    my ($class) = @_;
    my $self = bless {}, $class;

    my $perlfile;
    my $help;
    GetOptions(
        'perl=s' => \$perlfile,
        'help'   => \$help,
    ) or usage();
    usage() if $help;

    my $config = {};
    if (-e $config_file) {
        $config = decode_json(path($config_file)->slurp_utf8);
    }

    $self->{autotidy} = 0;

    $self->load_default_configuration;

    $self->{top} = MainWindow->new();
    if (exists $config->{geometry}) {
        $self->{top}->geometry($config->{geometry});
    }

    $self->{top}->bind("<Control-Shift-plus>", sub { $self->zoom($zoom) });
    $self->{top}->bind("<Control-minus>", sub { $self->zoom(-$zoom) });
    $self->{top}->bind("<Control-q>", sub { $self->exit_app(); });

    $self->create_menu;
    $self->create_text_widget;
    $self->create_config_panel;

    if ($perlfile) {



( run in 0.599 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )