App-Codit
view release on metacpan or search on metacpan
lib/App/Codit.pm view on Meta::CPAN
-contentfindbg => ['color', 'Background', -width => 8],
'*end',
'*section' => 'Spaces and tabs',
-contentbgdspace => ['color', 'Space bg', -width => 8],
'*column',
-contentbgdtab => ['color', 'Tab bg', -width => 8],
'*end',
'*section' => 'Matching {}, [] and ()',
-contentmatchfg => ['color', 'Foreground', -width => 8],
'*column',
-contentmatchbg => ['color', 'Background', -width => 8],
'*end',
'*section' => 'Other',
-errorcolor => ['color', 'Error', -width => 8],
-warningcolor => ['color', 'Warning', -width => 8],
'*column',
-linkcolor => ['color', 'Link', -width => 8],
-contentbookmarkcolor => ['color', 'Bookmark bg', -width => 8],
'*end',
'*page' => 'GUI',
'*section' => 'Icon sizes',
-iconsize => ['spin', 'General', -width => 4],
-sidebariconsize => ['spin', 'Side bars', -width => 4],
'*column',
-menuiconsize => ['spin', 'Menu bar', -width => 4],
-tooliconsize => ['spin', 'Tool bar', -width => 4],
'*end',
'*section' => 'Visibility at lauch',
'-tool barvisible' => ['boolean', 'Tool bar'],
'-status barvisible' => ['boolean', 'Status bar'],
'*column',
'-navigator panelvisible' => ['boolean', 'Navigator panel'],
'*end',
'*frame',
'*section' => 'Geometry',
-savegeometry => ['boolean', 'Save on exit',],
'*end',
'*column',
'*section' => 'Unique instance',
-uniqueinstance => ['boolean', 'Enabled', -onvalue => 1, -offvalue => 0],
'*end',
'*end',
'*section' => 'Tool bar',
-tooltextposition => ['radio', 'Text position', -values => [qw[none left right top bottom]]],
'*end',
],
-contentautoindent => 1,
-contentindent => 'tab',
-contentshowspaces => 0,
-contenttabs => '8m',
-contentwrap => 'none',
-showfolds => 1,
-shownumbers => 1,
-showstatus => 1,
);
for (keys %opts) {
$args->{$_} = $opts{$_}
}
$self->SUPER::Populate($args);
$self->geometry('800x600+150+150');
$self->{UNIQUE} = 0;
$self->extGet('Panels')->panelHide('TOOL');
$self->extGet('Panels')->panelHide('RIGHT');
$self->cmdConfig(
report_issue => ['ReportIssue', $self],
);
$self->addPostConfig('DoPostConfig', $self);
$self->ConfigSpecs(
-uniqueinstance => ['METHOD', undef, undef, 0],
DEFAULT => ['SELF'],
);
}
sub CanQuit {
my $self = shift;
my $file = $self->lockfile;
unlink $file if defined $file;
return $self->SUPER::CanQuit
}
sub DoPostConfig {
my $self = shift;
$self->SetThemeFile;
$self->cmdExecute('doc_new');
}
sub GetThemeFile {
return $_[0]->extGet('ConfigFolder')->ConfigFolder .'/highlight_theme.ctt';
}
sub lockfile {
my $self = shift;
my $file = $self->configGet('-configfolder') . '/lockfile';
return $file if -e $file;
return undef
}
sub lockModified {
my $self = shift;
my $file = $self->configGet('-configfolder') . '/lockfile';
if (-e $file) {
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($file);
my $lmod = $self->{LOCKMODIFIED};
return $lmod ne $mtime if defined $lmod;
}
return ''
}
sub lockReset {
my $self = shift;
my $file = $self->configGet('-configfolder') . '/lockfile';
if (open(LOUT, '>', $file)) {
print LOUT "\n";
close LOUT
}
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($file);
$self->{LOCKMODIFIED} = $mtime;
}
sub lockScan {
my $self = shift;
return unless $self->lockModified;
$self->deiconify unless $self->ismapped;
$self->focus;
$self->raise;
if (my $file = $self->lockfile) {
if (open(LIN, '<', $file)) {
while (<LIN>) {
my $line = $_;
chomp $line;
$self->cmdExecute('doc_open', $line) if -e $line
}
close LIN;
$self->lockReset;
}
}
}
=item B<mdi>
Returns a reference to the CoditMDI extension.
=cut
sub mdi {
return $_[0]->extGet('CoditMDI');
}
sub MenuItems {
my $self = shift;
return ($self->SUPER::MenuItems,
[ 'menu_normal', 'appname::h1', '~Report a problem', 'report_issue' ],
)
}
=item B<panels>
Returns a reference to the Panels extension.
=cut
sub panels {
return $_[0]->extGet('Panels');
}
sub ReportIssue {
my $self = shift;
$self->openURL('https://github.com/haje61/App-Codit/issues');
}
sub SetThemeFile {
my $self = shift;
my $themefile = $self->GetThemeFile;
$self->SetDefaultTheme unless -e $themefile;
$self->configPut(-highlight_themefile => $themefile);
}
sub SetDefaultTheme {
my $self = shift;
my $themefile = $self->GetThemeFile;
my $default = Tk::findINC('App/Codit/highlight_theme.ctt');
my $theme = Tk::CodeText::Theme->new;
$theme->load($default);
$theme->save($themefile);
}
=item B<sidebars>
Returns a reference to the SideBars extension.
=cut
sub sidebars {
return $_[0]->extGet('SideBars');
}
sub ToolBottomBookAdd {
my $self = shift;
return if $self->ToolBottomBookExists;
my $sb = $self->sidebars;
$sb->nbAdd('tool panel bottom', 'TOOL', 'bottom');
$sb->nbTextSide('tool panel bottom', 'right');
$self->panels->panelShow('TOOL')
}
sub ToolBottomBookExists {
my $self = shift;
return $self->sidebars->nbExists('tool panel bottom');
}
sub ToolBottomBookRemove {
( run in 0.450 second using v1.01-cache-2.11-cpan-99c4e6809bf )