blib/lib/Text/Editor/Vip/Buffer/Plugins/InsertDelete.pm

filter: Statementstmt 95.0% 57 / 60 Branchbran 80.0% 8 / 10 Conditioncond 100% 6 / 6 MC/DCmcdc 100% 4 / 4 Subroutinesub 86.6% 13 / 15 Podpod 100% 6 / 6 totaltotal 93.0% 94 / 101 CC 8 SCAR 7.4
CC
8
Cov
93%
__ANON__
4.1
__ANON__
3.0
RemoveTabFromSelection
2.0
CRAP 2.1
« blib/lib/Text/Editor/Vip/Selection.pm ↑ Summary blib/lib/Text/Editor/Vip/Buffer/Plugins/Selection.pm »
1  
2 package Text::Editor::Vip::Buffer::Plugins::InsertDelete ;
3  
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings ;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 BEGIN
8 2 ▶{
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Exporter ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 ▶use vars qw ($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 $VERSION = 0.01;
13 2 @ISA = qw (Exporter);
14 2 @EXPORT = qw ();
15 2 @EXPORT_OK = qw ();
16 2 %EXPORT_TAGS = ();
17 }
18  
19 =head1 NAME
20  
21 Text::Editor::Vip::Buffer::Plugins::InsertDelete- Vip::Buffer plugin
22  
23 =head1 SYNOPSIS
24  
25 =head1 DESCRIPTION
26  
27 Text::Editor::Vip::Buffer::Plugins::InsertConstruct- Vip::Buffer plugin
28  
29 =head1 FUNCTIONS
30  
31 =cut
32  
33 #-----------------------------------------------------------------------
34  
35 sub SetText
36 5 ▶{
Subroutine SetText: called CC=1 SCAR=0.0
Pod documented
37  
38 =head2 SetText
39  
40 Sets the buffers text.
41  
42 =cut
43  
44 5 my $buffer = shift ;
45 5 my $new_text = shift ;
46  
47 5 $buffer->ExpandedWithOrLoad('SelectAll', 'Text::Editor::Vip::Buffer::Plugins::Selection') ;
48  
49 5 $buffer->SelectAll() ;
50 5 $buffer->DeleteSelection() ;
51 5 $buffer->SetModificationPosition(0, 0) ;
52 5 $buffer->Insert($new_text) ;
53 }
54  
55 #-----------------------------------------------------------------------
56  
57 sub InsertNewLineBeforeCurrent
58 3 ▶{
Subroutine InsertNewLineBeforeCurrent: called CC=1 SCAR=0.0
Pod documented
59  
60 =head2 InsertNewLineBeforeCurrent
61  
62 Inserts a blank new line before the current line. Modification position is not changed.
63
64 =cut
65  
66 3 my $buffer = shift ;
67 3 $buffer->ExpandedWithOrLoad('MoveUp', 'Text::Editor::Vip::Buffer::Plugins::Movements') ;
68  
69 3 $buffer->{SELECTION}->Clear() ;
70  
71 3 my ($modification_line, $modification_character) = $buffer->GetModificationPosition() ;
72  
73 3 $buffer->SetModificationCharacter(0) ;
74 3 $buffer->InsertNewLine() ;
75 3 $buffer->SetModificationCharacter($modification_character) ;
76 }
77  
78 #-----------------------------------------------------------------------
79  
80 sub DeleteToBeginingOfWord
81 4 ▶{
Subroutine DeleteToBeginingOfWord: called CC=1 SCAR=0.0
Pod documented
82  
83 =head2 DeleteToBeginingOfWord
84  
85 Deletes from the current position to the begining of the word.
86  
87 =cut
88  
89 4 my $buffer = shift ;
90 4 $buffer->ExpandedWithOrLoad('ExtendSelectionToBeginingOfWord', 'Text::Editor::Vip::Buffer::Plugins::Selection') ;
91  
92 4 $buffer->ExtendSelectionToBeginingOfWord() ;
93 4 $buffer->DeleteSelection() ;
94 }
95  
96 #-----------------------------------------------------------------------
97  
98 sub DeleteToEndOfWord
99 4 ▶{
Subroutine DeleteToEndOfWord: called CC=1 SCAR=0.0
Pod documented
100  
101 =head2 DeleteToEndOfWord
102  
103 Deletes from the current position to the end of the word.
104  
105 =cut
106  
107 4 my $buffer = shift ;
108  
109 4 $buffer->ExtendSelectionToNextWord() ;
110 4 $buffer->DeleteSelection() ;
111 }
112  
113 #-----------------------------------------------------------------------
114  
115 sub InsertTab
116 14 ▶{
Subroutine InsertTab: called CC=2 SCAR=6.9
Pod documented
117  
118 =head2 InsertTab
119  
120 Inserts a tab at the current position. If there is a aselection, the whole selection is indented.
121  
122 =cut
123  
124 14 my $buffer = shift ;
125  
126 14 ▶if($buffer->GetSelection()->IsEmpty())
Branch: 1 branch
BranchTrueFalseTotal
if ($buffer->GetSelection->IsEmpty) { } 3 11 14
127 {
128 3 $buffer->Insert("\t") ;
129 }
130 else
131 {
132 11 my ($modification_line, $modification_character) = $buffer->GetModificationPosition() ;
133
134 $buffer->RunSubOnSelection
135 (
136 sub
137 24 ▶ {
Subroutine __ANON__: called CC=3 SCAR=11.0
138 24 my ($text, $selection_line_index, $modification_character, $original_selection, $buffer) = @_ ;
139
140 24 ▶ if($selection_line_index == $original_selection->GetEndLine() && 0 == $original_selection->GetEndCharacter())
Branch: 1 branch
BranchTrueFalseTotal
if ($selection_line_index == $original_selection->GetEndLine and 0 == $original_selection->GetEndCharacter) { } 7 17 24
Condition100%3/3
$selection_line_index == $original_selection->GetEndLine and 0 == $original_selection->GetEndCharacter
!ll&&!rl&&r
1347
MC/DC100%2/2
$selection_line_index == $original_selection->GetEndLine and 0 == $original_selection->GetEndCharacter
$selection_line_index == $original_selection->GetEndLine 0 == $original_selection->GetEndCharacter
Truth table100%3/3
A and B
A= $selection_line_index == $original_selection->GetEndLineB= 0 == $original_selection->GetEndCharacter
ABresult
0X0
100
111
141 {
142 7 return($text) ;
143 }
144 else
145 {
146 17 return("\t$text") ;
147 }
148 }
149 0 ▶ , sub { print "Please select text to shift" ;}
Subroutine __ANON__: not called CC=1 SCAR=6.9
150 11 ) ;
151
152 11 $buffer->SetModificationPosition($modification_line, $modification_character) ;
153 }
154 }
155  
156 #-----------------------------------------------------------------------
157  
158 sub RemoveTabFromSelection
159 4 ▶{
Subroutine RemoveTabFromSelection: called CC=2 SCAR=7.1
Pod documented
160  
161 =head2 RemoveTabFromSelection
162  
163 If there is a selection, it is outdented.
164  
165 =cut
166  
167 4 my $buffer = shift ;
168  
169 4 ▶unless($buffer->{SELECTION}->IsEmpty())
Branch: 1 branch
BranchTrueFalseTotal
unless ($buffer->{"SELECTION"}->IsEmpty) 4 0 4
170 {
171 $buffer->RunSubOnSelection
172 (
173 sub
174 7 ▶ {
Subroutine __ANON__: called CC=4 SCAR=14.0
175 7 my ($text, $selection_line_index, $modification_character, $original_selection, $buffer) = @_ ;
176
177 7 ▶ if($selection_line_index == $original_selection->GetEndLine() && 0 == $original_selection->GetEndCharacter())
Branch: 1 branch
BranchTrueFalseTotal
if ($selection_line_index == $original_selection->GetEndLine and 0 == $original_selection->GetEndCharacter) { } 1 6 7
Condition100%3/3
$selection_line_index == $original_selection->GetEndLine and 0 == $original_selection->GetEndCharacter
!ll&&!rl&&r
331
MC/DC100%2/2
$selection_line_index == $original_selection->GetEndLine and 0 == $original_selection->GetEndCharacter
$selection_line_index == $original_selection->GetEndLine 0 == $original_selection->GetEndCharacter
Truth table100%3/3
A and B
A= $selection_line_index == $original_selection->GetEndLineB= 0 == $original_selection->GetEndCharacter
ABresult
0X0
100
111
178 {
179 1 return($text) ;
180 }
181 else
182 {
183 6 ▶ if($text =~ /^[\t ]/o)
Branch: 1 branch
BranchTrueFalseTotal
if ($text =~ /^[\t ]/o) { } 6 0 6
184 {
185 6 return(substr($text, 1)) ;
186 }
187 else
188 {
189 0 return($text) ;
190 }
191 }
192 }
193
194 0 ▶ , sub { print "Please select text to un-shift" ;}
Subroutine __ANON__: not called CC=1 SCAR=6.9
195 4 ) ;
196 }
197 }
198  
199 #-------------------------------------------------------------------------------
200  
201 2 1 ;
202  
203 =head1 AUTHOR
204  
205 Khemir Nadim ibn Hamouda
206 CPAN ID: NKH
207 mailto:nadim@khemir.net
208 http:// no web site
209  
210 =head1 COPYRIGHT
211  
212 This program is free software; you can redistribute
213 it and/or modify it under the same terms as Perl itself.
214  
215 The full text of the license can be found in the
216 LICENSE file included with this module.
217  
218 =cut
« blib/lib/Text/Editor/Vip/Selection.pm ↑ Summary blib/lib/Text/Editor/Vip/Buffer/Plugins/Selection.pm »