App-Codit

 view release on metacpan or  search on metacpan

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

=item I<-p> or I<-plugins>

Launch with only these plugins .*

=item I<-s> or I<-session>

Loads a session at launch. The plugin Sessions must be loaded for this to work.

=item I<-y> or I<-syntax>

Specify the default syntax to use for syntax highlighting. Codit will determine the syntax
of documents by their extension. This options comes in handy when the file you are
loading does not have an extension.

=item I<-v> or I<-version>

Displays the version number on the command line and exits.

=back

* You can specify a list of items by separating them with a ':'.

=head1 TROUBLESHOOTING

Just hoping you never need this.

=head2 General troubleshooting

If you encounter problems and error messages using Codit here are some general troubleshooting steps:

=over 4

=item Use the -config command line option to point to a new, preferably fresh settingsfolder.

=item Use the -noplugins command line option to launch Codit without any plugins loaded.

=item Use the -plugins command line option to launch Codit with only the plugins loaded you specify here.

=back

=head2 No icons

If Codit launches without any icons do one or more of the following:

=over 4

=item Check if your icon theme is based on scalable vectors. Install Icons::LibRSVG if so. See also the Readme.md that comes with this distribution.

=item Locate where your icons are located on your system and use the -iconpath command line option to point there.

=item Select an icon library by using the -icontheme command line option.

=back

=head2 Session will not load

Sometimes it happens that a session file gets corrupted. You solve it like this:

=over 4

=item Launch the session manager. Menu->Session->Manage sessions.

=item Remove the affected session.

=item Rebuild it from scratch.

=back

Sorry, that is all we have to offer.

=head3 Report a bug

If all fails you are welcome to open a ticket here: L<https://github.com/haje61/App-Codit/issues>.

=head1 BASECLASSES

Codit comes with the base class L<App::Codit::BaseClasses::TextModPlugin>. It is used by several
plugins. You can use it to define your own plugin.

=head1 EXTENSIONS

Codit uses the following extensions from L<Tk::AppWindow>:

=over 4

=item B<Art> see L<Tk::AppWindow::Ext::Art>

=item B<ConfigFolder> see L<Tk::AppWindow::Ext::ConfigFolder>

=item B<Daemons> see L<Tk::AppWindow::Ext::Daemons>

=item B<Help> see L<Tk::AppWindow::Ext::Help>

=item B<Keyboard> see L<Tk::AppWindow::Ext::Keyboard>

=item B<MenuBar> see L<Tk::AppWindow::Ext::MenuBar>

=item B<Panels> see L<Tk::AppWindow::Ext::Panels>

=item B<Plugins> see L<Tk::AppWindow::Ext::Plugins>

=item B<Selector> see L<Tk::AppWindow::Ext::Selector>

=item B<Settings> see L<Tk::AppWindow::Ext::Settings>

=item B<SideBars> see L<Tk::AppWindow::Ext::SideBars>

=item B<StatusBar> see L<Tk::AppWindow::Ext::StatusBar>

=item B<ToolBar> see L<Tk::AppWindow::Ext::ToolBar>

=back

Codit has its own extension as multiple document interface.

=over 4

=item B<CoditMDI> see L<App::Codit::Ext::CoditMDI>

=back

=head1 PLUGINS

Codit comes with these plugins:

=over 4

=item B<Backups> see L<App::Codit::Plugins::Backups>

=item B<Bookmarks> see L<App::Codit::Plugins::Bookmarks>

=item B<Colors> see L<App::Codit::Plugins::Colors>

=item B<Console> see L<App::Codit::Plugins::Console>

=item B<Exporter> see L<App::Codit::Plugins::Exporter>

=item B<FileBrowser> see L<App::Codit::Plugins::FileBrowser>

=item B<Git> see L<App::Codit::Plugins::Git>

=item B<Icons> see L<App::Codit::Plugins::Icons>

=item B<PerlSubs> see L<App::Codit::Plugins::PerlSubs>

=item B<PodViewer> see L<App::Codit::Plugins::PodViewer>

=item B<SearchReplace> see L<App::Codit::Plugins::SearchReplace>

=item B<Sessions> see L<App::Codit::Plugins::Sessions>

=item B<Snippets> see L<App::Codit::Plugins::Snippets>

=item B<SpltView> see L<App::Codit::Plugins::SplitView>

=back

=head1 CONFIG VARIABLES

Codit defines one config variable.

=over 4

=item Switch B<-uniqueinstance>

Boolean flag. Default value 0. If set only this instance is used
for opening files through the command line.

=back

=head1 COMMANDS

Codit defines one command.

=over 4

=item Switch B<-report_issue>

Opens the issues web page of the App::Codit github repository.

=back

=head1 METHODS

B<App::Codit> inherits L<Tk::AppWindow> and all of its methods.

=over 4

=cut

sub Populate {
	my ($self,$args) = @_;

	my $rawdir = Tk::findINC('App/Codit/Icons');
	my %opts = (
#		-appname => 'Codit',
		-logo => Tk::findINC('App/Codit/codit_logo.png'),
		-extensions => [qw[Art CoditMDI ToolBar StatusBar MenuBar Selector Help Settings Plugins]],
		-documentinterface => 'CoditMDI',
		-namespace => 'App::Codit',
		-rawiconpath => [ $rawdir ],
		-savegeometry => 1,
		-updatesmenuitem => 1,

		#configure the application layout.
		-panelgeometry => 'grid',
		-panellayout => [
			CENTER => {
				-weight => 1,
				-in => 'MAIN',
				-column => 0,
				-row => 1,
				-sticky => 'nsew',
			},
			SUBCENTER => {
				-in => 'CENTER',
				-weight => 1,
				-column => 2,
				-row => 0,
				-sticky => 'nsew',
			},
			WORK => {
				-in => 'SUBCENTER',
				-weight => 1,
				-column => 0,
				-row => 0,
				-sticky => 'nsew',
			},
			TOOL => {
				-in => 'SUBCENTER',
				-weight => 1,
				-column => 0,
				-row => 2,
				-sticky => 'ew',
				-canhide => 1,
				-adjuster => 'bottom',
			},
			TOP => {
				-weight => 1,
				-in => 'MAIN',
				-column => 0,
				-row => 0,
				-sticky => 'ew',
				-canhide => 1,
			},
			BOTTOM => {
				-in => 'MAIN',
				-column => 0,
				-row => 2,
				-sticky => 'ew',
				-canhide => 1,
			},
			LEFT => {
				-in => 'CENTER',
				-column => 0,
				-row => 0,
				-sticky => 'ns',
				-canhide => 1,

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

			-contentautobrackets => ['boolean', 'Auto brackets'],
			'*column',
			-contentshowspaces => ['boolean', 'Show spaces'],
			'*end',
			'*frame',
			-contenttabs => ['text', 'Tab size', -regex => qr/^\d+\.?\d*[c|i|m|p]$/, -width => 4],
			'*column',
			-contentindent => ['text', 'Indent style', -regex => qr/^\d+|tab$/, -width => 4],
			'*end',
			-contentwrap => ['radio', 'Wrap', -values => [qw[none char word]]],
			'*end',
			'*section' => 'Show indicators',
			-showfolds => ['boolean', 'Fold indicators'],
			'*column',
			-shownumbers => ['boolean', 'Line numbers'],
			'*column',
			-showstatus => ['boolean', 'Doc status'],
			'*end',
			'*section' => 'Auto complete',
			-contentautocomplete => ['boolean', 'Enabled', -enables => ['-contentactivedelay', '-contentacpopsize', '-contentacscansize']],
			-contentactivedelay => ['spin', 'Pop delay', -width => 4],
			'*column',
			-contentacpopsize => ['spin', 'Pop size', -width => 4],
			-contentacscansize => ['spin', 'Scan size', -width => 4],
			'*end',

			'*page' => 'Colors',
			'*section' => 'Editing',
			-contentforeground => ['color', 'Foreground', -width => 8],
			'*column',
			-contentbackground => ['color', 'Background', -width => 8],
			'*end',
			'*section' => 'Find',
			-contentfindfg => ['color', 'Foreground', -width => 8],
			'*column',
			-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
}

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

}

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 1.227 second using v1.01-cache-2.11-cpan-d7f47b0818f )