| 1 | package TUI::Gadgets::ClockView; | ||||||||||
| 2 | # ABSTRACT: clock view which display the clock | ||||||||||
| 3 | |||||||||||
| 4 | 4 | ▶ | use 5.010; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 4 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 4 | our $VERSION = '2.000002'; | |||||||||
| 9 | 4 | $VERSION =~ tr/_//d; | |||||||||
| 10 | 4 | our $AUTHORITY = 'cpan:BRICKPOOL'; | |||||||||
| 11 | |||||||||||
| 12 | 4 | ▶ | use Exporter 'import'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 4 | our @EXPORT = qw( | |||||||||
| 14 | TClockView | ||||||||||
| 15 | new_TClockView | ||||||||||
| 16 | ); | ||||||||||
| 17 | |||||||||||
| 18 | 4 | ▶ | use POSIX qw( strftime ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 4 | ▶ | use TUI::toolkit; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | 4 | ▶ | use TUI::toolkit::Types qw( :Object ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | |||||||||||
| 22 | 4 | ▶ | use TUI::Views::DrawBuffer; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | 4 | ▶ | use TUI::Views::View; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 24 | |||||||||||
| 25 | sub TClockView() { __PACKAGE__ } | ||||||||||
| 26 | sub name() { 'TClockView' } | ||||||||||
| 27 | 0 | ▶ | sub new_TClockView { __PACKAGE__->from(@_) } | ||||||||
|
Subroutine
new_TClockView: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 28 | |||||||||||
| 29 | 4 | extends TView; | |||||||||
| 30 | |||||||||||
| 31 | # private attributes | ||||||||||
| 32 | 4 | has lastTime => ( is => 'bare' ); | |||||||||
| 33 | 4 | has curTime => ( is => 'bare' ); | |||||||||
| 34 | |||||||||||
| 35 | 0 | ▶ | sub BUILD { # void (\%args) | ||||||||
|
Subroutine
BUILD: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 36 | 0 | my ( $self, $args ) = @_; | |||||||||
| 37 | 0 | ▶ | assert ( @_ == 2 ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | 0 | ▶ | assert ( is_Object $self ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | 0 | $self->{lastTime} = " "; | |||||||||
| 40 | 0 | $self->{curTime} = " "; | |||||||||
| 41 | 0 | return; | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 0 | ▶ | sub draw { # void () | ||||||||
|
Subroutine
draw: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 45 | 0 | state $sig = signature( | |||||||||
| 46 | method => Object, | ||||||||||
| 47 | pos => [], | ||||||||||
| 48 | ); | ||||||||||
| 49 | 0 | my ( $self ) = $sig->( @_ ); | |||||||||
| 50 | |||||||||||
| 51 | 0 | my $buf = TDrawBuffer->new(); | |||||||||
| 52 | 0 | my $c = $self->getColor( 2 ); | |||||||||
| 53 | |||||||||||
| 54 | 0 | $buf->moveChar( 0, ' ', $c, $self->{size}{x} ); | |||||||||
| 55 | 0 | $buf->moveStr( 0, $self->{curTime}, $c ); | |||||||||
| 56 | 0 | $self->writeLine( 0, 0, $self->{size}{x}, 1, $buf ); | |||||||||
| 57 | 0 | return; | |||||||||
| 58 | } #/ sub draw | ||||||||||
| 59 | |||||||||||
| 60 | 0 | ▶ | sub update { # void () | ||||||||
|
Subroutine
update: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 61 | 0 | state $sig = signature( | |||||||||
| 62 | method => Object, | ||||||||||
| 63 | pos => [], | ||||||||||
| 64 | ); | ||||||||||
| 65 | 0 | my ( $self ) = $sig->( @_ ); | |||||||||
| 66 | |||||||||||
| 67 | 0 | $self->{curTime} = strftime( '%H:%M:%S', localtime ); | |||||||||
| 68 | |||||||||||
| 69 | 0 | ▶ | if ( $self->{lastTime} ne $self->{curTime} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 70 | 0 | $self->{lastTime} = $self->{curTime}; | |||||||||
| 71 | 0 | $self->drawView(); | |||||||||
| 72 | } | ||||||||||
| 73 | 0 | return; | |||||||||
| 74 | } #/ sub update | ||||||||||
| 75 | |||||||||||
| 76 | 4 | 1 | |||||||||
| 77 | |||||||||||
| 78 | __END__ | ||||||||||