lib/Kephra/App/Editor/Move.pm

filter: Statementstmt 2.5% 6 / 235 Branchbran 0.0% 0 / 114 Conditioncond 0.0% 0 / 27 MC/DCmcdc 0.0% 0 / 13 Subroutinesub 14.2% 2 / 14 Podpod n/a totaltotal 1.9% 8 / 403 CC 69 SCAR 41.7
CC
69
Cov
2%
move_left
132.0
move_line
90.0
move_block
90.0
CRAP 64.8
« lib/Kephra/Config.pm ↑ Summary lib/Kephra/IO/LocalFile.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::Move;
5  
6 package Kephra::App::Editor;
7  
8 0 ▶sub move_line {
Subroutine move_line: not called CC=9 SCAR=45.0
9 0 my ($ed, $from, $to) = @_;
10 0 ▶ return unless defined $to and $from < $ed->GetLineCount and $to < $ed->GetLineCount;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $to and $from < $ed->GetLineCount and $to < $ed->GetLineCount 0 0 0
Condition0%0/6
defined $to and $from < $ed->GetLineCount and $to < $ed->GetLineCount
!ll&&!rl&&r
000
defined $to and $from < $ed->GetLineCount
!ll&&!rl&&r
000
MC/DC0%0/3
defined $to and $from < $ed->GetLineCount and $to < $ed->GetLineCount
defined $to $from < $ed->GetLineCount $to < $ed->GetLineCount
Truth table0%0/4
A and B and C
A= defined $toB= $from < $ed->GetLineCountC= $to < $ed->GetLineCount
ABCresult
0XX0
10X0
1100
1111
11 0 ▶ $from = $ed->GetLineCount + $from if $from < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $from < 0 0 0 0
12 0 ▶ $to = $ed->GetLineCount + $to if $to < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $to < 0 0 0 0
13 0 ▶ return if $from == $to;
Branch: 1 branch
BranchTrueFalseTotal
if $from == $to 0 0 0
14 0 my $last_line_nr = $ed->GetLineCount - 1;
15 0 ▶ if ($from == $last_line_nr) {
Branch: 1 branch
BranchTrueFalseTotal
if ($from == $last_line_nr) 0 0 0
16 0 $ed->GotoLine( $from );
17 0 $ed->LineTranspose;
18 0 $from--;
19 }
20 0 $ed->SetSelection( $ed->PositionFromLine( $from ),
21 $ed->PositionFromLine( $from + 1 ) );
22 0 my $line = $ed->GetSelectedText( );
23 0 $ed->ReplaceSelection( '' );
24 0 ▶ if ($to == $last_line_nr) {
Branch: 1 branch
BranchTrueFalseTotal
if ($to == $last_line_nr) { } 0 0 0
25 0 $ed->InsertText( $ed->PositionFromLine($to - 1), $line );
26 0 $ed->GotoLine( $to );
27 0 $ed->LineTranspose;
28 0 } else { $ed->InsertText( $ed->PositionFromLine($to), $line ) }
29 }
30  
31 0 ▶sub move_block {
Subroutine move_block: not called CC=9 SCAR=45.0
32 0 my ($ed, $begin, $size, $newbegin) = @_;
33 0 ▶ return unless defined $newbegin and $begin < $ed->GetLineCount
Branch: 1 branch
BranchTrueFalseTotal
unless defined $newbegin and $begin < $ed->GetLineCount and $size < $ed->GetLineCount and $size > 0 and $newbegin < $ed->GetLineCount and $begin != $newbegin 0 0 0
Condition0%0/15
defined $newbegin and $begin < $ed->GetLineCount and $size < $ed->GetLineCount and $size > 0 and $newbegin < $ed->GetLineCount and $begin != $newbegin
!ll&&!rl&&r
000
defined $newbegin and $begin < $ed->GetLineCount and $size < $ed->GetLineCount and $size > 0 and $newbegin < $ed->GetLineCount
!ll&&!rl&&r
000
defined $newbegin and $begin < $ed->GetLineCount and $size < $ed->GetLineCount and $size > 0
!ll&&!rl&&r
000
defined $newbegin and $begin < $ed->GetLineCount and $size < $ed->GetLineCount
!ll&&!rl&&r
000
defined $newbegin and $begin < $ed->GetLineCount
!ll&&!rl&&r
000
MC/DC0%0/6
defined $newbegin and $begin < $ed->GetLineCount and $size < $ed->GetLineCount and $size > 0 and $newbegin < $ed->GetLineCount and $begin != $newbegin
defined $newbegin $begin < $ed->GetLineCount $size < $ed->GetLineCount $size > 0 $newbegin < $ed->GetLineCount $begin != $newbegin
Truth table0%0/7
A and B and C and D and E and F
A= defined $newbeginB= $begin < $ed->GetLineCountC= $size < $ed->GetLineCountD= $size > 0E= $newbegin < $ed->GetLineCountF= $begin != $newbegin
ABCDEFresult
0XXXXX0
10XXXX0
110XXX0
1110XX0
11110X0
1111100
1111111
34 and $size < $ed->GetLineCount and $size > 0
35 and $newbegin < $ed->GetLineCount and $begin != $newbegin;
36 0 ▶ $begin = $ed->GetLineCount + $begin if $begin < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $begin < 0 0 0 0
37 0 ▶ $newbegin = $ed->GetLineCount + $newbegin if $newbegin < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $newbegin < 0 0 0 0
38
39 0 $ed->GotoPos( $ed->GetTextLength );
40 0 $ed->NewLine ();
41 0 $ed->SetSelection( $ed->PositionFromLine( $begin ),
42 $ed->PositionFromLine( $begin + $size ) );
43 0 my $text = $ed->GetSelectedText( );
44 0 $ed->ReplaceSelection( '' );
45 0 $ed->InsertText( $ed->PositionFromLine( $newbegin ), $text );
46 0 $ed->SetSelection( $ed->GetLineEndPosition( $ed->GetLineCount - 2 ),
47 $ed->PositionFromLine( $ed->GetLineCount - 1) );
48 0 $ed->ReplaceSelection( '' );
49 }
50  
51 0 ▶sub move_up {
Subroutine move_up: not called CC=6 SCAR=37.4
52 0 my ($ed) = @_;
53 0 ▶ return if $ed->SelectionIsRectangle;
Branch: 1 branch
BranchTrueFalseTotal
if $ed->SelectionIsRectangle 0 0 0
54 0 my ($start_pos, $end_pos) = $ed->GetSelection;
55 0 my $start_line = $ed->LineFromPosition( $start_pos );
56 0 ▶ return unless $start_line; # need space above
Branch: 1 branch
BranchTrueFalseTotal
unless $start_line 0 0 0
57 0 my $end_line = $ed->LineFromPosition( $end_pos );
58 0 my $start_col = $ed->GetColumn( $start_pos );
59 0 $ed->BeginUndoAction();
60 0 ▶ if ($start_pos == $end_pos) {
Branch: 2 branches
BranchTrueFalseTotal
if ($start_pos == $end_pos) { } 0 0 0
elsif ($start_line != $end_line) { } 0 0 0
61 0 $ed->LineTranspose;
62 0 $ed->GotoPos ( $ed->PositionFromLine( $start_line - 1 ) + $start_col);
63 } elsif ($start_line != $end_line) {
64 0 $ed->move_line( $start_line - 1, $end_line);
65 0 $ed->SetSelection( $ed->PositionFromLine( $start_line - 1 ),
66 $ed->GetLineEndPosition( $end_line - 1 ) );
67 } else {
68 0 my $target_pos = $ed->PositionFromLine( $start_line - 1 ) + $start_col;
69 0 ▶ $target_pos = $ed->GetLineEndPosition( $start_line - 1 ) if $ed->GetLineEndPosition( $start_line - 1 ) < $target_pos;
Branch: 1 branch
BranchTrueFalseTotal
if $ed->GetLineEndPosition($start_line - 1) < $target_pos 0 0 0
70 0 my $text = $ed->GetSelectedText( );
71 0 $ed->ReplaceSelection( '' );
72 0 $ed->InsertText( $target_pos, $text );
73 0 $ed->SetSelection( $target_pos, $target_pos + length $text);
74 }
75 0 $ed->EndUndoAction();
76 }
77  
78 0 ▶sub move_down {
Subroutine move_down: not called CC=8 SCAR=42.8
79 0 my ($ed) = @_;
80 0 ▶ return if $ed->SelectionIsRectangle;
Branch: 1 branch
BranchTrueFalseTotal
if $ed->SelectionIsRectangle 0 0 0
81 0 my ($start_pos, $end_pos) = $ed->GetSelection;
82 0 my $start_line = $ed->LineFromPosition( $start_pos );
83 0 my $end_line = $ed->LineFromPosition( $end_pos );
84 0 my $start_col = $ed->GetColumn( $start_pos );
85 0 my $end_col = $ed->GetColumn( $end_pos );
86 0 $ed->BeginUndoAction();
87 0 ▶ if ( $end_line + 1 == $ed->GetLineCount ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($end_line + 1 == $ed->GetLineCount) { } 0 0 0
elsif ($start_pos == $end_pos) { } 0 0 0
elsif ($start_line != $end_line) { } 0 0 0
88 0 $ed->GotoLine( $start_line );
89 0 $ed->NewLine;
90 0 ▶ if ($start_pos == $end_pos) { $ed->GotoPos ( $ed->PositionFromLine( $start_line + 1 ) + $start_col) }
Branch: 2 branches
BranchTrueFalseTotal
if ($start_pos == $end_pos) { } 0 0 0
elsif ($start_line != $end_line) { } 0 0 0
91 0 elsif ($start_line != $end_line) { $ed->SetSelection( $ed->PositionFromLine( $start_line + 1 ) ,
92 $ed->GetLineEndPosition( $end_line + 1 ) ) }
93 0 else { my $next_line_pos = $ed->PositionFromLine( $start_line + 1 );
94 0 $ed->SetSelection( $next_line_pos + $start_col, $next_line_pos + $end_col) }
95 } elsif ($start_pos == $end_pos) {
96 0 $ed->GotoLine( $start_line + 1 );
97 0 $ed->LineTranspose;
98 0 $ed->GotoPos ( $ed->PositionFromLine( $start_line + 1 ) + $start_col);
99 } elsif ($start_line != $end_line) {
100 0 $ed->move_line( $end_line + 1, $start_line);
101 0 $ed->SetSelection( $ed->PositionFromLine( $start_line + 1 ) ,
102 $ed->GetLineEndPosition( $end_line + 1 ) );
103 } else {
104 0 my $text = $ed->GetSelectedText( );
105 0 $ed->ReplaceSelection( '' );
106 0 my $target_pos = $ed->PositionFromLine( $start_line + 1 ) + $start_col;
107 0 ▶ $target_pos = $ed->GetLineEndPosition( $start_line + 1 ) if $ed->GetLineEndPosition( $start_line + 1 ) < $target_pos;
Branch: 1 branch
BranchTrueFalseTotal
if $ed->GetLineEndPosition($start_line + 1) < $target_pos 0 0 0
108 0 $ed->InsertText( $target_pos, $text );
109 0 $ed->SetSelection( $target_pos, $target_pos + length $text);
110 }
111 0 $ed->EndUndoAction();
112 }
113  
114 0 ▶sub move_page_up {
Subroutine move_page_up: not called CC=7 SCAR=40.3
115 0 my ($ed) = @_;
116 0 ▶ return if $ed->SelectionIsRectangle;
Branch: 1 branch
BranchTrueFalseTotal
if $ed->SelectionIsRectangle 0 0 0
117 0 my ($start_pos, $end_pos) = $ed->GetSelection;
118 0 my $start_line = $ed->LineFromPosition( $start_pos );
119 0 ▶ return unless $start_line; # need space above
Branch: 1 branch
BranchTrueFalseTotal
unless $start_line 0 0 0
120 0 my $end_line = $ed->LineFromPosition( $end_pos );
121 0 my $start_col = $ed->GetColumn( $start_pos );
122 0 my $target_line = $start_line - 50;
123 0 ▶ $target_line = 0 if $target_line < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $target_line < 0 0 0 0
124 0 $ed->BeginUndoAction();
125 0 ▶ if ($start_pos == $end_pos) {
Branch: 2 branches
BranchTrueFalseTotal
if ($start_pos == $end_pos) { } 0 0 0
elsif ($start_line != $end_line) { } 0 0 0
126 0 $ed->move_line( $start_line, $target_line);
127 0 $ed->SetSelection( $ed->PositionFromLine( $target_line ) + $start_col,
128 $ed->PositionFromLine( $target_line ) + $start_col );
129  
130 } elsif ($start_line != $end_line) {
131 0 my $end_col = $ed->GetColumn( $end_pos );
132 0 $ed->move_block( $start_line, $end_line - $start_line + 1, $target_line);
133 0 $ed->SetSelection( $ed->PositionFromLine( $target_line ),
134 $ed->GetLineEndPosition( $target_line - $start_line + $end_line ) );
135 } else {
136 0 my $text = $ed->GetSelectedText( );
137 0 $ed->ReplaceSelection( '' );
138 0 my $target_pos = $ed->PositionFromLine( $target_line ) + $start_col;
139 0 ▶ $target_pos = $ed->GetLineEndPosition( $target_line ) if $ed->GetLineEndPosition( $target_line ) < $target_pos;
Branch: 1 branch
BranchTrueFalseTotal
if $ed->GetLineEndPosition($target_line) < $target_pos 0 0 0
140 0 $ed->InsertText( $target_pos, $text );
141 0 $ed->SetSelection( $target_pos, $target_pos + length $text);
142 }
143 0 $ed->EndUndoAction();
144 0 $ed->ScrollToLine( $target_line - $start_line + $end_line + 5 );
145 0 $ed->ScrollToLine( $target_line - 5 );
146 }
147  
148 0 ▶sub move_page_down {
Subroutine move_page_down: not called CC=6 SCAR=37.4
149 0 my ($ed) = @_;
150 0 ▶ return if $ed->SelectionIsRectangle;
Branch: 1 branch
BranchTrueFalseTotal
if $ed->SelectionIsRectangle 0 0 0
151 0 my ($start_pos, $end_pos) = $ed->GetSelection;
152 0 my $start_line = $ed->LineFromPosition( $start_pos );
153 0 my $end_line = $ed->LineFromPosition( $end_pos );
154 0 my $start_col = $ed->GetColumn( $start_pos );
155 0 my $target_line = $start_line + 50;
156 0 my $last_possible_line = $ed->GetLineCount - 1 - $end_line + $start_line;
157 0 ▶ $target_line = $last_possible_line if $target_line > $last_possible_line;
Branch: 1 branch
BranchTrueFalseTotal
if $target_line > $last_possible_line 0 0 0
158 0 $ed->BeginUndoAction();
159 0 ▶ if ($start_pos == $end_pos) {
Branch: 2 branches
BranchTrueFalseTotal
if ($start_pos == $end_pos) { } 0 0 0
elsif ($start_line != $end_line) { } 0 0 0
160 0 $ed->move_line( $start_line, $target_line);
161 0 $ed->SetSelection( $ed->PositionFromLine( $target_line ) + $start_col,
162 $ed->PositionFromLine( $target_line ) + $start_col );
163 } elsif ($start_line != $end_line) {
164 0 my $end_col = $ed->GetColumn( $end_pos );
165 0 $ed->move_block( $start_line, $end_line - $start_line + 1, $target_line);
166 0 $ed->SetSelection( $ed->PositionFromLine( $target_line ),
167 $ed->GetLineEndPosition( $target_line - $start_line + $end_line ) );
168 } else {
169 0 my $text = $ed->GetSelectedText( );
170 0 $ed->ReplaceSelection( '' );
171 0 my $target_pos = $ed->PositionFromLine( $target_line ) + $start_col;
172 0 ▶ $target_pos = $ed->GetLineEndPosition( $target_line ) if $ed->GetLineEndPosition( $target_line ) < $target_pos;
Branch: 1 branch
BranchTrueFalseTotal
if $ed->GetLineEndPosition($target_line) < $target_pos 0 0 0
173 0 $ed->InsertText( $target_pos, $text );
174 0 $ed->SetSelection( $target_pos, $target_pos + length $text);
175 }
176 0 $ed->EndUndoAction();
177 0 $ed->ScrollToLine( $target_line - $start_line + $end_line + 5 );
178 0 $ed->ScrollToLine( $target_line - 5 );
179 }
180  
181 0 ▶sub move_to_start {
Subroutine move_to_start: not called CC=6 SCAR=37.4
182 0 my ($ed) = @_;
183 0 ▶ return if $ed->SelectionIsRectangle;
Branch: 1 branch
BranchTrueFalseTotal
if $ed->SelectionIsRectangle 0 0 0
184 0 my ($start_pos, $end_pos) = $ed->GetSelection;
185 0 my $start_line = $ed->LineFromPosition( $start_pos );
186 0 my $end_line = $ed->LineFromPosition( $end_pos );
187 0 my $start_col = $ed->GetColumn( $start_pos );
188 0 my $end_col = $ed->GetColumn( $end_pos );
189 0 ▶ return unless $start_line; # need space above GetFirstVisibleLine
Branch: 1 branch
BranchTrueFalseTotal
unless $start_line 0 0 0
190 0 my $target_line = 0;
191 0 $ed->BeginUndoAction();
192 0 ▶ if ($start_pos == $end_pos) {
Branch: 2 branches
BranchTrueFalseTotal
if ($start_pos == $end_pos) { } 0 0 0
elsif ($start_line != $end_line) { } 0 0 0
193 0 $ed->move_line( $start_line, $target_line);
194 0 $ed->SetSelection( $ed->PositionFromLine( $target_line ) + $start_col,
195 $ed->PositionFromLine( $target_line ) + $start_col );
196 } elsif ($start_line != $end_line) {
197 0 $ed->move_block( $start_line, $end_line - $start_line + 1, $target_line);
198 0 $ed->SetSelection( $ed->PositionFromLine( $target_line ),
199 $ed->GetLineEndPosition( $target_line - $start_line + $end_line ) );
200 } else {
201 0 my $text = $ed->GetSelectedText( );
202 0 $ed->ReplaceSelection( '' );
203 0 my $target_pos = $ed->PositionFromLine( 0 ) + $start_col;
204 0 ▶ $target_pos = $ed->GetLineEndPosition( 0 ) if $ed->GetLineEndPosition( 0 ) < $target_pos;
Branch: 1 branch
BranchTrueFalseTotal
if $ed->GetLineEndPosition(0) < $target_pos 0 0 0
205 0 $ed->InsertText( $target_pos, $text );
206 0 $ed->SetSelection( $target_pos, $target_pos + length $text);
207 }
208 0 $ed->EndUndoAction();
209 0 $ed->ScrollToLine( 0 );
210 }
211  
212 0 ▶sub move_to_end {
Subroutine move_to_end: not called CC=5 SCAR=34.0
213 0 my ($ed) = @_;
214 0 ▶ return if $ed->SelectionIsRectangle;
Branch: 1 branch
BranchTrueFalseTotal
if $ed->SelectionIsRectangle 0 0 0
215 0 my ($start_pos, $end_pos) = $ed->GetSelection;
216 0 my $start_line = $ed->LineFromPosition( $start_pos );
217 0 my $end_line = $ed->LineFromPosition( $end_pos );
218 0 my $start_col = $ed->GetColumn( $start_pos );
219 0 my $end_col = $ed->GetColumn( $end_pos );
220 0 my $last_line = $ed->GetLineCount - 1;
221 0 my $target_line = $last_line - $end_line + $start_line;
222 0 $ed->BeginUndoAction();
223 0 ▶ if ($start_pos == $end_pos) {
Branch: 2 branches
BranchTrueFalseTotal
if ($start_pos == $end_pos) { } 0 0 0
elsif ($start_line != $end_line) { } 0 0 0
224 0 $ed->move_line( $start_line, $last_line);
225 0 $ed->SetSelection( $ed->PositionFromLine( $target_line ) + $start_col,
226 $ed->PositionFromLine( $target_line ) + $start_col );
227 } elsif ($start_line != $end_line) {
228 0 $ed->move_block( $start_line, $end_line - $start_line + 1, $target_line);
229 0 $ed->SetSelection( $ed->PositionFromLine( $target_line ),
230 $ed->GetLineEndPosition( $target_line - $start_line + $end_line ) );
231 } else {
232 0 my $text = $ed->GetSelectedText( );
233 0 $ed->ReplaceSelection( '' );
234 0 my $target_pos = $ed->PositionFromLine( $target_line ) + $start_col;
235 0 ▶ $target_pos = $ed->GetLineEndPosition( $target_line ) if $ed->GetLineEndPosition( $target_line ) < $target_pos;
Branch: 1 branch
BranchTrueFalseTotal
if $ed->GetLineEndPosition($target_line) < $target_pos 0 0 0
236 0 $ed->InsertText( $target_pos, $text );
237 0 $ed->SetSelection( $target_pos, $target_pos + length $text);
238 }
239 0 $ed->EndUndoAction();
240 0 $ed->ScrollToLine( $last_line );
241 }
242  
243 0 ▶sub move_line_left {
Subroutine move_line_left: not called CC=4 SCAR=30.0
244 0 my ($ed, $line_nr) = @_;
245 0 ▶ return 0 unless defined $line_nr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $line_nr 0 0 0
246 0 $ed->SetSelection( $ed->PositionFromLine( $line_nr ),
247 $ed->PositionFromLine( $line_nr ) + 1 );
248 0 my $s = $ed->GetSelectedText;
249 0 ▶ $s = $ed->{tab_space} if $s eq "\t";
Branch: 1 branch
BranchTrueFalseTotal
if $s eq "\t" 0 0 0
250 0 ▶ if (substr( $s, 0, 1 ) eq ' '){ chop $s }
Branch: 1 branch
BranchTrueFalseTotal
if (substr($s, 0, 1) eq ' ') { } 0 0 0
251 0 else { return 0 }
252 0 $ed->ReplaceSelection( $s );
253 0 return 1;
254 }
255  
256 0 ▶sub move_line_right {
Subroutine move_line_right: not called CC=3 SCAR=24.8
257 0 my ($ed, $line_nr) = @_;
258 0 ▶ return unless defined $line_nr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $line_nr 0 0 0
259 0 $ed->SetSelection( $ed->PositionFromLine( $line_nr ),
260 $ed->GetLineEndPosition( $line_nr ) );
261 0 my $line = $ed->GetSelectedText( );
262 0 ▶ $line =~ s/\t/$ed->{tab_space}/g if $line =~ /\t/;
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /\t/u 0 0 0
263 0 $ed->ReplaceSelection( ' '.$line );
264 }
265  
266 0 ▶sub move_left {
Subroutine move_left: not called CC=11 SCAR=48.8
267 0 my ($ed) = @_;
268 0 ▶ return if $ed->SelectionIsRectangle;
Branch: 1 branch
BranchTrueFalseTotal
if $ed->SelectionIsRectangle 0 0 0
269 0 my ($start_pos, $end_pos) = $ed->GetSelection;
270 0 my $start_line = $ed->LineFromPosition( $start_pos );
271 0 my $end_line = $ed->LineFromPosition( $end_pos );
272 0 my $start_col = $ed->GetColumn( $start_pos );
273 0 $ed->BeginUndoAction();
274 0 ▶ if ($start_pos == $end_pos) {
Branch: 2 branches
BranchTrueFalseTotal
if ($start_pos == $end_pos) { } 0 0 0
elsif ($start_line != $end_line) { } 0 0 0
275 0 ▶ $start_pos-- if $ed->move_line_left( $start_line ) and $start_col;
Branch: 1 branch
BranchTrueFalseTotal
if $ed->move_line_left($start_line) and $start_col 0 0 0
Condition0%0/3
$ed->move_line_left($start_line) and $start_col
!ll&&!rl&&r
000
MC/DC0%0/2
$ed->move_line_left($start_line) and $start_col
$ed->move_line_left($start_line) $start_col
Truth table0%0/3
A and B
A= $ed->move_line_left($start_line)B= $start_col
ABresult
0X0
100
111
276 0 $ed->GotoPos ( $start_pos );
277 } elsif ($start_line != $end_line) {
278 0 my $end_col = $ed->GetColumn( $end_pos );
279 0 ▶ $start_pos-- if $ed->move_line_left( $start_line ) and $end_col;
Branch: 1 branch
BranchTrueFalseTotal
if $ed->move_line_left($start_line) and $end_col 0 0 0
Condition0%0/3
$ed->move_line_left($start_line) and $end_col
!ll&&!rl&&r
000
MC/DC0%0/2
$ed->move_line_left($start_line) and $end_col
$ed->move_line_left($start_line) $end_col
Truth table0%0/3
A and B
A= $ed->move_line_left($start_line)B= $end_col
ABresult
0X0
100
111
280 0 ▶ $end_col-- if $ed->move_line_left( $end_line );
Branch: 1 branch
BranchTrueFalseTotal
if $ed->move_line_left($end_line) 0 0 0
281 0 $ed->move_line_left( $_ ) for $start_line + 1 .. $end_line - 1;
282 0 $ed->SetSelection( $ed->PositionFromLine( $start_line ), $ed->GetLineEndPosition( $end_line ) );
283 } else {
284 0 ▶ return unless $start_col;
Branch: 1 branch
BranchTrueFalseTotal
unless $start_col 0 0 0
285 0 my $text = $ed->GetSelectedText( );
286 0 $ed->ReplaceSelection( '' );
287 0 $ed->InsertText( $start_pos - 1, $text );
288 0 $ed->SetSelection( $start_pos - 1, $end_pos - 1);
289 }
290 0 $ed->EndUndoAction();
291 }
292  
293 0 ▶sub move_right {
Subroutine move_right: not called CC=6 SCAR=37.4
294 0 my ($ed) = @_;
295 0 ▶ return if $ed->SelectionIsRectangle;
Branch: 1 branch
BranchTrueFalseTotal
if $ed->SelectionIsRectangle 0 0 0
296 0 my ($start_pos, $end_pos) = $ed->GetSelection;
297 0 my $start_line = $ed->LineFromPosition( $start_pos );
298 0 my $end_line = $ed->LineFromPosition( $end_pos );
299 0 $ed->BeginUndoAction();
300 0 ▶ if ($start_pos == $end_pos) {
Branch: 2 branches
BranchTrueFalseTotal
if ($start_pos == $end_pos) { } 0 0 0
elsif ($start_line != $end_line) { } 0 0 0
301 0 $ed->move_line_right( $start_line );
302 0 $ed->GotoPos ( $start_pos + 1);
303 } elsif ($start_line != $end_line) {
304 0 $ed->move_line_right( $_ ) for $start_line .. $end_line;
305 0 $ed->SetSelection( $ed->PositionFromLine( $start_line ), $ed->GetLineEndPosition( $end_line ) );
306 } else {
307 0 my $end_col = $ed->GetColumn( $end_pos );
308 0 ▶ return if $end_pos == $ed->GetLineEndPosition( $end_line );
Branch: 1 branch
BranchTrueFalseTotal
if $end_pos == $ed->GetLineEndPosition($end_line) 0 0 0
309 0 my $text = $ed->GetSelectedText( );
310 0 $ed->ReplaceSelection( '' );
311 0 $ed->InsertText( $start_pos + 1, $text );
312 0 $ed->SetSelection( $start_pos + 1, $end_pos + 1);
313 }
314 0 $ed->EndUndoAction();
315 }
316  
317 1 1;
« lib/Kephra/Config.pm ↑ Summary lib/Kephra/IO/LocalFile.pm »