lib/Kephra/App/Editor/Goto.pm

filter: Statementstmt 5.7% 7 / 122 Branchbran 0.0% 0 / 36 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 7.4% 2 / 27 Podpod n/a totaltotal 4.7% 9 / 190 CC 21 SCAR 21.7
CC
21
Cov
4%
goto_last_edit
20.0
goto_prev_marker
20.0
goto_next_marker
20.0
CRAP 8.7
« lib/Kephra/App/Editor/View.pm ↑ Summary lib/Kephra/App/Editor/Edit.pm »
1 1 ▶use v5.12;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package Kephra::App::Editor::Goto;
5 package Kephra::App::Editor;
6  
7 0 ▶sub caret_left {
Subroutine caret_left: not called CC=1 SCAR=6.9
8 0 my ($self) = @_;
9 0 $self->del_caret_pos_cache();
10 0 $self->GotoPos( $self->GetCurrentPos - 1 );
11 }
12 0 ▶sub caret_right {
Subroutine caret_right: not called CC=1 SCAR=6.9
13 0 my ($self) = @_;
14 0 $self->del_caret_pos_cache();
15 0 $self->GotoPos( $self->GetCurrentPos + 1 );
16 }
17 0 ▶sub caret_home {
Subroutine caret_home: not called CC=1 SCAR=6.9
18 0 my ($self) = @_;
19 0 $self->del_caret_pos_cache();
20 0 $self->GotoPos( $self->PositionFromLine( $self->GetCurrentLine ) );
21 }
22 0 ▶sub caret_end {
Subroutine caret_end: not called CC=1 SCAR=6.9
23 0 my ($self) = @_;
24 0 $self->del_caret_pos_cache();
25 0 $self->GotoPos( $self->GetLineEndPosition( $self->GetCurrentLine ) );
26 }
27  
28 0 ▶sub caret_up {
Subroutine caret_up: not called CC=1 SCAR=6.9
29 0 my ($self) = @_;
30 0 $self->GotoPos( $self->column_in_prev_lines( $self->GetCurrentPos, 1) );
31 }
32 0 ▶sub caret_down {
Subroutine caret_down: not called CC=1 SCAR=6.9
33 0 my ($self) = @_;
34 0 $self->GotoPos( $self->column_in_next_lines( $self->GetCurrentPos, 1) );
35 }
36  
37 1 my $page_size = 45;
38 0 ▶sub caret_page_up {
Subroutine caret_page_up: not called CC=1 SCAR=6.9
39 0 my ($self) = @_;
40 0 $self->GotoPos( $self->column_in_prev_lines( $self->GetCurrentPos, $page_size) );
41 }
42 0 ▶sub caret_page_down {
Subroutine caret_page_down: not called CC=1 SCAR=6.9
43 0 my ($self) = @_;
44 0 $self->GotoPos( $self->column_in_next_lines( $self->GetCurrentPos, $page_size) );
45 }
46  
47 0 ▶sub select_left {
Subroutine select_left: not called CC=2 SCAR=17.9
48 0 my ($self) = @_;
49 0 my ($sel_start, $sel_end) = $self->GetSelection;
50 0 my $pos = $self->GetCurrentPos;
51 0 $self->del_caret_pos_cache();
52 0 $self->GotoPos( $pos - 1 );
53 0 ▶ if ($sel_start == $pos){ $self->SetAnchor($sel_end) }
Branch: 1 branch
BranchTrueFalseTotal
if ($sel_start == $pos) { } 0 0 0
54 0 else { $self->SetAnchor($sel_start) }
55 }
56 0 ▶sub select_right {
Subroutine select_right: not called CC=2 SCAR=17.9
57 0 my ($self) = @_;
58 0 my ($sel_start, $sel_end) = $self->GetSelection;
59 0 my $pos = $self->GetCurrentPos;
60 0 $self->del_caret_pos_cache();
61 0 $self->GotoPos( $pos + 1 );
62 0 ▶ if ($sel_start == $pos){ $self->SetAnchor($sel_end) }
Branch: 1 branch
BranchTrueFalseTotal
if ($sel_start == $pos) { } 0 0 0
63 0 else { $self->SetAnchor($sel_start) }
64 }
65  
66 0 ▶sub select_up {
Subroutine select_up: not called CC=2 SCAR=17.9
67 0 my ($self) = @_;
68 0 my ($sel_start, $sel_end) = $self->GetSelection;
69 0 my $pos = $self->GetCurrentPos;
70 0 my $new_pos = $self->column_in_prev_lines( $pos, 1);
71 0 $self->GotoPos( $new_pos );
72 0 ▶ if ($sel_start == $pos){ $self->SetAnchor($sel_end) }
Branch: 1 branch
BranchTrueFalseTotal
if ($sel_start == $pos) { } 0 0 0
73 0 else { $self->SetAnchor($sel_start) }
74 }
75 0 ▶sub select_down {
Subroutine select_down: not called CC=2 SCAR=17.9
76 0 my ($self) = @_;
77 0 my ($sel_start, $sel_end) = $self->GetSelection;
78 0 my $pos = $self->GetCurrentPos;
79 0 my $new_pos = $self->column_in_next_lines( $pos, 1);
80 0 $self->GotoPos( $new_pos );
81 0 ▶ if ($sel_start == $pos){ $self->SetAnchor($sel_end) }
Branch: 1 branch
BranchTrueFalseTotal
if ($sel_start == $pos) { } 0 0 0
82 0 else { $self->SetAnchor($sel_start) }
83 }
84  
85 0 ▶sub select_page_up {
Subroutine select_page_up: not called CC=2 SCAR=17.9
86 0 my ($self) = @_;
87 0 my ($sel_start, $sel_end) = $self->GetSelection;
88 0 my $pos = $self->GetCurrentPos;
89 0 my $new_pos = $self->column_in_prev_lines( $pos, $page_size);
90 0 $self->GotoPos( $new_pos );
91 0 ▶ if ($sel_start == $pos){ $self->SetAnchor($sel_end) }
Branch: 1 branch
BranchTrueFalseTotal
if ($sel_start == $pos) { } 0 0 0
92 0 else { $self->SetAnchor($sel_start) }
93 }
94 0 ▶sub select_page_down {
Subroutine select_page_down: not called CC=2 SCAR=17.9
95 0 my ($self) = @_;
96 0 my ($sel_start, $sel_end) = $self->GetSelection;
97 0 my $pos = $self->GetCurrentPos;
98 0 my $new_pos = $self->column_in_next_lines( $pos, $page_size);
99 0 $self->GotoPos( $new_pos );
100 0 ▶ if ($sel_start == $pos){ $self->SetAnchor($sel_end) }
Branch: 1 branch
BranchTrueFalseTotal
if ($sel_start == $pos) { } 0 0 0
101 0 else { $self->SetAnchor($sel_start) }
102 }
103  
104  
105  
106 0 ▶sub goto_last_edit {
Subroutine goto_last_edit: not called CC=4 SCAR=30.0
107 0 my ($self) = @_;
108 0 ▶ return $self->GotoPos( $self->{'change_pos'} ) unless $self->GetCurrentPos == $self->{'change_pos'} or $self->{'change_pos'} == -1;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->GetCurrentPos == $self->{"change_pos"} or $self->{"change_pos"} == -1 0 0 0
Condition0%0/3
$self->GetCurrentPos == $self->{"change_pos"} or $self->{"change_pos"} == -1
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->GetCurrentPos == $self->{"change_pos"} or $self->{"change_pos"} == -1
$self->GetCurrentPos == $self->{"change_pos"} $self->{"change_pos"} == -1
Truth table0%0/3
A or B
A= $self->GetCurrentPos == $self->{"change_pos"}B= $self->{"change_pos"} == -1
ABresult
1X1
011
000
109 0 ▶ $self->GotoPos( $self->{'change_prev'} ) unless $self->{'change_prev'} == -1;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"change_prev"} == -1 0 0 0
110 }
111  
112  
113 0 ▶sub init_marker {
Subroutine init_marker: not called CC=2 SCAR=17.9
114 0 my $self = shift;
115 0 $self->{'marker'} = {};
116 0 for my $line (@_) {
117 0 $self->{'marker'}{ $line }++;
118 0 $self->MarkerAdd( $line, 1)
119 }
120 }
121  
122 0 ▶sub marker_lines {
Subroutine marker_lines: not called CC=1 SCAR=6.9
123 0 my ($self) = @_;
124 0 return sort keys %{$self->{'marker'}};
125 }
126  
127  
128 0 ▶sub toggle_marker {
Subroutine toggle_marker: not called CC=3 SCAR=24.8
129 0 my ($self) = @_;
130 0 my $line = $self->GetCurrentLine ();
131 0 ▶ $self->MarkerGet( $line ) ? delete $self->{'marker'}{$line} : $self->{'marker'}{$line}++;
Branch: 1 branch
BranchTrueFalseTotal
$self->MarkerGet($line) ? : 0 0 0
132 0 ▶ $self->MarkerGet( $line ) ? $self->MarkerDelete( $line, 1) : $self->MarkerAdd( $line, 1);
Branch: 1 branch
BranchTrueFalseTotal
$self->MarkerGet($line) ? : 0 0 0
133 }
134  
135 0 ▶sub delete_all_marker { $_[0]->MarkerDeleteAll(1); $_[0]->{'marker'} = {}; }
Subroutine delete_all_marker: not called CC=1 SCAR=6.9
136  
137 0 ▶sub goto_prev_marker {
Subroutine goto_prev_marker: not called CC=4 SCAR=30.0
138 0 my ($self) = @_;
139 0 my $line = $self->GetCurrentLine ();
140 0 ▶ $line-- if $self->MarkerGet( $line );
Branch: 1 branch
BranchTrueFalseTotal
if $self->MarkerGet($line) 0 0 0
141 0 my $target = $self->MarkerPrevious ( $line, 2);
142 0 ▶ $target = $self->MarkerPrevious ( $self->GetLineCount, 2 ) if $target == -1;
Branch: 1 branch
BranchTrueFalseTotal
if $target == -1 0 0 0
143 0 ▶ $self->GotoLine( $target ) if $target > -1;
Branch: 1 branch
BranchTrueFalseTotal
if $target > -1 0 0 0
144 }
145  
146 0 ▶sub goto_next_marker {
Subroutine goto_next_marker: not called CC=4 SCAR=30.0
147 0 my ($self) = @_;
148 0 my $line = $self->GetCurrentLine ();
149 0 ▶ $line++ if $self->MarkerGet( $line );
Branch: 1 branch
BranchTrueFalseTotal
if $self->MarkerGet($line) 0 0 0
150 0 my $target = $self->MarkerNext( $line, 2);
151 0 ▶ $target = $self->MarkerNext( 0, 2 ) if $target == -1;
Branch: 1 branch
BranchTrueFalseTotal
if $target == -1 0 0 0
152 0 ▶ $self->GotoLine( $target ) if $target > -1;
Branch: 1 branch
BranchTrueFalseTotal
if $target > -1 0 0 0
153 }
154  
155 0 ▶sub goto_prev_block {
Subroutine goto_prev_block: not called CC=1 SCAR=6.9
156 0 my ($self) = @_;
157 0 $self->GotoPos( $self->smart_up_pos );
158 0 $self->EnsureCaretVisible;
159 }
160  
161 0 ▶sub goto_next_block {
Subroutine goto_next_block: not called CC=1 SCAR=6.9
162 0 my ($self) = @_;
163 0 $self->GotoPos( $self->smart_down_pos );
164 0 $self->EnsureCaretVisible;
165 }
166  
167 0 ▶sub goto_prev_sub {
Subroutine goto_prev_sub: not called CC=2 SCAR=17.9
168 0 my ($self) = @_;
169 0 my $pos = $self->GetCurrentPos;
170 0 my $new_pos = $self->prev_sub;
171 0 ▶ if ($new_pos > -1) { $self->GotoPos( $self->GetCurrentPos ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($new_pos > -1) { } 0 0 0
172 0 else { $self->GotoPos( $pos ) }
173  
174 }
175 0 ▶sub goto_next_sub {
Subroutine goto_next_sub: not called CC=2 SCAR=17.9
176 0 my ($self) = @_;
177 0 my $pos = $self->GetCurrentPos;
178 0 my $new_pos = $self->next_sub;
179 0 ▶ if ($new_pos > -1) { $self->GotoPos( $self->GetCurrentPos ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($new_pos > -1) { } 0 0 0
180 0 else { $self->GotoPos( $pos ) }
181 }
182  
183 1 1;
184  
« lib/Kephra/App/Editor/View.pm ↑ Summary lib/Kephra/App/Editor/Edit.pm »