ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/urxvt.pm
(Generate patch)

Comparing rxvt-unicode/src/urxvt.pm (file contents):
Revision 1.19 by root, Tue Jan 3 02:42:17 2006 UTC vs.
Revision 1.20 by root, Tue Jan 3 04:18:47 2006 UTC

53 53
54=back 54=back
55 55
56=item digital-clock 56=item digital-clock
57 57
58Displays a digital clock using the built-in overlay.
59
60=item example-refresh-hooks
61
58Displays a very simple digital clock in the upper right corner of the 62Displays a very simple digital clock in the upper right corner of the
59window. Illustrates overwriting the refresh callbacks to create your own 63window. Illustrates overwriting the refresh callbacks to create your own
60overlays or changes. 64overlays or changes.
61
62=item simple-overlay-clock
63
64Displays 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
428Return the current selection text and optionally replace it by C<$newtext>. 428Return 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#
432Create 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
436sub urxvt::term::scr_overlay { 436sub urxvt::term::scr_overlay {
437die;
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
452Create a new (empty) overlay at the given position with the given 453Create a new (empty) overlay at the given position with the given
453width/height. A border will be put around the box. If either C<$x> or 454width/height. C<$rstyle> defines the initial rendition style
454C<$y> is negative, then this is counted from the right/bottom side, 455(default: C<OVERLAY_RSTYLE>).
455respectively.
456 456
457=item $term->scr_overlay_off 457If C<$border> is C<2> (default), then a decorative border will be put
458around the box.
458 459
459Switch the overlay off again. 460If either C<$x> or C<$y> is negative, then this is counted from the
461right/bottom side, respectively.
460 462
461=item $term->scr_overlay_set_char ($x, $y, $char, $rend = OVERLAY_RSTYLE) 463This method returns an urxvt::overlay object. The overlay will be visible
464as long as the perl object is referenced.
462 465
463Put a single character (specified numerically) at the given overlay 466Currently, the only method on the C<urxvt::overlay> object is C<set>:
464position.
465 467
466=item $term->scr_overlay_set ($x, $y, $text) 468=item $overlay->set ($x, $y, $text, $rend)
467 469
468Write a string at the given position into the overlay. 470Similar to C<< $term->ROW_t >> and C<< $term->ROW_r >> in that it puts
471text in rxvt-unicode's special encoding and an array of rendition values
472at a specific position inside the overlay.
469 473
470=item $cellwidth = $term->strwidth $string 474=item $cellwidth = $term->strwidth $string
471 475
472Returns the number of screen-cells this string would need. Correctly 476Returns the number of screen-cells this string would need. Correctly
473accounts for wide and combining characters. 477accounts for wide and combining characters.
568=head2 The C<urxvt::timer> Class 572=head2 The C<urxvt::timer> Class
569 573
570This class implements timer watchers/events. Time is represented as a 574This class implements timer watchers/events. Time is represented as a
571fractional number of seconds since the epoch. Example: 575fractional 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
589Create a new timer object in stopped state. 590Create a new timer object in started state. It is scheduled to fire
591immediately.
590 592
591=item $timer = $timer->cb (sub { my ($timer) = @_; ... }) 593=item $timer = $timer->cb (sub { my ($timer) = @_; ... })
592 594
593Set the callback to be called when the timer triggers. 595Set the callback to be called when the timer triggers.
594 596
597Return the time this watcher will fire next. 599Return the time this watcher will fire next.
598 600
599=item $timer = $timer->set ($tstamp) 601=item $timer = $timer->set ($tstamp)
600 602
601Set the time the event is generated to $tstamp. 603Set the time the event is generated to $tstamp.
604
605=item $timer = $timer->interval ($interval)
606
607Normally (and when C<$interval> is C<0>), the timer will automatically
608stop after it has fired once. If C<$interval> is non-zero, then the timer
609is automatically rescheduled at the given intervals.
602 610
603=item $timer = $timer->start 611=item $timer = $timer->start
604 612
605Start the timer. 613Start the timer.
606 614

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines