App-Codit

 view release on metacpan or  search on metacpan

lib/App/Codit.pm  view on Meta::CPAN

		-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);
}



( run in 1.569 second using v1.01-cache-2.11-cpan-39bf76dae61 )