3 VI - VI module within perl embedded nvi
10 while ($i <= $VI::StopLine) {
11 $_ = $curscr->GetLine($i++);
14 $curscr->Msg("$words words");
19 This pseudo module is available to perl programs run from within nvi and
20 provides access to the files being edited and some internal data.
22 Beware that you should not use this module from within a C<perldo> or
23 from within an C<END> block or a C<DESTROY> method.
27 These are set by nvi before starting each perl command.
33 Object that represents the current screen.
34 It can be used as the ScreenId parameter of the functions below,
35 or you can use object oriented syntax.
37 # the following two are equivalent
39 VI::DelLine($curscr, 57);
43 Line number of the first line of the selected range or of the file if no
48 Line number of the last line of the selected range or of the file if no
59 VI::AppendLine(screenId,lineNumber,text);
61 Append the string text after the line in lineNumber.
65 VI::DelLine(screenId,lineNum);
71 VI::EndScreen(screenId);
79 Return the screen id associated with file name.
83 ($line, $column) = VI::GetCursor(screenId);
85 Return the current cursor position as a list with two elements.
89 VI::GetLine(screenId,lineNumber);
95 ($line, $column) = VI::GetMark(screenId,mark);
97 Return the mark's cursor position as a list with two elements.
101 VI::GetOpt(screenId,option);
103 Return the value of an option.
107 VI::InsertLine(screenId,lineNumber,text);
109 Insert the string text before the line in lineNumber.
113 VI::LastLine(screenId);
115 Return the last line in the screen.
119 VI::MapKey(screenId,key,perlproc);
121 Associate a key with a perl procedure.
125 VI::Msg(screenId,text);
127 Set the message line to text.
131 VI::NewScreen(screenId);
132 VI::NewScreen(screenId,file);
134 Create a new screen. If a filename is specified then the screen is
135 opened with that file.
139 VI::Run(screenId,cmd);
141 Run the ex command cmd.
145 VI::SetCursor(screenId,line,column);
147 Set the cursor to the line and column numbers supplied.
151 VI::SetLine(screenId,lineNumber,text);
153 Set lineNumber to the text supplied.
157 VI::SetMark(screenId,mark,line,column);
159 Set the mark to the line and column numbers supplied.
163 VI::SetOpt(screenId,command);
169 VI::SwitchScreen(screenId,screenId);
171 Change the current focus to screen.
175 $screen->TagQ("tag identification string")
177 Creates a new tag queue object associated to $screen
178 to which "tags" can be added.
179 See further about methods you can use on tag queues.
183 VI::UnmmapKey(screenId,key);
189 This is the default warning handler.
190 It adds any warnings to the error string.
196 Returns a tied hash representing the options of the screen.
197 Note that you can only retrieve and set hash elements.
203 Returns a tied hash representing the mappings of the screen.
204 Note that you can only retrieve, set and delete hash elements.
210 Returns a tied hash representing the marks of the screen.
216 Returns a tied array representing the lines of the screen.
220 =head2 Tag queue methods
224 $tagq->Add($filename, $searchstring, $msg)
226 Adds a tag to the tag queue.
227 The $searchstring argument is (line)number or
228 a string representing a regular expression.
234 Pushes the tag queue onto its associated screen.
235 The result of the operation is as if the user had enter the
236 tag command and nvi had found the locations that were added
237 using the Add method.
239 For an example, see the make.pl script.
247 for $mark ('a' .. 'z') {
248 eval {VI::GetMark($VI::ScreenId, $mark)};
249 $all .= $mark unless ($@);
251 VI::Msg($VI::ScreenId,"Set marks: $all");
256 my ($i) = $VI::StartLine-1;
257 while (++$i <= $VI::StopLine) {
258 $_ = VI::GetLine($VI::ScreenId, $i);
259 VI::SetLine($VI::ScreenId, $i, $_) if(&$code);
265 :perl forall sub{s/perlre/substitution/}
267 Although you'll probably use
269 :perldo s/perlre/substitution/
273 See L<perlre> for perl regular expressions.
281 Sven Verdoolaege <skimo@kotnet.org>