blib/lib/App/Asciio/Actions/Box.pm untested

filter: Statementstmt 0.0% 0 / 40 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 66 CC 4 SCAR 17.0
CC
4
Cov
0%
box_selected_element
12.0
context_menu
6.0
BEGIN
2.0
CRAP 5.5
1  
2 package App::Asciio::Actions::Box ;
3  
4 use strict ;
5 use warnings ;
6 use utf8 ;
7  
8 #----------------------------------------------------------------------------------------------
9  
10 use Scalar::Util ;
11  
12 use App::Asciio::Boxes ':const' ;
13  
14 use App::Asciio::stripes::exec_box ;
15  
16 #----------------------------------------------------------------------------------------------
17  
18 sub context_menu
19 {
20 my ($self, $popup_x, $popup_y) = @_ ;
21 my @context_menu_entries ;
22  
23 my @selected_elements = $self->get_selected_elements(1) ;
24 my $element = $selected_elements[0] ;
25  
26 if(@selected_elements == 1 && $element->isa('App::Asciio::stripes::editable_box2'))
27 {
28 push @context_menu_entries, [ '/box element', \&box_selected_element, { ELEMENT => $element} ] ;
29
30 for
31 (qw(
32 dash
33 dot
34 star
35 math_parantheses
36 unicode
37 unicode_bold
38 unicode_double_line
39 unicode_with_filler_type1
40 unicode_with_filler_type2
41 unicode_with_filler_type3
42 unicode_with_filler_type4
43 unicode_hollow_dot
44 unicode_math_parantheses
45 ))
46 {
47 push @context_menu_entries, [ "/box type/$_", \&App::Asciio::Boxes::change_type, { ELEMENT => $element, TYPE => $_ } ] ,
48 }
49 }
50  
51 return @context_menu_entries ;
52 }
53  
54 #----------------------------------------------------------------------------------------------
55  
56 sub box_selected_element
57 {
58 my ($self, $data) = @_ ;
59  
60 $self->create_undo_snapshot() ;
61  
62 my $element_type = $data->{ELEMENT}->get_box_type() ;
63 my ($title, $text) = $data->{ELEMENT}->get_text() ;
64  
65 for (0 .. $#$element_type)
66 {
67 next if $_ == TITLE_SEPARATOR && $title eq '' ;
68
69 $element_type->[$_][DISPLAY] = 1 ;
70 }
71  
72 $data->{ELEMENT}->set_box_type($element_type) ;
73  
74 $self->delete_connections_containing($data->{ELEMENT}) if $self->is_connected($data->{ELEMENT}) ;
75  
76 $self->call_hook('CANONIZE_CONNECTIONS', $self->{CONNECTIONS}, $self->get_character_size()) ;
77  
78 $self->update_display() ;
79 }
80  
81 #----------------------------------------------------------------------------------------------
82  
83 1 ;
84