… | |
… | |
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 | |
… | |
… | |
425 | |
425 | |
426 | =item $oldtext = $term->selection ([$newtext]) |
426 | =item $oldtext = $term->selection ([$newtext]) |
427 | |
427 | |
428 | 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>. |
429 | |
429 | |
430 | =item $term->scr_overlay ($x, $y, $text) |
430 | #=item $term->overlay ($x, $y, $text) |
431 | |
431 | # |
432 | 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. |
433 | |
433 | # |
434 | =cut |
434 | #=cut |
435 | |
435 | |
436 | sub urxvt::term::scr_overlay { |
436 | sub urxvt::term::scr_overlay { |
|
|
437 | die; |
437 | my ($self, $x, $y, $text) = @_; |
438 | my ($self, $x, $y, $text) = @_; |
438 | |
439 | |
439 | my @lines = split /\n/, $text; |
440 | my @lines = split /\n/, $text; |
440 | |
441 | |
441 | my $w = 0; |
442 | my $w = 0; |
… | |
… | |
445 | |
446 | |
446 | $self->scr_overlay_new ($x, $y, $w, scalar @lines); |
447 | $self->scr_overlay_new ($x, $y, $w, scalar @lines); |
447 | $self->scr_overlay_set (0, $_, $lines[$_]) for 0.. $#lines; |
448 | $self->scr_overlay_set (0, $_, $lines[$_]) for 0.. $#lines; |
448 | } |
449 | } |
449 | |
450 | |
450 | =item $term->scr_overlay_new ($x, $y, $width, $height) |
451 | =item $term->overlay ($x, $y, $width, $height[, $rstyle[, $border]]) |
451 | |
452 | |
452 | 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 |
453 | 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 |
454 | C<$y> is negative, then this is counted from the right/bottom side, |
455 | (default: C<OVERLAY_RSTYLE>). |
455 | respectively. |
|
|
456 | |
456 | |
457 | =item $term->scr_overlay_off |
457 | If C<$border> is C<2> (default), then a decorative border will be put |
|
|
458 | around the box. |
458 | |
459 | |
459 | 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. |
460 | |
462 | |
461 | =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. |
462 | |
465 | |
463 | Put a single character (specified numerically) at the given overlay |
466 | Currently, the only method on the C<urxvt::overlay> object is C<set>: |
464 | position. |
|
|
465 | |
467 | |
466 | =item $term->scr_overlay_set ($x, $y, $text) |
468 | =item $overlay->set ($x, $y, $text, $rend) |
467 | |
469 | |
468 | 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. |
469 | |
473 | |
470 | =item $cellwidth = $term->strwidth $string |
474 | =item $cellwidth = $term->strwidth $string |
471 | |
475 | |
472 | Returns the number of screen-cells this string would need. Correctly |
476 | Returns the number of screen-cells this string would need. Correctly |
473 | accounts for wide and combining characters. |
477 | accounts for wide and combining characters. |
… | |
… | |
568 | =head2 The C<urxvt::timer> Class |
572 | =head2 The C<urxvt::timer> Class |
569 | |
573 | |
570 | This class implements timer watchers/events. Time is represented as a |
574 | This class implements timer watchers/events. Time is represented as a |
571 | fractional number of seconds since the epoch. Example: |
575 | fractional number of seconds since the epoch. Example: |
572 | |
576 | |
573 | # create a digital clock display in upper right corner |
577 | $term->{overlay} = $term->overlay (-1, 0, 8, 1, urxvt::OVERLAY_RSTYLE, 0); |
574 | $term->{timer} = urxvt::timer |
578 | $term->{timer} = urxvt::timer |
575 | ->new |
579 | ->new |
576 | ->start (urxvt::NOW) |
580 | ->interval (1) |
577 | ->cb (sub { |
581 | ->cb (sub { |
578 | my ($timer) = @_; |
|
|
579 | my $time = $timer->at; |
|
|
580 | $timer->start ($time + 1); |
|
|
581 | $self->scr_overlay (-1, 0, |
582 | $term->{overlay}->set (0, 0, |
582 | POSIX::strftime "%H:%M:%S", localtime $time); |
583 | sprintf "%2d:%02d:%02d", (localtime urxvt::NOW)[2,1,0]); |
583 | }); |
584 | }); |
584 | |
585 | |
585 | =over 4 |
586 | =over 4 |
586 | |
587 | |
587 | =item $timer = new urxvt::timer |
588 | =item $timer = new urxvt::timer |
588 | |
589 | |
589 | Create a new timer object in stopped state. |
590 | Create a new timer object in started state. It is scheduled to fire |
|
|
591 | immediately. |
590 | |
592 | |
591 | =item $timer = $timer->cb (sub { my ($timer) = @_; ... }) |
593 | =item $timer = $timer->cb (sub { my ($timer) = @_; ... }) |
592 | |
594 | |
593 | Set the callback to be called when the timer triggers. |
595 | Set the callback to be called when the timer triggers. |
594 | |
596 | |
… | |
… | |
597 | Return the time this watcher will fire next. |
599 | Return the time this watcher will fire next. |
598 | |
600 | |
599 | =item $timer = $timer->set ($tstamp) |
601 | =item $timer = $timer->set ($tstamp) |
600 | |
602 | |
601 | 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. |
602 | |
610 | |
603 | =item $timer = $timer->start |
611 | =item $timer = $timer->start |
604 | |
612 | |
605 | Start the timer. |
613 | Start the timer. |
606 | |
614 | |