ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/doc/rxvtperl.3.html
Revision: 1.15
Committed: Sun Jan 8 00:20:12 2006 UTC (18 years, 6 months ago) by root
Content type: text/html
Branch: MAIN
Changes since 1.14: +79 -20 lines
Log Message:
*** empty log message ***

File Contents

# Content
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="#prepackaged_extensions">Prepackaged Extensions</a></li>
21 <li><a href="#general_api_considerations">General API Considerations</a></li>
22 <li><a href="#hooks">Hooks</a></li>
23 <li><a href="#variables_in_the_urxvt_package">Variables in the <code>urxvt</code> Package</a></li>
24 <li><a href="#functions_in_the_urxvt_package">Functions in the <code>urxvt</code> Package</a></li>
25 <li><a href="#rendition">RENDITION</a></li>
26 <li><a href="#the_urxvt__term_class">The <code>urxvt::term</code> Class</a></li>
27 <li><a href="#the_urxvt__popup_class">The <code>urxvt::popup</code> Class</a></li>
28 <li><a href="#the_urxvt__timer_class">The <code>urxvt::timer</code> Class</a></li>
29 <li><a href="#the_urxvt__iow_class">The <code>urxvt::iow</code> Class</a></li>
30 </ul>
31
32 <li><a href="#environment">ENVIRONMENT</a></li>
33 <ul>
34
35 <li><a href="#urxvt_perl_verbosity">URXVT_PERL_VERBOSITY</a></li>
36 </ul>
37
38 <li><a href="#author">AUTHOR</a></li>
39 </ul>
40 <!-- INDEX END -->
41
42 <hr />
43 <p>
44 </p>
45 <hr />
46 <h1><a name="name">NAME</a></h1>
47 <p>rxvtperl - rxvt-unicode's embedded perl interpreter</p>
48 <p>
49 </p>
50 <hr />
51 <h1><a name="synopsis">SYNOPSIS</a></h1>
52 <pre>
53 # create a file grab_test in $HOME:</pre>
54 <pre>
55 sub on_sel_grab {
56 warn &quot;you selected &quot;, $_[0]-&gt;selection;
57 ()
58 }</pre>
59 <pre>
60 # start a rxvt using it:</pre>
61 <pre>
62 rxvt --perl-lib $HOME -pe grab_test</pre>
63 <p>
64 </p>
65 <hr />
66 <h1><a name="description">DESCRIPTION</a></h1>
67 <p>Everytime a terminal object gets created, extension scripts specified via
68 the <code>perl</code> resource are loaded and associated with it.</p>
69 <p>Scripts are compiled in a 'use strict' and 'use utf8' environment, and
70 thus must be encoded as UTF-8.</p>
71 <p>Each script will only ever be loaded once, even in rxvtd, where
72 scripts will be shared (but not enabled) for all terminals.</p>
73 <p>
74 </p>
75 <h2><a name="prepackaged_extensions">Prepackaged Extensions</a></h2>
76 <p>This section describes the extensiosn delivered with this version. You can
77 find them in <em>/opt/rxvt/lib/urxvt/perl/</em>.</p>
78 <p>You can activate them like this:</p>
79 <pre>
80 rxvt -pe &lt;extensionname&gt;</pre>
81 <dl>
82 <dt><strong><a name="item_selection">selection</a></strong><br />
83 </dt>
84 <dd>
85 Intelligent selection. This extension tries to be more intelligent when
86 the user extends selections (double-click). Right now, it tries to select
87 urls and complete shell-quoted arguments, which is very convenient, too,
88 if your <em>ls</em> supports <code>--quoting-style=shell</code>.
89 </dd>
90 <dd>
91 <p>It also offers the following bindable event:</p>
92 </dd>
93 <dl>
94 <dt><strong><a name="item_rot13">rot13</a></strong><br />
95 </dt>
96 <dd>
97 Rot-13 the selection when activated. Used via keyboard trigger:
98 </dd>
99 <dd>
100 <pre>
101 URxvt.keysym.C-M-r: perl:selection:rot13</pre>
102 </dd>
103 <p></p></dl>
104 <dt><strong><a name="item_digital_2dclock">digital-clock</a></strong><br />
105 </dt>
106 <dd>
107 Displays a digital clock using the built-in overlay.
108 </dd>
109 <p></p>
110 <dt><strong><a name="item_mark_2durls">mark-urls</a></strong><br />
111 </dt>
112 <dd>
113 Uses per-line display filtering (<code>on_line_update</code>) to underline urls.
114 </dd>
115 <p></p>
116 <dt><strong><a name="item_block_2dgraphics_2dto_2dascii">block-graphics-to-ascii</a></strong><br />
117 </dt>
118 <dd>
119 A not very useful example of filtering all text output to the terminal,
120 by replacing all line-drawing characters (U+2500 .. U+259F) by a
121 similar-looking ascii character.
122 </dd>
123 <p></p>
124 <dt><strong><a name="item_example_2drefresh_2dhooks">example-refresh-hooks</a></strong><br />
125 </dt>
126 <dd>
127 Displays a very simple digital clock in the upper right corner of the
128 window. Illustrates overwriting the refresh callbacks to create your own
129 overlays or changes.
130 </dd>
131 <p></p></dl>
132 <p>
133 </p>
134 <h2><a name="general_api_considerations">General API Considerations</a></h2>
135 <p>All objects (such as terminals, time watchers etc.) are typical
136 reference-to-hash objects. The hash can be used to store anything you
137 like. All members starting with an underscore (such as <code>_ptr</code> or
138 <code>_hook</code>) are reserved for internal uses and <strong>MUST NOT</strong> be accessed or
139 modified).</p>
140 <p>When objects are destroyed on the C++ side, the perl object hashes are
141 emptied, so its best to store related objects such as time watchers and
142 the like inside the terminal object so they get destroyed as soon as the
143 terminal is destroyed.</p>
144 <p>Argument names also often indicate the type of a parameter. Here are some
145 hints on what they mean:</p>
146 <dl>
147 <dt><strong><a name="item__24text">$text</a></strong><br />
148 </dt>
149 <dd>
150 Rxvt-unicodes special way of encoding text, where one ``unicode'' character
151 always represents one screen cell. See <em>row_t</em> for a discussion of this format.
152 </dd>
153 <p></p>
154 <dt><strong><a name="item__24string">$string</a></strong><br />
155 </dt>
156 <dd>
157 A perl text string, with an emphasis on <em>text</em>. It can store all unicode
158 characters and is to be distinguished with text encoded in a specific
159 encoding (often locale-specific) and binary data.
160 </dd>
161 <p></p>
162 <dt><strong><a name="item__24octets">$octets</a></strong><br />
163 </dt>
164 <dd>
165 Either binary data or - more common - a text string encoded in a
166 locale-specific way.
167 </dd>
168 <p></p></dl>
169 <p>
170 </p>
171 <h2><a name="hooks">Hooks</a></h2>
172 <p>The following subroutines can be declared in extension files, and will be
173 called whenever the relevant event happens.</p>
174 <p>The first argument passed to them is an object private to each terminal
175 and extension package. You can call all <code>urxvt::term</code> methods on it, but
176 its not a real <code>urxvt::term</code> object. Instead, the real <code>urxvt::term</code>
177 object that is shared between all packages is stored in the <code>term</code>
178 member. It is, however, blessed intot he package of the extension script,
179 so for all practical purposes you can treat an extension script as a class.</p>
180 <p>All of them must return a boolean value. If it is true, then the event
181 counts as being <em>consumed</em>, and the invocation of other hooks is skipped,
182 and the relevant action might not be carried out by the C++ code.</p>
183 <p>When in doubt, return a false value (preferably <code>()</code>).</p>
184 <dl>
185 <dt><strong><a name="item_on_init__24term">on_init $term</a></strong><br />
186 </dt>
187 <dd>
188 Called after a new terminal object has been initialized, but before
189 windows are created or the command gets run. Most methods are unsafe to
190 call or deliver senseless data, as terminal size and other characteristics
191 have not yet been determined. You can safely query and change resources,
192 though.
193 </dd>
194 <p></p>
195 <dt><strong><a name="item_on_reset__24term">on_reset $term</a></strong><br />
196 </dt>
197 <dd>
198 Called after the screen is ``reset'' for any reason, such as resizing or
199 control sequences. Here is where you can react on changes to size-related
200 variables.
201 </dd>
202 <p></p>
203 <dt><strong><a name="item_on_start__24term">on_start $term</a></strong><br />
204 </dt>
205 <dd>
206 Called at the very end of initialisation of a new terminal, just before
207 returning to the mainloop.
208 </dd>
209 <p></p>
210 <dt><strong><a name="item_on_sel_make__24term_2c__24eventtime">on_sel_make $term, $eventtime</a></strong><br />
211 </dt>
212 <dd>
213 Called whenever a selection has been made by the user, but before the
214 selection text is copied, so changes to the beginning, end or type of the
215 selection will be honored.
216 </dd>
217 <dd>
218 <p>Returning a true value aborts selection making by urxvt, in which case you
219 have to make a selection yourself by calling <a href="#item_selection_grab"><code>$term-&gt;selection_grab</code></a>.</p>
220 </dd>
221 <p></p>
222 <dt><strong><a name="item_on_sel_grab__24term_2c__24eventtime">on_sel_grab $term, $eventtime</a></strong><br />
223 </dt>
224 <dd>
225 Called whenever a selection has been copied, but before the selection is
226 requested from the server. The selection text can be queried and changed
227 by calling <a href="#item_selection"><code>$term-&gt;selection</code></a>.
228 </dd>
229 <dd>
230 <p>Returning a true value aborts selection grabbing. It will still be hilighted.</p>
231 </dd>
232 <p></p>
233 <dt><strong><a name="item_on_sel_extend__24term">on_sel_extend $term</a></strong><br />
234 </dt>
235 <dd>
236 Called whenever the user tries to extend the selection (e.g. with a double
237 click) and is either supposed to return false (normal operation), or
238 should extend the selection itelf and return true to suppress the built-in
239 processing.
240 </dd>
241 <dd>
242 <p>See the <em>selection</em> example extension.</p>
243 </dd>
244 <p></p>
245 <dt><strong><a name="item_on_view_change__24term_2c__24offset">on_view_change $term, $offset</a></strong><br />
246 </dt>
247 <dd>
248 Called whenever the view offset changes, i..e the user or program
249 scrolls. Offset <code>0</code> means display the normal terminal, positive values
250 show this many lines of scrollback.
251 </dd>
252 <p></p>
253 <dt><strong><a name="item_on_scroll_back__24term_2c__24lines_2c__24saved">on_scroll_back $term, $lines, $saved</a></strong><br />
254 </dt>
255 <dd>
256 Called whenever lines scroll out of the terminal area into the scrollback
257 buffer. <code>$lines</code> is the number of lines scrolled out and may be larger
258 than the scroll back buffer or the terminal.
259 </dd>
260 <dd>
261 <p>It is called before lines are scrolled out (so rows 0 .. min ($lines - 1,
262 $nrow - 1) represent the lines to be scrolled out). <code>$saved</code> is the total
263 number of lines that will be in the scrollback buffer.</p>
264 </dd>
265 <p></p>
266 <dt><strong><a name="item_on_tty_activity__24term__2anyi_2a">on_tty_activity $term *NYI*</a></strong><br />
267 </dt>
268 <dd>
269 Called whenever the <code>program(s)</code> running in the urxvt window send output.
270 </dd>
271 <p></p>
272 <dt><strong><a name="item_on_osc_seq__24term_2c__24string">on_osc_seq $term, $string</a></strong><br />
273 </dt>
274 <dd>
275 Called whenever the <strong>ESC ] 777 ; string ST</strong> command sequence (OSC =
276 operating system command) is processed. Cursor position and other state
277 information is up-to-date when this happens. For interoperability, the
278 string should start with the extension name and a colon, to distinguish
279 it from commands for other extensions, and this might be enforced in the
280 future.
281 </dd>
282 <dd>
283 <p>Be careful not ever to trust (in a security sense) the data you receive,
284 as its source can not easily be controleld (e-mail content, messages from
285 other users on the same system etc.).</p>
286 </dd>
287 <p></p>
288 <dt><strong><a name="item_on_add_lines__24term_2c__24string">on_add_lines $term, $string</a></strong><br />
289 </dt>
290 <dd>
291 Called whenever text is about to be output, with the text as argument. You
292 can filter/change and output the text yourself by returning a true value
293 and calling <a href="#item_scr_add_lines"><code>$term-&gt;scr_add_lines</code></a> yourself. Please note that this
294 might be very slow, however, as your hook is called for <strong>all</strong> text being
295 output.
296 </dd>
297 <p></p>
298 <dt><strong><a name="item_on_line_update__24term_2c__24row">on_line_update $term, $row</a></strong><br />
299 </dt>
300 <dd>
301 Called whenever a line was updated or changed. Can be used to filter
302 screen output (e.g. underline urls or other useless stuff). Only lines
303 that are being shown will be filtered, and, due to performance reasons,
304 not always immediately.
305 </dd>
306 <dd>
307 <p>The row number is always the topmost row of the line if the line spans
308 multiple rows.</p>
309 </dd>
310 <dd>
311 <p>Please note that, if you change the line, then the hook might get called
312 later with the already-modified line (e.g. if unrelated parts change), so
313 you cannot just toggle rendition bits, but only set them.</p>
314 </dd>
315 <p></p>
316 <dt><strong><a name="item_on_refresh_begin__24term">on_refresh_begin $term</a></strong><br />
317 </dt>
318 <dd>
319 Called just before the screen gets redrawn. Can be used for overlay
320 or similar effects by modify terminal contents in refresh_begin, and
321 restoring them in refresh_end. The built-in overlay and selection display
322 code is run after this hook, and takes precedence.
323 </dd>
324 <p></p>
325 <dt><strong><a name="item_on_refresh_end__24term">on_refresh_end $term</a></strong><br />
326 </dt>
327 <dd>
328 Called just after the screen gets redrawn. See <code>on_refresh_begin</code>.
329 </dd>
330 <p></p>
331 <dt><strong><a name="item_on_keyboard_command__24term_2c__24string">on_keyboard_command $term, $string</a></strong><br />
332 </dt>
333 <dd>
334 Called whenever the user presses a key combination that has a
335 <code>perl:string</code> action bound to it (see description of the <strong>keysym</strong>
336 resource in the <code>rxvt(1)</code> manpage).
337 </dd>
338 <p></p>
339 <dt><strong><a name="item_on_focus_in__24term">on_focus_in $term</a></strong><br />
340 </dt>
341 <dd>
342 Called whenever the window gets the keyboard focus, before rxvt-unicode
343 does focus in processing.
344 </dd>
345 <p></p>
346 <dt><strong><a name="item_on_focus_out__24term">on_focus_out $term</a></strong><br />
347 </dt>
348 <dd>
349 Called wheneever the window loses keyboard focus, before rxvt-unicode does
350 focus out processing.
351 </dd>
352 <p></p>
353 <dt><strong><a name="item_on_key_press__24term_2c__24event_2c__24octets">on_key_press $term, $event, $octets</a></strong><br />
354 </dt>
355 <dt><strong><a name="item_on_key_release__24term_2c__24event">on_key_release $term, $event</a></strong><br />
356 </dt>
357 <dt><strong><a name="item_on_button_press__24term_2c__24event">on_button_press $term, $event</a></strong><br />
358 </dt>
359 <dt><strong><a name="item_on_button_release__24term_2c__24event">on_button_release $term, $event</a></strong><br />
360 </dt>
361 <dt><strong><a name="item_on_motion_notify__24term_2c__24event">on_motion_notify $term, $event</a></strong><br />
362 </dt>
363 <dt><strong><a name="item_on_map_notify__24term_2c__24event">on_map_notify $term, $event</a></strong><br />
364 </dt>
365 <dt><strong><a name="item_on_unmap_notify__24term_2c__24event">on_unmap_notify $term, $event</a></strong><br />
366 </dt>
367 <dd>
368 Called whenever the corresponding X event is received for the terminal If
369 the hook returns true, then the even will be ignored by rxvt-unicode.
370 </dd>
371 <dd>
372 <p>The event is a hash with most values as named by Xlib (see the XEvent
373 manpage), with the additional members <code>row</code> and <code>col</code>, which are the row
374 and column under the mouse cursor.</p>
375 </dd>
376 <dd>
377 <p><code>on_key_press</code> additionally receives the string rxvt-unicode would
378 output, if any, in locale-specific encoding.</p>
379 </dd>
380 <dd>
381 <p>subwindow.</p>
382 </dd>
383 <p></p></dl>
384 <p>
385 </p>
386 <h2><a name="variables_in_the_urxvt_package">Variables in the <code>urxvt</code> Package</a></h2>
387 <dl>
388 <dt><strong><a name="item__24urxvt_3a_3aterm">$urxvt::TERM</a></strong><br />
389 </dt>
390 <dd>
391 The current terminal. This variable stores the current <code>urxvt::term</code>
392 object, whenever a callback/hook is executing.
393 </dd>
394 <p></p></dl>
395 <p>
396 </p>
397 <h2><a name="functions_in_the_urxvt_package">Functions in the <code>urxvt</code> Package</a></h2>
398 <dl>
399 <dt><strong><a name="item__24term__3d_new_urxvt__5barg_2e_2e_2e_5d">$term = new urxvt [arg...]</a></strong><br />
400 </dt>
401 <dd>
402 Creates a new terminal, very similar as if you had started it with
403 <code>system $binfile, arg...</code>. Croaks (and probably outputs an error message)
404 if the new instance couldn't be created. Returns <code>undef</code> if the new
405 instance didn't initialise perl, and the terminal object otherwise. The
406 <code>init</code> and <a href="#item_start"><code>start</code></a> hooks will be called during the call.
407 </dd>
408 <p></p>
409 <dt><strong><a name="item_urxvt_3a_3afatal__24errormessage">urxvt::fatal $errormessage</a></strong><br />
410 </dt>
411 <dd>
412 Fatally aborts execution with the given error message. Avoid at all
413 costs! The only time this is acceptable is when the terminal process
414 starts up.
415 </dd>
416 <p></p>
417 <dt><strong><a name="item_urxvt_3a_3awarn__24string">urxvt::warn $string</a></strong><br />
418 </dt>
419 <dd>
420 Calls <code>rxvt_warn</code> with the given string which should not include a
421 newline. The module also overwrites the <code>warn</code> builtin with a function
422 that calls this function.
423 </dd>
424 <dd>
425 <p>Using this function has the advantage that its output ends up in the
426 correct place, e.g. on stderr of the connecting urxvtc client.</p>
427 </dd>
428 <p></p>
429 <dt><strong><a name="item__24time__3d_urxvt_3a_3anow">$time = urxvt::NOW</a></strong><br />
430 </dt>
431 <dd>
432 Returns the ``current time'' (as per the event loop).
433 </dd>
434 <p></p>
435 <dt><strong><a name="item_urxvt_3a_3acurrenttime">urxvt::CurrentTime</a></strong><br />
436 </dt>
437 <dt><strong><a name="item_urxvt_3a_3ashiftmask_2c_lockmask_2c_controlmask_2c">urxvt::ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask,
438 Mod3Mask, Mod4Mask, Mod5Mask, Button1Mask, Button2Mask, Button3Mask,
439 Button4Mask, Button5Mask, AnyModifier</a></strong><br />
440 </dt>
441 <dd>
442 Various constants for use in X events.
443 </dd>
444 <p></p></dl>
445 <p>
446 </p>
447 <h2><a name="rendition">RENDITION</a></h2>
448 <p>Rendition bitsets contain information about colour, font, font styles and
449 similar information for each screen cell.</p>
450 <p>The following ``macros'' deal with changes in rendition sets. You should
451 never just create a bitset, you should always modify an existing one,
452 as they contain important information required for correct operation of
453 rxvt-unicode.</p>
454 <dl>
455 <dt><strong><a name="item__24rend__3d_urxvt_3a_3adefault_rstyle">$rend = urxvt::DEFAULT_RSTYLE</a></strong><br />
456 </dt>
457 <dd>
458 Returns the default rendition, as used when the terminal is starting up or
459 being reset. Useful as a base to start when creating renditions.
460 </dd>
461 <p></p>
462 <dt><strong><a name="item__24rend__3d_urxvt_3a_3aoverlay_rstyle">$rend = urxvt::OVERLAY_RSTYLE</a></strong><br />
463 </dt>
464 <dd>
465 Return the rendition mask used for overlays by default.
466 </dd>
467 <p></p>
468 <dt><strong><a name="item__24rendbit__3d_urxvt_3a_3ars_bold_2c_rs_italic_2c_">$rendbit = urxvt::RS_Bold, RS_Italic, RS_Blink, RS_RVid, RS_Uline</a></strong><br />
469 </dt>
470 <dd>
471 Return the bit that enabled bold, italic, blink, reverse-video and
472 underline, respectively. To enable such a style, just logically OR it into
473 the bitset.
474 </dd>
475 <p></p>
476 <dt><strong><a name="item__24foreground__3d_urxvt_3a_3aget_basefg__24rend">$foreground = urxvt::GET_BASEFG $rend</a></strong><br />
477 </dt>
478 <dt><strong><a name="item__24background__3d_urxvt_3a_3aget_basebg__24rend">$background = urxvt::GET_BASEBG $rend</a></strong><br />
479 </dt>
480 <dd>
481 Return the foreground/background colour index, respectively.
482 </dd>
483 <p></p>
484 <dt><strong><a name="item_set_fgcolor">$rend = urxvt::SET_FGCOLOR ($rend, $new_colour)</a></strong><br />
485 </dt>
486 <dt><strong><a name="item_set_bgcolor">$rend = urxvt::SET_BGCOLOR ($rend, $new_colour)</a></strong><br />
487 </dt>
488 <dd>
489 Replace the foreground/background colour in the rendition mask with the
490 specified one.
491 </dd>
492 <p></p>
493 <dt><strong><a name="item_get_custom">$value = urxvt::GET_CUSTOM ($rend)</a></strong><br />
494 </dt>
495 <dd>
496 Return the ``custom'' value: Every rendition has 5 bits for use by
497 extensions. They can be set and changed as you like and are initially
498 zero.
499 </dd>
500 <p></p>
501 <dt><strong><a name="item_set_custom">$rend = urxvt::SET_CUSTOM ($rend, $new_value)</a></strong><br />
502 </dt>
503 <dd>
504 Change the custom value.
505 </dd>
506 <p></p></dl>
507 <p>
508 </p>
509 <h2><a name="the_urxvt__term_class">The <code>urxvt::term</code> Class</a></h2>
510 <dl>
511 <dt><strong><a name="item_destroy">$term-&gt;destroy</a></strong><br />
512 </dt>
513 <dd>
514 Destroy the terminal object (close the window, free resources etc.).
515 </dd>
516 <p></p>
517 <dt><strong><a name="item_option">$isset = $term-&gt;option ($optval[, $set])</a></strong><br />
518 </dt>
519 <dd>
520 Returns true if the option specified by <code>$optval</code> is enabled, and
521 optionally change it. All option values are stored by name in the hash
522 <code>%urxvt::OPTION</code>. Options not enabled in this binary are not in the hash.
523 </dd>
524 <dd>
525 <p>Here is a a likely non-exhaustive list of option names, please see the
526 source file <em>/src/optinc.h</em> to see the actual list:</p>
527 </dd>
528 <dd>
529 <pre>
530 borderLess console cursorBlink cursorUnderline hold iconic insecure
531 intensityStyles jumpScroll loginShell mapAlert meta8 mouseWheelScrollPage
532 pastableTabs pointerBlank reverseVideo scrollBar scrollBar_floating
533 scrollBar_right scrollTtyKeypress scrollTtyOutput scrollWithBuffer
534 secondaryScreen secondaryScroll skipBuiltinGlyphs transparent
535 tripleclickwords utmpInhibit visualBell</pre>
536 </dd>
537 <p></p>
538 <dt><strong><a name="item_resource">$value = $term-&gt;resource ($name[, $newval])</a></strong><br />
539 </dt>
540 <dd>
541 Returns the current resource value associated with a given name and
542 optionally sets a new value. Setting values is most useful in the <code>init</code>
543 hook. Unset resources are returned and accepted as <code>undef</code>.
544 </dd>
545 <dd>
546 <p>The new value must be properly encoded to a suitable character encoding
547 before passing it to this method. Similarly, the returned value may need
548 to be converted from the used encoding to text.</p>
549 </dd>
550 <dd>
551 <p>Resource names are as defined in <em>src/rsinc.h</em>. Colours can be specified
552 as resource names of the form <code>color+&lt;index&gt;</code>, e.g. <code>color+5</code>. (will
553 likely change).</p>
554 </dd>
555 <dd>
556 <p>Please note that resource strings will currently only be freed when the
557 terminal is destroyed, so changing options frequently will eat memory.</p>
558 </dd>
559 <dd>
560 <p>Here is a a likely non-exhaustive list of resource names, not all of which
561 are supported in every build, please see the source file <em>/src/rsinc.h</em>
562 to see the actual list:</p>
563 </dd>
564 <dd>
565 <pre>
566 answerbackstring backgroundPixmap backspace_key boldFont boldItalicFont
567 borderLess color cursorBlink cursorUnderline cutchars delete_key
568 display_name embed ext_bwidth fade font geometry hold iconName
569 imFont imLocale inputMethod insecure int_bwidth intensityStyles
570 italicFont jumpScroll lineSpace loginShell mapAlert menu meta8 modifier
571 mouseWheelScrollPage name pastableTabs path perl_eval perl_ext_1 perl_ext_2
572 perl_lib pointerBlank pointerBlankDelay preeditType print_pipe pty_fd
573 reverseVideo saveLines scrollBar scrollBar_align scrollBar_floating
574 scrollBar_right scrollBar_thickness scrollTtyKeypress scrollTtyOutput
575 scrollWithBuffer scrollstyle secondaryScreen secondaryScroll selectstyle
576 shade term_name title transparent transparent_all tripleclickwords
577 utmpInhibit visualBell</pre>
578 </dd>
579 <p></p>
580 <dt><strong><a name="item_rstyle">$rend = $term-&gt;rstyle ([$new_rstyle])</a></strong><br />
581 </dt>
582 <dd>
583 Return and optionally change the current rendition. Text that is output by
584 the terminal application will use this style.
585 </dd>
586 <p></p>
587 <dt><strong><a name="item_screen_cur">($row, $col) = $term-&gt;screen_cur ([$row, $col])</a></strong><br />
588 </dt>
589 <dd>
590 Return the current coordinates of the text cursor position and optionally
591 set it (which is usually bad as applications don't expect that).
592 </dd>
593 <p></p>
594 <dt><strong><a name="item_selection_mark">($row, $col) = $term-&gt;selection_mark ([$row, $col])</a></strong><br />
595 </dt>
596 <dt><strong><a name="item_selection_beg">($row, $col) = $term-&gt;selection_beg ([$row, $col])</a></strong><br />
597 </dt>
598 <dt><strong><a name="item_selection_end">($row, $col) = $term-&gt;selection_end ([$row, $col])</a></strong><br />
599 </dt>
600 <dd>
601 Return the current values of the selection mark, begin or end positions,
602 and optionally set them to new values.
603 </dd>
604 <p></p>
605 <dt><strong><a name="item_selection_grab">$success = $term-&gt;selection_grab ($eventtime)</a></strong><br />
606 </dt>
607 <dd>
608 Try to request the primary selection from the server (for example, as set
609 by the next method).
610 </dd>
611 <p></p>
612 <dt><strong>$oldtext = $term-&gt;selection ([$newtext])</strong><br />
613 </dt>
614 <dd>
615 Return the current selection text and optionally replace it by <code>$newtext</code>.
616 </dd>
617 <dd>
618 <p>#=item $term-&gt;overlay ($x, $y, $text)
619 #
620 #Create a simple multi-line overlay box. See the next method for details.
621 #
622 #=cut
623 #
624 #sub urxvt::term::scr_overlay {
625 # my ($self, $x, $y, $text) = @_;
626 #
627 # my @lines = split /\n/, $text;
628 #
629 # my $w = 0;
630 # for (map $self-&gt;strwidth ($_), @lines) {
631 # $w = $_ if $w &lt; $_;
632 # }
633 #
634 # $self-&gt;scr_overlay_new ($x, $y, $w, scalar @lines);
635 # $self-&gt;scr_overlay_set (0, $_, $lines[$_]) for 0.. $#lines;
636 #}</p>
637 </dd>
638 <p></p>
639 <dt><strong><a name="item_overlay">$term-&gt;overlay ($x, $y, $width, $height[, $rstyle[, $border]])</a></strong><br />
640 </dt>
641 <dd>
642 Create a new (empty) overlay at the given position with the given
643 width/height. <code>$rstyle</code> defines the initial rendition style
644 (default: <code>OVERLAY_RSTYLE</code>).
645 </dd>
646 <dd>
647 <p>If <code>$border</code> is <code>2</code> (default), then a decorative border will be put
648 around the box.</p>
649 </dd>
650 <dd>
651 <p>If either <code>$x</code> or <code>$y</code> is negative, then this is counted from the
652 right/bottom side, respectively.</p>
653 </dd>
654 <dd>
655 <p>This method returns an urxvt::overlay object. The overlay will be visible
656 as long as the perl object is referenced.</p>
657 </dd>
658 <dd>
659 <p>The methods currently supported on <code>urxvt::overlay</code> objects are:</p>
660 </dd>
661 <dl>
662 <dt><strong><a name="item_set">$overlay-&gt;set ($x, $y, $text, $rend)</a></strong><br />
663 </dt>
664 <dd>
665 Similar to <a href="#item_row_t"><code>$term-&gt;ROW_t</code></a> and <a href="#item_row_r"><code>$term-&gt;ROW_r</code></a> in that it puts
666 text in rxvt-unicode's special encoding and an array of rendition values
667 at a specific position inside the overlay.
668 </dd>
669 <p></p>
670 <dt><strong><a name="item_hide">$overlay-&gt;hide</a></strong><br />
671 </dt>
672 <dd>
673 If visible, hide the overlay, but do not destroy it.
674 </dd>
675 <p></p>
676 <dt><strong><a name="item_show">$overlay-&gt;show</a></strong><br />
677 </dt>
678 <dd>
679 If hidden, display the overlay again.
680 </dd>
681 <p></p></dl>
682 <dt><strong><a name="item_popup">$popup = $term-&gt;popup ($event)</a></strong><br />
683 </dt>
684 <dd>
685 Creates a new <code>urxvt::popup</code> object that implements a popup menu. The
686 <code>$event</code> <em>must</em> be the event causing the menu to pop up (a button event,
687 currently).
688 </dd>
689 <p></p>
690 <dt><strong><a name="item_strwidth">$cellwidth = $term-&gt;strwidth ($string)</a></strong><br />
691 </dt>
692 <dd>
693 Returns the number of screen-cells this string would need. Correctly
694 accounts for wide and combining characters.
695 </dd>
696 <p></p>
697 <dt><strong><a name="item_locale_encode">$octets = $term-&gt;locale_encode ($string)</a></strong><br />
698 </dt>
699 <dd>
700 Convert the given text string into the corresponding locale encoding.
701 </dd>
702 <p></p>
703 <dt><strong><a name="item_locale_decode">$string = $term-&gt;locale_decode ($octets)</a></strong><br />
704 </dt>
705 <dd>
706 Convert the given locale-encoded octets into a perl string.
707 </dd>
708 <p></p>
709 <dt><strong><a name="item_scr_add_lines">$term-&gt;scr_add_lines ($string)</a></strong><br />
710 </dt>
711 <dd>
712 Write the given text string to the screen, as if output by the application
713 running inside the terminal. It may not contain command sequences (escape
714 codes), but is free to use line feeds, carriage returns and tabs. The
715 string is a normal text string, not in locale-dependent encoding.
716 </dd>
717 <dd>
718 <p>Normally its not a good idea to use this function, as programs might be
719 confused by changes in cursor position or scrolling. Its useful inside a
720 <code>on_add_lines</code> hook, though.</p>
721 </dd>
722 <p></p>
723 <dt><strong><a name="item_cmd_parse">$term-&gt;cmd_parse ($octets)</a></strong><br />
724 </dt>
725 <dd>
726 Similar to <a href="#item_scr_add_lines"><code>scr_add_lines</code></a>, but the argument must be in the
727 locale-specific encoding of the terminal and can contain command sequences
728 (escape codes) that will be interpreted.
729 </dd>
730 <p></p>
731 <dt><strong><a name="item_tt_write">$term-&gt;tt_write ($octets)</a></strong><br />
732 </dt>
733 <dd>
734 Write the octets given in <code>$data</code> to the tty (i.e. as program input). To
735 pass characters instead of octets, you should convert your strings first
736 to the locale-specific encoding using <a href="#item_locale_encode"><code>$term-&gt;locale_encode</code></a>.
737 </dd>
738 <p></p>
739 <dt><strong><a name="item_parent">$windowid = $term-&gt;parent</a></strong><br />
740 </dt>
741 <dd>
742 Return the window id of the toplevel window.
743 </dd>
744 <p></p>
745 <dt><strong><a name="item_vt">$windowid = $term-&gt;vt</a></strong><br />
746 </dt>
747 <dd>
748 Return the window id of the terminal window.
749 </dd>
750 <p></p>
751 <dt><strong><a name="item_width">$window_width = $term-&gt;width</a></strong><br />
752 </dt>
753 <dt><strong><a name="item_height">$window_height = $term-&gt;height</a></strong><br />
754 </dt>
755 <dt><strong><a name="item_fwidth">$font_width = $term-&gt;fwidth</a></strong><br />
756 </dt>
757 <dt><strong><a name="item_fheight">$font_height = $term-&gt;fheight</a></strong><br />
758 </dt>
759 <dt><strong><a name="item_fbase">$font_ascent = $term-&gt;fbase</a></strong><br />
760 </dt>
761 <dt><strong><a name="item_nrow">$terminal_rows = $term-&gt;nrow</a></strong><br />
762 </dt>
763 <dt><strong><a name="item_ncol">$terminal_columns = $term-&gt;ncol</a></strong><br />
764 </dt>
765 <dt><strong><a name="item_focus">$has_focus = $term-&gt;focus</a></strong><br />
766 </dt>
767 <dt><strong><a name="item_mapped">$is_mapped = $term-&gt;mapped</a></strong><br />
768 </dt>
769 <dt><strong><a name="item_savelines">$max_scrollback = $term-&gt;saveLines</a></strong><br />
770 </dt>
771 <dt><strong><a name="item_total_rows">$nrow_plus_saveLines = $term-&gt;total_rows</a></strong><br />
772 </dt>
773 <dt><strong><a name="item_nsaved">$lines_in_scrollback = $term-&gt;nsaved</a></strong><br />
774 </dt>
775 <dd>
776 Return various integers describing terminal characteristics.
777 </dd>
778 <p></p>
779 <dt><strong><a name="item_modlevel3mask">$modifiermask = $term-&gt;ModLevel3Mask</a></strong><br />
780 </dt>
781 <dt><strong><a name="item_modmetamask">$modifiermask = $term-&gt;ModMetaMask</a></strong><br />
782 </dt>
783 <dt><strong><a name="item_modnumlockmask">$modifiermask = $term-&gt;ModNumLockMask</a></strong><br />
784 </dt>
785 <dd>
786 Return the modifier masks corresponding to the ``ISO Level 3 Shift'' (often
787 AltGr), the meta key (often Alt) and the num lock key, if applicable.
788 </dd>
789 <p></p>
790 <dt><strong><a name="item_view_start">$view_start = $term-&gt;view_start ([$newvalue])</a></strong><br />
791 </dt>
792 <dd>
793 Returns the negative row number of the topmost line. Minimum value is
794 <code>0</code>, which displays the normal terminal contents. Larger values scroll
795 this many lines into the scrollback buffer.
796 </dd>
797 <p></p>
798 <dt><strong><a name="item_want_refresh">$term-&gt;want_refresh</a></strong><br />
799 </dt>
800 <dd>
801 Requests a screen refresh. At the next opportunity, rxvt-unicode will
802 compare the on-screen display with its stored representation. If they
803 differ, it redraws the differences.
804 </dd>
805 <dd>
806 <p>Used after changing terminal contents to display them.</p>
807 </dd>
808 <p></p>
809 <dt><strong><a name="item_row_t">$text = $term-&gt;ROW_t ($row_number[, $new_text[, $start_col]])</a></strong><br />
810 </dt>
811 <dd>
812 Returns the text of the entire row with number <code>$row_number</code>. Row <code>0</code>
813 is the topmost terminal line, row <code>$term-&gt;$ncol-1</code> is the bottommost
814 terminal line. The scrollback buffer starts at line <code>-1</code> and extends to
815 line <a href="#item_nsaved"><code>-$term-&gt;nsaved</code></a>. Nothing will be returned if a nonexistent line
816 is requested.
817 </dd>
818 <dd>
819 <p>If <code>$new_text</code> is specified, it will replace characters in the current
820 line, starting at column <code>$start_col</code> (default <code>0</code>), which is useful
821 to replace only parts of a line. The font index in the rendition will
822 automatically be updated.</p>
823 </dd>
824 <dd>
825 <p><a href="#item__24text"><code>$text</code></a> is in a special encoding: tabs and wide characters that use more
826 than one cell when displayed are padded with urxvt::NOCHAR characters
827 (<code>chr 65535</code>). Characters with combining characters and other characters
828 that do not fit into the normal tetx encoding will be replaced with
829 characters in the private use area.</p>
830 </dd>
831 <dd>
832 <p>You have to obey this encoding when changing text. The advantage is
833 that <code>substr</code> and similar functions work on screen cells and not on
834 characters.</p>
835 </dd>
836 <dd>
837 <p>The methods <code>$term-&gt;special_encode</code> and <a href="#item_special_decode"><code>$term-&gt;special_decode</code></a>
838 can be used to convert normal strings into this encoding and vice versa.</p>
839 </dd>
840 <p></p>
841 <dt><strong><a name="item_row_r">$rend = $term-&gt;ROW_r ($row_number[, $new_rend[, $start_col]])</a></strong><br />
842 </dt>
843 <dd>
844 Like <a href="#item_row_t"><code>$term-&gt;ROW_t</code></a>, but returns an arrayref with rendition
845 bitsets. Rendition bitsets contain information about colour, font, font
846 styles and similar information. See also <a href="#item_row_t"><code>$term-&gt;ROW_t</code></a>.
847 </dd>
848 <dd>
849 <p>When setting rendition, the font mask will be ignored.</p>
850 </dd>
851 <dd>
852 <p>See the section on RENDITION, above.</p>
853 </dd>
854 <p></p>
855 <dt><strong><a name="item_row_l">$length = $term-&gt;ROW_l ($row_number[, $new_length])</a></strong><br />
856 </dt>
857 <dd>
858 Returns the number of screen cells that are in use (``the line
859 length''). Unlike the urxvt core, this returns <a href="#item_ncol"><code>$term-&gt;ncol</code></a> if the
860 line is joined with the following one.
861 </dd>
862 <p></p>
863 <dt><strong><a name="item_is_longer">$bool = $term-&gt;is_longer ($row_number)</a></strong><br />
864 </dt>
865 <dd>
866 Returns true if the row is part of a multiple-row logical ``line'' (i.e.
867 joined with the following row), which means all characters are in use
868 and it is continued on the next row (and possibly a continuation of the
869 previous row(s)).
870 </dd>
871 <p></p>
872 <dt><strong><a name="item_line">$line = $term-&gt;line ($row_number)</a></strong><br />
873 </dt>
874 <dd>
875 Create and return a new <code>urxvt::line</code> object that stores information
876 about the logical line that row <code>$row_number</code> is part of. It supports the
877 following methods:
878 </dd>
879 <dl>
880 <dt><strong><a name="item_t">$text = $line-&gt;t ([$new_text])</a></strong><br />
881 </dt>
882 <dd>
883 Returns or replaces the full text of the line, similar to <a href="#item_row_t"><code>ROW_t</code></a>
884 </dd>
885 <p></p>
886 <dt><strong><a name="item_r">$rend = $line-&gt;r ([$new_rend])</a></strong><br />
887 </dt>
888 <dd>
889 Returns or replaces the full rendition array of the line, similar to <a href="#item_row_r"><code>ROW_r</code></a>
890 </dd>
891 <p></p>
892 <dt><strong><a name="item_l">$length = $line-&gt;l</a></strong><br />
893 </dt>
894 <dd>
895 Returns the length of the line in cells, similar to <a href="#item_row_l"><code>ROW_l</code></a>.
896 </dd>
897 <p></p>
898 <dt><strong><a name="item_beg">$rownum = $line-&gt;beg</a></strong><br />
899 </dt>
900 <dt><strong><a name="item_end">$rownum = $line-&gt;end</a></strong><br />
901 </dt>
902 <dd>
903 Return the row number of the first/last row of the line, respectively.
904 </dd>
905 <p></p>
906 <dt><strong><a name="item_offset_of">$offset = $line-&gt;offset_of ($row, $col)</a></strong><br />
907 </dt>
908 <dd>
909 Returns the character offset of the given row|col pair within the logical
910 line.
911 </dd>
912 <p></p>
913 <dt><strong><a name="item_coord_of">($row, $col) = $line-&gt;coord_of ($offset)</a></strong><br />
914 </dt>
915 <dd>
916 Translates a string offset into terminal coordinates again.
917 </dd>
918 <p></p></dl>
919 <dt><strong>($row, $col) = $line-&gt;coord_of ($offset)
920 =item $text = $term-&gt;special_encode $string</strong><br />
921 </dt>
922 <dd>
923 Converts a perl string into the special encoding used by rxvt-unicode,
924 where one character corresponds to one screen cell. See
925 <a href="#item_row_t"><code>$term-&gt;ROW_t</code></a> for details.
926 </dd>
927 <p></p>
928 <dt><strong><a name="item_special_decode">$string = $term-&gt;special_decode $text</a></strong><br />
929 </dt>
930 <dd>
931 Converts rxvt-unicodes text reprsentation into a perl string. See
932 <a href="#item_row_t"><code>$term-&gt;ROW_t</code></a> for details.
933 </dd>
934 <p></p></dl>
935 <p>
936 </p>
937 <h2><a name="the_urxvt__popup_class">The <code>urxvt::popup</code> Class</a></h2>
938 <p>
939 </p>
940 <h2><a name="the_urxvt__timer_class">The <code>urxvt::timer</code> Class</a></h2>
941 <p>This class implements timer watchers/events. Time is represented as a
942 fractional number of seconds since the epoch. Example:</p>
943 <pre>
944 $term-&gt;{overlay} = $term-&gt;overlay (-1, 0, 8, 1, urxvt::OVERLAY_RSTYLE, 0);
945 $term-&gt;{timer} = urxvt::timer
946 -&gt;new
947 -&gt;interval (1)
948 -&gt;cb (sub {
949 $term-&gt;{overlay}-&gt;set (0, 0,
950 sprintf &quot;%2d:%02d:%02d&quot;, (localtime urxvt::NOW)[2,1,0]);
951 });</pre>
952 <dl>
953 <dt><strong><a name="item__24timer__3d_new_urxvt_3a_3atimer">$timer = new urxvt::timer</a></strong><br />
954 </dt>
955 <dd>
956 Create a new timer object in started state. It is scheduled to fire
957 immediately.
958 </dd>
959 <p></p>
960 <dt><strong><a name="item_cb">$timer = $timer-&gt;cb (sub { my ($timer) = @_; ... })</a></strong><br />
961 </dt>
962 <dd>
963 Set the callback to be called when the timer triggers.
964 </dd>
965 <p></p>
966 <dt><strong><a name="item_at">$tstamp = $timer-&gt;at</a></strong><br />
967 </dt>
968 <dd>
969 Return the time this watcher will fire next.
970 </dd>
971 <p></p>
972 <dt><strong>$timer = $timer-&gt;set ($tstamp)</strong><br />
973 </dt>
974 <dd>
975 Set the time the event is generated to $tstamp.
976 </dd>
977 <p></p>
978 <dt><strong><a name="item_interval">$timer = $timer-&gt;interval ($interval)</a></strong><br />
979 </dt>
980 <dd>
981 Normally (and when <code>$interval</code> is <code>0</code>), the timer will automatically
982 stop after it has fired once. If <code>$interval</code> is non-zero, then the timer
983 is automatically rescheduled at the given intervals.
984 </dd>
985 <p></p>
986 <dt><strong><a name="item_start">$timer = $timer-&gt;start</a></strong><br />
987 </dt>
988 <dd>
989 Start the timer.
990 </dd>
991 <p></p>
992 <dt><strong>$timer = $timer-&gt;start ($tstamp)</strong><br />
993 </dt>
994 <dd>
995 Set the event trigger time to <code>$tstamp</code> and start the timer.
996 </dd>
997 <p></p>
998 <dt><strong><a name="item_stop">$timer = $timer-&gt;stop</a></strong><br />
999 </dt>
1000 <dd>
1001 Stop the timer.
1002 </dd>
1003 <p></p></dl>
1004 <p>
1005 </p>
1006 <h2><a name="the_urxvt__iow_class">The <code>urxvt::iow</code> Class</a></h2>
1007 <p>This class implements io watchers/events. Example:</p>
1008 <pre>
1009 $term-&gt;{socket} = ...
1010 $term-&gt;{iow} = urxvt::iow
1011 -&gt;new
1012 -&gt;fd (fileno $term-&gt;{socket})
1013 -&gt;events (1) # wait for read data
1014 -&gt;start
1015 -&gt;cb (sub {
1016 my ($iow, $revents) = @_;
1017 # $revents must be 1 here, no need to check
1018 sysread $term-&gt;{socket}, my $buf, 8192
1019 or end-of-file;
1020 });</pre>
1021 <dl>
1022 <dt><strong><a name="item__24iow__3d_new_urxvt_3a_3aiow">$iow = new urxvt::iow</a></strong><br />
1023 </dt>
1024 <dd>
1025 Create a new io watcher object in stopped state.
1026 </dd>
1027 <p></p>
1028 <dt><strong>$iow = $iow-&gt;cb (sub { my ($iow, $reventmask) = @_; ... })</strong><br />
1029 </dt>
1030 <dd>
1031 Set the callback to be called when io events are triggered. <code>$reventmask</code>
1032 is a bitset as described in the <a href="#item_events"><code>events</code></a> method.
1033 </dd>
1034 <p></p>
1035 <dt><strong><a name="item_fd">$iow = $iow-&gt;fd ($fd)</a></strong><br />
1036 </dt>
1037 <dd>
1038 Set the filedescriptor (not handle) to watch.
1039 </dd>
1040 <p></p>
1041 <dt><strong><a name="item_events">$iow = $iow-&gt;events ($eventmask)</a></strong><br />
1042 </dt>
1043 <dd>
1044 Set the event mask to watch. Bit #0 (value <code>1</code>) enables watching for read
1045 data, Bit #1 (value <code>2</code>) enables watching for write data.
1046 </dd>
1047 <p></p>
1048 <dt><strong>$iow = $iow-&gt;start</strong><br />
1049 </dt>
1050 <dd>
1051 Start watching for requested events on the given handle.
1052 </dd>
1053 <p></p>
1054 <dt><strong>$iow = $iow-&gt;stop</strong><br />
1055 </dt>
1056 <dd>
1057 Stop watching for events on the given filehandle.
1058 </dd>
1059 <p></p></dl>
1060 <p>
1061 </p>
1062 <hr />
1063 <h1><a name="environment">ENVIRONMENT</a></h1>
1064 <p>
1065 </p>
1066 <h2><a name="urxvt_perl_verbosity">URXVT_PERL_VERBOSITY</a></h2>
1067 <p>This variable controls the verbosity level of the perl extension. Higher
1068 numbers indicate more verbose output.</p>
1069 <dl>
1070 <dt><strong><a name="item__3d0__2d_only_fatal_messages">=0 - only fatal messages</a></strong><br />
1071 </dt>
1072 <dt><strong><a name="item__3d3__2d_script_loading_and_management">=3 - script loading and management</a></strong><br />
1073 </dt>
1074 <dt><strong><a name="item__3d10__2d_all_events_received">=10 - all events received</a></strong><br />
1075 </dt>
1076 </dl>
1077 <p>
1078 </p>
1079 <hr />
1080 <h1><a name="author">AUTHOR</a></h1>
1081 <pre>
1082 Marc Lehmann &lt;pcg@goof.com&gt;
1083 <a href="http://software.schmorp.de/pkg/rxvt-unicode">http://software.schmorp.de/pkg/rxvt-unicode</a></pre>
1084
1085 </body>
1086
1087 </html>