line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
3
|
|
|
|
|
|
|
# Text::Editor::Perl - Perl source code head-less editor written in Perl. |
4
|
|
|
|
|
|
|
# Philip R Brenan at gmail dot com, Appa Apps Ltd Inc., 2018 |
5
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Text::Editor::Perl; |
8
|
|
|
|
|
|
|
our $VERSION = "20180616"; |
9
|
|
|
|
|
|
|
require v5.16; |
10
|
1
|
|
|
1
|
|
477
|
use warnings FATAL => qw(all); |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
30
|
|
11
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
12
|
1
|
|
|
1
|
|
5
|
use Carp qw(confess); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
63
|
|
13
|
1
|
|
|
1
|
|
440
|
use Data::Dump qw(dump); |
|
1
|
|
|
|
|
6484
|
|
|
1
|
|
|
|
|
56
|
|
14
|
1
|
|
|
1
|
|
793
|
use Data::Table::Text qw(:all); |
|
1
|
|
|
|
|
68120
|
|
|
1
|
|
|
|
|
619
|
|
15
|
1
|
|
|
1
|
|
797
|
use Storable; |
|
1
|
|
|
|
|
5689
|
|
|
1
|
|
|
|
|
90
|
|
16
|
1
|
|
|
1
|
|
13
|
use utf8; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
10
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#1 Editor # A new editor |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub newEditor(@) #S Construct a new editor |
21
|
1
|
|
|
1
|
1
|
4
|
{my (@attributes) = @_; # Attributes for a new editor |
22
|
1
|
|
|
|
|
25
|
bless {@_}; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
#2 Editor Attributes # Attributes for an editor |
26
|
|
|
|
|
|
|
genLValueScalarMethods(qw(editorFile)); # Name of the file from whence the text came |
27
|
|
|
|
|
|
|
genLValueScalarMethods(qw(editorLog)); # [Instruction to roll changes back or reapply them ...] |
28
|
|
|
|
|
|
|
genLValueScalarMethods(qw(editorLines)); # [lines of text to be editted ...] |
29
|
|
|
|
|
|
|
genLValueScalarMethods(qw(editorViews)); # [Views of the text ...] |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#2 Editor Methods # Methods for a Attributes of a view |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub newLastLine($@) # Create a new line |
34
|
1
|
|
|
1
|
1
|
5
|
{my ($editor, @attributes) = @_; # Editor, attributes |
35
|
1
|
|
|
|
|
6
|
my $l = Text::Editor::Perl::Line::newLine(@attributes); |
36
|
1
|
|
|
|
|
28
|
$l->lineEditor = $editor; |
37
|
1
|
|
|
|
|
15
|
push @{$editor->editorLines}, $l; |
|
1
|
|
|
|
|
27
|
|
38
|
1
|
|
|
|
|
42
|
$l |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub newEditorView($@) # Create a new view |
42
|
1
|
|
|
1
|
1
|
5
|
{my ($editor, @attributes) = @_; # Editor, attributes |
43
|
1
|
|
|
|
|
5
|
my $v = Text::Editor::Perl::View::newView(@attributes); |
44
|
1
|
|
|
|
|
31
|
$v->viewEditor = $editor; |
45
|
1
|
|
|
|
|
69
|
$v |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub printEditor($) # Print an editor |
49
|
1
|
|
|
1
|
1
|
4
|
{my ($editor) = @_; # Editor |
50
|
1
|
|
|
|
|
21
|
my $lines = $editor->editorLines; |
51
|
1
|
|
|
|
|
7
|
my @l; |
52
|
1
|
|
|
|
|
4
|
for my $line(@$lines) |
53
|
1
|
|
|
|
|
20
|
{push @l, $line->lineText |
54
|
|
|
|
|
|
|
} |
55
|
1
|
|
|
|
|
24
|
{lines=>[@l]} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
#1 View # A view of the text being editted |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
package Text::Editor::Perl::View; |
61
|
1
|
|
|
1
|
|
387
|
use Data::Dump qw(dump); |
|
1
|
|
|
|
|
14
|
|
|
1
|
|
|
|
|
77
|
|
62
|
1
|
|
|
1
|
|
9
|
use Data::Table::Text qw(:all); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1238
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
#2 View Attributes # Attributes of a view |
65
|
|
|
|
|
|
|
genLValueScalarMethods(qw(viewEditor)); # The editor that owns this view |
66
|
|
|
|
|
|
|
genLValueScalarMethods(qw(viewCursorLine)); # Line the cursor is in |
67
|
|
|
|
|
|
|
genLValueScalarMethods(qw(viewCursorChar)); # The char position of the cursor with 0 being just before the first character |
68
|
|
|
|
|
|
|
genLValueScalarMethods(qw(viewCursorVertical)); # The number of lines the cursor spans |
69
|
|
|
|
|
|
|
genLValueScalarMethods(qw(viewStartLine)); # The line number (numbered from zero) at which this view starts to display |
70
|
|
|
|
|
|
|
genLValueScalarMethods(qw(viewStartChar)); # The character position at which this view starts to display |
71
|
|
|
|
|
|
|
genLValueScalarMethods(qw(viewLines)); # The height of the view in rows |
72
|
|
|
|
|
|
|
genLValueScalarMethods(qw(viewChars)); # The width of the view in chars |
73
|
|
|
|
|
|
|
genLValueScalarMethods(qw(viewSelections)); # [Selection specifications ...] |
74
|
|
|
|
|
|
|
genLValueScalarMethods(qw(viewBoxes)); # [Box specifications ...] - a rectangular selection |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
#2 View Methods # Methods for a Attributes of a view |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub newView(@) #S Create a new view |
79
|
1
|
|
|
1
|
|
6
|
{my (@attributes) = @_; # Attributes |
80
|
1
|
|
|
|
|
9
|
bless {viewCursorChar=>0, viewCursorVertical=>1, @_} |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub viewAddChars($$) # Add the specified chars through the specifed view |
84
|
1
|
|
|
1
|
|
4
|
{my ($view, $textToAdd) = @_; # View, text to add |
85
|
1
|
|
|
|
|
28
|
my $line = $view->viewCursorLine; |
86
|
1
|
|
|
|
|
30
|
my $text = $line->lineText; |
87
|
1
|
|
|
|
|
27
|
my $cc = $view->viewCursorChar; |
88
|
1
|
50
|
|
|
|
11
|
if ($cc >= length($text)) |
89
|
1
|
|
|
|
|
34
|
{$line->lineText .= $textToAdd; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
else |
92
|
0
|
|
|
|
|
0
|
{$line->lineText = substr($text, 0, $cc).$textToAdd.substr($text, $cc+1); # Update line of text |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub printView($) # Print a view |
97
|
0
|
|
|
0
|
|
0
|
{my ($view) = @_; # View |
98
|
0
|
|
|
|
|
0
|
my $editor = $view->viewEditor; |
99
|
0
|
|
|
|
|
0
|
my $lines = $editor->editorLines; |
100
|
0
|
|
|
|
|
0
|
my @l; |
101
|
0
|
|
|
|
|
0
|
for my $line(@$lines) |
102
|
0
|
|
|
|
|
0
|
{push @l, $line->text |
103
|
|
|
|
|
|
|
} |
104
|
0
|
|
|
|
|
0
|
{lines=>[@l]} |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
#1 Selection # A selection delimits a contiguous block of text |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
package Text::Editor::Perl::Selection; |
110
|
1
|
|
|
1
|
|
10
|
use Data::Dump qw(dump); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
55
|
|
111
|
1
|
|
|
1
|
|
9
|
use Data::Table::Text qw(:all); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
815
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub newSelection(@) #S Construct a new view of the data being editted |
114
|
0
|
|
|
0
|
|
0
|
{my (@attributes) = @_; # Attributes for a new selection |
115
|
0
|
|
|
|
|
0
|
bless {@_}; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
#2 Selection Attributes # Attributes for a selection |
119
|
|
|
|
|
|
|
genLValueScalarMethods(qw(selectionView)); # The view that owns this selection |
120
|
|
|
|
|
|
|
genLValueScalarMethods(qw(selectionStartLine)); # The line number (numbered from zero) at which this selection starts |
121
|
|
|
|
|
|
|
genLValueScalarMethods(qw(selectionStartChar)); # The character position at which this selection starts |
122
|
|
|
|
|
|
|
genLValueScalarMethods(qw(selectionEndLine)); # The line number (numbered from zero) at which this selection ends |
123
|
|
|
|
|
|
|
genLValueScalarMethods(qw(selectionEndChar)); # The character position at which this selection ends |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
#1 Box # A box is a rectangular block of text |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
package Text::Editor::Perl::Box; |
128
|
1
|
|
|
1
|
|
11
|
use Data::Dump qw(dump); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
65
|
|
129
|
1
|
|
|
1
|
|
8
|
use Data::Table::Text qw(:all); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
844
|
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub newBox(@) #S Construct a new box |
132
|
0
|
|
|
0
|
|
0
|
{my (@attributes) = @_; # Attributes for a new box |
133
|
0
|
|
|
|
|
0
|
bless {@_}; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
#2 Box Attributes # Attributes for a box |
137
|
|
|
|
|
|
|
genLValueScalarMethods(qw(boxView)); # The view that owns this box |
138
|
|
|
|
|
|
|
genLValueScalarMethods(qw(boxStartLine)); # The line number (numbered from zero) at which this box starts |
139
|
|
|
|
|
|
|
genLValueScalarMethods(qw(boxStartChar)); # The character position at which this box end |
140
|
|
|
|
|
|
|
genLValueScalarMethods(qw(boxWidth)); # The width of the box in characters - can be positive, zero or negative |
141
|
|
|
|
|
|
|
genLValueScalarMethods(qw(boxHeight)); # The height if the boc in lines - can be positive, zero or negative |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
#1 Line # A line holds a line of text being editted |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
package Text::Editor::Perl::Line; |
146
|
1
|
|
|
1
|
|
10
|
use Data::Dump qw(dump); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
71
|
|
147
|
1
|
|
|
1
|
|
9
|
use Data::Table::Text qw(:all); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
882
|
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub newLine(@) #S Construct a new line |
150
|
1
|
|
|
1
|
|
3
|
{my (@attributes) = @_; # Attributes for a new line |
151
|
1
|
|
|
|
|
6
|
bless {lineText=>q(), @_}; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
#2 Line Attributes # Attributes for a line |
155
|
|
|
|
|
|
|
genLValueScalarMethods(qw(lineEditor)); # The editor that contains this line |
156
|
|
|
|
|
|
|
genLValueScalarMethods(qw(lineText)); # A string holding the text being editted |
157
|
|
|
|
|
|
|
genLValueScalarMethods(qw(lineCharAttrs)); # A vec string which bolds 8 bits for each character in the string describing its display attributes |
158
|
|
|
|
|
|
|
genLValueScalarMethods(qw(lineLabel)); # A string naming this line |
159
|
|
|
|
|
|
|
genLValueScalarMethods(qw(lineCommand)); # A string naming a command that starts or ends on this line |
160
|
|
|
|
|
|
|
genLValueScalarMethods(qw(lineVisible)); # The line id visible if true |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
#1 Snippet # A snippet is a replacement string |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
package Text::Editor::Perl::Snippet; |
165
|
1
|
|
|
1
|
|
9
|
use Data::Dump qw(dump); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
55
|
|
166
|
1
|
|
|
1
|
|
8
|
use Data::Table::Text qw(:all); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
774
|
|
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub newSnippet(@) #S Construct a new snippet |
169
|
0
|
|
|
0
|
|
0
|
{my (@attributes) = @_; # Attributes for a new snippet |
170
|
0
|
|
|
|
|
0
|
bless {@_}; |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
#2 Snippet Attributes # Attributes for a snippet |
174
|
|
|
|
|
|
|
genLValueScalarMethods(qw(snippetSource)); # The source to be expanded |
175
|
|
|
|
|
|
|
genLValueScalarMethods(qw(snippetReplacement)); # Replacement string |
176
|
|
|
|
|
|
|
genLValueScalarMethods(qw(snippetCursor)); # cursor offset in replacement string |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
package Text::Editor::Perl; |
179
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
180
|
|
|
|
|
|
|
# Export |
181
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
182
|
|
|
|
|
|
|
|
183
|
1
|
|
|
1
|
|
10
|
use Exporter qw(import); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
56
|
|
184
|
|
|
|
|
|
|
|
185
|
1
|
|
|
1
|
|
8
|
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
408
|
|
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
188
|
|
|
|
|
|
|
@EXPORT_OK = qw( |
189
|
|
|
|
|
|
|
); |
190
|
|
|
|
|
|
|
%EXPORT_TAGS = (all=>[@EXPORT, @EXPORT_OK]); |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
# podDocumentation |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=pod |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=encoding utf-8 |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head1 Name |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
Text::Editor::Perl - Perl source code head-less editor written in Perl. |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head1 Synopsis |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
Perl source code head-less editor written in Perl. |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head1 Description |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
Perl source code head-less editor written in Perl. |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
The following sections describe the methods in each functional area of this |
211
|
|
|
|
|
|
|
module. For an alphabetic listing of all methods by name see L. |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=head1 Editor |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
A new editor |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=head2 newEditor(@) |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
Construct a new editor |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
Parameter Description |
224
|
|
|
|
|
|
|
1 @attributes Attributes for a new editor |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
Example: |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
my $e = newEditor; |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
This is a static method and so should be invoked as: |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
Text::Editor::Perl::newEditor |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=head2 Editor Attributes |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
Attributes for an editor |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=head3 editorFile :lvalue |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
Name of the file from whence the text came |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=head3 editorLog :lvalue |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
[Instruction to roll changes back or reapply them ...] |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=head3 editorLines :lvalue |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
[lines of text to be editted ...] |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=head3 editorViews :lvalue |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
[Views of the text ...] |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=head2 Editor Methods |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
Methods for a Attributes of a view |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=head3 newLastLine($@) |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
Create a new line |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
Parameter Description |
270
|
|
|
|
|
|
|
1 $editor Editor |
271
|
|
|
|
|
|
|
2 @attributes Attributes |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
Example: |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
my $l = $e->newLastLine(); |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=head3 newEditorView($@) |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
Create a new view |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
Parameter Description |
284
|
|
|
|
|
|
|
1 $editor Editor |
285
|
|
|
|
|
|
|
2 @attributes Attributes |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
Example: |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
my $v = $e->newEditorView(viewCursorLine=>$l, viewCursorChar=>0); |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
=head3 printEditor($) |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
Print an editor |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
Parameter Description |
298
|
|
|
|
|
|
|
1 $editor Editor |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
Example: |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
is_deeply $e->printEditor, {lines => ["Hello World"]}; |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
=head1 View |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
A view of the text being editted |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
=head2 View Attributes |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
Attributes of a view |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
=head3 viewEditor :lvalue |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
The editor that owns this view |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
=head3 viewCursorLine :lvalue |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
Line the cursor is in |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
=head3 viewCursorChar :lvalue |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
The char position of the cursor with 0 being just before the first character |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
=head3 viewCursorVertical :lvalue |
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
The number of lines the cursor spans |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
=head3 viewStartLine :lvalue |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
The line number (numbered from zero) at which this view starts to display |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
=head3 viewStartChar :lvalue |
340
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
The character position at which this view starts to display |
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
=head3 viewLines :lvalue |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
The height of the view in rows |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
=head3 viewChars :lvalue |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
The width of the view in chars |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
=head3 viewSelections :lvalue |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
[Selection specifications ...] |
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
|
359
|
|
|
|
|
|
|
=head3 viewBoxes :lvalue |
360
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
[Box specifications ...] - a rectangular selection |
362
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
=head2 View Methods |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
Methods for a Attributes of a view |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
=head3 newView(@) |
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
Create a new view |
371
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
Parameter Description |
373
|
|
|
|
|
|
|
1 @attributes Attributes |
374
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
This is a static method and so should be invoked as: |
376
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
Text::Editor::Perl::newView |
378
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
=head3 viewAddChars($$) |
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
Add the specified chars through the specifed view |
383
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
Parameter Description |
385
|
|
|
|
|
|
|
1 $view View |
386
|
|
|
|
|
|
|
2 $textToAdd Text to add |
387
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
Example: |
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
$v->viewAddChars(q(Hello World)); |
392
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
=head3 printView($) |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
Print a view |
397
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
Parameter Description |
399
|
|
|
|
|
|
|
1 $view View |
400
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
=head1 Selection |
402
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
A selection delimits a contiguous block of text |
404
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
=head2 newSelection(@) |
406
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
Construct a new view of the data being editted |
408
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
Parameter Description |
410
|
|
|
|
|
|
|
1 @attributes Attributes for a new selection |
411
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
This is a static method and so should be invoked as: |
413
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
Text::Editor::Perl::newSelection |
415
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
=head2 Selection Attributes |
418
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
Attributes for a selection |
420
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
=head3 selectionView :lvalue |
422
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
The view that owns this selection |
424
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
=head3 selectionStartLine :lvalue |
427
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
The line number (numbered from zero) at which this selection starts |
429
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
=head3 selectionStartChar :lvalue |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
The character position at which this selection starts |
434
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
=head3 selectionEndLine :lvalue |
437
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
The line number (numbered from zero) at which this selection ends |
439
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
=head3 selectionEndChar :lvalue |
442
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
The character position at which this selection ends |
444
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
=head1 Box |
447
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
A box is a rectangular block of text |
449
|
|
|
|
|
|
|
|
450
|
|
|
|
|
|
|
=head2 newBox(@) |
451
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
Construct a new box |
453
|
|
|
|
|
|
|
|
454
|
|
|
|
|
|
|
Parameter Description |
455
|
|
|
|
|
|
|
1 @attributes Attributes for a new box |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
This is a static method and so should be invoked as: |
458
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
Text::Editor::Perl::newBox |
460
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
|
462
|
|
|
|
|
|
|
=head2 Box Attributes |
463
|
|
|
|
|
|
|
|
464
|
|
|
|
|
|
|
Attributes for a box |
465
|
|
|
|
|
|
|
|
466
|
|
|
|
|
|
|
=head3 boxView :lvalue |
467
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
The view that owns this box |
469
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
=head3 boxStartLine :lvalue |
472
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
The line number (numbered from zero) at which this box starts |
474
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
|
476
|
|
|
|
|
|
|
=head3 boxStartChar :lvalue |
477
|
|
|
|
|
|
|
|
478
|
|
|
|
|
|
|
The character position at which this box end |
479
|
|
|
|
|
|
|
|
480
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
=head3 boxWidth :lvalue |
482
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
The width of the box in characters - can be positive, zero or negative |
484
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
=head3 boxHeight :lvalue |
487
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
The height if the boc in lines - can be positive, zero or negative |
489
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
=head1 Line |
492
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
A line holds a line of text being editted |
494
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
=head2 newLine(@) |
496
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
Construct a new line |
498
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
Parameter Description |
500
|
|
|
|
|
|
|
1 @attributes Attributes for a new line |
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
This is a static method and so should be invoked as: |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
Text::Editor::Perl::newLine |
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
=head2 Line Attributes |
508
|
|
|
|
|
|
|
|
509
|
|
|
|
|
|
|
Attributes for a line |
510
|
|
|
|
|
|
|
|
511
|
|
|
|
|
|
|
=head3 lineEditor :lvalue |
512
|
|
|
|
|
|
|
|
513
|
|
|
|
|
|
|
The editor that contains this line |
514
|
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
=head3 lineText :lvalue |
517
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
A string holding the text being editted |
519
|
|
|
|
|
|
|
|
520
|
|
|
|
|
|
|
|
521
|
|
|
|
|
|
|
=head3 lineCharAttrs :lvalue |
522
|
|
|
|
|
|
|
|
523
|
|
|
|
|
|
|
A vec string which bolds 8 bits for each character in the string describing its display attributes |
524
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
|
526
|
|
|
|
|
|
|
=head3 lineLabel :lvalue |
527
|
|
|
|
|
|
|
|
528
|
|
|
|
|
|
|
A string naming this line |
529
|
|
|
|
|
|
|
|
530
|
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
=head3 lineCommand :lvalue |
532
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
A string naming a command that starts or ends on this line |
534
|
|
|
|
|
|
|
|
535
|
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
=head3 lineVisible :lvalue |
537
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
The line id visible if true |
539
|
|
|
|
|
|
|
|
540
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
=head1 Snippet |
542
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
A snippet is a replacement string |
544
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
=head2 newSnippet(@) |
546
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
Construct a new snippet |
548
|
|
|
|
|
|
|
|
549
|
|
|
|
|
|
|
Parameter Description |
550
|
|
|
|
|
|
|
1 @attributes Attributes for a new snippet |
551
|
|
|
|
|
|
|
|
552
|
|
|
|
|
|
|
This is a static method and so should be invoked as: |
553
|
|
|
|
|
|
|
|
554
|
|
|
|
|
|
|
Text::Editor::Perl::newSnippet |
555
|
|
|
|
|
|
|
|
556
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
=head2 Snippet Attributes |
558
|
|
|
|
|
|
|
|
559
|
|
|
|
|
|
|
Attributes for a snippet |
560
|
|
|
|
|
|
|
|
561
|
|
|
|
|
|
|
=head3 snippetSource :lvalue |
562
|
|
|
|
|
|
|
|
563
|
|
|
|
|
|
|
The source to be expanded |
564
|
|
|
|
|
|
|
|
565
|
|
|
|
|
|
|
|
566
|
|
|
|
|
|
|
=head3 snippetReplacement :lvalue |
567
|
|
|
|
|
|
|
|
568
|
|
|
|
|
|
|
Replacement string |
569
|
|
|
|
|
|
|
|
570
|
|
|
|
|
|
|
|
571
|
|
|
|
|
|
|
=head3 snippetCursor :lvalue |
572
|
|
|
|
|
|
|
|
573
|
|
|
|
|
|
|
cursor offset in replacement string |
574
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
|
576
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
=head1 Index |
578
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
|
580
|
|
|
|
|
|
|
1 L |
581
|
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
2 L |
583
|
|
|
|
|
|
|
|
584
|
|
|
|
|
|
|
3 L |
585
|
|
|
|
|
|
|
|
586
|
|
|
|
|
|
|
4 L |
587
|
|
|
|
|
|
|
|
588
|
|
|
|
|
|
|
5 L |
589
|
|
|
|
|
|
|
|
590
|
|
|
|
|
|
|
6 L |
591
|
|
|
|
|
|
|
|
592
|
|
|
|
|
|
|
7 L |
593
|
|
|
|
|
|
|
|
594
|
|
|
|
|
|
|
8 L |
595
|
|
|
|
|
|
|
|
596
|
|
|
|
|
|
|
9 L |
597
|
|
|
|
|
|
|
|
598
|
|
|
|
|
|
|
10 L |
599
|
|
|
|
|
|
|
|
600
|
|
|
|
|
|
|
11 L |
601
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
12 L |
603
|
|
|
|
|
|
|
|
604
|
|
|
|
|
|
|
13 L |
605
|
|
|
|
|
|
|
|
606
|
|
|
|
|
|
|
14 L |
607
|
|
|
|
|
|
|
|
608
|
|
|
|
|
|
|
15 L |
609
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
16 L |
611
|
|
|
|
|
|
|
|
612
|
|
|
|
|
|
|
17 L |
613
|
|
|
|
|
|
|
|
614
|
|
|
|
|
|
|
18 L |
615
|
|
|
|
|
|
|
|
616
|
|
|
|
|
|
|
19 L |
617
|
|
|
|
|
|
|
|
618
|
|
|
|
|
|
|
20 L |
619
|
|
|
|
|
|
|
|
620
|
|
|
|
|
|
|
21 L |
621
|
|
|
|
|
|
|
|
622
|
|
|
|
|
|
|
22 L |
623
|
|
|
|
|
|
|
|
624
|
|
|
|
|
|
|
23 L |
625
|
|
|
|
|
|
|
|
626
|
|
|
|
|
|
|
24 L |
627
|
|
|
|
|
|
|
|
628
|
|
|
|
|
|
|
25 L |
629
|
|
|
|
|
|
|
|
630
|
|
|
|
|
|
|
26 L |
631
|
|
|
|
|
|
|
|
632
|
|
|
|
|
|
|
27 L |
633
|
|
|
|
|
|
|
|
634
|
|
|
|
|
|
|
28 L |
635
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
29 L |
637
|
|
|
|
|
|
|
|
638
|
|
|
|
|
|
|
30 L |
639
|
|
|
|
|
|
|
|
640
|
|
|
|
|
|
|
31 L |
641
|
|
|
|
|
|
|
|
642
|
|
|
|
|
|
|
32 L |
643
|
|
|
|
|
|
|
|
644
|
|
|
|
|
|
|
33 L |
645
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
34 L |
647
|
|
|
|
|
|
|
|
648
|
|
|
|
|
|
|
35 L |
649
|
|
|
|
|
|
|
|
650
|
|
|
|
|
|
|
36 L |
651
|
|
|
|
|
|
|
|
652
|
|
|
|
|
|
|
37 L |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
38 L |
655
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
39 L |
657
|
|
|
|
|
|
|
|
658
|
|
|
|
|
|
|
40 L |
659
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
41 L |
661
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
42 L |
663
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
43 L |
665
|
|
|
|
|
|
|
|
666
|
|
|
|
|
|
|
44 L |
667
|
|
|
|
|
|
|
|
668
|
|
|
|
|
|
|
=head1 Installation |
669
|
|
|
|
|
|
|
|
670
|
|
|
|
|
|
|
This module is written in 100% Pure Perl and, thus, it is easy to read, |
671
|
|
|
|
|
|
|
comprehend, use, modify and install via B: |
672
|
|
|
|
|
|
|
|
673
|
|
|
|
|
|
|
sudo cpan install Text::Editor::Perl |
674
|
|
|
|
|
|
|
|
675
|
|
|
|
|
|
|
=head1 Author |
676
|
|
|
|
|
|
|
|
677
|
|
|
|
|
|
|
L |
678
|
|
|
|
|
|
|
|
679
|
|
|
|
|
|
|
L |
680
|
|
|
|
|
|
|
|
681
|
|
|
|
|
|
|
=head1 Copyright |
682
|
|
|
|
|
|
|
|
683
|
|
|
|
|
|
|
Copyright (c) 2016-2018 Philip R Brenan. |
684
|
|
|
|
|
|
|
|
685
|
|
|
|
|
|
|
This module is free software. It may be used, redistributed and/or modified |
686
|
|
|
|
|
|
|
under the same terms as Perl itself. |
687
|
|
|
|
|
|
|
|
688
|
|
|
|
|
|
|
=cut |
689
|
|
|
|
|
|
|
|
690
|
|
|
|
|
|
|
|
691
|
|
|
|
|
|
|
|
692
|
|
|
|
|
|
|
# Tests and documentation |
693
|
|
|
|
|
|
|
|
694
|
|
|
|
|
|
|
sub test |
695
|
1
|
|
|
1
|
0
|
6
|
{my $p = __PACKAGE__; |
696
|
1
|
|
|
|
|
8
|
binmode($_, ":utf8") for *STDOUT, *STDERR; |
697
|
1
|
50
|
|
|
|
53
|
return if eval "eof(${p}::DATA)"; |
698
|
1
|
|
|
|
|
44
|
my $s = eval "join('', <${p}::DATA>)"; |
699
|
1
|
50
|
|
|
|
5
|
$@ and die $@; |
700
|
1
|
|
|
1
|
|
5
|
eval $s; |
|
1
|
|
|
1
|
|
1
|
|
|
1
|
|
|
1
|
|
32
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
|
1
|
|
|
|
|
543
|
|
|
1
|
|
|
|
|
56263
|
|
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
53
|
|
701
|
1
|
50
|
|
|
|
1030
|
$@ and die $@; |
702
|
|
|
|
|
|
|
} |
703
|
|
|
|
|
|
|
|
704
|
|
|
|
|
|
|
test unless caller; |
705
|
|
|
|
|
|
|
|
706
|
|
|
|
|
|
|
1; |
707
|
|
|
|
|
|
|
# podDocumentation |
708
|
|
|
|
|
|
|
__DATA__ |