ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/doc/rxvtperl.3.html
Revision: 1.2
Committed: Mon Jan 2 17:21:59 2006 UTC (18 years, 6 months ago) by root
Content type: text/html
Branch: MAIN
Changes since 1.1: +65 -0 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
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 root 1.2 <li><a href="#environment">ENVIRONMENT</a></li>
28     <ul>
29    
30     <li><a href="#urxvt_perl_verbosity">URXVT_PERL_VERBOSITY</a></li>
31     </ul>
32    
33 root 1.1 <li><a href="#author">AUTHOR</a></li>
34     </ul>
35     <!-- INDEX END -->
36    
37     <hr />
38     <p>
39     </p>
40     <h1><a name="name">NAME</a></h1>
41     <p>rxvtperl - rxvt-unicode's embedded perl interpreter</p>
42     <p>
43     </p>
44     <hr />
45     <h1><a name="synopsis">SYNOPSIS</a></h1>
46     <p>* Put your scripts into <em>/opt/rxvt/lib/urxvt/perl-ext/</em>, they will be loaded automatically.</p>
47     <p>* Each script will only be loaded once, even in urxvtd, and will be valid
48     globally.</p>
49     <p>* Scripts are evaluated in a 'use strict' and 'use utf8' environment, and
50     thus must be encoded as UTF-8.</p>
51     <pre>
52     sub on_sel_grab {
53     warn &quot;you selected &quot;, $_[0]-&gt;selection;
54     ()
55     }</pre>
56     <pre>
57     1</pre>
58     <p>
59     </p>
60     <hr />
61     <h1><a name="description">DESCRIPTION</a></h1>
62     <p>
63     </p>
64     <h2><a name="hooks">Hooks</a></h2>
65     <p>The following subroutines can be declared in loaded scripts, and will be called
66     whenever the relevant event happens.</p>
67     <p>All of them must return a boolean value. If it is true, then the event
68     counts as being <em>consumed</em>, and the invocation of other hooks is skipped,
69     and the relevant action might not be carried out by the C++ code.</p>
70     <p>When in doubt, return a false value (preferably <code>()</code>).</p>
71     <dl>
72     <dt><strong><a name="item_on_init__24term">on_init $term</a></strong><br />
73     </dt>
74     <dd>
75     Called after a new terminal object has been initialized, but before
76     windows are created or the command gets run.
77     </dd>
78     <p></p>
79     <dt><strong><a name="item_on_reset__24term">on_reset $term</a></strong><br />
80     </dt>
81     <dd>
82     Called after the screen is ``reset'' for any reason, such as resizing or
83     control sequences. Here is where you can react on changes to size-related
84     variables.
85     </dd>
86     <p></p>
87     <dt><strong><a name="item_on_start__24term">on_start $term</a></strong><br />
88     </dt>
89     <dd>
90     Called at the very end of initialisation of a new terminal, just before
91     returning to the mainloop.
92     </dd>
93     <p></p>
94     <dt><strong><a name="item_on_sel_make__24term_2c__24eventtime">on_sel_make $term, $eventtime</a></strong><br />
95     </dt>
96     <dd>
97     Called whenever a selection has been made by the user, but before the
98     selection text is copied, so changes to the beginning, end or type of the
99     selection will be honored.
100     </dd>
101     <dd>
102     <p>Returning a true value aborts selection making by urxvt, in which case you
103     have to make a selection yourself by calling <a href="#item_selection_grab"><code>$term-&gt;selection_grab</code></a>.</p>
104     </dd>
105     <p></p>
106     <dt><strong><a name="item_on_sel_grab__24term_2c__24eventtime">on_sel_grab $term, $eventtime</a></strong><br />
107     </dt>
108     <dd>
109     Called whenever a selection has been copied, but before the selection is
110     requested from the server. The selection text can be queried and changed
111     by calling <a href="#item_selection"><code>$term-&gt;selection</code></a>.
112     </dd>
113     <dd>
114     <p>Returning a true value aborts selection grabbing. It will still be hilighted.</p>
115     </dd>
116     <p></p>
117     <dt><strong><a name="item_on_focus_in__24term">on_focus_in $term</a></strong><br />
118     </dt>
119     <dd>
120     Called whenever the window gets the keyboard focus, before urxvt does
121     focus in processing.
122     </dd>
123     <p></p>
124     <dt><strong><a name="item_on_focus_out__24term">on_focus_out $term</a></strong><br />
125     </dt>
126     <dd>
127     Called wheneever the window loses keyboard focus, before urxvt does focus
128     out processing.
129     </dd>
130     <p></p>
131     <dt><strong><a name="item_on_view_change__24term_2c__24offset">on_view_change $term, $offset</a></strong><br />
132     </dt>
133     <dd>
134     Called whenever the view offset changes, i..e the user or program
135     scrolls. Offset <code>0</code> means display the normal terminal, positive values
136     show this many lines of scrollback.
137     </dd>
138     <p></p>
139     <dt><strong><a name="item_on_scroll_back__24term_2c__24lines_2c__24saved">on_scroll_back $term, $lines, $saved</a></strong><br />
140     </dt>
141     <dd>
142     Called whenever lines scroll out of the terminal area into the scrollback
143     buffer. <code>$lines</code> is the number of lines scrolled out and may be larger
144     than the scroll back buffer or the terminal.
145     </dd>
146     <dd>
147     <p>It is called before lines are scrolled out (so rows 0 .. min ($lines - 1,
148     $nrow - 1) represent the lines to be scrolled out). <code>$saved</code> is the total
149     number of lines that will be in the scrollback buffer.</p>
150     </dd>
151     <p></p>
152     <dt><strong><a name="item_on_tty_activity__24term__2anyi_2a">on_tty_activity $term *NYI*</a></strong><br />
153     </dt>
154     <dd>
155     Called whenever the <code>program(s)</code> running in the urxvt window send output.
156     </dd>
157     <p></p>
158     <dt><strong><a name="item_on_refresh_begin__24term">on_refresh_begin $term</a></strong><br />
159     </dt>
160     <dd>
161     Called just before the screen gets redrawn. Can be used for overlay
162     or similar effects by modify terminal contents in refresh_begin, and
163     restoring them in refresh_end. The built-in overlay and selection display
164     code is run after this hook, and takes precedence.
165     </dd>
166     <p></p>
167     <dt><strong><a name="item_on_refresh_end__24term">on_refresh_end $term</a></strong><br />
168     </dt>
169     <dd>
170     Called just after the screen gets redrawn. See <code>on_refresh_begin</code>.
171     </dd>
172     <p></p></dl>
173     <p>
174     </p>
175     <h2><a name="functions_in_the_urxvt_package">Functions in the <code>urxvt</code> Package</a></h2>
176     <dl>
177     <dt><strong><a name="item_urxvt_3a_3afatal__24errormessage">urxvt::fatal $errormessage</a></strong><br />
178     </dt>
179     <dd>
180     Fatally aborts execution with the given error message. Avoid at all
181     costs! The only time this is acceptable is when the terminal process
182     starts up.
183     </dd>
184     <p></p>
185     <dt><strong><a name="item_urxvt_3a_3awarn__24string">urxvt::warn $string</a></strong><br />
186     </dt>
187     <dd>
188     Calls <code>rxvt_warn</code> witht eh given string which should not include a
189     newline. The module also overwrites the <code>warn</code> builtin with a function
190     that calls this function.
191     </dd>
192     <dd>
193     <p>Using this function has the advantage that its output ends up in the
194     correct place, e.g. on stderr of the connecting urxvtc client.</p>
195     </dd>
196     <p></p>
197     <dt><strong><a name="item__24cellwidth__3d_urxvt_3a_3awcswidth__24string">$cellwidth = urxvt::wcswidth $string</a></strong><br />
198     </dt>
199     <dd>
200     Returns the number of screen-cells this string would need. Correctly
201     accounts for wide and combining characters.
202     </dd>
203     <p></p>
204     <dt><strong><a name="item__24time__3d_urxvt_3a_3anow">$time = urxvt::NOW</a></strong><br />
205     </dt>
206     <dd>
207     Returns the ``current time'' (as per the event loop).
208     </dd>
209     <p></p></dl>
210     <p>
211     </p>
212     <h2><a name="the_urxvt__term_class">The <code>urxvt::term</code> Class</a></h2>
213     <dl>
214 root 1.2 <dt><strong><a name="item_resource">$value = $term-&gt;resource ($name[, $newval])</a></strong><br />
215     </dt>
216     <dd>
217     Returns the current resource value associated with a given name and
218     optionally sets a new value. Setting values is most useful in the <code>init</code>
219     hook. Unset resources are returned and accepted as <code>undef</code>.
220     </dd>
221     <dd>
222     <p>The new value must be properly encoded to a suitable character encoding
223     before passing it to this method. Similarly, the returned value may need
224     to be converted from the used encoding to text.</p>
225     </dd>
226     <dd>
227     <p>Resource names are as defined in <em>src/rsinc.h</em>. Colours can be specified
228     as resource names of the form <code>color+&lt;index&gt;</code>, e.g. <code>color+5</code>. (will
229     likely change).</p>
230     </dd>
231     <dd>
232     <p>Please note that resource strings will currently only be freed when the
233     terminal is destroyed, so changing options frequently will eat memory.</p>
234     </dd>
235     <dd>
236     <p>Here is a a likely non-exhaustive list of resource names, not all of which
237     are supported in every build, please see the source to see the actual
238     list:</p>
239     </dd>
240     <dd>
241     <pre>
242     answerbackstring backgroundPixmap backspace_key boldFont boldItalicFont
243     borderLess color cursorBlink cursorUnderline cutchars delete_key
244     display_name embed ext_bwidth fade font geometry hold iconName
245     imFont imLocale inputMethod insecure int_bwidth intensityStyles
246     italicFont jumpScroll lineSpace loginShell mapAlert menu meta8
247     modifier mouseWheelScrollPage name pastableTabs path pointerBlank
248     pointerBlankDelay preeditType print_pipe pty_fd reverseVideo saveLines
249     scrollBar scrollBar_align scrollBar_floating scrollBar_right
250     scrollBar_thickness scrollTtyKeypress scrollTtyOutput scrollWithBuffer
251     scrollstyle secondaryScreen secondaryScroll selectstyle shade term_name
252     title transparent transparent_all tripleclickwords utmpInhibit
253     visualBell</pre>
254     </dd>
255     <p></p>
256 root 1.1 <dt><strong><a name="item_selection_mark">($row, $col) = $term-&gt;selection_mark ([$row, $col])</a></strong><br />
257     </dt>
258     <dt><strong><a name="item_selection_beg">($row, $col) = $term-&gt;selection_beg ([$row, $col])</a></strong><br />
259     </dt>
260     <dt><strong><a name="item_selection_end">($row, $col) = $term-&gt;selection_end ([$row, $col])</a></strong><br />
261     </dt>
262     <dd>
263     Return the current values of the selection mark, begin or end positions,
264     and optionally set them to new values.
265     </dd>
266     <p></p>
267     <dt><strong><a name="item_selection_grab">$success = $term-&gt;selection_grab ($eventtime)</a></strong><br />
268     </dt>
269     <dd>
270     Try to request the primary selection from the server (for example, as set
271     by the next method).
272     </dd>
273     <p></p>
274     <dt><strong><a name="item_selection">$oldtext = $term-&gt;selection ([$newtext])</a></strong><br />
275     </dt>
276     <dd>
277     Return the current selection text and optionally replace it by <code>$newtext</code>.
278     </dd>
279     <p></p>
280     <dt><strong><a name="item_scr_overlay">$term-&gt;scr_overlay ($x, $y, $text)</a></strong><br />
281     </dt>
282     <dd>
283     Create a simple multi-line overlay box. See the next method for details.
284     </dd>
285     <p></p>
286     <dt><strong><a name="item_scr_overlay_new">$term-&gt;scr_overlay_new ($x, $y, $width, $height)</a></strong><br />
287     </dt>
288     <dd>
289     Create a new (empty) overlay at the given position with the given
290     width/height. A border will be put around the box. If either <code>$x</code> or
291     <code>$y</code> is negative, then this is counted from the right/bottom side,
292     respectively.
293     </dd>
294     <p></p>
295     <dt><strong><a name="item_scr_overlay_off">$term-&gt;scr_overlay_off</a></strong><br />
296     </dt>
297     <dd>
298     Switch the overlay off again.
299     </dd>
300     <p></p>
301     <dt><strong><a name="item_scr_overlay_set_char">$term-&gt;scr_overlay_set_char ($x, $y, $char, $rend = OVERLAY_RSTYLE)</a></strong><br />
302     </dt>
303     <dd>
304     Put a single character (specified numerically) at the given overlay
305     position.
306     </dd>
307     <p></p>
308     <dt><strong><a name="item_scr_overlay_set">$term-&gt;scr_overlay_set ($x, $y, $text)</a></strong><br />
309     </dt>
310     <dd>
311     Write a string at the given position into the overlay.
312     </dd>
313     <p></p></dl>
314     <p>
315     </p>
316     <h2><a name="the_urxvt__timer_class">The <code>urxvt::timer</code> Class</a></h2>
317     <p>This class implements timer watchers/events. Time is represented as a
318     fractional number of seconds since the epoch. Example:</p>
319     <pre>
320     # create a digital clock display in upper right corner
321     $term-&gt;{timer} = urxvt::timer
322     -&gt;new
323     -&gt;start (urxvt::NOW)
324     -&gt;cb (sub {
325     my ($timer) = @_;
326     my $time = $timer-&gt;at;
327     $timer-&gt;start ($time + 1);
328     $self-&gt;scr_overlay (-1, 0,
329     POSIX::strftime &quot;%H:%M:%S&quot;, localtime $time);
330     });</pre>
331     <dl>
332     <dt><strong><a name="item__24timer__3d_new_urxvt_3a_3atimer">$timer = new urxvt::timer</a></strong><br />
333     </dt>
334     <dd>
335     Create a new timer object in stopped state.
336     </dd>
337     <p></p>
338     <dt><strong><a name="item_cb">$timer = $timer-&gt;cb (sub { my ($timer) = @_; ... })</a></strong><br />
339     </dt>
340     <dd>
341     Set the callback to be called when the timer triggers.
342     </dd>
343     <p></p>
344     <dt><strong><a name="item_at">$tstamp = $timer-&gt;at</a></strong><br />
345     </dt>
346     <dd>
347     Return the time this watcher will fire next.
348     </dd>
349     <p></p>
350     <dt><strong><a name="item_set">$timer = $timer-&gt;set ($tstamp)</a></strong><br />
351     </dt>
352     <dd>
353     Set the time the event is generated to $tstamp.
354     </dd>
355     <p></p>
356     <dt><strong><a name="item_start">$timer = $timer-&gt;start</a></strong><br />
357     </dt>
358     <dd>
359     Start the timer.
360     </dd>
361     <p></p>
362     <dt><strong>$timer = $timer-&gt;start ($tstamp)</strong><br />
363     </dt>
364     <dd>
365     Set the event trigger time to <code>$tstamp</code> and start the timer.
366     </dd>
367     <p></p>
368     <dt><strong><a name="item_stop">$timer = $timer-&gt;stop</a></strong><br />
369     </dt>
370     <dd>
371     Stop the timer.
372     </dd>
373     <p></p></dl>
374     <p>
375     </p>
376     <h2><a name="the_urxvt__iow_class">The <code>urxvt::iow</code> Class</a></h2>
377     <p>This class implements io watchers/events. Example:</p>
378     <pre>
379     $term-&gt;{socket} = ...
380     $term-&gt;{iow} = urxvt::iow
381     -&gt;new
382     -&gt;fd (fileno $term-&gt;{socket})
383     -&gt;events (1) # wait for read data
384     -&gt;start
385     -&gt;cb (sub {
386     my ($iow, $revents) = @_;
387     # $revents must be 1 here, no need to check
388     sysread $term-&gt;{socket}, my $buf, 8192
389     or end-of-file;
390     });</pre>
391     <dl>
392     <dt><strong><a name="item__24iow__3d_new_urxvt_3a_3aiow">$iow = new urxvt::iow</a></strong><br />
393     </dt>
394     <dd>
395     Create a new io watcher object in stopped state.
396     </dd>
397     <p></p>
398     <dt><strong>$iow = $iow-&gt;cb (sub { my ($iow, $reventmask) = @_; ... })</strong><br />
399     </dt>
400     <dd>
401     Set the callback to be called when io events are triggered. <code>$reventmask</code>
402     is a bitset as described in the <a href="#item_events"><code>events</code></a> method.
403     </dd>
404     <p></p>
405     <dt><strong><a name="item_fd">$iow = $iow-&gt;fd ($fd)</a></strong><br />
406     </dt>
407     <dd>
408     Set the filedescriptor (not handle) to watch.
409     </dd>
410     <p></p>
411     <dt><strong><a name="item_events">$iow = $iow-&gt;events ($eventmask)</a></strong><br />
412     </dt>
413     <dd>
414     Set the event mask to watch. Bit #0 (value <code>1</code>) enables watching for read
415     data, Bit #1 (value <code>2</code>) enables watching for write data.
416     </dd>
417     <p></p>
418     <dt><strong>$iow = $iow-&gt;start</strong><br />
419     </dt>
420     <dd>
421     Start watching for requested events on the given handle.
422     </dd>
423     <p></p>
424     <dt><strong>$iow = $iow-&gt;stop</strong><br />
425     </dt>
426     <dd>
427     Stop watching for events on the given filehandle.
428     </dd>
429     <p></p></dl>
430     <p>
431     </p>
432     <hr />
433 root 1.2 <h1><a name="environment">ENVIRONMENT</a></h1>
434     <p>
435     </p>
436     <h2><a name="urxvt_perl_verbosity">URXVT_PERL_VERBOSITY</a></h2>
437     <p>This variable controls the verbosity level of the perl extension. Higher
438     numbers indicate more verbose output.</p>
439     <ol>
440     <li><strong><a name="item__2d_only_fatal_messages">- only fatal messages</a></strong><br />
441     </li>
442     <li><strong><a name="item__2d_script_loading_and_management">- script loading and management</a></strong><br />
443     </li>
444     <li><strong><a name="item__2d_all_events_received">- all events received</a></strong><br />
445     </li>
446     </ol>
447     <p>
448     </p>
449     <hr />
450 root 1.1 <h1><a name="author">AUTHOR</a></h1>
451     <pre>
452     Marc Lehmann &lt;pcg@goof.com&gt;
453     <a href="http://software.schmorp.de/pkg/rxvt-unicode">http://software.schmorp.de/pkg/rxvt-unicode</a></pre>
454    
455     </body>
456    
457     </html>