File: VI.pod

package info (click to toggle)
nvi 1.81.6-15
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 11,852 kB
  • sloc: ansic: 43,645; sh: 11,207; makefile: 604; perl: 262; tcl: 234; awk: 19
file content (281 lines) | stat: -rw-r--r-- 5,110 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
=head1 NAME

VI - VI module within perl embedded nvi

=head1 SYNOPSIS

    sub wc {
      my $words;
      $i = $VI::StartLine;
      while ($i <= $VI::StopLine) {
	$_ = $curscr->GetLine($i++);
        $words+=split;
      }
      $curscr->Msg("$words words");
    }

=head1 DESCRIPTION

This pseudo module is available to perl programs run from within nvi and
provides access to the files being edited and some internal data.

Beware that you should not use this module from within a C<perldo> or
from within an C<END> block or a C<DESTROY> method.

=head2 Variables

These are set by nvi before starting each perl command.

=over 8

=item * $curscr

Object that represents the current screen.
It can be used as the ScreenId parameter of the functions below,
or you can use object oriented syntax.

	# the following two are equivalent
	$curscr->DelLine(57);
	VI::DelLine($curscr, 57);

=item * $StartLine

Line number of the first line of the selected range or of the file if no
range was specified.

=item * $StopLine

Line number of the last line of the selected range or of the file if no
range was specified.

=back

=head2 Functions

=over 8

=item * AppendLine

    VI::AppendLine(screenId,lineNumber,text);

Append the string text after the line in lineNumber.

=item * DelLine

    VI::DelLine(screenId,lineNum);

Delete lineNum.

=item * EndScreen

VI::EndScreen(screenId);

End a screen.

=item * FindScreen

    VI::FindScreen(file);

Return the screen id associated with file name.

=item * GetCursor

    ($line, $column) = VI::GetCursor(screenId);

Return the current cursor position as a list with two elements.

=item * GetLine

    VI::GetLine(screenId,lineNumber);

Return lineNumber.

=item * GetMark

    ($line, $column) = VI::GetMark(screenId,mark);

Return the mark's cursor position as a list with two elements.

=item * GetOpt

    VI::GetOpt(screenId,option);

Return the value of an option.

=item * InsertLine

    VI::InsertLine(screenId,lineNumber,text);

Insert the string text before the line in lineNumber.

=item * LastLine

    VI::LastLine(screenId);

Return the last line in the screen.

=item * MapKey

    VI::MapKey(screenId,key,perlproc);

Associate a key with a perl procedure.

=item * Msg

    VI::Msg(screenId,text);

Set the message line to text.

=item * NewScreen

    VI::NewScreen(screenId);
    VI::NewScreen(screenId,file);

Create a new screen.  If a filename is specified then the screen is
opened with that file.

=item * Run

    VI::Run(screenId,cmd);

Run the ex command cmd.

=item * SetCursor

    VI::SetCursor(screenId,line,column);

Set the cursor to the line and column numbers supplied.

=item * SetLine

    VI::SetLine(screenId,lineNumber,text);

Set lineNumber to the text supplied.

=item * SetMark

    VI::SetMark(screenId,mark,line,column);

Set the mark to the line and column numbers supplied.

=item * SetOpt

    VI::SetOpt(screenId,command);

Set an option.

=item * SwitchScreen

    VI::SwitchScreen(screenId,screenId);

Change the current focus to screen.

=item * TagQ

    $screen->TagQ("tag identification string")

Creates a new tag queue object associated to $screen
to which "tags" can be added.
See further about methods you can use on tag queues.

=item * UnmapKey

    VI::UnmmapKey(screenId,key);

Unmap a key.

=item * Warn

This is the default warning handler.
It adds any warnings to the error string.

=item * Opt

    $screen->Opt;

Returns a tied hash representing the options of the screen.
Note that you can only retrieve and set hash elements.

=item * Map

    $screen->Map;

Returns a tied hash representing the mappings of the screen.
Note that you can only retrieve, set and delete hash elements.

=item * Mark

    $screen->Mark;

Returns a tied hash representing the marks of the screen.

=item * Line

    $screen->Line;

Returns a tied array representing the lines of the screen.

=back

=head2 Tag queue methods

=item * Add

    $tagq->Add($filename, $searchstring, $msg)

Adds a tag to the tag queue. 
The $searchstring argument is (line)number or
a string representing a regular expression.

=item * Push

    $tagq->Push()

Pushes the tag queue onto its associated screen.
The result of the operation is as if the user had enter the
tag command and nvi had found the locations that were added
using the Add method.

For an example, see the make.pl script.

=back

=head1 EXAMPLES

    sub showmarks {
      my ($mark, $all);
      for $mark ('a' .. 'z') {
        eval {VI::GetMark($VI::ScreenId, $mark)};
        $all .= $mark unless ($@);
      }
      VI::Msg($VI::ScreenId,"Set marks: $all");
    }

    sub forall {
      my ($code) = shift;
      my ($i) = $VI::StartLine-1;
      while (++$i <= $VI::StopLine) {
        $_ = VI::GetLine($VI::ScreenId, $i);
        VI::SetLine($VI::ScreenId, $i, $_) if(&$code);
      }
    }

Now you can do

    :perl forall sub{s/perlre/substitution/}

Although you'll probably use

    :perldo s/perlre/substitution/

instead.

See L<perlre> for perl regular expressions.

=head1 SEE ALSO

L<nviperl>

=head1 AUTHOR

Sven Verdoolaege <skimo@kotnet.org>