| 1 | package TUI::Drivers::ScreenCharacter; | ||||||||||||||||||||
| 2 | # ABSTRACT: character value type for screen cells | ||||||||||||||||||||
| 3 | |||||||||||||||||||||
| 4 | 104 | ▶ | use 5.010; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 104 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 104 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 104 | our $VERSION = '2.000002'; | |||||||||||||||||||
| 9 | 104 | $VERSION =~ tr/_//d; | |||||||||||||||||||
| 10 | 104 | our $AUTHORITY = 'cpan:BRICKPOOL'; | |||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 104 | ▶ | use Exporter 'import'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | 104 | our @EXPORT = qw( | |||||||||||||||||||
| 14 | TScreenCharacter | ||||||||||||||||||||
| 15 | ); | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 104 | require bytes; | |||||||||||||||||||
| 18 | 104 | ▶ | use PerlX::Assert::PP; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 19 | 104 | ▶ | use Scalar::Util qw( blessed ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 20 | 104 | ▶ | use Terminal::WCWidth qw( wcswidth ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | sub TScreenCharacter() { __PACKAGE__ } | ||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | 24 | ▶ | sub new { # $cch (|%args) | ||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=18.6
Pod
documented
| |||||||||||||||||||||
| 25 | 24 | my ( $class, @args ) = @_; | |||||||||||||||||||
| 26 | 24 | ▶ | assert ( $class and !ref $class ); | ||||||||||||||||||
|
Condition33%1/3
$class && !ref($class)
MC/DC0%0/2
$class && !ref($class)
$class
!ref($class)
Truth table33%1/3
A && not(B)
A= $classB= !ref($class)
| |||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | # TScreenCharacter->new() | ||||||||||||||||||||
| 29 | 24 | my $text; | |||||||||||||||||||
| 30 | 24 | ▶ | if ( !@args ) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 31 | 6 | $text = ''; # Watch out! This is a trivial constructor. | |||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | # TScreenCharacter->new( text => Str ) | ||||||||||||||||||||
| 35 | ▶ | elsif ( @args == 2 && $args[0] eq 'text' ) { | |||||||||||||||||||
|
Condition66%2/3
@args == 2 and $args[0] eq "text"
MC/DC50%1/2
@args == 2 and $args[0] eq "text"
@args == 2
$args[0] eq "text"
Truth table66%2/3
A and B
A= @args == 2B= $args[0] eq "text"
| |||||||||||||||||||||
| 36 | 17 | $text = $args[1]; | |||||||||||||||||||
| 37 | 17 | ▶ | assert ( !ref $text and length $text ); | ||||||||||||||||||
|
Condition33%1/3
!ref($text) && length $text
MC/DC0%0/2
!ref($text) && length $text
!ref($text)
length $text
Truth table33%1/3
not(A) && B
A= !ref($text)B= length $text
| |||||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | else { | ||||||||||||||||||||
| 41 | 1 | return; | |||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 23 | return bless \$text, $class; | |||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 0 | ▶ | sub assign { # void ($other) | ||||||||||||||||||
|
Subroutine
assign: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 48 | 0 | my ( $self, $other ) = @_; | |||||||||||||||||||
| 49 | 0 | assert ( blessed $self ); | |||||||||||||||||||
| 50 | 0 | assert ( blessed $other ); | |||||||||||||||||||
| 51 | 0 | $$self = $$other; | |||||||||||||||||||
| 52 | 0 | return; | |||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 0 | ▶ | sub clone { # $cch () | ||||||||||||||||||
|
Subroutine
clone: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 56 | 0 | my ( $self ) = @_; | |||||||||||||||||||
| 57 | 0 | assert ( blessed $self ); | |||||||||||||||||||
| 58 | 0 | my $v = $$self; | |||||||||||||||||||
| 59 | 0 | return bless \$v, ref $self; | |||||||||||||||||||
| 60 | } | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 8 | ▶ | sub isWide { # $bool () | ||||||||||||||||||
|
Subroutine
isWide: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 63 | 8 | assert ( blessed $_[0] ); | |||||||||||||||||||
| 64 | 8 | my $text = ${ $_[0] }; | |||||||||||||||||||
| 65 | 8 | ▶ | return !!0 | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 66 | if bytes::length( $text ) <= 1; | ||||||||||||||||||||
| 67 | 5 | return wcswidth( ${ $_[0] } ) >= 2; | |||||||||||||||||||
| 68 | } | ||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | 4 | ▶ | sub isWideCharTrail { # $bool () | ||||||||||||||||||
|
Subroutine
isWideCharTrail: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 71 | 4 | assert ( blessed $_[0] ); | |||||||||||||||||||
| 72 | 4 | return ${ $_[0] } eq "\0"; | |||||||||||||||||||
| 73 | } | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | 1 | ▶ | sub appendZeroWidthChar { # void ($mbc) | ||||||||||||||||||
|
Subroutine
appendZeroWidthChar: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 76 | 1 | my ( $self, $mbc ) = @_; | |||||||||||||||||||
| 77 | 1 | assert ( blessed $self ); | |||||||||||||||||||
| 78 | 1 | assert ( !ref $mbc ); | |||||||||||||||||||
| 79 | 1 | ${$self} .= $mbc; | |||||||||||||||||||
| 80 | 1 | return; | |||||||||||||||||||
| 81 | } | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | 7 | ▶ | sub getText { # $ch () | ||||||||||||||||||
|
Subroutine
getText: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 84 | 7 | assert ( blessed $_[0] ); | |||||||||||||||||||
| 85 | 7 | my $text = ${ $_[0] }; | |||||||||||||||||||
| 86 | 7 | ▶ | return length( $text ) ? $text : "\0"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 87 | } | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | 104 | 1; | |||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | __END__ | ||||||||||||||||||||