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 | |
|
|
9 | Displays a very simple digital clock in the upper right corner of the |
|
|
10 | window. Illustrates overwriting the refresh callbacks to create your own |
|
|
11 | overlays or changes. |
|
|
12 | |
|
|
13 | =cut |
4 | |
14 | |
5 | sub on_init { |
15 | sub 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 |