| 1 | package TUI::ColorSel::MonoSelector; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: A selector for monochrome attributes. | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use 5.010; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 6 | our $VERSION = '2.000003'; | |||||||||||||||||||||||||||
| 9 | 6 | $VERSION =~ tr/_//d; | |||||||||||||||||||||||||||
| 10 | 6 | our $AUTHORITY = 'cpan:BRICKPOOL'; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 6 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 6 | our @EXPORT = qw( | |||||||||||||||||||||||||||
| 14 | TMonoSelector | ||||||||||||||||||||||||||||
| 15 | new_TMonoSelector | ||||||||||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 6 | ▶ | use Carp (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 6 | ▶ | use Storable; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 6 | ▶ | use TUI::toolkit; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 6 | ▶ | use TUI::toolkit::Types qw( :types ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 6 | ▶ | use TUI::Drivers::Const qw( evBroadcast ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 6 | ▶ | use TUI::Dialogs::Cluster; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 6 | ▶ | use TUI::Dialogs::StrItem; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | 6 | ▶ | use TUI::ColorSel::Const qw( :cmXXXX ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 27 | 6 | ▶ | use TUI::Objects::Rect; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | 6 | ▶ | use TUI::Views::Util qw( message ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | sub TMonoSelector() { __PACKAGE__ } | ||||||||||||||||||||||||||||
| 31 | sub name() { 'TMonoSelector' } | ||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub new_TMonoSelector { __PACKAGE__->from( @_ ) } | ||||||||||||||||||||||||||
|
Subroutine
new_TMonoSelector: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 6 | extends TCluster; | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | # declare global variables | ||||||||||||||||||||||||||||
| 37 | 6 | our $button = " ( ) "; | |||||||||||||||||||||||||||
| 38 | 6 | our $normal = "Normal"; | |||||||||||||||||||||||||||
| 39 | 6 | our $highlight = "Highlight"; | |||||||||||||||||||||||||||
| 40 | 6 | our $underline = "Underline"; | |||||||||||||||||||||||||||
| 41 | 6 | our $inverse = "Inverse"; | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | # lookup table of monochrome color values | ||||||||||||||||||||||||||||
| 44 | 6 | my @monoColors = ( 0x07, 0x0f, 0x01, 0x70, 0x09 ); | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 0 | ▶ | sub BUILDARGS { # \%args (%args) | ||||||||||||||||||||||||||
|
Subroutine
BUILDARGS: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 47 | 0 | state $sig = signature( | |||||||||||||||||||||||||||
| 48 | method => 1, | ||||||||||||||||||||||||||||
| 49 | named => [ | ||||||||||||||||||||||||||||
| 50 | bounds => Object, | ||||||||||||||||||||||||||||
| 51 | ], | ||||||||||||||||||||||||||||
| 52 | caller_level => +1, | ||||||||||||||||||||||||||||
| 53 | ); | ||||||||||||||||||||||||||||
| 54 | 0 | my ( $class, $args1 ) = $sig->( @_ ); | |||||||||||||||||||||||||||
| 55 | 0 | local $Carp::CarpLevel = $Carp::CarpLevel + 1; | |||||||||||||||||||||||||||
| 56 | my $args2 = $class->SUPER::BUILDARGS( | ||||||||||||||||||||||||||||
| 57 | bounds => $args1->{bounds}, | ||||||||||||||||||||||||||||
| 58 | 0 | strings => new_TSItem( $normal, | |||||||||||||||||||||||||||
| 59 | new_TSItem( $highlight, | ||||||||||||||||||||||||||||
| 60 | new_TSItem( $underline, | ||||||||||||||||||||||||||||
| 61 | new_TSItem( $inverse, undef )))), | ||||||||||||||||||||||||||||
| 62 | ); | ||||||||||||||||||||||||||||
| 63 | 0 | return { %$args1, %$args2 }; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 0 | ▶ | sub from { # $obj ($bounds) | ||||||||||||||||||||||||||
|
Subroutine
from: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 67 | 0 | state $sig = signature( | |||||||||||||||||||||||||||
| 68 | method => 1, | ||||||||||||||||||||||||||||
| 69 | pos => [Object], | ||||||||||||||||||||||||||||
| 70 | ); | ||||||||||||||||||||||||||||
| 71 | 0 | my ( $class, $bounds ) = $sig->( @_ ); | |||||||||||||||||||||||||||
| 72 | 0 | return $class->new( bounds => $bounds ); | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | ▶ | sub draw { # void () | ||||||||||||||||||||||||||
|
Subroutine
draw: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 76 | 0 | state $sig = signature( | |||||||||||||||||||||||||||
| 77 | method => Object, | ||||||||||||||||||||||||||||
| 78 | pos => [], | ||||||||||||||||||||||||||||
| 79 | ); | ||||||||||||||||||||||||||||
| 80 | 0 | my ( $self ) = $sig->( @_ ); | |||||||||||||||||||||||||||
| 81 | 0 | $self->drawBox( $button, "\x7" ); | |||||||||||||||||||||||||||
| 82 | 0 | return; | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | ▶ | sub handleEvent { # void ($event) | ||||||||||||||||||||||||||
|
Subroutine
handleEvent: not called CC=3 SCAR=20.3
Pod
documented
| |||||||||||||||||||||||||||||
| 86 | 6 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 87 | 0 | state $sig = signature( | |||||||||||||||||||||||||||
| 88 | method => Object, | ||||||||||||||||||||||||||||
| 89 | pos => [Object], | ||||||||||||||||||||||||||||
| 90 | ); | ||||||||||||||||||||||||||||
| 91 | 0 | my ( $self, $event ) = $sig->( @_ ); | |||||||||||||||||||||||||||
| 92 | 0 | $self->SUPER::handleEvent( $event ); | |||||||||||||||||||||||||||
| 93 | 0 | ▶ | if ( $event->{what} == evBroadcast | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$event->{"what"} == 512 and $event->{"message"}{"command"} == 73
MC/DC0%0/2
$event->{"what"} == 512 and $event->{"message"}{"command"} == 73
$event->{"what"} == 512
$event->{"message"}{"command"} == 73
Truth table0%0/3
A and B
A= $event->{"what"} == 512B= $event->{"message"}{"command"} == 73
| |||||||||||||||||||||||||||||
| 94 | && $event->{message}{command} == cmColorSet | ||||||||||||||||||||||||||||
| 95 | ) { | ||||||||||||||||||||||||||||
| 96 | 0 | $self->{value} = $event->{message}{infoByte}; | |||||||||||||||||||||||||||
| 97 | 0 | $self->drawView(); | |||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | 0 | return; | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 0 | ▶ | sub mark { # $bool ($item) | ||||||||||||||||||||||||||
|
Subroutine
mark: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 103 | 0 | state $sig = signature( | |||||||||||||||||||||||||||
| 104 | method => Object, | ||||||||||||||||||||||||||||
| 105 | pos => [Int], | ||||||||||||||||||||||||||||
| 106 | ); | ||||||||||||||||||||||||||||
| 107 | 0 | my ( $self, $item ) = $sig->( @_ ); | |||||||||||||||||||||||||||
| 108 | 0 | return $monoColors[$item] == $self->{value}; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 0 | ▶ | sub newColor { # void () | ||||||||||||||||||||||||||
|
Subroutine
newColor: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 112 | 0 | state $sig = signature( | |||||||||||||||||||||||||||
| 113 | method => Object, | ||||||||||||||||||||||||||||
| 114 | pos => [], | ||||||||||||||||||||||||||||
| 115 | ); | ||||||||||||||||||||||||||||
| 116 | 0 | my ( $self ) = $sig->( @_ ); | |||||||||||||||||||||||||||
| 117 | message( $self->{owner}, evBroadcast, cmColorForegroundChanged, | ||||||||||||||||||||||||||||
| 118 | 0 | $self->{value} & 0x0f ); | |||||||||||||||||||||||||||
| 119 | message( $self->{owner}, evBroadcast, cmColorBackgroundChanged, | ||||||||||||||||||||||||||||
| 120 | 0 | ( $self->{value} >> 4 ) & 0x0f ); | |||||||||||||||||||||||||||
| 121 | 0 | return; | |||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 0 | ▶ | sub press { # void ($item) | ||||||||||||||||||||||||||
|
Subroutine
press: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 125 | 0 | state $sig = signature( | |||||||||||||||||||||||||||
| 126 | method => Object, | ||||||||||||||||||||||||||||
| 127 | pos => [Int], | ||||||||||||||||||||||||||||
| 128 | ); | ||||||||||||||||||||||||||||
| 129 | 0 | my ( $self, $item ) = $sig->( @_ ); | |||||||||||||||||||||||||||
| 130 | 0 | $self->{value} = $monoColors[$item]; | |||||||||||||||||||||||||||
| 131 | 0 | $self->newColor(); | |||||||||||||||||||||||||||
| 132 | 0 | return; | |||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | 0 | ▶ | sub movedTo { # void ($item) | ||||||||||||||||||||||||||
|
Subroutine
movedTo: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 136 | 0 | state $sig = signature( | |||||||||||||||||||||||||||
| 137 | method => Object, | ||||||||||||||||||||||||||||
| 138 | pos => [Int], | ||||||||||||||||||||||||||||
| 139 | ); | ||||||||||||||||||||||||||||
| 140 | 0 | my ( $self, $item ) = $sig->( @_ ); | |||||||||||||||||||||||||||
| 141 | 0 | $self->{value} = $monoColors[$item]; | |||||||||||||||||||||||||||
| 142 | 0 | $self->newColor(); | |||||||||||||||||||||||||||
| 143 | 0 | return; | |||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 0 | ▶ | sub build { # $obj () | ||||||||||||||||||||||||||
|
Subroutine
build: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 147 | 0 | my ( $class ) = @_; | |||||||||||||||||||||||||||
| 148 | 0 | ▶ | assert ( @_ == 1 ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 149 | 0 | ▶ | assert ( is_Str $class ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 150 | 0 | ▶ | assert ( Storable::is_retrieving ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 151 | 0 | return $class->new( bounds => TRect->new() ); | |||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 6 | 1 | |||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | __END__ | ||||||||||||||||||||||||||||