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.18 by root, Tue Jan 3 02:01:27 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
218Return the rendition mask used for overlays by default. 218Return the rendition mask used for overlays by default.
219 219
220=item $rendbit = urxvt::RS_Bold, RS_Italic, RS_Blink, RS_RVid, RS_Uline 220=item $rendbit = urxvt::RS_Bold, RS_Italic, RS_Blink, RS_RVid, RS_Uline
221 221
222Return the bit that enabled bold, italic, blink, reverse-video and 222Return the bit that enabled bold, italic, blink, reverse-video and
223underline, respectively. To enable such a style, just or it onto the 223underline, respectively. To enable such a style, just logically OR it into
224bitset. 224the bitset.
225 225
226=item $foreground = urxvt::GET_BASEFG $rend 226=item $foreground = urxvt::GET_BASEFG $rend
227 227
228=item $background = urxvt::GET_BASEBG $rend 228=item $background = urxvt::GET_BASEBG $rend
229 229
233 233
234=item $rend = urxvt::SET_BGCOLOR ($rend, $new_colour) 234=item $rend = urxvt::SET_BGCOLOR ($rend, $new_colour)
235 235
236Replace the foreground/background colour in the rendition mask with the 236Replace the foreground/background colour in the rendition mask with the
237specified one. 237specified one.
238
239=item $value = urxvt::GET_CUSTOM ($rend)
240
241Return the "custom" value: Every rendition has 5 bits for use by
242extensions. They can be set and changed as you like and are initially
243zero.
244
245=item $rend = urxvt::SET_CUSTOM ($rend, $new_value)
246
247Change the custom value.
238 248
239=back 249=back
240 250
241=cut 251=cut
242 252
415 425
416=item $oldtext = $term->selection ([$newtext]) 426=item $oldtext = $term->selection ([$newtext])
417 427
418Return the current selection text and optionally replace it by C<$newtext>. 428Return 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#
422Create 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
426sub urxvt::term::scr_overlay { 436sub urxvt::term::scr_overlay {
437die;
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
442Create a new (empty) overlay at the given position with the given 453Create a new (empty) overlay at the given position with the given
443width/height. A border will be put around the box. If either C<$x> or 454width/height. C<$rstyle> defines the initial rendition style
444C<$y> is negative, then this is counted from the right/bottom side, 455(default: C<OVERLAY_RSTYLE>).
445respectively.
446 456
447=item $term->scr_overlay_off 457If C<$border> is C<2> (default), then a decorative border will be put
458around the box.
448 459
449Switch the overlay off again. 460If either C<$x> or C<$y> is negative, then this is counted from the
461right/bottom side, respectively.
450 462
451=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.
452 465
453Put a single character (specified numerically) at the given overlay 466Currently, the only method on the C<urxvt::overlay> object is C<set>:
454position.
455 467
456=item $term->scr_overlay_set ($x, $y, $text) 468=item $overlay->set ($x, $y, $text, $rend)
457 469
458Write 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.
459 473
460=item $cellwidth = $term->strwidth $string 474=item $cellwidth = $term->strwidth $string
461 475
462Returns the number of screen-cells this string would need. Correctly 476Returns the number of screen-cells this string would need. Correctly
463accounts for wide and combining characters. 477accounts for wide and combining characters.
558=head2 The C<urxvt::timer> Class 572=head2 The C<urxvt::timer> Class
559 573
560This class implements timer watchers/events. Time is represented as a 574This class implements timer watchers/events. Time is represented as a
561fractional number of seconds since the epoch. Example: 575fractional 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
579Create a new timer object in stopped state. 590Create a new timer object in started state. It is scheduled to fire
591immediately.
580 592
581=item $timer = $timer->cb (sub { my ($timer) = @_; ... }) 593=item $timer = $timer->cb (sub { my ($timer) = @_; ... })
582 594
583Set the callback to be called when the timer triggers. 595Set the callback to be called when the timer triggers.
584 596
587Return the time this watcher will fire next. 599Return the time this watcher will fire next.
588 600
589=item $timer = $timer->set ($tstamp) 601=item $timer = $timer->set ($tstamp)
590 602
591Set 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.
592 610
593=item $timer = $timer->start 611=item $timer = $timer->start
594 612
595Start the timer. 613Start the timer.
596 614

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines