Codit.pm untested

filter: Statementstmt 0.0% 0 / 206 Branchbran 0.0% 0 / 44 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 36 Podpod 0.0% 0 / 28 totaltotal 0.0% 0 / 314 CC 23 SCAR 23.8
CC
23
Cov
0%
lockScan
42.0
uniqueinstance
30.0
lockModified
12.0
CRAP 10.8
1 package App::Codit;
2  
3 use strict;
4 use warnings;
5 use Carp;
6 use vars qw($VERSION);
7 $VERSION = '0.23';
8 use Tk;
9 use App::Codit::CodeTextManager;
10 use Config;
11 my $mswin = $Config{'osname'} eq 'MSWin32';
12  
13 use base qw(Tk::Derived Tk::AppWindow);
14 Construct Tk::Widget 'Codit';
15  
16 =head1 NAME
17  
18 App::Codit - IDE for and in Perl
19  
20 =head1 DESCRIPTION
21  
22 Codit is a versatile text editor / integrated development environment aimed at the
23 Perl programming language.
24  
25 It is written in Perl/Tk and based on the L<Tk::AppWindow> application framework.
26  
27 It uses the L<Tk::CodeText> text widget for editing.
28  
29 Codit has been under development for about one year now. It has gone quite some miles on our systems
30 and can be considered beta software as of version 0.10.
31  
32 It features a multi document interface that can hold an unlimited number of documents,
33 navigable through the tab bar at the top and a document list in the left side panel.
34  
35 It has a plugin system designed to invite users to write their own plugins.
36  
37 It is fully configurable through a configuration window, allowing you to set defaults
38 for editing, the graphical user interface, syntax highlighting and (un)loading plugins.
39  
40 L<Tk::CodeText> offers syntax highlighting and code folding in plenty formats and languages.
41 It has and advanced word based undo/redo stack that keeps track of selections and save points.
42 It does auto indent, auto brackets, auto complete, bookmarks, comment, uncomment, indent and unindent.
43 Tab size and indent style are fully user configurable.
44  
45 An online manual can be found here:
46 L<http://www.perlgui.org/wp-content/uploads/2025/01/manual-0.16.pdf>
47  
48 =head1 RUNNING CODIT
49  
50 You can launch Codit from the command line as follows:
51  
52 codit [options] [files]
53  
54 The following command line options are available:
55  
56 =over 4
57  
58 =item I<-c> or I<-config>
59  
60 Specifies the configfolder to use. If the path does not exist it will be created.
61  
62 =item I<-h> or I<-help>
63  
64 Displays a help message on the command line and exits.
65  
66 =item I<-i> or I<-iconpath>
67  
68 Point to the folders where your icon libraries are located.*
69  
70 =item I<-t> or I<-icontheme>
71  
72 Icon theme to load.
73  
74 =item I<-np> or I<-noplugins>
75  
76 Launch without any plugins loaded. This supersedes the -plugins option.
77  
78 =item I<-p> or I<-plugins>
79  
80 Launch with only these plugins .*
81  
82 =item I<-s> or I<-session>
83  
84 Loads a session at launch. The plugin Sessions must be loaded for this to work.
85  
86 =item I<-y> or I<-syntax>
87  
88 Specify the default syntax to use for syntax highlighting. Codit will determine the syntax
89 of documents by their extension. This options comes in handy when the file you are
90 loading does not have an extension.
91  
92 =item I<-v> or I<-version>
93  
94 Displays the version number on the command line and exits.
95  
96 =back
97  
98 * You can specify a list of items by separating them with a ':'.
99  
100 =head1 TROUBLESHOOTING
101  
102 Just hoping you never need this.
103  
104 =head2 General troubleshooting
105  
106 If you encounter problems and error messages using Codit here are some general troubleshooting steps:
107  
108 =over 4
109  
110 =item Use the -config command line option to point to a new, preferably fresh settingsfolder.
111  
112 =item Use the -noplugins command line option to launch Codit without any plugins loaded.
113  
114 =item Use the -plugins command line option to launch Codit with only the plugins loaded you specify here.
115  
116 =back
117  
118 =head2 No icons
119  
120 If Codit launches without any icons do one or more of the following:
121  
122 =over 4
123  
124 =item Check if your icon theme is based on scalable vectors. Install Image::LibRSVG if so. See also the Readme.md that comes with this distribution.
125  
126 =item Locate where your icons are located on your system and use the -iconpath command line option to point there.
127  
128 =item Select an icon library by using the -icontheme command line option.
129  
130 =back
131  
132 =head2 Session will not load
133  
134 Sometimes it happens that a session file gets corrupted. You solve it like this:
135  
136 =over 4
137  
138 =item Launch the session manager. Menu->Session->Manage sessions.
139  
140 =item Remove the affected session.
141  
142 =item Rebuild it from scratch.
143  
144 =back
145  
146 Sorry, that is all we have to offer.
147  
148 =head3 Report a bug
149  
150 If all fails you are welcome to open a ticket here: L<https://github.com/haje61/App-Codit/issues>.
151  
152 =head1 BASECLASSES
153  
154 Codit comes with the base class L<App::Codit::BaseClasses::TextModPlugin>. It is used by several
155 plugins. You can use it to define your own plugin.
156  
157 =head1 EXTENSIONS
158  
159 Codit uses the following extensions from L<Tk::AppWindow>:
160  
161 =over 4
162  
163 =item B<Art> see L<Tk::AppWindow::Ext::Art>
164  
165 =item B<ConfigFolder> see L<Tk::AppWindow::Ext::ConfigFolder>
166  
167 =item B<Daemons> see L<Tk::AppWindow::Ext::Daemons>
168  
169 =item B<Help> see L<Tk::AppWindow::Ext::Help>
170  
171 =item B<Keyboard> see L<Tk::AppWindow::Ext::Keyboard>
172  
173 =item B<MenuBar> see L<Tk::AppWindow::Ext::MenuBar>
174  
175 =item B<Panels> see L<Tk::AppWindow::Ext::Panels>
176  
177 =item B<Plugins> see L<Tk::AppWindow::Ext::Plugins>
178  
179 =item B<Selector> see L<Tk::AppWindow::Ext::Selector>
180  
181 =item B<Settings> see L<Tk::AppWindow::Ext::Settings>
182  
183 =item B<SideBars> see L<Tk::AppWindow::Ext::SideBars>
184  
185 =item B<StatusBar> see L<Tk::AppWindow::Ext::StatusBar>
186  
187 =item B<ToolBar> see L<Tk::AppWindow::Ext::ToolBar>
188  
189 =back
190  
191 Codit has its own extension as multiple document interface.
192  
193 =over 4
194  
195 =item B<CoditMDI> see L<App::Codit::Ext::CoditMDI>
196  
197 =back
198  
199 =head1 PLUGINS
200  
201 Codit comes with these plugins:
202  
203 =over 4
204  
205 =item B<Backups> see L<App::Codit::Plugins::Backups>
206  
207 =item B<Bookmarks> see L<App::Codit::Plugins::Bookmarks>
208  
209 =item B<Colors> see L<App::Codit::Plugins::Colors>
210  
211 =item B<Console> see L<App::Codit::Plugins::Console>
212  
213 =item B<Critic> see L<App::Codit::Plugins::Critic>
214  
215 =item B<Diff> see L<App::Codit::Plugins::Diff>
216  
217 =item B<Exporter> see L<App::Codit::Plugins::Exporter>
218  
219 =item B<FileBrowser> see L<App::Codit::Plugins::FileBrowser>
220  
221 =item B<Git> see L<App::Codit::Plugins::Git>
222  
223 =item B<Icons> see L<App::Codit::Plugins::Icons>
224  
225 =item B<PerlSubs> see L<App::Codit::Plugins::PerlSubs>
226  
227 =item B<PodViewer> see L<App::Codit::Plugins::PodViewer>
228  
229 =item B<SearchReplace> see L<App::Codit::Plugins::SearchReplace>
230  
231 =item B<Sessions> see L<App::Codit::Plugins::Sessions>
232  
233 =item B<Snippets> see L<App::Codit::Plugins::Snippets>
234  
235 =item B<SpltView> see L<App::Codit::Plugins::SplitView>
236  
237 =back
238  
239 =head1 CONFIG VARIABLES
240  
241 Codit defines the following config variables. The I<-content...> variables all
242 have an undefined default value. Most of them can be set through the Settings panel.
243 As long as you do not set them, the factory value of the L<Tk::CodeText> widget is used.
244  
245 =over 4
246  
247 =item Switch B<-contentacpopsize>
248  
249 Specifies how many characters you type before an auto complete suggestion list pops up.
250  
251 =item Switch B<-contentacscansize>
252  
253 Specifies the minimum word length for an addition to the database.
254  
255 =item Switch B<-contentactivedelay>
256  
257 Specifies the delay in ms between the moment the user stops typing and the moment an
258 auto complete suggestion list pops up.
259  
260 =item Switch B<-contentautobrackets>
261  
262 Boolean. If set, Every time you type a (, {, {, ' or " it's counterpart will be placed
263 right after it and the insert cursor in between.
264  
265 =item Switch B<-contentautocomplete>
266  
267 Boolean. If set, auto complete is on.
268  
269 =item Switch B<-contentautoindent>
270  
271 Boolean. If set, auto indent is on.
272  
273 =item Switch B<-contentbackground>
274  
275 Background color of the Tk::CodeText widget.
276  
277 =item Switch B<-contentbgdspace>
278  
279 Background color of leading and trailing spaces when showspaces is on.
280  
281 =item Switch B<-contentbgdtab>
282  
283 Background color of leading and trailing tabs when showspaces is on.
284  
285 =item Switch B<-contentbookmarkcolor>
286  
287 Background color of line number indicator of bookmarked lines.
288  
289 =item Switch B<-contentfindbg>
290  
291 Background color search hits.
292  
293 =item Switch B<-contentfontfamily>
294  
295 Font family to be used for editing.
296  
297 =item Switch B<-contentfontsize>
298  
299 Font size to be used for editing.
300  
301 =item Switch B<-contentforeground>
302  
303 Background color of the Tk::CodeText widget.
304  
305 =item Switch B<-contentindent>
306  
307 Set the preferred indent style. You can set it to 'tab'
308 if you use tabs for indenting. Or you set it to the number
309 of spaces you want to use for indenting.
310  
311 =item Switch B<-contentmatchbg>
312  
313 Background color used when matching {}, (), and [].
314  
315 =item Switch B<-contentmatchfg>
316  
317 Foreground color used when matching {}, (), and [].
318  
319 =item Switch B<-contentshowspaces>
320  
321 Boolean. If set, Leading and trailing spaces and tabs are shown
322 with a special background..
323  
324 =item Switch B<-contentsyntax>
325  
326 Default syntax setting for a new text document.
327  
328 =item Switch B<-contenttabs>
329  
330 Specify your tab size. See also L<Tk::Text>.
331  
332 =item Switch B<-contentwrap>
333  
334 Specify your wrap style. See also L<Tk::Text>.
335  
336 =item Switch B<-highlight_themefile>
337  
338 Specify the theme file used for syntax highlighting.
339  
340 =item Switch B<-showfolds>
341  
342 Boolean. If you clear it the fold indicators in the L<Tk::CodeText> widget
343 will be hidden.
344  
345 =item Switch B<-shownumbers>
346  
347 Boolean. If you clear it the line number indicators in the L<Tk::CodeText> widget
348 will be hidden.
349  
350 =item Switch B<-showstatus>
351  
352 Boolean. If you clear it the status bar in the L<Tk::CodeText> widget
353 will be hidden.
354  
355 =item Switch B<-uniqueinstance>
356  
357 Boolean flag. Default value 0. If set only this instance is used
358 for opening files through the command line.
359  
360 =back
361  
362 =head1 COMMANDS
363  
364 Codit defines one command.
365  
366 =over 4
367  
368 =item Switch B<-report_issue>
369  
370 Opens the issues web page of the App::Codit github repository.
371  
372 =back
373  
374 =head1 METHODS
375  
376 B<App::Codit> inherits L<Tk::AppWindow> and all of its methods.
377  
378 =over 4
379  
380 =cut
381  
382 sub Populate {
383 my ($self,$args) = @_;
384  
385 my $rawdir = Tk::findINC('App/Codit/Icons');
386 my %opts = (
387 # -appname => 'Codit',
388 -logo => Tk::findINC('App/Codit/codit_logo.png'),
389 -extensions => [qw[Art CoditMDI ToolBar StatusBar MenuBar Selector Help Settings Plugins]],
390 -documentinterface => 'CoditMDI',
391 -namespace => 'App::Codit',
392 -rawiconpath => [ $rawdir ],
393 -savegeometry => 1,
394 -updatesmenuitem => 1,
395  
396 #configure the application layout.
397 -panelgeometry => 'grid',
398 -panellayout => [
399 CENTER => {
400 -weight => 1,
401 -in => 'MAIN',
402 -column => 0,
403 -row => 1,
404 -sticky => 'nsew',
405 },
406 SUBCENTER => {
407 -in => 'CENTER',
408 -weight => 1,
409 -column => 2,
410 -row => 0,
411 -sticky => 'nsew',
412 },
413 WORK => {
414 -in => 'SUBCENTER',
415 -weight => 1,
416 -column => 0,
417 -row => 0,
418 -sticky => 'nsew',
419 },
420 TOOL => {
421 -in => 'SUBCENTER',
422 -weight => 1,
423 -column => 0,
424 -row => 2,
425 -sticky => 'ew',
426 -canhide => 1,
427 -adjuster => 'bottom',
428 },
429 TOP => {
430 -weight => 1,
431 -in => 'MAIN',
432 -column => 0,
433 -row => 0,
434 -sticky => 'ew',
435 -canhide => 1,
436 },
437 BOTTOM => {
438 -in => 'MAIN',
439 -column => 0,
440 -row => 2,
441 -sticky => 'ew',
442 -canhide => 1,
443 },
444 LEFT => {
445 -in => 'CENTER',
446 -column => 0,
447 -row => 0,
448 -sticky => 'ns',
449 -canhide => 1,
450 -adjuster => 'left',
451 },
452 RIGHT => {
453 -in => 'CENTER',
454 -column => 4,
455 -row => 0,
456 -sticky => 'ns',
457 -canhide => 1,
458 -adjuster => 'right',
459 },
460 ],
461  
462 #help info
463 -aboutinfo => {
464 author => 'Hans Jeuken',
465 components => [
466 'FreeDesktop::Icons',
467 'Imager',
468 'Syntax::Kamelon',
469 'Tk',
470 'Tk::AppWindow',
471 'Tk::CodeText',
472 'Tk::ColorEntry',
473 'Tk::DocumentTree',
474 'Tk::FileBrowser',
475 'Tk::ListBrowser',
476 'Tk::ListEntry',
477 'Tk::PodViewer',
478 'Tk::PopList',
479 'Tk::QuickForm',
480 'Tk::Terminal',
481 'Tk::YADialog',
482 'Tk::YANoteBook',
483 ],
484 http => 'https://www.perlgui.org/appcodit/',
485 },
486 -helpfile => 'https://www.perlgui.org/wp-content/uploads/2026/07/manual-0.22.pdf',
487  
488 #configure content manager
489 -contentmanagerclass => 'CodeTextManager',
490 -contentmanageroptions => [
491 '-contentacpopsize',
492 '-contentacscansize',
493 '-contentactivedelay',
494 '-contentautobrackets',
495 '-contentautocomplete',
496 '-contentautoindent',
497 '-contentbackground',
498 '-contentbgdspace',
499 '-contentbgdtab',
500 '-contentbookmarkcolor',
501 '-contentfindbg',
502 '-contentfontfamily',
503 '-contentfontsize',
504 '-contentforeground',
505 '-contentindent',
506 '-contentmatchbg',
507 '-contentmatchfg',
508 '-contentshowspaces',
509 '-contentsyntax',
510 '-contenttabs',
511 '-contentwrap',
512 '-showfolds',
513 '-shownumbers',
514 '-showstatus',
515 '-highlight_themefile',
516 ],
517  
518 #configure the settings panel
519 -useroptions => [
520 '*page' => 'Editing',
521 '*section' => 'Font',
522 -contentfontfamily => ['list', 'Family', -filter => 1, -values => sub { return sort $self->fontFams }
523 ],
524 '*column',
525 -contentfontsize => ['spin', 'Size'],
526 '*end',
527 '*section' => 'Editor settings',
528 '*frame',
529 -contentautoindent => ['boolean', 'Auto indent'],
530 '*column',
531 -contentautobrackets => ['boolean', 'Auto brackets'],
532 '*column',
533 -contentshowspaces => ['boolean', 'Show spaces'],
534 '*end',
535 '*frame',
536 -contenttabs => ['text', 'Tab size', -regex => qr/^\d+\.?\d*[c|i|m|p]$/, -width => 4],
537 '*column',
538 -contentindent => ['text', 'Indent style', -regex => qr/^\d+|tab$/, -width => 4],
539 '*end',
540 -contentwrap => ['radio', 'Wrap', -values => [qw[none char word]]],
541 '*end',
542 '*section' => 'Show indicators',
543 -showfolds => ['boolean', 'Fold indicators'],
544 '*column',
545 -shownumbers => ['boolean', 'Line numbers'],
546 '*column',
547 -showstatus => ['boolean', 'Doc status'],
548 '*end',
549 '*section' => 'Auto complete',
550 -contentautocomplete => ['boolean', 'Enabled', -enables => ['-contentactivedelay', '-contentacpopsize', '-contentacscansize']],
551 -contentactivedelay => ['spin', 'Pop delay', -width => 4],
552 '*column',
553 -contentacpopsize => ['spin', 'Pop size', -width => 4],
554 -contentacscansize => ['spin', 'Scan size', -width => 4],
555 '*end',
556  
557 '*page' => 'Colors',
558 '*section' => 'Editing',
559 -contentforeground => ['color', 'Foreground', -width => 8],
560 '*column',
561 -contentbackground => ['color', 'Background', -width => 8],
562 '*end',
563 '*section' => 'Find',
564 -contentfindfg => ['color', 'Foreground', -width => 8],
565 '*column',
566 -contentfindbg => ['color', 'Background', -width => 8],
567 '*end',
568 '*section' => 'Spaces and tabs',
569 -contentbgdspace => ['color', 'Space bg', -width => 8],
570 '*column',
571 -contentbgdtab => ['color', 'Tab bg', -width => 8],
572 '*end',
573 '*section' => 'Matching {}, [] and ()',
574 -contentmatchfg => ['color', 'Foreground', -width => 8],
575 '*column',
576 -contentmatchbg => ['color', 'Background', -width => 8],
577 '*end',
578 '*section' => 'Other',
579 -errorcolor => ['color', 'Error', -width => 8],
580 -warningcolor => ['color', 'Warning', -width => 8],
581 '*column',
582 -linkcolor => ['color', 'Link', -width => 8],
583 -contentbookmarkcolor => ['color', 'Bookmark bg', -width => 8],
584 '*end',
585  
586 '*page' => 'GUI',
587 '*section' => 'Icon sizes',
588 -iconsize => ['spin', 'General', -width => 4],
589 -sidebariconsize => ['spin', 'Side bars', -width => 4],
590 '*column',
591 -menuiconsize => ['spin', 'Menu bar', -width => 4],
592 -tooliconsize => ['spin', 'Tool bar', -width => 4],
593 '*end',
594 '*section' => 'Visibility at lauch',
595 '-tool barvisible' => ['boolean', 'Tool bar'],
596 '-status barvisible' => ['boolean', 'Status bar'],
597 '*column',
598 '-navigator panelvisible' => ['boolean', 'Navigator panel'],
599 '*end',
600 '*frame',
601 '*section' => 'Geometry',
602 -savegeometry => ['boolean', 'Save on exit',],
603 '*end',
604 '*column',
605 '*section' => 'Unique instance',
606 -uniqueinstance => ['boolean', 'Enabled', -onvalue => 1, -offvalue => 0],
607 '*end',
608 '*end',
609 '*section' => 'Tool bar',
610 -tooltextposition => ['radio', 'Text position', -values => [qw[none left right top bottom]]],
611 '*end',
612 ],
613 -contentautoindent => 1,
614 -contentindent => 'tab',
615 -contentshowspaces => 0,
616 -contenttabs => '8m',
617 -contentwrap => 'none',
618 -showfolds => 1,
619 -shownumbers => 1,
620 -showstatus => 1,
621  
622 );
623 for (keys %opts) {
624 $args->{$_} = $opts{$_}
625 }
626 $self->SUPER::Populate($args);
627
628 $self->geometry('800x600+150+150');
629  
630 $self->{UNIQUE} = 0;
631  
632 $self->extGet('Panels')->panelHide('TOOL');
633 $self->extGet('Panels')->panelHide('RIGHT');
634
635 $self->cmdConfig(
636 report_issue => ['ReportIssue', $self],
637 );
638
639 $self->addPostConfig('DoPostConfig', $self);
640 $self->ConfigSpecs(
641 -uniqueinstance => ['METHOD', undef, undef, 0],
642 DEFAULT => ['SELF'],
643 );
644 }
645  
646 sub CanQuit {
647 my $self = shift;
648 my $file = $self->lockfile;
649 unlink $file if defined $file;
650 return $self->SUPER::CanQuit
651 }
652  
653 sub DoPostConfig {
654 my $self = shift;
655 $self->SetThemeFile;
656 $self->cmdExecute('doc_new');
657 }
658  
659 sub GetThemeFile {
660 return $_[0]->extGet('ConfigFolder')->ConfigFolder .'/highlight_theme.ctt';
661 }
662  
663 sub lockfile {
664 my $self = shift;
665 my $file = $self->configGet('-configfolder') . '/lockfile';
666 return $file if -e $file;
667 return undef
668 }
669  
670 sub lockModified {
671 my $self = shift;
672 my $file = $self->configGet('-configfolder') . '/lockfile';
673 if (-e $file) {
674 my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($file);
675 my $lmod = $self->{LOCKMODIFIED};
676 return $lmod ne $mtime if defined $lmod;
677 }
678 return ''
679 }
680  
681 sub lockReset {
682 my $self = shift;
683 my $file = $self->configGet('-configfolder') . '/lockfile';
684 if (open(LOUT, '>', $file)) {
685 print LOUT "\n";
686 close LOUT
687 }
688 my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($file);
689 $self->{LOCKMODIFIED} = $mtime;
690 }
691  
692 sub lockScan {
693 my $self = shift;
694 return unless $self->lockModified;
695 $self->deiconify unless $self->ismapped;
696 $self->focus;
697 $self->raise;
698 if (my $file = $self->lockfile) {
699 if (open(LIN, '<', $file)) {
700 while (<LIN>) {
701 my $line = $_;
702 chomp $line;
703 $self->cmdExecute('doc_open', $line) if -e $line
704 }
705 close LIN;
706 $self->lockReset;
707 }
708 }
709 }
710  
711 =item B<mdi>
712  
713 Returns a reference to the CoditMDI extension.
714  
715 =cut
716  
717 sub mdi {
718 return $_[0]->extGet('CoditMDI');
719 }
720  
721 sub MenuItems {
722 my $self = shift;
723 return ($self->SUPER::MenuItems,
724 [ 'menu_normal', 'appname::h1', '~Report a problem', 'report_issue' ],
725 )
726 }
727  
728 =item B<panels>
729  
730 Returns a reference to the Panels extension.
731  
732 =cut
733  
734 sub panels {
735 return $_[0]->extGet('Panels');
736 }
737  
738 sub ReportIssue {
739 my $self = shift;
740 $self->openURL('https://github.com/haje61/App-Codit/issues');
741 }
742  
743 sub SetThemeFile {
744 my $self = shift;
745 my $themefile = $self->GetThemeFile;
746 $self->SetDefaultTheme unless -e $themefile;
747 $self->configPut(-highlight_themefile => $themefile);
748 }
749  
750 sub SetDefaultTheme {
751 my $self = shift;
752 my $themefile = $self->GetThemeFile;
753 my $default = Tk::findINC('App/Codit/highlight_theme.ctt');
754 my $theme = Tk::CodeText::Theme->new;
755 $theme->load($default);
756 $theme->save($themefile);
757 }
758  
759 =item B<sidebars>
760  
761 Returns a reference to the SideBars extension.
762  
763 =cut
764  
765 sub sidebars {
766 return $_[0]->extGet('SideBars');
767 }
768  
769 sub ToolBottomBookAdd {
770 my $self = shift;
771 return if $self->ToolBottomBookExists;
772 my $sb = $self->sidebars;
773 $sb->nbAdd('tool panel bottom', 'TOOL', 'bottom');
774 $sb->nbTextSide('tool panel bottom', 'right');
775 $self->panels->panelShow('TOOL')
776 }
777  
778 sub ToolBottomBookExists {
779 my $self = shift;
780 return $self->sidebars->nbExists('tool panel bottom');
781 }
782  
783 sub ToolBottomBookRemove {
784 my $self = shift;
785 return unless $self->ToolBottomBookExists;
786 $self->sidebars->nbDelete('tool panel bottom');
787 $self->panels->panelHide('TOOL');
788 }
789  
790 =item B<ToolBottomPageAdd>I<($name, $image, $text, $statustext, $initialsize)>
791  
792 See also the B<pageAdd> method in L<Tk::AppWindow::Ext::SideBars>.
793 Adds a new page to the tool panel at the bottom of the CENTER window.
794 Creates the notebook widget if it does not exists.
795  
796 =cut
797  
798 sub ToolBottomPageAdd {
799 my $self = shift;
800 $self->ToolBottomBookAdd;
801 return $self->sidebars->pageAdd('tool panel bottom', @_);
802 }
803  
804 =item B<ToolBottomPageRemove>I<($name)>
805  
806 See also the B<pageDelete> method in L<Tk::AppWindow::Ext::SideBars>.
807 Removes page $name from the tool panel at the bottom of the CENTER window.
808 Removes the notebook widget if it holds no more entries.
809  
810 =cut
811  
812 sub ToolBottomPageRemove {
813 my ($self, $page) = @_;
814 my $sb = $self->sidebars;
815 $self->sidebars->pageDelete('tool panel bottom', $page);
816 $self->ToolBottomBookRemove unless $sb->pageCount('tool panel bottom');
817 }
818  
819 =item B<ToolLeftPageAdd>I<($name, $image, $text, $statustext, $initialsize)>
820  
821 See also the B<pageAdd> method in L<Tk::AppWindow::Ext::SideBars>.
822 Adds a new page to the navigator panel at the left.
823  
824 =cut
825  
826 sub ToolLeftPageAdd {
827 my $self = shift;
828 return $self->sidebars->pageAdd('navigator panel', @_);
829 }
830  
831 =item B<ToolLeftPageRemove>I<($name)>
832  
833 See also the B<pageDelete> method in L<Tk::AppWindow::Ext::SideBars>.
834 Removes page $name from the navigator panel at the left.
835  
836 =cut
837  
838 sub ToolLeftPageRemove {
839 my ($self, $page) = @_;
840 my $sb = $self->sidebars;
841 $self->sidebars->pageDelete('navigator panel', $page);
842 }
843  
844 sub ToolRightBookAdd {
845 my $self = shift;
846 return if $self->ToolRightBookExists;
847 my $sb = $self->sidebars;
848 $sb->nbAdd('tool panel right', 'RIGHT', 'right');
849 # $sb->nbTextSide('tool panel bottom', 'right');
850 if ($sb->canRotateText) {
851 $sb->nbTextSide('tool panel right', 'bottom');
852 $sb->nbTextRotate('tool panel right', 270);
853 }
854 $self->panels->panelShow('RIGHT')
855 }
856  
857 sub ToolRightBookExists {
858 my $self = shift;
859 return $self->sidebars->nbExists('tool panel right');
860 }
861  
862 sub ToolRightBookRemove {
863 my $self = shift;
864 return unless $self->ToolRightBookExists;
865 $self->sidebars->nbDelete('tool panel right');
866 $self->panels->panelHide('RIGHT');
867 }
868  
869 =item B<ToolRightPageAdd>I<($notebook, $name, $image, $text, $statustext, $initialsize)>
870  
871 See also the B<pageAdd> method in L<Tk::AppWindow::Ext::SideBars>.
872 Adds a new page to the tool panel at the right of the application window.
873 Creates the notebook widget if it does not exists.
874  
875 =cut
876  
877 sub ToolRightPageAdd {
878 my $self = shift;
879 $self->ToolRightBookAdd;
880 return $self->sidebars->pageAdd('tool panel right', @_);
881 }
882  
883 =item B<ToolRightPageRemove>I<($page)>
884  
885 See also the B<pageDelete> method in L<Tk::AppWindow::Ext::SideBars>.
886 Removes page $name from the tool panel at the right of the application window.
887 Removes the notebook widget if it holds no more entries.
888  
889 =cut
890  
891 sub ToolRightPageRemove {
892 my ($self, $page) = @_;
893 my $sb = $self->sidebars;
894 $self->sidebars->pageDelete('tool panel right', $page);
895 $self->ToolRightBookRemove unless $sb->pageCount('tool panel right');
896 }
897  
898 sub uniqueinstance {
899 my $self = shift;
900 if (@_) {
901 my $val = shift;
902 my $file = $self->configGet('-configfolder') . '/lockfile';
903 my $daem = $self->extGet('Daemons');
904 my $job = 'codit_lock_scan';
905 if ($val) {
906 $self->after(100, sub {
907 $self->lockReset;
908 $daem->jobAdd($job, 100, 'lockScan', $self) unless $daem->jobExists($job)
909 });
910 } else {
911 unlink $file;
912 $daem->jobRemove($job) if $daem->jobExists($job);
913 }
914 $self->{UNIQUE} = $val;
915 }
916 return $self->{UNIQUE}
917 }
918  
919 =back
920  
921 =head1 LICENSE
922  
923 Same as Perl.
924  
925 =head1 AUTHOR
926  
927 Hans Jeuken (hanje at cpan dot org)
928  
929 =head1 BUGS AND CAVEATS
930  
931 If you find any bugs, please report them here L<https://github.com/haje61/App-Codit/issues>.
932  
933 =head1 SEE ALSO
934  
935 =over 4
936  
937 =item L<Tk::AppWindow>
938  
939 =item L<Tk::AppWindow::OverView>
940  
941 =item L<Tk::AppWindow::CookBook>
942  
943 =item L<Tk::AppWindow::Ext::MDI>
944  
945 =item L<Tk::AppWindow::Ext::Plugins>
946  
947 =item L<App::Codit::Ext::CoditMDI>
948  
949 =item L<App::Codit::Commands>
950  
951 =item L<App::Codit::ConfigVariables>
952  
953 =back
954  
955 =cut
956  
957 1;