… | |
… | |
60 | |
60 | |
61 | =item digital-clock |
61 | =item digital-clock |
62 | |
62 | |
63 | Displays a digital clock using the built-in overlay. |
63 | Displays a digital clock using the built-in overlay. |
64 | |
64 | |
|
|
65 | =item mark-urls |
|
|
66 | |
|
|
67 | Uses per-line display filtering (C<on_line_update>) to underline urls. |
|
|
68 | |
|
|
69 | =item block-graphics-to-ascii |
|
|
70 | |
|
|
71 | A not very useful example of filtering all text output to the terminal, |
|
|
72 | by replacing all line-drawing characters (U+2500 .. U+259F) by a |
|
|
73 | similar-looking ascii character. |
|
|
74 | |
65 | =item example-refresh-hooks |
75 | =item example-refresh-hooks |
66 | |
76 | |
67 | Displays a very simple digital clock in the upper right corner of the |
77 | Displays a very simple digital clock in the upper right corner of the |
68 | window. Illustrates overwriting the refresh callbacks to create your own |
78 | window. Illustrates overwriting the refresh callbacks to create your own |
69 | overlays or changes. |
79 | overlays or changes. |
70 | |
|
|
71 | =item mark-urls |
|
|
72 | |
|
|
73 | A not very useful example of filtering all text output to the terminal, by |
|
|
74 | underlining all urls that matches a certain regex (i.e. some urls :). It |
|
|
75 | is not very useful because urls that are output in multiple steps (e.g. |
|
|
76 | when typing them) do not get marked. |
|
|
77 | |
80 | |
78 | =back |
81 | =back |
79 | |
82 | |
80 | =head2 General API Considerations |
83 | =head2 General API Considerations |
81 | |
84 | |
… | |
… | |
113 | |
116 | |
114 | =back |
117 | =back |
115 | |
118 | |
116 | =head2 Hooks |
119 | =head2 Hooks |
117 | |
120 | |
118 | The following subroutines can be declared in loaded scripts, and will be |
121 | The following subroutines can be declared in extension files, and will be |
119 | called whenever the relevant event happens. |
122 | called whenever the relevant event happens. |
120 | |
123 | |
121 | The first argument passed to them is an object private to each terminal |
124 | The first argument passed to them is an object private to each terminal |
122 | and extension package. You can call all C<urxvt::term> methods on it, but |
125 | and extension package. You can call all C<urxvt::term> methods on it, but |
123 | its not a real C<urxvt::term> object. Instead, the real C<urxvt::term> |
126 | its not a real C<urxvt::term> object. Instead, the real C<urxvt::term> |
… | |
… | |
133 | =over 4 |
136 | =over 4 |
134 | |
137 | |
135 | =item on_init $term |
138 | =item on_init $term |
136 | |
139 | |
137 | Called after a new terminal object has been initialized, but before |
140 | Called after a new terminal object has been initialized, but before |
138 | windows are created or the command gets run. |
141 | windows are created or the command gets run. Most methods are unsafe to |
|
|
142 | call or deliver senseless data, as terminal size and other characteristics |
|
|
143 | have not yet been determined. You can safely query and change resources, |
|
|
144 | though. |
139 | |
145 | |
140 | =item on_reset $term |
146 | =item on_reset $term |
141 | |
147 | |
142 | Called after the screen is "reset" for any reason, such as resizing or |
148 | Called after the screen is "reset" for any reason, such as resizing or |
143 | control sequences. Here is where you can react on changes to size-related |
149 | control sequences. Here is where you can react on changes to size-related |
… | |
… | |
223 | can filter/change and output the text yourself by returning a true value |
229 | can filter/change and output the text yourself by returning a true value |
224 | and calling C<< $term->scr_add_lines >> yourself. Please note that this |
230 | and calling C<< $term->scr_add_lines >> yourself. Please note that this |
225 | might be very slow, however, as your hook is called for B<all> text being |
231 | might be very slow, however, as your hook is called for B<all> text being |
226 | output. |
232 | output. |
227 | |
233 | |
|
|
234 | =item on_line_update $term, $row |
|
|
235 | |
|
|
236 | Called whenever a line was updated or changed. Can be used to filter |
|
|
237 | screen output (e.g. underline urls or other useless stuff). Only lines |
|
|
238 | that are being shown will be filtered, and, due to performance reasons, |
|
|
239 | not always immediately. |
|
|
240 | |
|
|
241 | The row number is always the topmost row of the line if the line spans |
|
|
242 | multiple rows. |
|
|
243 | |
|
|
244 | Please note that, if you change the line, then the hook might get called |
|
|
245 | later with the already-modified line (e.g. if unrelated parts change), so |
|
|
246 | you cannot just toggle rendition bits, but only set them. |
|
|
247 | |
228 | =item on_refresh_begin $term |
248 | =item on_refresh_begin $term |
229 | |
249 | |
230 | Called just before the screen gets redrawn. Can be used for overlay |
250 | Called just before the screen gets redrawn. Can be used for overlay |
231 | or similar effects by modify terminal contents in refresh_begin, and |
251 | or similar effects by modify terminal contents in refresh_begin, and |
232 | restoring them in refresh_end. The built-in overlay and selection display |
252 | restoring them in refresh_end. The built-in overlay and selection display |
… | |
… | |
240 | |
260 | |
241 | Called whenever the user presses a key combination that has a |
261 | Called whenever the user presses a key combination that has a |
242 | C<perl:string> action bound to it (see description of the B<keysym> |
262 | C<perl:string> action bound to it (see description of the B<keysym> |
243 | resource in the @@RXVT_NAME@@(1) manpage). |
263 | resource in the @@RXVT_NAME@@(1) manpage). |
244 | |
264 | |
|
|
265 | =item on_key_press $term, $event, $octets |
|
|
266 | |
|
|
267 | =item on_key_release $term, $event |
|
|
268 | |
|
|
269 | =item on_button_press $term, $event |
|
|
270 | |
|
|
271 | =item on_button_release $term, $event |
|
|
272 | |
|
|
273 | =item on_motion_notify $term, $event |
|
|
274 | |
|
|
275 | Called whenever the corresponding X event is received for the terminal If |
|
|
276 | the hook returns true, then the even will be ignored by rxvt-unicode. |
|
|
277 | |
|
|
278 | The event is a hash with most values as named by Xlib (see the XEvent |
|
|
279 | manpage), with the additional members C<row> and C<col>, which are the row |
|
|
280 | and column under the mouse cursor. |
|
|
281 | |
|
|
282 | C<on_key_press> additionally receives the string rxvt-unicode would |
|
|
283 | output, if any, in locale-specific encoding. |
|
|
284 | |
|
|
285 | subwindow. |
|
|
286 | |
245 | =back |
287 | =back |
246 | |
288 | |
247 | =head2 Variables in the C<urxvt> Package |
289 | =head2 Variables in the C<urxvt> Package |
248 | |
290 | |
249 | =over 4 |
291 | =over 4 |
250 | |
292 | |
251 | =item $urxvt::TERM |
293 | =item $urxvt::TERM |
252 | |
294 | |
253 | The current terminal. Whenever a callback/Hook is bein executed, this |
295 | The current terminal. This variable stores the current C<urxvt::term> |
254 | variable stores the current C<urxvt::term> object. |
296 | object, whenever a callback/hook is executing. |
255 | |
297 | |
256 | =back |
298 | =back |
257 | |
299 | |
258 | =head2 Functions in the C<urxvt> Package |
300 | =head2 Functions in the C<urxvt> Package |
259 | |
301 | |
260 | =over 4 |
302 | =over 4 |
|
|
303 | |
|
|
304 | =item $term = new urxvt [arg...] |
|
|
305 | |
|
|
306 | Creates a new terminal, very similar as if you had started it with |
|
|
307 | C<system $binfile, arg...>. Croaks (and probably outputs an error message) |
|
|
308 | if the new instance couldn't be created. Returns C<undef> if the new |
|
|
309 | instance didn't initialise perl, and the terminal object otherwise. The |
|
|
310 | C<init> and C<start> hooks will be called during the call. |
261 | |
311 | |
262 | =item urxvt::fatal $errormessage |
312 | =item urxvt::fatal $errormessage |
263 | |
313 | |
264 | Fatally aborts execution with the given error message. Avoid at all |
314 | Fatally aborts execution with the given error message. Avoid at all |
265 | costs! The only time this is acceptable is when the terminal process |
315 | costs! The only time this is acceptable is when the terminal process |
… | |
… | |
414 | my $htype = shift; |
464 | my $htype = shift; |
415 | |
465 | |
416 | if ($htype == 0) { # INIT |
466 | if ($htype == 0) { # INIT |
417 | my @dirs = ((split /:/, $TERM->resource ("perl_lib")), "$LIBDIR/perl"); |
467 | my @dirs = ((split /:/, $TERM->resource ("perl_lib")), "$LIBDIR/perl"); |
418 | |
468 | |
419 | for my $ext (map { split /:/, $TERM->resource ("perl_ext_$_") } 1, 2) { |
469 | for my $ext (map { split /,/, $TERM->resource ("perl_ext_$_") } 1, 2) { |
420 | my @files = grep -f $_, map "$_/$ext", @dirs; |
470 | my @files = grep -f $_, map "$_/$ext", @dirs; |
421 | |
471 | |
422 | if (@files) { |
472 | if (@files) { |
423 | register_package script_package $files[0]; |
473 | register_package script_package $files[0]; |
424 | } else { |
474 | } else { |
… | |
… | |
482 | } |
532 | } |
483 | |
533 | |
484 | =head2 The C<urxvt::term> Class |
534 | =head2 The C<urxvt::term> Class |
485 | |
535 | |
486 | =over 4 |
536 | =over 4 |
|
|
537 | |
|
|
538 | =item $term->destroy |
|
|
539 | |
|
|
540 | Destroy the terminal object (close the window, free resources etc.). |
487 | |
541 | |
488 | =item $value = $term->resource ($name[, $newval]) |
542 | =item $value = $term->resource ($name[, $newval]) |
489 | |
543 | |
490 | Returns the current resource value associated with a given name and |
544 | Returns the current resource value associated with a given name and |
491 | optionally sets a new value. Setting values is most useful in the C<init> |
545 | optionally sets a new value. Setting values is most useful in the C<init> |
… | |
… | |
608 | |
662 | |
609 | If hidden, display the overlay again. |
663 | If hidden, display the overlay again. |
610 | |
664 | |
611 | =back |
665 | =back |
612 | |
666 | |
613 | =item $cellwidth = $term->strwidth $string |
667 | =item $cellwidth = $term->strwidth ($string) |
614 | |
668 | |
615 | Returns the number of screen-cells this string would need. Correctly |
669 | Returns the number of screen-cells this string would need. Correctly |
616 | accounts for wide and combining characters. |
670 | accounts for wide and combining characters. |
617 | |
671 | |
618 | =item $octets = $term->locale_encode $string |
672 | =item $octets = $term->locale_encode ($string) |
619 | |
673 | |
620 | Convert the given text string into the corresponding locale encoding. |
674 | Convert the given text string into the corresponding locale encoding. |
621 | |
675 | |
622 | =item $string = $term->locale_decode $octets |
676 | =item $string = $term->locale_decode ($octets) |
623 | |
677 | |
624 | Convert the given locale-encoded octets into a perl string. |
678 | Convert the given locale-encoded octets into a perl string. |
625 | |
679 | |
626 | =item $term->scr_add_lines ($string) |
680 | =item $term->scr_add_lines ($string) |
627 | |
681 | |
… | |
… | |
632 | |
686 | |
633 | Normally its not a good idea to use this function, as programs might be |
687 | Normally its not a good idea to use this function, as programs might be |
634 | confused by changes in cursor position or scrolling. Its useful inside a |
688 | confused by changes in cursor position or scrolling. Its useful inside a |
635 | C<on_add_lines> hook, though. |
689 | C<on_add_lines> hook, though. |
636 | |
690 | |
|
|
691 | =item $term->cmd_parse ($octets) |
|
|
692 | |
|
|
693 | Similar to C<scr_add_lines>, but the argument must be in the |
|
|
694 | locale-specific encoding of the terminal and can contain command sequences |
|
|
695 | (escape codes) that will be interpreted. |
|
|
696 | |
637 | =item $term->tt_write ($octets) |
697 | =item $term->tt_write ($octets) |
638 | |
698 | |
639 | Write the octets given in C<$data> to the tty (i.e. as program input). To |
699 | Write the octets given in C<$data> to the tty (i.e. as program input). To |
640 | pass characters instead of octets, you should convert your strings first |
700 | pass characters instead of octets, you should convert your strings first |
641 | to the locale-specific encoding using C<< $term->locale_encode >>. |
701 | to the locale-specific encoding using C<< $term->locale_encode >>. |
|
|
702 | |
|
|
703 | =item $windowid = $term->parent |
|
|
704 | |
|
|
705 | Return the window id of the toplevel window. |
|
|
706 | |
|
|
707 | =item $windowid = $term->vt |
|
|
708 | |
|
|
709 | Return the window id of the terminal window. |
642 | |
710 | |
643 | =item $window_width = $term->width |
711 | =item $window_width = $term->width |
644 | |
712 | |
645 | =item $window_height = $term->height |
713 | =item $window_height = $term->height |
646 | |
714 | |
… | |
… | |
735 | about the logical line that row C<$row_number> is part of. It supports the |
803 | about the logical line that row C<$row_number> is part of. It supports the |
736 | following methods: |
804 | following methods: |
737 | |
805 | |
738 | =over 4 |
806 | =over 4 |
739 | |
807 | |
740 | =item $text = $line->t |
808 | =item $text = $line->t ([$new_text]) |
741 | |
809 | |
742 | Returns the full text of the line, similar to C<ROW_t> |
810 | Returns or replaces the full text of the line, similar to C<ROW_t> |
743 | |
811 | |
744 | =item $rend = $line->r |
812 | =item $rend = $line->r ([$new_rend]) |
745 | |
813 | |
746 | Returns the full rendition array of the line, similar to C<ROW_r> |
814 | Returns or replaces the full rendition array of the line, similar to C<ROW_r> |
747 | |
815 | |
748 | =item $length = $line->l |
816 | =item $length = $line->l |
749 | |
817 | |
750 | Returns the length of the line in cells, similar to C<ROW_l>. |
818 | Returns the length of the line in cells, similar to C<ROW_l>. |
751 | |
819 | |