App-Codit

 view release on metacpan or  search on metacpan

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


	my $text = $self->CodeText(
		-contextmenu => $ext->ContextMenu,
		-height => 8,
		-keyreleasecall => ['KeyReleased', $self],
		-logcall => ['log', $self],
		-modifiedcall => ['Modified', $self],
		-saveimage => $ext->getArt('document-save', 16),
		-scrollbars => 'osoe',
		-width => 8,
	)->pack(-expand => 1, -fill => 'both');
	$self->CWidg($text);
	my $xt = $text->Subwidget('XText');
	$xt->bind('<Control-f>', sub { $ext->cmdExecute('doc_find') });
	$xt->bind('<Control-r>', sub { $ext->cmdExecute('doc_replace') });
	$self->{NAME} = '';

	$self->ConfigSpecs(
		-contentacpopsize => [{-acpopsize => $xt}],
		-contentacscansize => [{-acscansize => $xt}],
		-contentactivedelay => [{-activedelay => $xt}],

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

	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 {
			my ($file) = $ext->pickFileSave(
				-loadfilter => '.ctt',
			);
			$te->save($file) if defined $file;

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


=item B<git_collapse> in L<App::Codit::Plugins::Git>

Collapses the git document tree and only opens the current selected document, if it is in
the current selected repository.

=item B<git_command> I<$project>, I<$commandstring> in L<App::Codit::Plugins::Git>

Executes the git command in $commandstring for repository $project.

=item B<git_expand> in L<App::Codit::Plugins::Git>

Epxands the git document tree.

=item B<git_open_all> in L<App::Codit::Plugins::Git>

Opens all files in the current selected repository.

=item B<git_remove> I<?$name?> in L<App::Codit::Plugins::Git>

If $name is not specified, $name is the selected document.

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


=back

Default value:

 [
    CENTER => {
       -in => 'MAIN',
       -side => 'top',
       -fill => 'both',
       -expand => 1,
    },
    WORK => {
       -in => 'CENTER',
       -side => 'left',
       -fill => 'both',
       -expand => 1,
    },
    TOP => {
       -in => 'MAIN',
       -side => 'top',
       -before => 'CENTER',
       -fill => 'x',
       -canhide => 1,
    },
    BOTTOM => {
       -in => 'MAIN',

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

#require Tk::AppWindow::PluginsForm;
require App::Codit::CoditTagsEditor;
require App::Codit::Macro;
require Tk::YADialog;

my @navcontextmenu = (
	[ 'menu_normal',    undef,  '~Close',  'doc_close',	 'document-close', '*CTRL+SHIFT+O'],
	[ 'menu_normal',    undef,  '~Delete',  'doc_delete_dialog',	 'edit-delete'],
	[ 'menu_separator', undef,  'c1'],
	[ 'menu_normal',    undef,  '~Collapse all',  'nav_collapse'],
	[ 'menu_normal',    undef,  '~Expand all',  'nav_expand'],
);

=head1 SYNOPSIS

my $app = new App::Codit(@options,
	-extensions => ['CoditMDI'],
);
$app->MainLoop;

=head1 DESCRIPTION

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

		doc_get_text => ['docGetText', $self],
		doc_remove_trailing => ['docRemoveTrailing', $self],
		doc_replace => ['docPopFindReplace', $self, 0],
		doc_wrap => ['docWrap', $self],
		edit_delete => ['editDelete', $self],
		edit_insert => ['editInsert', $self],
		edit_replace => ['editReplace', $self],
		key_released => ['keyReleased', $self],
		modified => ['contentModified', $self],
		nav_collapse => ['navCollapse', $self],
		nav_expand => ['navExpand', $self],
	);
	return $self;
}

sub _mcr { return $_[0]->{MACROS} }

sub bookmarkAdd {
	my $self = shift;
	my $doc = $self->docSelected;
	if (defined $doc) {

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

	my $git = $self->extGet('Plugins')->plugGet('Git');
	push @items, [ 'menu_normal', 'c1', '~Add to project', 'git_add', 'git-icon',] if defined $git;

	my $stack = $self->extGet('MenuBar')->menuStack(@items);
	$nav->configure('-contextmenu', $stack);
}

sub navExpand {
	my $self = shift;
	my $tree = $self->Subwidget('NAVTREE');
	$tree->expandAll;
}

sub SettingsPage {
	my $self = shift;
	my ($first) = $self->docList;
	my $doc = $self->docGet($first);
	return () unless defined $doc;
	my $themefile = $doc->cget('-highlight_themefile');
	my $historyfile = $self->extGet('ConfigFolder')->ConfigFolder . '/color_history';
	my @opt = (

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


	$self->{CURRENT} = undef;
	$self->{NEXT} = [];
	$self->{PREVIOUS} = [];

	my $tree = $page->Scrolled('ITree',
		-height => 4,
		-browsecmd => ['Select', $self],
		-scrollbars => 'osoe',
		-separator => '@',
	)->pack(-padx => 2, -pady => 2, -expand => 1, -fill => 'both');
	$self->{TREE} = $tree;

	$self->after(100, ['Initialize', $self]);
	return $self;
}

sub _visible {
	my $self = shift;
	return $self->tree->ismapped;
}

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


	$bframe->Button(
		-text => 'Insert',
		-command => sub {
			if ($picker->validate($color)) {
				$self->cmdExecute('edit_insert', 'insert', $color);
				$picker->historyAdd($picker->getHEX);
				$picker->historyUpdate;
			}
		},
	)->pack(@padding, -side => 'left', -expand => 1, -fill => 'x');

	$bframe->Button(
		-text => 'Copy',
		-command => sub {
			if ($picker->validate($color)) {
				$self->clipboardClear;
				$self->clipboardAppend($color);
				$picker->historyAdd($picker->getHEX);
				$picker->historyUpdate;
			}
		},
	)->pack(@padding, -side => 'left', -expand => 1, -fill => 'x');

	my $indicator = $eframe->Label(
		-width => 4,
		-relief => 'sunken',
		-borderwidth => 2,
	)->pack(@padding, -side => 'left', -expand => 1, -fill => 'both');
	$self->{INDICATOR} = $indicator;

	$picker = $page->ColorPicker(
		-depthselect => 1,
		-notationselect => 1,
		-historyfile => $self->extGet('ConfigFolder')->ConfigFolder . '/color_history',
		-updatecall => ['updatePicker', $self],
	)->pack(-padx => 2, -pady => 2, -expand => 1, -fill => 'both');
	$self->{PICKER} = $picker;
	$self->jobStart('selection_check', 'SelectionCheck', $self);
	return $self;
}

sub _ent {
	my ($self, $value) = @_;
	my $entry = $self->{ENTRY};
	if (defined $value) {
		$entry->delete('0', 'end');

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

	
	my $folder = $self->configGet('-configfolder');
	my $hist = "$folder/console_history";
	my $text = $page->Scrolled('Terminal',
		-width => 8,
		-height => 8,
		-historyfile => $hist,
		-scrollbars => 'oe',
		-linkcall => ['linkSelect', $self],
		-linkreg => qr/[^\s]+\sline\s\d+/,
	)->pack(@pad, -expand => 1, -fill => 'both');
	$text->bind('<Button-3>', [$self, 'popMenu']);
	$self->{TXT} = $text;
	$workdir = $text->cget('-workdir');
	my $sb = $self->sidebars;
	$sb->pageSelectCall('Console', sub { $text->focus });
	$sb->pageUnselectCall('Console', sub { 
		my $w = $self->mdi->docWidget;
		$w->focus if defined $w;
	});
	

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

		push @op, $opt, $img if defined $img;
	}

	my $b = $page->FileManager(@op,
		-invokefile => ['fbInvoke', $self],
		-listmenu => $self->extGet('MenuBar')->menuStack(@contextmenu),
		-diriconcall => ['getDirIcon', $self],
		-fileiconcall => ['getFileIcon', $self],
		-linkiconcall => ['getLinkIcon', $self],
		-selectmode => 'extended',
	)->pack(-expand => 1, -fill => 'both');
	$self->cmdConfig(
		'fb_copy' => ['clipboardCopy', $b],
		'fb_cut' => ['clipboardCut', $b],
		'fb_delete' => ['delete', $b],
		'fb_open' => ['fbOpen', $self],
		'fb_paste' => ['clipboardPaste', $b],
		'fb_properties' => ['propertiesPop', $b],
	);
	$self->after(1000, ['load', $b]);
	$self->{BROWSER} = $b;

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

use File::Basename;

use Config;
my $mswin = $Config{'osname'} eq 'MSWin32';

my @contextmenu = (
	[ 'menu_normal',    undef,  '~Open all files',  'git_open_all',	 'document-open'],
	[ 'menu_normal',    undef,  '~Remove from project',  'git_remove_dialog',	 'edit-delete'],
	[ 'menu_separator', undef,  'c1'],
	[ 'menu_normal',    undef,  '~Collapse all',  'git_collapse'],
	[ 'menu_normal',    undef,  '~Expand all',  'git_expand'],
);

=head1 DESCRIPTION

Integrate Git into Codit.

=head1 DETAILS

This plugin will only load if the git executable is installed.

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

it will add the repository to the top menu list. If you select a repository
from that list all documents in that repository are loaded in the file list.
Selecting a document in the list will open it if it is not yet opened and select it.

When a file is closed it will check if there are any remaining documents in it's repository
are opened. If none are open it will unselect the repository and remove it from the
top menu list.

It has a context menu that pops with the right mouse button. You can quickly open all files in
the repository, or remove the current selected file from the repository. And you can collapse
and expand the list.

=head1 COMMANDS

Thi Git plugin adds the following commands to Codit.

=over 4

=item B<git_collapse>

Collapses the git document tree and only opens the current selected document, if it is in
the current selected repository.

=item B<git_command> I<$project>, I<$commandstring>

Executes the git command in $commandstring for repository $project.

=item B<git_expand>

Epxands the git document tree.

=item B<git_open_all>

Opens all files in the current selected repository.

=item B<git_remove> I<?$name?>

If $name is not specified, $name is the selected document.

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

	my $git = `git -v`;
	return undef unless $git =~/^git\sversion/;

	$self->cmdHookAfter('doc_open', 'openDocAfter', $self);
	$self->cmdHookAfter('doc_close', 'closeDocAfter', $self);
	$self->cmdHookBefore('doc_select', 'selectDocBefore', $self);
	$self->cmdConfig(
		git_add => ['gitAdd', $self],
		git_collapse => ['gitCollapse', $self],
		git_command => ['gitCommand', $self],
		git_expand => ['gitExpand', $self],
		git_open_all => ['gitOpenAll', $self],
		git_remove => ['gitRemove', $self],
		git_remove_dialog => ['gitRemoveDialog', $self],
	);

	$self->{PROJECTS} = {};

	my $page = $self->ToolLeftPageAdd('Git', 'git-icon', undef, 'Manage your projects', 250);
	
	my $pframe = $page->Frame->pack(-fill => 'x');
	$pframe->Label(-text => 'Project:')->pack(-side => 'left');

	my $current = '';
	$self->{CURRENT} = \$current;
	my $mb = $pframe->Menubutton(
		-anchor => 'w',
		-textvariable => \$current,
	)->pack(-side => 'left', -expand => 1, -fill => 'x');

	my $menu = $mb->Menu(-tearoff => 0);
	$mb->configure(-menu => $menu);
	$self->{PMENU} = $menu;

	my $nav = $self->extGet('Selector');
	my $gtree = $page->DocumentTree(
		-entryselect => ['selectInternal', $self],
		-diriconcall => ['GetDirIcon', $nav],
		-fileiconcall => ['GetFileIcon', $nav],
		-saveiconcall => ['GetSaveIcon', $nav],
	)->pack(-expand => 1, -fill => 'both');
	my $stack =$self->extGet('MenuBar')->menuStack(@contextmenu);
	$gtree->configure('-contextmenu', $stack);
	$self->{TREE} = $gtree;
	
	$self->after(10, ['doPostConfig', $self]);
	return $self;
}

sub closeDocAfter {
	my ($self, $file) = @_;

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


sub gitCollapse {	$_[0]->{TREE}->collapseAll }

sub gitCommand {
	my ($self, $project, $command) = @_;
	my $folder = $self->projectFolder($project);
	return unless defined $folder;
	return `cd $folder; git $command`
}

sub gitExpand {	$_[0]->{TREE}->expandAll }

sub gitFileList {
	my ($self, $project) = @_;
	my $list = $self->gitCommand($project, 'ls-files');
	my $folder = $self->projectFolder($project);
	my $sep = $self->{TREE}->cget('-separator');
	my @items = ();
	while ($list =~ s/([^\n]*)\n//) {
		my $file = "$folder$sep$1";
		push @items, $file

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

	$self->cmdExecute('doc_select', $name) if $mdi->docExists($name);
}

sub Unload {
	my $self = shift;
	$self->ToolLeftPageRemove('Git');
	for (
		'git_add',
		'git_collapse',
		'git_command',
		'git_expand',
		'git_open_all',
		'git_remove',
		'git_remove_dialog',
	) {
		$self->cmdRemove($_);
	}
	$self->cmdUnhookAfter('doc_close', 'closeDocAfter', $self);
	$self->cmdUnhookAfter('doc_open', 'openDocAfter', $self);
	$self->cmdUnhookBefore('doc_select', 'selectDocBefore', $self);
	my $flag = $self->SUPER::Unload;

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

	my $eframe = $page->Frame(
		-relief => 'groove',
		-borderwidth => 2,
	)->pack(-fill => 'x');
	$eframe->Button(
		-text => 'Insert',
		-command => sub {
			my ($sel) = $list->selectionGet;
			$self->cmdExecute('edit_insert', 'insert', $sel) if defined $sel;
		},
	)->pack(@padding, -side => 'left', -expand => 1, -fill => 'x');
	$eframe->Button(
		-text => 'Copy',
		-command => sub {
			my ($sel) = $list->selectionGet;
			if (defined $sel) {
				$self->clipboardClear;
				$self->clipboardAppend($sel);
			}
		},
	)->pack(@padding, -side => 'left', -expand => 1, -fill => 'x');

	my $current = '';
	my $l = $page->Label(
		-textvariable => \$current,
	)->pack(-fill => 'x', -pady => 2);
	$self->{INDICATOR} = \$current,

	$list = $page->ListBrowser(
		-arrange => 'row',
		-itemtype => 'imagetext',
		-wraplength => 70,
		-textside => 'bottom',
	)->pack(-expand => 1, -fill => 'both');
	my $art = $self->extGet('Art');
	my @icons = $art->AvailableIcons($self->cget('-icontheme'));
	for (@icons) {
		my $img = $art->getIcon($_, 48);
		next if $img->height > 48;
		my $text = $self->abbreviate($_, 30);
		$list->add($_,
			-image => $img,
			-text => $text,
		)

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


	$self->{CURRENT} = [];
	$self->{SORTON} = 'Line';
	$self->{SORTORDER} = 'ascending';
	
	my $hlist = $page->Scrolled('HList',
		-browsecmd => ['Select', $self],
		-columns => 2,
		-header => 1,
		-scrollbars => 'osoe',
	)->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'),

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

		my ($opt, $icon, $text) = @$_;
		my $img = $art->getIcon($icon, 22);
		push @vopt, $opt, $art->createCompound(
			-image => $img,
			-text => $text,
		) if defined $img;
	}
	my $pod = $page->PodViewerFull(@vopt,
		-font => $font,
		-linkcolor => $self->configGet('-linkcolor'),
	)->pack(-expand => 1, -fill => 'both');
	my $sb = $self->sidebars;
	$sb->pageSelectCall('Pod', sub { $self->after(100, ['Refresh', $self]) });
	$self->{PODWIDGET} = $pod;

	return $self;
}


sub _visible {
	my $self = shift;

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

	$self->{SEARCH} = \$searchterm;
	$self->{SKIPPED} = 0;

	my @padding = (-padx => 2, -pady => 2);

	my $sa = $page->Frame(
		-relief => 'groove',
		-borderwidth => 2,
	)->pack(@padding, -fill => 'x');

	my $sf = $sa->Frame->pack(-expand => 1, -fill => 'x');
	$sf->Label(
		-text => 'Search',
		-width => 7,
		-anchor => 'e',
	)->pack(@padding, -side => 'left');
	my $se = $sf->Entry(
		-textvariable => \$searchterm,
	)->pack(@padding, -side => 'left', -expand => 1, -fill => 'x');
	$se->bind('<Return>', [$self, 'Find']);

	my $rf = $sa->Frame->pack(-expand => 1, -fill => 'x');
	$rf->Label(
		-text => 'Replace',
		-width => 7,
		-anchor => 'e',
	)->pack(@padding, -side => 'left');
	$rf->Entry(
		-textvariable => \$replaceterm,
	)->pack(@padding, -side => 'left', -expand => 1, -fill => 'x');

	my $sb = $page->LabFrame(
		-labelside => 'acrosstop',
		-relief => 'groove',
		-label => 'Search options',
	)->pack(@padding, -fill => 'x');

	$sb->Checkbutton(
		-variable => \$useregex,
		-text => 'Regular expression',

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

	$sc->Button(
		-command => ['Skip', $self],
		-text => 'Skip',
		-width => 8,
	)->grid(@padding, -column => 1, -row => 1, -sticky => 'ew');


	my $tf = $page->Frame(
		-relief => 'groove',
		-borderwidth => 2,
	)->pack(@padding, -expand => 1, -fill => 'both');
	$tf->gridColumnconfigure(0, -weight => 2);
	$tf->gridColumnconfigure(1, -weight => 2);
	$tf->gridRowconfigure(1, -weight => 2);
	$tf->Button(
		-text => 'Previous',
		-command => ['BrowsePrevious', $self],
		-width => 8,
	)->grid(@padding, -column => 0, -row => 0, -sticky => 'ew');
	$tf->Button(
		-text => 'Next',

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

		-command => ['snippetCopy', $self],
	)->pack(@padding, -fill=> 'x');
	$lf->Button(
		-text => 'Delete',
		-command => ['snippetDelete', $self],
	)->pack(@padding, -fill => 'x');
	my $hlist = $lf->Scrolled('HList',
		-browsecmd => ['listSelect', $self],
		-height => 4,
		-scrollbars => 'osoe',
	)->pack(@padding, -expand => 1, -fill => 'both');
	$self->{LIST} = $hlist;

	$page->Adjuster(
		-side => 'top',
		-widget => $lf,
	)->pack(-fill => 'x');
	
	my $sf = $page->Frame(
		-relief => 'groove',
		-borderwidth => 2,
	)->pack(@padding, -expand => 1, -fill => 'both');
	$sf->Button(
		-text => 'Insert',
		-command => ['snippetInsert', $self],
	)->pack(@padding, -fill => 'x');
	$sf->Button(
		-text => 'Clipboard',
		-command => ['snippetClipboard', $self],
	)->pack(@padding, -fill => 'x');
	$sf->Button(
		-text => 'Create',
		-command => ['snippetCreate', $self],
	)->pack(@padding, -fill => 'x');
	my @to = ();
	my $text = $sf->Scrolled('XText', @to,
		-scrollbars => 'osoe',
		-tabs => '8m',
		-wrap => 'none',
		-height => 4,
		-width => 20,
	)->pack(@padding, -expand => 1, -fill => 'both');
	$self->after(200, sub {
		$text->configure('-font', $self->mdi->docWidget->cget('-font'))
	});
	$self->{TEXT} = $text;

	$self->listRefresh;
	return $self;
}

sub _list {

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


sub splitSelect {
	my ($self, $name) = @_;
	my $split = $self->split;
	my $mdi = $self->mdi;
	my $w;
	unless (exists $self->{DOCS}->{$name}) {
		my $page = $split->getPage($name);
		my $man = $page->CodeTextManager(
			-extension => $mdi,
		)->pack(-expand => 1, -fill => 'both');
		$w = $man->CWidg;
		$w->configure('-readonly', 1);
		$self->{DOCS}->{$name} = $w;
	} else {
		$w = $self->{DOCS}->{$name}
	}
	if ($mdi->deferredExists($name)) {
		$w->load($name);
	} else {
		my $d = $mdi->docGet($name);

t/010-App-Codit-CodeTextManager.t  view on Meta::CPAN


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

# createapp(
# );
# 
# my $manager;
# if (defined $app) {
# 	$manager = $app->CodeTextManager(
# 		-extension => $app,
# 	)->pack(-expand => 1, -fill => 'both');
# }
# 
# push @tests , [ sub { return defined $manager }, 1, 'CodeTextManager created'];
# 
# starttesting;

t/020-App-Codit-SessionManager.t  view on Meta::CPAN

use Test::More tests => 1;
$mwclass = 'Tk::AppWindow';

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

# createapp(
# );
# 
# my $text;
# if (defined $app) {
# 	$text = $app->CoditText->pack(-expand => 1, -fill => 'both');
# }
# 
# push @tests , [ sub { return defined $text }, 1, 'CoditText created'];
# 
# starttesting;

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


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'];


starttesting;



( run in 1.254 second using v1.01-cache-2.11-cpan-5b529ec07f3 )