… | |
… | |
53 | |
53 | |
54 | =back |
54 | =back |
55 | |
55 | |
56 | =item digital-clock |
56 | =item digital-clock |
57 | |
57 | |
|
|
58 | Displays a digital clock using the built-in overlay. |
|
|
59 | |
|
|
60 | =item example-refresh-hooks |
|
|
61 | |
58 | Displays a very simple digital clock in the upper right corner of the |
62 | Displays a very simple digital clock in the upper right corner of the |
59 | window. Illustrates overwriting the refresh callbacks to create your own |
63 | window. Illustrates overwriting the refresh callbacks to create your own |
60 | overlays or changes. |
64 | overlays or changes. |
61 | |
|
|
62 | =item simple-overlay-clock |
|
|
63 | |
|
|
64 | Displays a digital clock using the built-in overlay (colourful, useless). |
|
|
65 | |
65 | |
66 | =back |
66 | =back |
67 | |
67 | |
68 | =head2 General API Considerations |
68 | =head2 General API Considerations |
69 | |
69 | |
… | |
… | |
194 | |
194 | |
195 | =item $time = urxvt::NOW |
195 | =item $time = urxvt::NOW |
196 | |
196 | |
197 | Returns the "current time" (as per the event loop). |
197 | Returns the "current time" (as per the event loop). |
198 | |
198 | |
|
|
199 | =back |
|
|
200 | |
199 | =head2 RENDITION |
201 | =head2 RENDITION |
200 | |
202 | |
201 | Rendition bitsets contain information about colour, font, font styles and |
203 | Rendition bitsets contain information about colour, font, font styles and |
202 | similar information for each screen cell. |
204 | similar information for each screen cell. |
203 | |
205 | |
… | |
… | |
218 | Return the rendition mask used for overlays by default. |
220 | Return the rendition mask used for overlays by default. |
219 | |
221 | |
220 | =item $rendbit = urxvt::RS_Bold, RS_Italic, RS_Blink, RS_RVid, RS_Uline |
222 | =item $rendbit = urxvt::RS_Bold, RS_Italic, RS_Blink, RS_RVid, RS_Uline |
221 | |
223 | |
222 | Return the bit that enabled bold, italic, blink, reverse-video and |
224 | Return the bit that enabled bold, italic, blink, reverse-video and |
223 | underline, respectively. To enable such a style, just or it onto the |
225 | underline, respectively. To enable such a style, just logically OR it into |
224 | bitset. |
226 | the bitset. |
225 | |
227 | |
226 | =item $foreground = urxvt::GET_BASEFG $rend |
228 | =item $foreground = urxvt::GET_BASEFG $rend |
227 | |
229 | |
228 | =item $background = urxvt::GET_BASEBG $rend |
230 | =item $background = urxvt::GET_BASEBG $rend |
229 | |
231 | |
… | |
… | |
233 | |
235 | |
234 | =item $rend = urxvt::SET_BGCOLOR ($rend, $new_colour) |
236 | =item $rend = urxvt::SET_BGCOLOR ($rend, $new_colour) |
235 | |
237 | |
236 | Replace the foreground/background colour in the rendition mask with the |
238 | Replace the foreground/background colour in the rendition mask with the |
237 | specified one. |
239 | specified one. |
|
|
240 | |
|
|
241 | =item $value = urxvt::GET_CUSTOM ($rend) |
|
|
242 | |
|
|
243 | Return the "custom" value: Every rendition has 5 bits for use by |
|
|
244 | extensions. They can be set and changed as you like and are initially |
|
|
245 | zero. |
|
|
246 | |
|
|
247 | =item $rend = urxvt::SET_CUSTOM ($rend, $new_value) |
|
|
248 | |
|
|
249 | Change the custom value. |
238 | |
250 | |
239 | =back |
251 | =back |
240 | |
252 | |
241 | =cut |
253 | =cut |
242 | |
254 | |
… | |
… | |
348 | return 1 if $v->($term, @_); |
360 | return 1 if $v->($term, @_); |
349 | } |
361 | } |
350 | |
362 | |
351 | 0 |
363 | 0 |
352 | } |
364 | } |
353 | |
|
|
354 | =back |
|
|
355 | |
365 | |
356 | =head2 The C<urxvt::term> Class |
366 | =head2 The C<urxvt::term> Class |
357 | |
367 | |
358 | =over 4 |
368 | =over 4 |
359 | |
369 | |
… | |
… | |
415 | |
425 | |
416 | =item $oldtext = $term->selection ([$newtext]) |
426 | =item $oldtext = $term->selection ([$newtext]) |
417 | |
427 | |
418 | Return the current selection text and optionally replace it by C<$newtext>. |
428 | Return the current selection text and optionally replace it by C<$newtext>. |
419 | |
429 | |
420 | =item $term->scr_overlay ($x, $y, $text) |
430 | #=item $term->overlay ($x, $y, $text) |
421 | |
431 | # |
422 | Create a simple multi-line overlay box. See the next method for details. |
432 | #Create a simple multi-line overlay box. See the next method for details. |
423 | |
433 | # |
424 | =cut |
434 | #=cut |
425 | |
435 | |
426 | sub urxvt::term::scr_overlay { |
436 | sub urxvt::term::scr_overlay { |
|
|
437 | die; |
427 | my ($self, $x, $y, $text) = @_; |
438 | my ($self, $x, $y, $text) = @_; |
428 | |
439 | |
429 | my @lines = split /\n/, $text; |
440 | my @lines = split /\n/, $text; |
430 | |
441 | |
431 | my $w = 0; |
442 | my $w = 0; |
… | |
… | |
435 | |
446 | |
436 | $self->scr_overlay_new ($x, $y, $w, scalar @lines); |
447 | $self->scr_overlay_new ($x, $y, $w, scalar @lines); |
437 | $self->scr_overlay_set (0, $_, $lines[$_]) for 0.. $#lines; |
448 | $self->scr_overlay_set (0, $_, $lines[$_]) for 0.. $#lines; |
438 | } |
449 | } |
439 | |
450 | |
440 | =item $term->scr_overlay_new ($x, $y, $width, $height) |
451 | =item $term->overlay ($x, $y, $width, $height[, $rstyle[, $border]]) |
441 | |
452 | |
442 | Create a new (empty) overlay at the given position with the given |
453 | Create a new (empty) overlay at the given position with the given |
443 | width/height. A border will be put around the box. If either C<$x> or |
454 | width/height. C<$rstyle> defines the initial rendition style |
444 | C<$y> is negative, then this is counted from the right/bottom side, |
455 | (default: C<OVERLAY_RSTYLE>). |
445 | respectively. |
|
|
446 | |
456 | |
447 | =item $term->scr_overlay_off |
457 | If C<$border> is C<2> (default), then a decorative border will be put |
|
|
458 | around the box. |
448 | |
459 | |
449 | Switch the overlay off again. |
460 | If either C<$x> or C<$y> is negative, then this is counted from the |
|
|
461 | right/bottom side, respectively. |
450 | |
462 | |
451 | =item $term->scr_overlay_set_char ($x, $y, $char, $rend = OVERLAY_RSTYLE) |
463 | This method returns an urxvt::overlay object. The overlay will be visible |
|
|
464 | as long as the perl object is referenced. |
452 | |
465 | |
453 | Put a single character (specified numerically) at the given overlay |
466 | Currently, the only method on the C<urxvt::overlay> object is C<set>: |
454 | position. |
|
|
455 | |
467 | |
456 | =item $term->scr_overlay_set ($x, $y, $text) |
468 | =item $overlay->set ($x, $y, $text, $rend) |
457 | |
469 | |
458 | Write a string at the given position into the overlay. |
470 | Similar to C<< $term->ROW_t >> and C<< $term->ROW_r >> in that it puts |
|
|
471 | text in rxvt-unicode's special encoding and an array of rendition values |
|
|
472 | at a specific position inside the overlay. |
459 | |
473 | |
460 | =item $cellwidth = $term->strwidth $string |
474 | =item $cellwidth = $term->strwidth $string |
461 | |
475 | |
462 | Returns the number of screen-cells this string would need. Correctly |
476 | Returns the number of screen-cells this string would need. Correctly |
463 | accounts for wide and combining characters. |
477 | accounts for wide and combining characters. |
… | |
… | |
558 | =head2 The C<urxvt::timer> Class |
572 | =head2 The C<urxvt::timer> Class |
559 | |
573 | |
560 | This class implements timer watchers/events. Time is represented as a |
574 | This class implements timer watchers/events. Time is represented as a |
561 | fractional number of seconds since the epoch. Example: |
575 | fractional number of seconds since the epoch. Example: |
562 | |
576 | |
563 | # create a digital clock display in upper right corner |
577 | $term->{overlay} = $term->overlay (-1, 0, 8, 1, urxvt::OVERLAY_RSTYLE, 0); |
564 | $term->{timer} = urxvt::timer |
578 | $term->{timer} = urxvt::timer |
565 | ->new |
579 | ->new |
566 | ->start (urxvt::NOW) |
580 | ->interval (1) |
567 | ->cb (sub { |
581 | ->cb (sub { |
568 | my ($timer) = @_; |
|
|
569 | my $time = $timer->at; |
|
|
570 | $timer->start ($time + 1); |
|
|
571 | $self->scr_overlay (-1, 0, |
582 | $term->{overlay}->set (0, 0, |
572 | POSIX::strftime "%H:%M:%S", localtime $time); |
583 | sprintf "%2d:%02d:%02d", (localtime urxvt::NOW)[2,1,0]); |
573 | }); |
584 | }); |
574 | |
585 | |
575 | =over 4 |
586 | =over 4 |
576 | |
587 | |
577 | =item $timer = new urxvt::timer |
588 | =item $timer = new urxvt::timer |
578 | |
589 | |
579 | Create a new timer object in stopped state. |
590 | Create a new timer object in started state. It is scheduled to fire |
|
|
591 | immediately. |
580 | |
592 | |
581 | =item $timer = $timer->cb (sub { my ($timer) = @_; ... }) |
593 | =item $timer = $timer->cb (sub { my ($timer) = @_; ... }) |
582 | |
594 | |
583 | Set the callback to be called when the timer triggers. |
595 | Set the callback to be called when the timer triggers. |
584 | |
596 | |
… | |
… | |
587 | Return the time this watcher will fire next. |
599 | Return the time this watcher will fire next. |
588 | |
600 | |
589 | =item $timer = $timer->set ($tstamp) |
601 | =item $timer = $timer->set ($tstamp) |
590 | |
602 | |
591 | Set the time the event is generated to $tstamp. |
603 | Set the time the event is generated to $tstamp. |
|
|
604 | |
|
|
605 | =item $timer = $timer->interval ($interval) |
|
|
606 | |
|
|
607 | Normally (and when C<$interval> is C<0>), the timer will automatically |
|
|
608 | stop after it has fired once. If C<$interval> is non-zero, then the timer |
|
|
609 | is automatically rescheduled at the given intervals. |
592 | |
610 | |
593 | =item $timer = $timer->start |
611 | =item $timer = $timer->start |
594 | |
612 | |
595 | Start the timer. |
613 | Start the timer. |
596 | |
614 | |