ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/perl/example-refresh-hooks
(Generate patch)

Comparing rxvt-unicode/src/perl/example-refresh-hooks (file contents):
Revision 1.1 by root, Tue Jan 3 04:18:47 2006 UTC vs.
Revision 1.3 by root, Sun Jun 10 17:31:53 2012 UTC

1#! perl 1#! perl
2 2
3# this creates a simple digital clock by overwriting the refresh hooks 3=head1 NAME
4
5 example-refresh-hooks - example of how to use refresh hooks
6
7=head1 DESCRPTION
8
9Displays a very simple digital clock in the upper right corner of the
10window. Illustrates overwriting the refresh callbacks to create your own
11overlays or changes.
12
13=cut
4 14
5sub on_init { 15sub on_init {
6 my ($self) = @_; 16 my ($self) = @_;
7 17
8 # force a refresh every second 18 # force a refresh every second
9 $self->{digital_clock_refresh} = urxvt::timer 19 $self->{digital_clock_refresh} = urxvt::timer
10 ->new 20 ->new
11 ->start (urxvt::NOW) 21 ->start (1 + int urxvt::NOW)
12 ->cb (sub { 22 ->interval (1)
13 $self->{digital_clock_refresh}->start ($self->{digital_clock_refresh}->at + 1);
14 $self->want_refresh; 23 ->cb (sub { $self->want_refresh });
15 });
16 24
17 () 25 ()
18} 26}
19 27
20# before refreshing: replace upper right with the clock display 28# before refreshing: replace upper right with the clock display

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines