App-Codit

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

0.17 Sat Feb 08 2025
	- Modified font selection in settings.
	- Adapted plugins to the modifications in base class Callback of Tk::AppWindow 0.21

0.16 Sun Jan 19 2025
	- Corrected bug in pod
	- Plugin PodViewer has sytem link color
	- Fixed bug in plugin SearchReplace
	- App::Codit::CodeTextManager differentiates between different kinds of log calls.
	- Added documentation App::Codit::Commands and App:Codit::ConfigVariables.
	- Removed -contentinsertbg option. The insert background is automatically set to the foreground color.
	- Changed the -P command line argument of the codit executable to -np. Windows handles them case insensitive.
	- Updated documentation and manual.
	- Context menu of FileBrowser plugin has a Properties entry.
	- CoditTagsEditor uses the new file dialogs.
	- Fixed bug in plugin Sessions. method sessionSaveAs.
	- Moved code for upper and lower case module to Tk::CodeText.

0.15 Sun Jan 05 2025
	- Moved autocomplete code from plugin WordCompletion to module Tk::CodeText.
	- Integrated the new Tk::CodeText in Codit.

Changes  view on Meta::CPAN

	- Fixed bug in plugins PerlSubs and PodViewer
	- improved testing for windows

0.03 Mon May 20 2024
	- Fixed bug in PerlSubs
	- Improved unloading of plugins
	- Added website to the about dialog

0.02 Mon May 20 2024
	- Fixed bug in PodViewer plugin
	- Made PodViewer and PerlSubs respond to the modified command instead of using background jobs.
	- Improved testing
	- ContentHandler is now set to a name upon creation

0.01 Sun May 19 2024
	- Initial upload to CPAN

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


		#configure content manager
		-contentmanagerclass => 'CodeTextManager',
		-contentmanageroptions => [
			'-contentacpopsize',
			'-contentacscansize',
			'-contentactivedelay',
			'-contentautobrackets',
			'-contentautocomplete',
			'-contentautoindent',
			'-contentbackground',
			'-contentbgdspace',
			'-contentbgdtab',
			'-contentbookmarkcolor',
			'-contentfindbg',
			'-contentfindfg',
#			'-contentfont',
			'-contentfontfamily',
			'-contentfontsize',
			'-contentforeground',
			'-contentindent',

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

			-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],

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

	$xt->bind('<Control-r>', sub { $ext->cmdExecute('doc_replace') });
	$self->{NAME} = '';

	$self->ConfigSpecs(
		-contentacpopsize => [{-acpopsize => $xt}],
		-contentacscansize => [{-acscansize => $xt}],
		-contentactivedelay => [{-activedelay => $xt}],
		-contentautobrackets => [{-autobrackets => $xt}],
		-contentautocomplete => [{-autocomplete => $xt}],
		-contentautoindent => [{-autoindent => $xt}],
		-contentbackground => [{-background => $xt}],
		-contentbgdspace => [{-spacebackground => $text}],
		-contentbgdtab => [{-tabbackground => $text}],
		-contentbookmarkcolor => [{-bookmarkcolor => $text}],
		-contentfindbg => ['PASSIVE'],
		-contentfindfg => ['PASSIVE'],
		-contentmatchbg => ['PASSIVE'],
		-contentmatchfg => ['PASSIVE'],
		-contentforeground => [{-foreground => $xt}],
#		-contentfont => [{-font => $xt}],
		-contentfontfamily => ['PASSIVE'],
		-contentfontsize => ['PASSIVE'],
		-contentindent => [{-indentstyle => $xt}],

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

	return 1;
}

sub configureTags {
	my $self = shift;
	my $widg = $self->CWidg;

	#configuring the find options
	my @findoptions = ();
	my $fbg = $self->cget('-contentfindbg');
	push @findoptions, '-background', $fbg if (defined $fbg) and ($fbg ne '');
	my $ffg = $self->cget('-contentfindfg');
	push @findoptions, '-foreground', $ffg if (defined $ffg) and ($ffg ne '');
	$widg->configure('-findoptions', \@findoptions) if @findoptions;
	
	#configuring the match options
	my @matchoptions = ();
	my $mbg = $self->cget('-contentmatchbg');
	push @matchoptions, '-background', $mbg if  (defined $mbg) and ($mbg ne '');
	my $mfg = $self->cget('-contentmatchfg');
	push @matchoptions, '-foreground', $mfg if  (defined $mfg) and ($mfg ne '');;
	$widg->configure('-matchoptions', \@matchoptions) if @matchoptions;
	
	#configuring insert background
	$widg->configure('-insertbackground', $widg->cget('-foreground'));
	
	#configuring font
	my $xt = $widg->Subwidget('XText');
	my $fam = $self->cget('-contentfontfamily');
	$fam = 'Courier' unless defined $fam;
	my $siz = $self->cget('-contentfontsize');
	$siz = 10 unless defined $siz;
	$widg->configure(-font => "{$fam} $siz");

	#configuring showspaces. Hack, do not know why this is needed.

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

use Tk;
use Tie::Watch;
require Tk::CodeText::TagsEditor;

use base qw(Tk::Derived Tk::Frame);
Construct Tk::Widget 'CoditTagsEditor';

sub Populate {
	my ($self,$args) = @_;
	
	my $dbackground = delete $args->{'-defaultbackground'};
	die 'You must specify the -defaultbackground option' unless defined $dbackground;
	my $dforeground = delete $args->{'-defaultforeground'};
	die 'You must specify the -defaultforeground option' unless defined $dforeground;
	my $dfont = delete $args->{'-defaultfont'};
	die 'You must specify the -defaultfont option' unless defined $dfont;
	my $ext = delete	$args->{'-extension'};
	die 'You must specify the -extension option' unless defined $ext;
	my $hist = delete	$args->{'-historyfile'};
	die 'You must specify the -historyfile option' unless defined $hist;
	my $themefile = delete $args->{'-themefile'};
	die 'You must specify the -themefile option' unless defined $themefile;
	
	$self->SUPER::Populate($args);
	my $te = $self->TagsEditor(
		-defaultbackground => $dbackground,
		-defaultforeground => $dforeground,
		-defaultfont => $dfont,
		-historyfile => $hist,
	)->pack(-expand => 1, -fill => 'both');
	$self->Advertise(TE => $te);

	my $toolframe =  $self->Frame(
	)->pack(-fill => 'x');
	$toolframe->Button(
		-command => sub {

lib/App/Codit/ConfigVariables.pod  view on Meta::CPAN


=item B<-useroptions> I<hookable> in L<Tk::AppWindow::Ext::Settings>

Name of the settings file. Default is I<settingsrc>. A typical setup might look
like this:

 -useroptions => [
    '*page' => 'Editing',
    '*section' => 'User interface',
    -contentforeground => ['color', 'Foreground'],
    -contentbackground => ['color', 'Background'],
    -contentfont => ['font', 'Font'],
    '*end',
    '*section' => 'Editor settings',
    -contenttabs => ['text', 'Tab size'],
    -contentwrap => ['radio', 'Wrap', [qw[none char word]]],
    '*end',
    '*page' => 'Icons',
    -icontheme => ['list', 'Icon theme', 'available_icon_themes'],
    -iconsize => ['list', 'Icon size', 'available_icon_sizes'],
    '*page' => 'Bars',

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

	return unless defined $doc;
	$self->docGet($doc)->replace(@_);
}

sub keyReleased {
#	my ($self, $name, $key) = @_;
}

=back

Macros are callbacks executed in the background. For each line in the document the macro is linked to,
the callback is executed with a reference to the text widget and the line number as parameter.
the macro ends after the last line has been processed. Codit uses macro callback to do tasks like show
leading and trailing tabs and spaces and reparing indentation.

=over 4

=item B<macroGet>I<($doc, $name)>

Returns a reference to the macro object $name belonging to $doc.

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

	my @opt = (
		-applycall => sub {
			my $themefile = shift;
			my @list = $self->docList;
			for (@list) {
				my $d = $self->docGet($_);
				$d->configure(-highlight_themefile => $themefile);
				$d->configureTags;
			}
		},
		-defaultbackground => $doc->cget('-contentbackground'),
		-defaultforeground => $doc->cget('-contentforeground'),
		-defaultfont => $doc->CWidg->Subwidget('XText')->cget('-font'),
		-historyfile => $historyfile,
		-extension => $self,
		-themefile => $themefile,
	);
	return (
		'Highlighting' => ['CoditTagsEditor', @opt]
	)
}

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


use base qw( Tk::AppWindow::BaseClasses::PluginJobs );

=head1 DESCRIPTION

Protect yourself against crashes. This plugin keeps backups of your unsaved files.

=head1 DETAILS

The Backups plugin protects you against crashes of all kinds.
It silently does it's job in the background and only reports when it
finds an existing backup of a file you open.

It keeps backups of all open and unsaved files. Whenever a file is saved or closed
the backup is removed.

It keeps the backups in the configuration folder, it does not pollute your working folders.

=cut

sub new {

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

	my $entry = $self->{ENTRY};
	if (defined $value) {
		$entry->delete('0', 'end');
		$entry->insert('end', $value);
	}
	return $entry
}

sub _ind {
	my ($self, $value) = @_;
	$self->{INDICATOR}->configure(-background => $self->_pick->convert($value)) if defined $value;
	return $self->{INDICATOR}
}

sub _pick {
	my ($self, $value) = @_;
	$self->{PICKER}->put($value) if defined $value;
	return $self->{PICKER}
}

sub SelectionCheck {

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


sub updateEntry {
	my ($self, $value) = @_;
	$value = $self->_ent->get unless defined $value;
	my $pick = $self->_pick;
	if ($self->_pick->validate($value)) {
		$self->_ind($pick->getHEX);
		$self->_ent->configure(-foreground => $self->configGet('-foreground'));
		$self->_pick($value);
	} else {
		$self->_ind($self->configGet('-background'));
		$self->_ent->configure(-foreground => $self->configGet('-errorcolor'));
	}
}

sub updatePicker {
	my ($self, $value) = @_;
	$self->_ent($value);
	$self->_ind($self->_pick->getHEX);
}

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

for Output file are saved. You can set:

=over 4

=item B<Output file>

A default file is suggested. Change it if you like.

=item B<Background>

Background color of your image. By default the background
color of the Tk::CodeText widget is set.

=item B<Foreground>

Default color of the text in your image. By default the foreground
color of the Tk::CodeText widget is set.

=item B<Theme file>

Select the Tk::CodeText theme file (extension '.ctt') to use for syntax highlighting.

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

	$self->{XPOS} = 0;
	$self->{TABSTRING} = '';
	$self->{YPOS} = 0;
	$self->cmdConfig(
		'export_html' => ['export2html', $self],
		'export_png' => ['export2png', $self],
	);
	return $self;
}

sub background {
	my $self = shift;
	$self->{BACKGROUND} = shift if @_;
	return $self->{BACKGROUND}
}

sub export2html {
	my $self = shift;
	my $mdi = $self->mdi;

	#setting initial values

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

	my %iv = ();
	my $name = $mdi->docSelected;
	return unless defined $name;
	my $widg = $mdi->docWidget;

	my $folder = $self->configGet('-configfolder');
	if (-e "$folder/export2pngrc") {
		my $cff = $self->extGet('ConfigFolder');
		%iv = $cff->loadHash('export2pngrc', 'exporterpng');
	} else {
		$iv{'background'} = $widg->Subwidget('XText')->cget('-background');
		$iv{'foreground'} = $widg->Subwidget('XText')->cget('-foreground');
		$iv{'themefile'} = $self->extGet('ConfigFolder')->ConfigFolder . '/highlight_theme.ctt';
		$iv{'font'} = $self->configGet('-contentfont');
		$iv{'linenumbers'} = 1;
		$iv{'margins'} = 10;
		$iv{'maxwidth'} = 0;
		$iv{'tabsize'} = 3;
	}
	$iv{'outfile'} = "$name.png";

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

	my %options = $self->popForm(
#		-acceptempty => 1,
		-initialvalues => \%iv,
		-oktext => 'Export',
		-structure => [
			'*section' => 'Output',
			outfile => ['file', 'File', -width => 50],
			'*end',
			'*section' => 'Theme',
			'*frame',
			background => ['color', 'Background', -width => 8],
			'*column',
			foreground => ['color', 'Foreground', -width => 8],
			'*end',
			themefile => ['file', 'Theme file'],
			font => ['font', 'Font'],
			'*end',
			'*section' => 'Features',
			linenumbers => ['boolean', 'Line numbers'],
			tabsize => ['spin', 'Tab size', -width => 6],
			'*column',

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


	#saving options
	my $cff = $self->extGet('ConfigFolder');
	$cff->saveHash('export2pngrc', 'exporterpng', %options);

	#checking data
	my $file = delete $options{'outfile'};
	croak "Outfile not specified" if $file eq '';
	my $tabstr = '';
	for (1 .. $options{'tabsize'}) { $tabstr = "$tabstr " }
	$self->background(Imager::Color->new($options{'background'}));
	$self->imargin($options{'margins'});
	$self->linenumbers($options{'linenumbers'});
	$self->linecolumn(length($widg->linenumber('end - 1c')));
	$self->maxwidth($options{'maxwidth'});
	$self->tabstring($tabstr);

	#converting data
	my $art = $self->extGet('Art');
	my $l = $self->Label(-font => $options{'font'});
	my $f = $l->cget('-font');

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

			$options{'-font'} = $fntnorm
		}
		my $fg = $theme->getItem($tag, '-foreground');
		if ($fg ne '') {
#			print "  setting foreground $fg\n";
			$options{'-foreground'} = Imager::Color->new($fg);
		} else {
#			print "  default foreground remains\n";
			$options{'-foreground'} = $foreground;
		}
		my $bg = $theme->getItem($tag, '-background');
		if ($bg ne '') {
#			print "  default background $bg\n";
			$options{'-background'} = Imager::Color->new($bg);
		} else {
#			print "  default background remains\n";
#			$options{'-background'} = $self->background;
		}
		$tags{$tag} = \%options;
	}

	#setting up highlighter
	my $syntax = $widg->cget('-syntax');
	my $hl;
	if ($syntax ne 'None') {
		$hl = Syntax::Kamelon->new(
			syntax => $syntax,

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


		my $line = $widg->get($linestart, $lineend);
		if ($syntax eq 'None') {
			$self->iprint($line, $fntnorm, $foreground);
		} else {
			my @h = $hl->ParseRaw($line);
			while (@h) {
				my $string = shift @h;
				my $tag = shift @h;
				my $t = $tags{$tag};
				$self->iprint($string, $t->{'-font'}, $t->{'-foreground'}, $t->{'-background'});
			};
			$self->iprint("\n", $fntnorm, $foreground) if $line =~ /\n$/;
		}
		$count++;
		$self->update;
	}
	$self->mdi->progressRemove('exporter');
	
	my $out = $self->inew($self->iwidth, $self->iheight);
	$out->paste(src => $self->image);

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

sub imargin {
	my $self = shift;
	$self->{IMARGIN} = shift if @_;
	return $self->{IMARGIN}
}


sub inew {
	my ($self, $width, $height) = @_;
	my $new = Imager->new(xsize => $width, ysize => $height, channels => 4);
	$new->flood_fill(x => 0, y => 0, color => $self->background);
	return $new
}

sub inewline {
	my ($self, $font) = @_;
	my $linespace = $self->fontMetrics($font, '-linespace');
	my $height = $self->iheight + $linespace;
	my $new = $self->inew($self->iwidth, $height);
	$new->paste(src => $self->image);
	$self->image($new);

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

	my $ifont = $self->extGet('Art')->imagerFont($font);
	my $partsize = $self->fontMeasure($font, $string);
	my $linesize = $self->xpos + $partsize + $self->imargin;
	if ($linesize > $self->iwidth) { #need to enlarge in x direction?
		my $new = $self->inew($linesize, $self->iheight);
		$new->paste(src => $self->image);
		$self->image($new);
		$self->iwidth($linesize);
	}
	
	if (defined $bg) { #paint background
		my $linespace = $self->fontMetrics($font, '-linespace');
		my $descent = $self->fontMetrics($font, '-descent');
		my $x1 = $self->xpos;
		my $x2 = $x1 + $partsize;
		my $y2 = $self->ypos + $descent;
		my $y1 = $y2 - $linespace;
		$self->image->polygon(
			points => [[$x1, $y1], [$x2, $y1], [$x2, $y2], [$x1, $y2]],
			color => $bg,
		);

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

	)->pack(-expand => 1, -fill => 'both');
	$self->{HLIST} = $hlist;
	my $count = 0;
	for ('Sub', 'Line') {
		my $header = $hlist->Header(
			-column => $count,
			-sortcall => ['Sortcall', $self],
			-text => $_,
		);
		$hlist->headerCreate($count,
			-headerbackground => $self->configGet('-background'),
			-itemtype => 'window', 
			-widget => $header
		);
		$count ++;
	}
	my $h2 = $hlist->headerCget(1, '-widget');
	$h2->configure(-sortorder => 'ascending');

	return $self;
}

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

	$bf->Button(
		-image => $art->createCompound(
			-text => 'Delete',
			-image => $art->getIcon('edit-delete', 22),
		),
		-anchor => 'w',
		-command => ['Delete', $self],
	)->pack(@padding, -fill => 'x');

	$self->ConfigSpecs(
		-background => ['SELF', 'DESCENDANTS'],
		DEFAULT => [$self],
	);
	$self->Refresh;
}

sub Delete {
	my $self = shift;
	my $sel = $self->GetSelected;
	return unless defined $sel;
	my $plug = $self->{PLUGIN};

lib/App/Codit/highlight_theme.ctt  view on Meta::CPAN

Tk::CodeText theme file
[Alert]
-background=#DB7C47
-foreground=#FFFFFF
[Annotation]
-foreground=#5A5A5A
[Attribute]
-foreground=#00B900
-weight=bold
[BaseN]
-foreground=#0000A9
[BuiltIn]
-foreground=#B500E6

lib/App/Codit/highlight_theme.ctt  view on Meta::CPAN

-foreground=#0062AD
[DataType]
-foreground=#0080A8
-weight=bold
[DecVal]
-foreground=#9C4E2B
[Documentation]
-foreground=#7F5A41
-slant=italic
[Error]
-background=#FF0000
-foreground=#FFFF00
[Extension]
-foreground=#9A53D1
[Float]
-foreground=#9C4E2B
-weight=bold
[Function]
-foreground=#008A00
[Import]
-foreground=#950000

lib/App/Codit/highlight_theme.ctt  view on Meta::CPAN

[Keyword]
-weight=bold
[Normal]
[Operator]
-foreground=#85530E
[Others]
-foreground=#FF6200
[Preprocessor]
-slant=italic
[RegionMarker]
-background=#00CFFF
[SpecialChar]
-foreground=#9A53D1
[SpecialString]
-foreground=#FF4449
[String]
-foreground=#FF0000
[Variable]
-foreground=#0000FF
-weight=bold
[VerbatimString]
-foreground=#FF4449
-weight=bold
[Warning]
-background=#FFFF00
-foreground=#FF0000

t/030-App-Codit-CoditTagsEditor.t  view on Meta::CPAN


BEGIN { use_ok('App::Codit::CoditTagsEditor') };

createapp(
);

my $editor;
if (defined $app) {
	$editor = $app->CoditTagsEditor(
		-extension => $app,
		-defaultbackground => '#FFFFFF',
		-defaultforeground => '#000000',
		-defaultfont => $app->Font(-family => 'Hack', -size => 12),
		-historyfile => 't/color_history',
		-themefile => 'blib/lib/App/Codit/highlight_theme.ctt',
	)->pack(-expand => 1, -fill => 'both');
}

push @tests , [ sub { return defined $editor }, 1, 'CoditTagsEditor created'];


t/078-App-Codit-Plugins-Exporter.t  view on Meta::CPAN

);

my $pext;
my $exp;
if (defined $app) {
	pause(300);
	$pext = $app->extGet('Plugins');
	$exp = $pext->plugGet('Exporter');
}

testaccessors($exp, qw/background iheight image imargin iwidth linecolumn linenumbers maxwidth tabstring xpos ypos/);

push @tests, (
	[ sub { 
		return $pext->plugExists('Exporter') 
	}, 1, 'Plugin Exporter loaded' ],
	[ sub {
		pause(100);
		$pext->plugUnload('Exporter');
		my $b = $pext->plugGet('Exporter');
		return defined $b 



( run in 3.773 seconds using v1.01-cache-2.11-cpan-0d23b851a93 )