blib/lib/App/Asciio.pm

filter: Statementstmt 42.5% 71 / 167 Branchbran 3.8% 1 / 26 Conditioncond 0.0% 0 / 23 MC/DCmcdc 0.0% 0 / 13 Subroutinesub 46.8% 22 / 47 Podpod 0.0% 0 / 27 totaltotal 31.0% 94 / 303 CC 24 SCAR 24.8
CC
24
Cov
33%
button_release_event
56.0
motion_notify_event
42.0
set_font
12.0
CRAP 12.0
« blib/lib/App/Asciio/Text/Asciio/Menues.pm ↑ Summary lib/App/Asciio/stripes/wirl_arrow.pm »
1  
2 package App::Asciio ;
3  
4 4 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 4 ▶use Clone;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use Data::TreeDumper ;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use List::Util qw(min max first) ;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 4 ▶use List::MoreUtils qw(any minmax first_value) ;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 4 ▶use App::Asciio::Actions ;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 4 ▶use App::Asciio::Ascii ;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 4 ▶use App::Asciio::Dialogs ;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 4 ▶use App::Asciio::Elements ;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 4 ▶use App::Asciio::Io ;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 4 ▶use App::Asciio::Menues ;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 4 ▶use App::Asciio::Options ;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 4 ▶use App::Asciio::Setup ;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 4 ▶use App::Asciio::String ;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 4 ▶use App::Asciio::Markup ;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 4 ▶use App::Asciio::Undo ;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 #-----------------------------------------------------------------------------
27  
28 4 our $VERSION = '1.9.02' ;
29  
30 #-----------------------------------------------------------------------------
31  
32 =encoding utf8
33  
34 =head1 NAME
35  
36 ___ _ _ ____
37 / | __________(_|_) __ \
38 / /| | / ___/ ___/ / / / / /
39 / ___ |(__ ) /__/ / / /_/ /
40 /_/ |_/____/\___/_/_/\____/
41  
42  
43 =head1 SYNOPSIS
44  
45 $> asciio [file.asciio] # GUI application using Gtk3
46  
47 $> tasciio [file.asciio] # TUI application
48  
49 $> asciio_to_text file.asciio # converts asciio files to ASCII
50  
51 =head1 DESCRIPTION
52  
53 Asciio allows you to draw ASCII diagrams in a GUI or TUI. The diagrams can be
54 saved as ASCII text or in a format that allows you to modify them later.
55  
56 Diagrams consist of boxes and text elements connected by arrows. Boxes stay
57 connected when you move them around.
58  
59 Both GUI and TUI have vim-like bindings, the GUI has a few extra bindings that
60 are usually found in GUI applications.
61  
62 Keyboard bindings are the best way to use Asciio, they are listed at the end of
63 this documentation. Bindings can also be modified.
64  
65 =head1 DOCUMENTATION
66  
67 =head2 GUI
68  
69 .-------------------------------------------------------------.
70 | ........................................................... |
71 | ..........-------------..------------..--------------...... |
72 | .........| stencils > || asciio > || box |..... |
73 | .........| Rulers > || computer > || text |..... |
74 | .........| File > || people > || wirl_arrow |..... |
75 grid----->......'-------------'| divers > || axis |..... |
76 | ..................^.....'------------'| ... |..... |
77 | ..................|...................'--------------'..... |
78 | ..................|........................................ |
79 '-------------------|-----------------------------------------'
80 |
81 context menu access some commands
82 most are accessed through the keyboard
83  
84 =head2 Exporting to ASCII
85  
86 You can export to a file in ASCII by using a '.txt' file extension.
87  
88 You can also export the selection, in ASCII, to the Primary clipboard.
89  
90 =head2 Elements
91  
92 =head3 boxes and text
93  
94 .----------.
95 | title |
96 .----------. |----------| ************
97 | | | body 1 | * *
98 '----------' | body 2 | ************
99 '----------'
100 any text
101 (\_/) |
102 text (O.o) <------'
103 (> <)
104  
105 =head3 if-box and process-box
106  
107 .--------------.
108 / a == b \ __________
109 ( && ) \ \
110 \ 'string' ne '' / ) process )
111 '--------------' /_________/
112
113  
114 =head3 user boxes and exec-boxes
115  
116 For simple elements, put your design in a box, with or without a frame.
117  
118 The an "exec-box" object that lets you put the output of an external
119 application in a box, in the example below the table is generated, if you
120 already have text in a file you can use 'cat your_file' as the command.
121  
122 +------------+------------+------------+------------+
123 | input_size ‖ algorithmA | algorithmB | algorithmC |
124 +============+============+============+============+
125 | 1 ‖ 206.4 sec. | 206.4 sec. | 0.02 sec. |
126 +------------+------------+------------+------------+
127 | 250 ‖ - | 80 min. | 2.27 sec. |
128 +------------+------------+------------+------------+
129  
130 =head3 wirl-arrow
131  
132 Rotating the end clockwise or counter-clockwise changes its direction.
133  
134 ^ ^
135 | -----. \
136 | | \
137 '---- | '-------
138 ------> |
139 v
140
141 =head3 multi section wirl-arrow
142  
143 A set of whirl arrows connected to each other.
144  
145 .----------. .
146 | | \ / \
147 .-------' ^ \ / \
148 | .-----------> \ ' .
149 | '----. \ /
150 | | \ /
151 '--------' '------'
152
153  
154 =head3 angled-arrow and axis
155  
156 -------. .-------
157 \ /
158 \ / ^
159 | ^
160 / \ | /
161 / \ | /
162 ------' '------- -------->
163
164 =head2 Examples
165  
166 .----Base::Class::Derived_B
167 /
168 Something::Else /
169 \ .-------Base::Class::Derived_C
170 \ /
171 '-------Base::Class
172 ' \
173 / '----Latest::Greatest
174 Some::Thing--'
175  
176 _____
177 | ___ |
178 ||___|| load
179 | ooo |--.------------------.------------------------.
180 '_____' | | |
181 v v v
182 .----------. .--------------------------. .----------------.
183 | module C | | module A | | module B |
184 '----------' |--------------------------| | (instrumented) |
185 | | .-----. | '----------------'
186 '---------------->| A.o | | |
187 | '-----' | |
188 | .------------------. | |
189 | | A.instrumented.o |<-------------'
190 | '------------------' |
191 '--------------------------'
192  
193 =head3 Unicode example
194  
195 ╭───────────────────────────────────────────────────────╮
196 │ 中文韩文和unicode符号支持以及全新的菱形元素 │
197 │ Chinese Korean and unicode symbols and rhombus object │
198 ╰───────────────────────────────────────────────────────╯
199 ,',
200 ,' ',
201 ,' ',
202 ╭────────: :───────────╮
203 │ ', ,' │
204 │ ', ,' │
205 │ ',' │
206 │ │ v
207 v v ⎛ ⎞
208 ┌───┐ ╭───╮ ⎜ ⎟
209 │ │ │ │ ⎜ ⎟
210 └───┘ ╰───╯ ⎝ ⎠
211  
212 ┌──────────────┐ ┌──────────────┐
213 │ 主机1(host1) │ │ 主机2(host2) │
214 └──────────────┘ └──────────────┘
215 ^ ^ ^ ^
216 │ │ │ │
217 │ ╰───────────────────────╮ │ │
218 │ │ │ │
219 │ ╭───────────────────│───╯ │
220 │ │ │ │
221 PCIEx4│ PCIEx4│ PCIEx4 │ PCIEx4│
222 ┌─────────────┐ ┌─────────────┐
223 │ HBA card1 │ │ HBA card2 │
224 └─────────────┘ └─────────────┘
225  
226 ## Exporting to SVG
227  
228 The "goat" project (https://github.com/blampe/goat) must be installed.
229  
230 =head2 Bindings
231  
232 <Enter> Edit selected element
233  
234 <d> Delete selected element(s)
235  
236 <u> Undo
237  
238 <C>-r Redo
239  
240 <.> Quick link
241  
242 <,> Quick copy
243  
244 <r> Add vertical ruler
245  
246 <A-r> Add horizontal ruler
247  
248 <R> Remove rulers
249  
250 Moving elements:
251  
252 =over 4
253  
254 <h> Move selected elements left
255  
256 <j> Move selected elements down
257  
258 <k> Move selected elements up
259  
260 <l> Move selected elements right
261  
262  
263 <Left> Move selected elements left
264  
265 <Down> Move selected elements down
266  
267 <Up> Move selected elements up
268  
269 <Right> Move selected elements right
270  
271 =back
272  
273 Selecting elements:
274  
275 =over 4
276  
277 <n> Select next element
278  
279 <N> Select previous element
280  
281 <Tab> Select next element move mouse
282  
283 <V> Select all elements
284  
285 <v> Select connected elements
286  
287 <Escape> Deselect all elements
288  
289 =back
290  
291 Resizing elements:
292  
293 =over 4
294  
295 <1> Make element narrower
296  
297 <2> Make element taller
298  
299 <3> Make element shorter
300  
301 <4> Make element wider
302  
303 <s> Shrink box
304  
305 =back
306  
307 Clipboard:
308  
309 =over 4
310  
311 <y> Copy to clipboard
312  
313 <p> Insert from clipboard
314  
315 <Y> Export to clipboard & primary as ascii
316  
317 <P> Import from primary to box
318  
319 <A-P> Import from primary to text
320  
321 =back
322  
323 <:> command group:
324  
325 =over 4
326  
327 <q> Quit
328  
329 <Q> Quit no save
330  
331 <w> Save
332  
333 <W> SaveAs
334  
335 <e> Open
336  
337 <r> Insert
338  
339 <m> Display manpage
340  
341 <h> Help
342  
343 <c> Display commands
344  
345 <f> Display action files
346  
347 <k> Display keyboard mapping
348  
349 =back
350  
351 <i> Insert group:
352  
353 =over 4
354  
355 <A> Add angled arrow
356  
357 <a> Add arrow
358  
359 <A-a> Add unicode arrow
360  
361 <B> Add shrink box
362  
363 <b> Add box
364  
365 <A-b> Add unicode box
366  
367 <C-b> Add multiple boxes
368  
369 <c> Add connector
370  
371 <E> Add exec-box no border
372  
373 <e> Add exec-box
374  
375 <f> Insert from file
376  
377 <g> Add group object type 1
378  
379 <h> Add help box
380  
381 <i> Add if-box
382  
383 <R> Add horizontal ruler
384  
385 <x> External command output in a box
386  
387 <X> External command output in a box no frame
388  
389 <p> Add process
390  
391 <r> Add vertical ruler
392  
393 <t> Add text
394  
395 <C-t> Add multiple text
396  
397 =back
398  
399 <a> arrow group:
400  
401 =over 4
402  
403 <S> Insert multi-wirl section
404  
405 <f> Flip arrow start and end
406  
407 <d> Change arrow direction
408  
409 <s> Append multi-wirl sectioni
410  
411 <A-s> Remove last section from multi-wirl
412  
413 =back
414  
415  
416 <A> align group:
417  
418 =over 4
419  
420 <t> Align top
421  
422 <l> Align left
423  
424 <b> Align bottom
425  
426 <r> Align right
427  
428 <v> Align vertically
429  
430 <h> Align horizontally
431  
432 =back
433  
434 <g> grouping group:
435  
436 =over 4
437  
438 <g> Group selected elements
439  
440 <u> Ungroup selected elements
441  
442 <F> Temporary move selected element to the front
443  
444 <f> Move selected elements to the front
445  
446 <b> Move selected elements to the back
447  
448 =back
449  
450 <A-g> stripes-group group:
451  
452 =over 4
453  
454 <1> Create one stripe group
455  
456 <g> Create stripes group
457  
458 <u> Ungroup stripes group
459  
460 =back
461  
462 <z> display group:
463  
464 =over 4
465  
466 <C> Change grid color
467  
468 <c> Change Asciio background color
469  
470 <g> Flip grid display
471  
472 <s> Flip color scheme
473  
474 <t> Flip transparent element background
475  
476 =back
477  
478 <D> debug group:
479  
480 =over 4
481  
482 <E> Dump selected elements
483  
484 <e> Dump all elements
485  
486 <S> Display undo stack statistics
487  
488 <o> Test
489  
490 <s> Dump self
491  
492 <t> Display numbered objects
493  
494 =back
495  
496 <S> slides group:
497  
498 =over 4
499  
500 <N> Previous slide
501  
502 <g> First slide
503  
504 <l> Load slides
505  
506 <n> Next slide
507  
508 =back
509  
510 Mouse emulation:
511  
512 =over 4
513  
514 <'> Toggle> mouse
515  
516 <Ö> Mouse shift-left-click
517  
518 <ö> Mouse left-click
519  
520 <ä> Mouse right-click
521  
522 <H> Mouse drag left 3
523  
524 <J> Mouse drag down 3
525  
526 <K> Mouse drag up 3
527  
528 <L> Mouse drag right 3
529  
530 <Down> Mouse drag down
531  
532 <Left> Mouse drag left
533  
534 <Right> Mouse drag right
535  
536 <Up> Mouse drag up
537  
538  
539 <A-Down> Mouse drag down
540  
541 <A-Left> Mouse drag left
542  
543 <A-Right> Mouse drag right
544  
545 <A-Up> Mouse drag up
546  
547  
548 <ö> Mouse alt-left-click
549  
550 <ö> Mouse ctl-left-click
551  
552 =back
553  
554 =head2 GUI extra bindings
555  
556 <C00-a> Select all elements
557  
558 <C00-c> Copy to clipboard
559  
560 <C00-v> Insert from clipboard
561  
562 <C00-e> Export to clipboard & primary as ascii
563  
564 <C0S-V> Import from primary to box
565  
566 <C00-z> Undo
567  
568 <C00-y> Redo
569  
570 <+> Zoom in
571  
572 <-> Zoom out
573  
574 <double-click> Edit selected element
575  
576 <C00-button-1> Add to delection
577  
578 <0A0-button-1> Quick link
579  
580 <0AS-button-1> Duplicate elements
581  
582 <CA0-button-1> Insert flex point
583  
584 =head1 Asciio and Vim
585  
586 You can call Asciio from vim and insert your diagram.
587  
588 map <leader><leader>a :call TAsciio()<cr>
589  
590 function! TAsciio()
591 let line = getline('.')
592  
593 let tempn = tempname()
594 let tempnt = tempn . '.txt'
595 let temp = shellescape(tempn)
596 let tempt = shellescape(tempnt)
597  
598 exec "normal i Asciio_file:" . tempn . "\<Esc>"
599  
600 if ! has("gui_running")
601 exec "silent !mkdir -p $(dirname " . temp . ")"
602 exec "silent !cp ~/.config/Asciio/templates/empty.asciio ". temp . "; tasciio " . temp . "; asciio_to_text " . temp . " >" . tempt
603 exec "read " . tempnt
604 endif
605  
606 redraw!
607 endfunction
608  
609 =cut
610  
611 sub new
612 169 ▶{
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
613 169 my ($class) = @_ ;
614  
615 169 my $self =
616 bless
617 {
618 ELEMENT_TYPES => [],
619 ELEMENTS => [],
620 CONNECTIONS => [],
621 CLIPBOARD => {},
622 FONT_FAMILY => 'Monospace',
623 FONT_SIZE => '10',
624 TAB_AS_SPACES => ' ',
625 OPAQUE_ELEMENTS => 1,
626 DISPLAY_GRID => 1,
627 DISPLAY_GRID2 => 1,
628
629
630 PREVIOUS_X => 0, PREVIOUS_Y => 0,
631 MOUSE_X => 0, MOUSE_Y => 0,
632 DRAGGING => undef,
633 SELECTION_RECTANGLE =>{START_X => 0, START_Y => 0},
634
635 ACTIONS => {},
636
637 COPY_OFFSET_X => 3,
638 COPY_OFFSET_Y => 3,
639 COLORS => {},
640
641 NEXT_GROUP_COLOR => 0,
642
643 WORK_DIRECTORY => '.asciio_work_dir',
644 CREATE_BACKUP => 1,
645 MODIFIED => 0,
646
647 DO_STACK_POINTER => 0,
648 DO_STACK => [] ,
649 }, $class ;
650  
651  
652 169 return($self) ;
653 }
654  
655 #-----------------------------------------------------------------------------
656  
657 sub event_options_changed
658 0 ▶{
Subroutine event_options_changed: not called CC=2 SCAR=17.9
Pod undocumented
659 0 my ($self) = @_;
660  
661 0 $self->{CURRENT_ACTIONS} = $self->{ACTIONS} ;
662  
663 0 $self->set_font($self->{FONT_FAMILY}, $self->{FONT_SIZE}) ;
664  
665 0 ▶$self->{TAB_AS_SPACES} = ' ' unless defined $self->{TAB_AS_SPACES} ;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"TAB_AS_SPACES"} 0 0 0
666  
667 0 App::Asciio::Markup::use_markup($self->{USE_MARKUP_MODE}) ;
668 }
669  
670 #-----------------------------------------------------------------------------
671  
672 sub exit
673 0 ▶{
Subroutine exit: not called CC=2 SCAR=17.9
Pod undocumented
674 0 my ($self, $code) = @_ ;
675  
676 0 ▶exit ($code // 0) ;
Condition0%0/2
$code // 0
l!l
00
MC/DC0%0/1
$code // 0
$code
Truth table0%0/2
A
A= $code
Aresult
11
00
677 }
678  
679 #-----------------------------------------------------------------------------
680  
681 sub set_title
682 0 ▶{
Subroutine set_title: not called CC=2 SCAR=17.9
Pod undocumented
683 0 my ($self, $title) = @_;
684  
685 0 ▶defined $title and $self->{TITLE} = $title ;
Branch: 1 branch
BranchTrueFalseTotal
defined $title and $self->{"TITLE"} = $title 0 0 0
686 }
687  
688 sub get_title
689 0 ▶{
Subroutine get_title: not called CC=1 SCAR=6.9
Pod undocumented
690 0 my ($self) = @_;
691 0 Encode::_utf8_on($self->{TITLE});
692 0 $self->{TITLE} ;
693 }
694  
695 #-----------------------------------------------------------------------------
696  
697 sub set_font
698 0 ▶{
Subroutine set_font: not called CC=3 SCAR=24.8
Pod undocumented
699 0 my ($self, $font_family, $font_size) = @_;
700  
701 0 ▶$self->{FONT_FAMILY} = $font_family || 'Monospace';
Condition0%0/2
$font_family || 'Monospace'
l!l
00
MC/DC0%0/1
$font_family || 'Monospace'
$font_family
Truth table0%0/2
A
A= $font_family
Aresult
11
00
702 0 ▶$self->{FONT_SIZE} = $font_size || 10 ;
Condition0%0/2
$font_size || 10
l!l
00
MC/DC0%0/1
$font_size || 10
$font_size
Truth table0%0/2
A
A= $font_size
Aresult
11
00
703 }
704  
705 sub get_font
706 0 ▶{
Subroutine get_font: not called CC=1 SCAR=6.9
Pod undocumented
707 0 my ($self) = @_;
708  
709 0 return($self->{FONT_FAMILY}, $self->{FONT_SIZE}) ;
710 }
711  
712 sub get_font_as_string
713 0 ▶{
Subroutine get_font_as_string: not called CC=1 SCAR=6.9
Pod undocumented
714 0 my ($self) = @_;
715  
716 0 return("$self->{FONT_FAMILY} $self->{FONT_SIZE}") ;
717 }
718  
719 #-----------------------------------------------------------------------------
720  
721 sub update_display
722 0 ▶{
Subroutine update_display: not called CC=1 SCAR=6.9
Pod undocumented
723 0 my ($self) = @_;
724  
725 0 $self->call_hook('CANONIZE_CONNECTIONS', $self->{CONNECTIONS}, $self->get_character_size()) ;
726 }
727  
728 #-----------------------------------------------------------------------------
729  
730 sub call_hook
731 0 ▶{
Subroutine call_hook: not called CC=2 SCAR=17.9
Pod undocumented
732 0 my ($self, $hook_name, @arguments) = @_;
733  
734 0 ▶$self->{HOOKS}{$hook_name}->(@arguments) if (exists $self->{HOOKS}{$hook_name}) ;
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"HOOKS"}{$hook_name} 0 0 0
735 }
736  
737 #-----------------------------------------------------------------------------
738  
739 sub button_release_event
740 0 ▶{
Subroutine button_release_event: not called CC=7 SCAR=40.3
Pod undocumented
741 0 my ($self, $event) = @_ ;
742  
743 0 ▶if((defined $self->{EDIT_SEMAPHORE}) && ($self->{EDIT_SEMAPHORE} > 0))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"EDIT_SEMAPHORE"} and $self->{"EDIT_SEMAPHORE"} > 0) 0 0 0
Condition0%0/3
defined $self->{"EDIT_SEMAPHORE"} and $self->{"EDIT_SEMAPHORE"} > 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"EDIT_SEMAPHORE"} and $self->{"EDIT_SEMAPHORE"} > 0
defined $self->{"EDIT_SEMAPHORE"} $self->{"EDIT_SEMAPHORE"} > 0
Truth table0%0/3
A and B
A= defined $self->{"EDIT_SEMAPHORE"}B= $self->{"EDIT_SEMAPHORE"} > 0
ABresult
0X0
100
111
744 {
745 0 $self->{EDIT_SEMAPHORE}--;
746 0 return ;
747 }
748  
749 0 my $button = $event->{BUTTON} ;
750 0 my $modifiers = $event->{MODIFIERS} ;
751  
752 0 ▶if($self->exists_action("${modifiers}$event->{TYPE}-$button"))
Branch: 1 branch
BranchTrueFalseTotal
if ($self->exists_action(qq[$modifiers$event->{"TYPE"}-$button])) 0 0 0
753 {
754 0 $self->run_actions(["${modifiers}$event->{TYPE}-$button", $event]) ;
755 }
756  
757 0 undef $self->{DRAGGING} ;
758  
759 0 ▶if(defined $self->{MODIFIED_INDEX} && defined $self->{MODIFIED} && $self->{MODIFIED_INDEX} == $self->{MODIFIED})
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"MODIFIED_INDEX"} and defined $self->{"MODIFIED"} and $self->{"MODIFIED_INDEX"} == $self->{"MODIFIED"}) 0 0 0
Condition0%0/6
defined $self->{"MODIFIED_INDEX"} and defined $self->{"MODIFIED"} and $self->{"MODIFIED_INDEX"} == $self->{"MODIFIED"}
!ll&&!rl&&r
000
defined $self->{"MODIFIED_INDEX"} and defined $self->{"MODIFIED"}
!ll&&!rl&&r
000
MC/DC0%0/3
defined $self->{"MODIFIED_INDEX"} and defined $self->{"MODIFIED"} and $self->{"MODIFIED_INDEX"} == $self->{"MODIFIED"}
defined $self->{"MODIFIED_INDEX"} defined $self->{"MODIFIED"} $self->{"MODIFIED_INDEX"} == $self->{"MODIFIED"}
Truth table0%0/4
A and B and C
A= defined $self->{"MODIFIED_INDEX"}B= defined $self->{"MODIFIED"}C= $self->{"MODIFIED_INDEX"} == $self->{"MODIFIED"}
ABCresult
0XX0
10X0
1100
1111
760 {
761 0 $self->pop_undo_buffer(1) ; # no changes
762 }
763  
764 0 $self->update_display();
765 }
766  
767 #-----------------------------------------------------------------------------
768  
769 sub button_press_event
770 0 ▶{
Subroutine button_press_event: not called CC=1 SCAR=6.9
Pod undocumented
771 0 my ($self, $event) = @_ ;
772  
773 0 undef $self->{DRAGGING} ;
774 0 delete $self->{RESIZE_CONNECTOR_NAME} ;
775  
776 0 $self->create_undo_snapshot() ;
777 0 $self->{MODIFIED_INDEX} = $self->{MODIFIED} ;
778  
779 0 my $button = $event->{BUTTON} ;
780 0 my $modifiers = $event->{MODIFIERS} ;
781  
782 0 $self->run_actions(["${modifiers}$event->{TYPE}-$button", $event]) ;
783 }
784  
785 #-----------------------------------------------------------------------------
786  
787 sub motion_notify_event
788 0 ▶{
Subroutine motion_notify_event: not called CC=6 SCAR=37.4
Pod undocumented
789 0 my ($self, $event) = @_ ;
790  
791 0 ▶if((defined $self->{EDIT_SEMAPHORE}) && ($self->{EDIT_SEMAPHORE} > 0))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"EDIT_SEMAPHORE"} and $self->{"EDIT_SEMAPHORE"} > 0) 0 0 0
Condition0%0/3
defined $self->{"EDIT_SEMAPHORE"} and $self->{"EDIT_SEMAPHORE"} > 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"EDIT_SEMAPHORE"} and $self->{"EDIT_SEMAPHORE"} > 0
defined $self->{"EDIT_SEMAPHORE"} $self->{"EDIT_SEMAPHORE"} > 0
Truth table0%0/3
A and B
A= defined $self->{"EDIT_SEMAPHORE"}B= $self->{"EDIT_SEMAPHORE"} > 0
ABresult
0X0
100
111
792 {
793 0 $self->{EDIT_SEMAPHORE}--;
794 0 return ;
795 }
796  
797 # my $button = $event->{BUTTON} ;
798 0 my($x, $y) = @{$event->{COORDINATES}} ;
799 0 my $modifiers = $event->{MODIFIERS} ;
800  
801 0 ▶if($self->{PREVIOUS_X} != $x || $self->{PREVIOUS_Y} != $y)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"PREVIOUS_X"} != $x or $self->{"PREVIOUS_Y"} != $y) 0 0 0
Condition0%0/3
$self->{"PREVIOUS_X"} != $x or $self->{"PREVIOUS_Y"} != $y
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"PREVIOUS_X"} != $x or $self->{"PREVIOUS_Y"} != $y
$self->{"PREVIOUS_X"} != $x $self->{"PREVIOUS_Y"} != $y
Truth table0%0/3
A or B
A= $self->{"PREVIOUS_X"} != $xB= $self->{"PREVIOUS_Y"} != $y
ABresult
1X1
011
000
802 {
803 0 ▶ if($self->exists_action("${modifiers}motion_notify"))
Branch: 1 branch
BranchTrueFalseTotal
if ($self->exists_action("${modifiers}motion_notify")) { } 0 0 0
804 {
805 0 $self->run_actions(["${modifiers}motion_notify", $event]) ;
806 }
807 else
808 {
809 0 ($self->{PREVIOUS_X}, $self->{PREVIOUS_Y}) = ($x, $y) ;
810 0 ($self->{MOUSE_X}, $self->{MOUSE_Y}) = ($x, $y) ;
811 }
812 }
813 }
814  
815 #-----------------------------------------------------------------------------
816  
817 sub select_element_event
818 0 ▶{
Subroutine select_element_event: not called CC=2 SCAR=17.9
Pod undocumented
819 0 my ($self, $x, $y, $filter) = @_ ;
820  
821 0 my ($x_offset, $y_offset) = ($x - $self->{PREVIOUS_X}, $y - $self->{PREVIOUS_Y}) ;
822  
823 0 $self->{SELECTION_RECTANGLE}{END_X} = $x ;
824 0 $self->{SELECTION_RECTANGLE}{END_Y} = $y ;
825  
826 0 ▶$filter = sub {1} unless defined $filter ;
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
unless defined $filter 0 0 0
827  
828 $self->select_elements
829 (
830 1,
831 grep
832 0 { $filter->($_) }
833 grep # elements within selection rectangle
834 {
835 $self->element_completely_within_rectangle
836 (
837 $_,
838 $self->{SELECTION_RECTANGLE},
839 )
840 0 } @{$self->{ELEMENTS}}
841 ) ;
842  
843 0 $self->update_display();
844 }
845  
846 #-----------------------------------------------------------------------------
847  
848 sub move_elements_event
849 0 ▶{
Subroutine move_elements_event: not called CC=1 SCAR=6.9
Pod undocumented
850 0 my ($self, $x, $y) = @_;
851  
852 0 my ($x_offset, $y_offset) = ($x - $self->{PREVIOUS_X}, $y - $self->{PREVIOUS_Y}) ;
853  
854 0 my @selected_elements = $self->get_selected_elements(1) ;
855  
856 0 $self->move_elements($x_offset, $y_offset, @selected_elements) ;
857 0 $self->update_display();
858 }
859  
860 #-----------------------------------------------------------------------------
861  
862 sub resize_element_event
863 0 ▶{
Subroutine resize_element_event: not called CC=1 SCAR=6.9
Pod undocumented
864 0 my ($self, $x, $y) = @_ ;
865  
866 0 my ($x_offset, $y_offset) = ($x - $self->{PREVIOUS_X}, $y - $self->{PREVIOUS_Y}) ;
867  
868 0 my ($selected_element) = $self->get_selected_elements(1) ;
869  
870 $self->{RESIZE_CONNECTOR_NAME} =
871 $self->resize_element
872 (
873 $self->{PREVIOUS_X} - $selected_element->{X}, $self->{PREVIOUS_Y} - $selected_element->{Y} ,
874 $x - $selected_element->{X}, $y - $selected_element->{Y} ,
875 $selected_element,
876 $self->{RESIZE_CONNECTOR_NAME},
877 0 ) ;
878
879 0 $self->update_display();
880 }
881  
882 #-----------------------------------------------------------------------------
883  
884 4 my %ignored_keys = map { $_ => 1 } qw(000-Control_L 000-Control_R 000-Shift_L 000-Shift_R 000-Alt_L 000-ISO_Level3_Shift) ;
885  
886 sub key_press_event
887 0 ▶{
Subroutine key_press_event: not called CC=2 SCAR=17.9
Pod undocumented
888 0 my ($self, $event)= @_;
889  
890 0 my $modifiers = $event->{MODIFIERS} ;
891 0 my $key = $event->{KEY_NAME} ;
892  
893 0 $self->{CACHE}{ORIGINAL_EVENT} = $event ;
894  
895 0 ▶$self->run_actions("${modifiers}$key") unless exists $ignored_keys{"${modifiers}$key"} ;
Branch: 1 branch
BranchTrueFalseTotal
unless exists $ignored_keys{"$modifiers$key"} 0 0 0
896 }
897  
898 #-----------------------------------------------------------------------------
899  
900 sub mouse_scroll_event
901 0 ▶{
Subroutine mouse_scroll_event: not called CC=1 SCAR=6.9
Pod undocumented
902 0 my ($self, $event)= @_;
903  
904 0 my ($modifiers, $direction) = ($event->{MODIFIERS}, $event->{DIRECTION}) ;
905  
906 0 $self->run_actions("${modifiers}$direction") ;
907 }
908  
909 #-----------------------------------------------------------------------------
910  
911 sub update_quadrants
912 0 ▶{
Subroutine update_quadrants: not called CC=1 SCAR=6.9
Pod undocumented
913 0 my ($self, $element) = @_ ;
914  
915 0 my ($x1, $x2, $y1, $y2) = $element->get_extents() ;
916 }
917  
918 #-----------------------------------------------------------------------------
919  
920 {
921  
922 4 my $overlays_sub ;
923  
924 0 ▶sub set_overlays_sub { $overlays_sub = $_[1] ; }
Subroutine set_overlays_sub: not called CC=1 SCAR=6.9
Pod undocumented
925 0 ▶sub get_overlays { defined $overlays_sub ? $overlays_sub->(@_) : () ; }
Subroutine get_overlays: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
defined $overlays_sub ? : 0 0 0
926  
927 }
928  
929 #-----------------------------------------------------------------------------
930  
931 4 ▶sub show_pointer { ; }
Subroutine show_pointer: not called CC=1 SCAR=0.0
Pod undocumented
932 0 ▶sub hide_pointer { ; }
Subroutine hide_pointer: not called CC=1 SCAR=0.0
Pod undocumented
933
934 #-----------------------------------------------------------------------------
935  
936 sub get_character_size
937 96 ▶{
Subroutine get_character_size: called CC=2 SCAR=7.6
Pod undocumented
938 96 my ($self) = @_ ;
939
940 96 ▶if(exists $self->{USER_CHARACTER_WIDTH})
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{'USER_CHARACTER_WIDTH'}) { } 96 0 96
941 {
942 96 return ($self->{USER_CHARACTER_WIDTH}, $self->{USER_CHARACTER_HEIGHT}) ;
943 }
944 else
945 {
946 0 return (8, 16) ;
947 }
948 }
949  
950 #-----------------------------------------------------------------------------
951  
952 sub set_character_size
953 169 ▶{
Subroutine set_character_size: called CC=1 SCAR=0.0
Pod undocumented
954 169 my ($self, $width, $height) = @_ ;
955  
956 169 ($self->{USER_CHARACTER_WIDTH}, $self->{USER_CHARACTER_HEIGHT}) = ($width, $height) ;
957 }
958  
959 #-----------------------------------------------------------------------------
960  
961 sub get_color
962 0 ▶{
Subroutine get_color: not called CC=2 SCAR=17.9
Pod undocumented
963 0 my ($self, $name) = @_;
964  
965 0 ▶return($self->{COLORS}{$name} // [1, 0, 0]) ;
Condition0%0/2
$self->{"COLORS"}{$name} // [1, 0, 0]
l!l
00
MC/DC0%0/1
$self->{"COLORS"}{$name} // [1, 0, 0]
$self->{"COLORS"}{$name}
Truth table0%0/2
A
A= $self->{"COLORS"}{$name}
Aresult
11
00
966 }
967  
968 #-----------------------------------------------------------------------------
969  
970 sub invalidate_rendering_cache
971 0 ▶{
Subroutine invalidate_rendering_cache: not called CC=2 SCAR=17.9
Pod undocumented
972 0 my ($self) = @_ ;
973  
974 0 for my $element (@{$self->{ELEMENTS}})
975 {
976 0 delete $element->{CACHE} ;
977 }
978  
979 0 delete $self->{CACHE} ;
980 }
981  
982 #-----------------------------------------------------------------------------
983  
984 =head1 DEPENDENCIES
985  
986 gnome libraries, gtk, gtk-perl for the gtk version
987  
988 =head1 BUGS AND LIMITATIONS
989  
990 Please report errors at https://github.com/nkh/P5-App-Asciio/issues.
991  
992 =head1 AUTHORS
993  
994 Khemir Nadim ibn Hamouda
995 https://github.com/nkh
996 CPAN ID: NKH
997  
998 Qin Qing
999 northisland2017@gmail.com
1000 unicode support, scroll bar, and rhombus object
1001
1002 =head1 LICENSE AND COPYRIGHT
1003  
1004 This program is free software; you can redistribute it and/or modify it under
1005 the same terms as Perl itself or GPL3.
1006  
1007 =head2 Docker Image
1008  
1009 There are docker images made by third parties, use a search engine for the latest.
1010  
1011 example image: https://gist.github.com/BruceWind/32920cf74ba5b7172b31b06fec38aabb
1012  
1013 =head1 SEE ALSO
1014  
1015 http://www.jave.de
1016 http://search.cpan.org/~osfameron/Text-JavE-0.0.2/JavE.pm
1017 http://ditaa.sourceforge.net/
1018 http://www.codeproject.com/KB/macros/codeplotter.aspx
1019 http://search.cpan.org/~jpierce/Text-FIGlet-1.06/FIGlet.pm
1020 http://www.ascii-art.de (used some entries as base for the network stencil)
1021 http://www.textfiles.com/art/
1022 http://www2.b3ta.com/_bunny/texbunny.gif
1023  
1024  
1025 *\o_ _o/*
1026 / * * \
1027 <\ *\o/* />
1028 )
1029 o/* / > *\o
1030 <\ />
1031 __o */\ /\* o__
1032 * /> <\ *
1033 /\* __o_ _o__ */\
1034 * / * * \ *
1035 <\ />
1036 *\o/*
1037 ejm97 __)__
1038  
1039 =cut
1040  
1041 #------------------------------------------------------------------------------------------------------
1042  
1043 4 "
1044 (\_/)
1045 (O.o)
1046 /> ASCII world domination!
1047 "
1048  
1049  
« blib/lib/App/Asciio/Text/Asciio/Menues.pm ↑ Summary lib/App/Asciio/stripes/wirl_arrow.pm »