1 |
root |
1.1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
2 |
|
|
<html xmlns="http://www.w3.org/1999/xhtml"> |
3 |
|
|
<head> |
4 |
|
|
<title>rxvtperl - rxvt-unicode's embedded perl interpreter</title> |
5 |
|
|
<link rev="made" href="mailto:perl-binary@plan9.de" /> |
6 |
|
|
</head> |
7 |
|
|
|
8 |
|
|
<body style="background-color: white"> |
9 |
|
|
|
10 |
|
|
<p><a name="__index__"></a></p> |
11 |
|
|
<!-- INDEX BEGIN --> |
12 |
|
|
|
13 |
|
|
<ul> |
14 |
|
|
|
15 |
|
|
<li><a href="#name">NAME</a></li> |
16 |
|
|
<li><a href="#synopsis">SYNOPSIS</a></li> |
17 |
|
|
<li><a href="#description">DESCRIPTION</a></li> |
18 |
|
|
<ul> |
19 |
|
|
|
20 |
|
|
<li><a href="#hooks">Hooks</a></li> |
21 |
|
|
<li><a href="#functions_in_the_urxvt_package">Functions in the <code>urxvt</code> Package</a></li> |
22 |
|
|
<li><a href="#the_urxvt__term_class">The <code>urxvt::term</code> Class</a></li> |
23 |
|
|
<li><a href="#the_urxvt__timer_class">The <code>urxvt::timer</code> Class</a></li> |
24 |
|
|
<li><a href="#the_urxvt__iow_class">The <code>urxvt::iow</code> Class</a></li> |
25 |
|
|
</ul> |
26 |
|
|
|
27 |
|
|
<li><a href="#author">AUTHOR</a></li> |
28 |
|
|
</ul> |
29 |
|
|
<!-- INDEX END --> |
30 |
|
|
|
31 |
|
|
<hr /> |
32 |
|
|
<p> |
33 |
|
|
</p> |
34 |
|
|
<h1><a name="name">NAME</a></h1> |
35 |
|
|
<p>rxvtperl - rxvt-unicode's embedded perl interpreter</p> |
36 |
|
|
<p> |
37 |
|
|
</p> |
38 |
|
|
<hr /> |
39 |
|
|
<h1><a name="synopsis">SYNOPSIS</a></h1> |
40 |
|
|
<p>* Put your scripts into <em>/opt/rxvt/lib/urxvt/perl-ext/</em>, they will be loaded automatically.</p> |
41 |
|
|
<p>* Each script will only be loaded once, even in urxvtd, and will be valid |
42 |
|
|
globally.</p> |
43 |
|
|
<p>* Scripts are evaluated in a 'use strict' and 'use utf8' environment, and |
44 |
|
|
thus must be encoded as UTF-8.</p> |
45 |
|
|
<pre> |
46 |
|
|
sub on_sel_grab { |
47 |
|
|
warn "you selected ", $_[0]->selection; |
48 |
|
|
() |
49 |
|
|
}</pre> |
50 |
|
|
<pre> |
51 |
|
|
1</pre> |
52 |
|
|
<p> |
53 |
|
|
</p> |
54 |
|
|
<hr /> |
55 |
|
|
<h1><a name="description">DESCRIPTION</a></h1> |
56 |
|
|
<p> |
57 |
|
|
</p> |
58 |
|
|
<h2><a name="hooks">Hooks</a></h2> |
59 |
|
|
<p>The following subroutines can be declared in loaded scripts, and will be called |
60 |
|
|
whenever the relevant event happens.</p> |
61 |
|
|
<p>All of them must return a boolean value. If it is true, then the event |
62 |
|
|
counts as being <em>consumed</em>, and the invocation of other hooks is skipped, |
63 |
|
|
and the relevant action might not be carried out by the C++ code.</p> |
64 |
|
|
<p>When in doubt, return a false value (preferably <code>()</code>).</p> |
65 |
|
|
<dl> |
66 |
|
|
<dt><strong><a name="item_on_init__24term">on_init $term</a></strong><br /> |
67 |
|
|
</dt> |
68 |
|
|
<dd> |
69 |
|
|
Called after a new terminal object has been initialized, but before |
70 |
|
|
windows are created or the command gets run. |
71 |
|
|
</dd> |
72 |
|
|
<p></p> |
73 |
|
|
<dt><strong><a name="item_on_reset__24term">on_reset $term</a></strong><br /> |
74 |
|
|
</dt> |
75 |
|
|
<dd> |
76 |
|
|
Called after the screen is ``reset'' for any reason, such as resizing or |
77 |
|
|
control sequences. Here is where you can react on changes to size-related |
78 |
|
|
variables. |
79 |
|
|
</dd> |
80 |
|
|
<p></p> |
81 |
|
|
<dt><strong><a name="item_on_start__24term">on_start $term</a></strong><br /> |
82 |
|
|
</dt> |
83 |
|
|
<dd> |
84 |
|
|
Called at the very end of initialisation of a new terminal, just before |
85 |
|
|
returning to the mainloop. |
86 |
|
|
</dd> |
87 |
|
|
<p></p> |
88 |
|
|
<dt><strong><a name="item_on_sel_make__24term_2c__24eventtime">on_sel_make $term, $eventtime</a></strong><br /> |
89 |
|
|
</dt> |
90 |
|
|
<dd> |
91 |
|
|
Called whenever a selection has been made by the user, but before the |
92 |
|
|
selection text is copied, so changes to the beginning, end or type of the |
93 |
|
|
selection will be honored. |
94 |
|
|
</dd> |
95 |
|
|
<dd> |
96 |
|
|
<p>Returning a true value aborts selection making by urxvt, in which case you |
97 |
|
|
have to make a selection yourself by calling <a href="#item_selection_grab"><code>$term->selection_grab</code></a>.</p> |
98 |
|
|
</dd> |
99 |
|
|
<p></p> |
100 |
|
|
<dt><strong><a name="item_on_sel_grab__24term_2c__24eventtime">on_sel_grab $term, $eventtime</a></strong><br /> |
101 |
|
|
</dt> |
102 |
|
|
<dd> |
103 |
|
|
Called whenever a selection has been copied, but before the selection is |
104 |
|
|
requested from the server. The selection text can be queried and changed |
105 |
|
|
by calling <a href="#item_selection"><code>$term->selection</code></a>. |
106 |
|
|
</dd> |
107 |
|
|
<dd> |
108 |
|
|
<p>Returning a true value aborts selection grabbing. It will still be hilighted.</p> |
109 |
|
|
</dd> |
110 |
|
|
<p></p> |
111 |
|
|
<dt><strong><a name="item_on_focus_in__24term">on_focus_in $term</a></strong><br /> |
112 |
|
|
</dt> |
113 |
|
|
<dd> |
114 |
|
|
Called whenever the window gets the keyboard focus, before urxvt does |
115 |
|
|
focus in processing. |
116 |
|
|
</dd> |
117 |
|
|
<p></p> |
118 |
|
|
<dt><strong><a name="item_on_focus_out__24term">on_focus_out $term</a></strong><br /> |
119 |
|
|
</dt> |
120 |
|
|
<dd> |
121 |
|
|
Called wheneever the window loses keyboard focus, before urxvt does focus |
122 |
|
|
out processing. |
123 |
|
|
</dd> |
124 |
|
|
<p></p> |
125 |
|
|
<dt><strong><a name="item_on_view_change__24term_2c__24offset">on_view_change $term, $offset</a></strong><br /> |
126 |
|
|
</dt> |
127 |
|
|
<dd> |
128 |
|
|
Called whenever the view offset changes, i..e the user or program |
129 |
|
|
scrolls. Offset <code>0</code> means display the normal terminal, positive values |
130 |
|
|
show this many lines of scrollback. |
131 |
|
|
</dd> |
132 |
|
|
<p></p> |
133 |
|
|
<dt><strong><a name="item_on_scroll_back__24term_2c__24lines_2c__24saved">on_scroll_back $term, $lines, $saved</a></strong><br /> |
134 |
|
|
</dt> |
135 |
|
|
<dd> |
136 |
|
|
Called whenever lines scroll out of the terminal area into the scrollback |
137 |
|
|
buffer. <code>$lines</code> is the number of lines scrolled out and may be larger |
138 |
|
|
than the scroll back buffer or the terminal. |
139 |
|
|
</dd> |
140 |
|
|
<dd> |
141 |
|
|
<p>It is called before lines are scrolled out (so rows 0 .. min ($lines - 1, |
142 |
|
|
$nrow - 1) represent the lines to be scrolled out). <code>$saved</code> is the total |
143 |
|
|
number of lines that will be in the scrollback buffer.</p> |
144 |
|
|
</dd> |
145 |
|
|
<p></p> |
146 |
|
|
<dt><strong><a name="item_on_tty_activity__24term__2anyi_2a">on_tty_activity $term *NYI*</a></strong><br /> |
147 |
|
|
</dt> |
148 |
|
|
<dd> |
149 |
|
|
Called whenever the <code>program(s)</code> running in the urxvt window send output. |
150 |
|
|
</dd> |
151 |
|
|
<p></p> |
152 |
|
|
<dt><strong><a name="item_on_refresh_begin__24term">on_refresh_begin $term</a></strong><br /> |
153 |
|
|
</dt> |
154 |
|
|
<dd> |
155 |
|
|
Called just before the screen gets redrawn. Can be used for overlay |
156 |
|
|
or similar effects by modify terminal contents in refresh_begin, and |
157 |
|
|
restoring them in refresh_end. The built-in overlay and selection display |
158 |
|
|
code is run after this hook, and takes precedence. |
159 |
|
|
</dd> |
160 |
|
|
<p></p> |
161 |
|
|
<dt><strong><a name="item_on_refresh_end__24term">on_refresh_end $term</a></strong><br /> |
162 |
|
|
</dt> |
163 |
|
|
<dd> |
164 |
|
|
Called just after the screen gets redrawn. See <code>on_refresh_begin</code>. |
165 |
|
|
</dd> |
166 |
|
|
<p></p></dl> |
167 |
|
|
<p> |
168 |
|
|
</p> |
169 |
|
|
<h2><a name="functions_in_the_urxvt_package">Functions in the <code>urxvt</code> Package</a></h2> |
170 |
|
|
<dl> |
171 |
|
|
<dt><strong><a name="item_urxvt_3a_3afatal__24errormessage">urxvt::fatal $errormessage</a></strong><br /> |
172 |
|
|
</dt> |
173 |
|
|
<dd> |
174 |
|
|
Fatally aborts execution with the given error message. Avoid at all |
175 |
|
|
costs! The only time this is acceptable is when the terminal process |
176 |
|
|
starts up. |
177 |
|
|
</dd> |
178 |
|
|
<p></p> |
179 |
|
|
<dt><strong><a name="item_urxvt_3a_3awarn__24string">urxvt::warn $string</a></strong><br /> |
180 |
|
|
</dt> |
181 |
|
|
<dd> |
182 |
|
|
Calls <code>rxvt_warn</code> witht eh given string which should not include a |
183 |
|
|
newline. The module also overwrites the <code>warn</code> builtin with a function |
184 |
|
|
that calls this function. |
185 |
|
|
</dd> |
186 |
|
|
<dd> |
187 |
|
|
<p>Using this function has the advantage that its output ends up in the |
188 |
|
|
correct place, e.g. on stderr of the connecting urxvtc client.</p> |
189 |
|
|
</dd> |
190 |
|
|
<p></p> |
191 |
|
|
<dt><strong><a name="item__24cellwidth__3d_urxvt_3a_3awcswidth__24string">$cellwidth = urxvt::wcswidth $string</a></strong><br /> |
192 |
|
|
</dt> |
193 |
|
|
<dd> |
194 |
|
|
Returns the number of screen-cells this string would need. Correctly |
195 |
|
|
accounts for wide and combining characters. |
196 |
|
|
</dd> |
197 |
|
|
<p></p> |
198 |
|
|
<dt><strong><a name="item__24time__3d_urxvt_3a_3anow">$time = urxvt::NOW</a></strong><br /> |
199 |
|
|
</dt> |
200 |
|
|
<dd> |
201 |
|
|
Returns the ``current time'' (as per the event loop). |
202 |
|
|
</dd> |
203 |
|
|
<p></p></dl> |
204 |
|
|
<p> |
205 |
|
|
</p> |
206 |
|
|
<h2><a name="the_urxvt__term_class">The <code>urxvt::term</code> Class</a></h2> |
207 |
|
|
<dl> |
208 |
|
|
<dt><strong><a name="item_selection_mark">($row, $col) = $term->selection_mark ([$row, $col])</a></strong><br /> |
209 |
|
|
</dt> |
210 |
|
|
<dt><strong><a name="item_selection_beg">($row, $col) = $term->selection_beg ([$row, $col])</a></strong><br /> |
211 |
|
|
</dt> |
212 |
|
|
<dt><strong><a name="item_selection_end">($row, $col) = $term->selection_end ([$row, $col])</a></strong><br /> |
213 |
|
|
</dt> |
214 |
|
|
<dd> |
215 |
|
|
Return the current values of the selection mark, begin or end positions, |
216 |
|
|
and optionally set them to new values. |
217 |
|
|
</dd> |
218 |
|
|
<p></p> |
219 |
|
|
<dt><strong><a name="item_selection_grab">$success = $term->selection_grab ($eventtime)</a></strong><br /> |
220 |
|
|
</dt> |
221 |
|
|
<dd> |
222 |
|
|
Try to request the primary selection from the server (for example, as set |
223 |
|
|
by the next method). |
224 |
|
|
</dd> |
225 |
|
|
<p></p> |
226 |
|
|
<dt><strong><a name="item_selection">$oldtext = $term->selection ([$newtext])</a></strong><br /> |
227 |
|
|
</dt> |
228 |
|
|
<dd> |
229 |
|
|
Return the current selection text and optionally replace it by <code>$newtext</code>. |
230 |
|
|
</dd> |
231 |
|
|
<p></p> |
232 |
|
|
<dt><strong><a name="item_scr_overlay">$term->scr_overlay ($x, $y, $text)</a></strong><br /> |
233 |
|
|
</dt> |
234 |
|
|
<dd> |
235 |
|
|
Create a simple multi-line overlay box. See the next method for details. |
236 |
|
|
</dd> |
237 |
|
|
<p></p> |
238 |
|
|
<dt><strong><a name="item_scr_overlay_new">$term->scr_overlay_new ($x, $y, $width, $height)</a></strong><br /> |
239 |
|
|
</dt> |
240 |
|
|
<dd> |
241 |
|
|
Create a new (empty) overlay at the given position with the given |
242 |
|
|
width/height. A border will be put around the box. If either <code>$x</code> or |
243 |
|
|
<code>$y</code> is negative, then this is counted from the right/bottom side, |
244 |
|
|
respectively. |
245 |
|
|
</dd> |
246 |
|
|
<p></p> |
247 |
|
|
<dt><strong><a name="item_scr_overlay_off">$term->scr_overlay_off</a></strong><br /> |
248 |
|
|
</dt> |
249 |
|
|
<dd> |
250 |
|
|
Switch the overlay off again. |
251 |
|
|
</dd> |
252 |
|
|
<p></p> |
253 |
|
|
<dt><strong><a name="item_scr_overlay_set_char">$term->scr_overlay_set_char ($x, $y, $char, $rend = OVERLAY_RSTYLE)</a></strong><br /> |
254 |
|
|
</dt> |
255 |
|
|
<dd> |
256 |
|
|
Put a single character (specified numerically) at the given overlay |
257 |
|
|
position. |
258 |
|
|
</dd> |
259 |
|
|
<p></p> |
260 |
|
|
<dt><strong><a name="item_scr_overlay_set">$term->scr_overlay_set ($x, $y, $text)</a></strong><br /> |
261 |
|
|
</dt> |
262 |
|
|
<dd> |
263 |
|
|
Write a string at the given position into the overlay. |
264 |
|
|
</dd> |
265 |
|
|
<p></p></dl> |
266 |
|
|
<p> |
267 |
|
|
</p> |
268 |
|
|
<h2><a name="the_urxvt__timer_class">The <code>urxvt::timer</code> Class</a></h2> |
269 |
|
|
<p>This class implements timer watchers/events. Time is represented as a |
270 |
|
|
fractional number of seconds since the epoch. Example:</p> |
271 |
|
|
<pre> |
272 |
|
|
# create a digital clock display in upper right corner |
273 |
|
|
$term->{timer} = urxvt::timer |
274 |
|
|
->new |
275 |
|
|
->start (urxvt::NOW) |
276 |
|
|
->cb (sub { |
277 |
|
|
my ($timer) = @_; |
278 |
|
|
my $time = $timer->at; |
279 |
|
|
$timer->start ($time + 1); |
280 |
|
|
$self->scr_overlay (-1, 0, |
281 |
|
|
POSIX::strftime "%H:%M:%S", localtime $time); |
282 |
|
|
});</pre> |
283 |
|
|
<dl> |
284 |
|
|
<dt><strong><a name="item__24timer__3d_new_urxvt_3a_3atimer">$timer = new urxvt::timer</a></strong><br /> |
285 |
|
|
</dt> |
286 |
|
|
<dd> |
287 |
|
|
Create a new timer object in stopped state. |
288 |
|
|
</dd> |
289 |
|
|
<p></p> |
290 |
|
|
<dt><strong><a name="item_cb">$timer = $timer->cb (sub { my ($timer) = @_; ... })</a></strong><br /> |
291 |
|
|
</dt> |
292 |
|
|
<dd> |
293 |
|
|
Set the callback to be called when the timer triggers. |
294 |
|
|
</dd> |
295 |
|
|
<p></p> |
296 |
|
|
<dt><strong><a name="item_at">$tstamp = $timer->at</a></strong><br /> |
297 |
|
|
</dt> |
298 |
|
|
<dd> |
299 |
|
|
Return the time this watcher will fire next. |
300 |
|
|
</dd> |
301 |
|
|
<p></p> |
302 |
|
|
<dt><strong><a name="item_set">$timer = $timer->set ($tstamp)</a></strong><br /> |
303 |
|
|
</dt> |
304 |
|
|
<dd> |
305 |
|
|
Set the time the event is generated to $tstamp. |
306 |
|
|
</dd> |
307 |
|
|
<p></p> |
308 |
|
|
<dt><strong><a name="item_start">$timer = $timer->start</a></strong><br /> |
309 |
|
|
</dt> |
310 |
|
|
<dd> |
311 |
|
|
Start the timer. |
312 |
|
|
</dd> |
313 |
|
|
<p></p> |
314 |
|
|
<dt><strong>$timer = $timer->start ($tstamp)</strong><br /> |
315 |
|
|
</dt> |
316 |
|
|
<dd> |
317 |
|
|
Set the event trigger time to <code>$tstamp</code> and start the timer. |
318 |
|
|
</dd> |
319 |
|
|
<p></p> |
320 |
|
|
<dt><strong><a name="item_stop">$timer = $timer->stop</a></strong><br /> |
321 |
|
|
</dt> |
322 |
|
|
<dd> |
323 |
|
|
Stop the timer. |
324 |
|
|
</dd> |
325 |
|
|
<p></p></dl> |
326 |
|
|
<p> |
327 |
|
|
</p> |
328 |
|
|
<h2><a name="the_urxvt__iow_class">The <code>urxvt::iow</code> Class</a></h2> |
329 |
|
|
<p>This class implements io watchers/events. Example:</p> |
330 |
|
|
<pre> |
331 |
|
|
$term->{socket} = ... |
332 |
|
|
$term->{iow} = urxvt::iow |
333 |
|
|
->new |
334 |
|
|
->fd (fileno $term->{socket}) |
335 |
|
|
->events (1) # wait for read data |
336 |
|
|
->start |
337 |
|
|
->cb (sub { |
338 |
|
|
my ($iow, $revents) = @_; |
339 |
|
|
# $revents must be 1 here, no need to check |
340 |
|
|
sysread $term->{socket}, my $buf, 8192 |
341 |
|
|
or end-of-file; |
342 |
|
|
});</pre> |
343 |
|
|
<dl> |
344 |
|
|
<dt><strong><a name="item__24iow__3d_new_urxvt_3a_3aiow">$iow = new urxvt::iow</a></strong><br /> |
345 |
|
|
</dt> |
346 |
|
|
<dd> |
347 |
|
|
Create a new io watcher object in stopped state. |
348 |
|
|
</dd> |
349 |
|
|
<p></p> |
350 |
|
|
<dt><strong>$iow = $iow->cb (sub { my ($iow, $reventmask) = @_; ... })</strong><br /> |
351 |
|
|
</dt> |
352 |
|
|
<dd> |
353 |
|
|
Set the callback to be called when io events are triggered. <code>$reventmask</code> |
354 |
|
|
is a bitset as described in the <a href="#item_events"><code>events</code></a> method. |
355 |
|
|
</dd> |
356 |
|
|
<p></p> |
357 |
|
|
<dt><strong><a name="item_fd">$iow = $iow->fd ($fd)</a></strong><br /> |
358 |
|
|
</dt> |
359 |
|
|
<dd> |
360 |
|
|
Set the filedescriptor (not handle) to watch. |
361 |
|
|
</dd> |
362 |
|
|
<p></p> |
363 |
|
|
<dt><strong><a name="item_events">$iow = $iow->events ($eventmask)</a></strong><br /> |
364 |
|
|
</dt> |
365 |
|
|
<dd> |
366 |
|
|
Set the event mask to watch. Bit #0 (value <code>1</code>) enables watching for read |
367 |
|
|
data, Bit #1 (value <code>2</code>) enables watching for write data. |
368 |
|
|
</dd> |
369 |
|
|
<p></p> |
370 |
|
|
<dt><strong>$iow = $iow->start</strong><br /> |
371 |
|
|
</dt> |
372 |
|
|
<dd> |
373 |
|
|
Start watching for requested events on the given handle. |
374 |
|
|
</dd> |
375 |
|
|
<p></p> |
376 |
|
|
<dt><strong>$iow = $iow->stop</strong><br /> |
377 |
|
|
</dt> |
378 |
|
|
<dd> |
379 |
|
|
Stop watching for events on the given filehandle. |
380 |
|
|
</dd> |
381 |
|
|
<p></p></dl> |
382 |
|
|
<p> |
383 |
|
|
</p> |
384 |
|
|
<hr /> |
385 |
|
|
<h1><a name="author">AUTHOR</a></h1> |
386 |
|
|
<pre> |
387 |
|
|
Marc Lehmann <pcg@goof.com> |
388 |
|
|
<a href="http://software.schmorp.de/pkg/rxvt-unicode">http://software.schmorp.de/pkg/rxvt-unicode</a></pre> |
389 |
|
|
|
390 |
|
|
</body> |
391 |
|
|
|
392 |
|
|
</html> |