| 1 | package UI::Dialog::Backend::XOSD; | ||||||||||||||||||||||||||||
| 2 | ############################################################################### | ||||||||||||||||||||||||||||
| 3 | # Copyright (C) 2004-2016 Kevin C. Krinke <kevin@krinke.ca> | ||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||
| 5 | # This library is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||
| 6 | # modify it under the terms of the GNU Lesser General Public | ||||||||||||||||||||||||||||
| 7 | # License as published by the Free Software Foundation; either | ||||||||||||||||||||||||||||
| 8 | # version 2.1 of the License, or (at your option) any later version. | ||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||
| 10 | # This library is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||||||||||||||||||||||||||
| 13 | # Lesser General Public License for more details. | ||||||||||||||||||||||||||||
| 14 | # | ||||||||||||||||||||||||||||
| 15 | # You should have received a copy of the GNU Lesser General Public | ||||||||||||||||||||||||||||
| 16 | # License along with this library; if not, write to the Free Software | ||||||||||||||||||||||||||||
| 17 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||||||||||||||||||||||||||||
| 18 | ############################################################################### | ||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use 5.006; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 1 | ▶ | use UI::Dialog::Backend; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use FileHandle; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | #: Ideas: | ||||||||||||||||||||||||||||
| 27 | # - implement debugging code... | ||||||||||||||||||||||||||||
| 28 | # - what about tail("/file")? | ||||||||||||||||||||||||||||
| 29 | # - and my $fh = tail_pipe() ? | ||||||||||||||||||||||||||||
| 30 | # (or pipe_start(), pipe_print() and pipe_close()) | ||||||||||||||||||||||||||||
| 31 | # - now here's a kicker, what about a "valid fonts" list and a | ||||||||||||||||||||||||||||
| 32 | # suitable mechanism to use (and cache) `xlsfonts` to determine | ||||||||||||||||||||||||||||
| 33 | # the font to use. Once the decision is made the decision should | ||||||||||||||||||||||||||||
| 34 | # simply be enforced rather than revalidated again and again. | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | BEGIN { | ||||||||||||||||||||||||||||
| 37 | 1 | ▶ | use vars qw( $VERSION @ISA ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 38 | 1 | ▶ | @ISA = qw( UI::Dialog::Backend ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 39 | 1 | $VERSION = '1.20'; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | sub new { | ||||||||||||||||||||||||||||
| 43 | 1 | ▶ | my $proto = shift(); | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=27 SCAR=45.6
Pod
documented
| |||||||||||||||||||||||||||||
| 44 | 1 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||
| 45 | 1 | ▶ | my $cfg = ((ref($_[0]) eq "HASH") ? $_[0] : (@_) ? { @_ } : {}); | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 46 | 1 | my $self = {}; | |||||||||||||||||||||||||||
| 47 | 1 | bless($self, $class); | |||||||||||||||||||||||||||
| 48 | 1 | $self->{'_opts'} = {}; | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | #: Dynamic path discovery... | ||||||||||||||||||||||||||||
| 51 | 1 | my $CFG_PATH = $cfg->{'PATH'}; | |||||||||||||||||||||||||||
| 52 | 1 | ▶ | if ($CFG_PATH) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 53 | 0 | ▶ | if (ref($CFG_PATH) eq "ARRAY") { $self->{'PATHS'} = $CFG_PATH; } | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 54 | 0 | elsif ($CFG_PATH =~ m!:!) { $self->{'PATHS'} = [ split(/:/,$CFG_PATH) ]; } | |||||||||||||||||||||||||||
| 55 | 0 | elsif (-d $CFG_PATH) { $self->{'PATHS'} = [ $CFG_PATH ]; } | |||||||||||||||||||||||||||
| 56 | 1 | } elsif ($ENV{'PATH'}) { $self->{'PATHS'} = [ split(/:/,$ENV{'PATH'}) ]; } | |||||||||||||||||||||||||||
| 57 | 0 | else { $self->{'PATHS'} = ''; } | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 1 | $self->{'_opts'}->{'bin'} = $self->_find_bin('osd_cat'); | |||||||||||||||||||||||||||
| 60 | 1 | $self->{'_opts'}->{'tail'} = $self->_find_bin('tail'); | |||||||||||||||||||||||||||
| 61 | 1 | $self->{'_opts'}->{'kill'} = $self->_find_bin('kill'); | |||||||||||||||||||||||||||
| 62 | 1 | ▶ | $self->{'_opts'}->{'pos'} = $cfg->{'pos'} || undef(); | ||||||||||||||||||||||||||
|
Condition50%1/2
$cfg->{'pos'} || undef()
MC/DC0%0/1
$cfg->{'pos'} || undef()
$cfg->{'pos'}
Truth table50%1/2
A
A= $cfg->{'pos'}
| |||||||||||||||||||||||||||||
| 63 | 1 | ▶ | $self->{'_opts'}->{'offset'} = $cfg->{'offset'} || 0; | ||||||||||||||||||||||||||
|
Condition50%1/2
$cfg->{'offset'} || 0
MC/DC0%0/1
$cfg->{'offset'} || 0
$cfg->{'offset'}
Truth table50%1/2
A
A= $cfg->{'offset'}
| |||||||||||||||||||||||||||||
| 64 | 1 | ▶ | $self->{'_opts'}->{'align'} = $cfg->{'align'} || undef(); | ||||||||||||||||||||||||||
|
Condition50%1/2
$cfg->{'align'} || undef()
MC/DC0%0/1
$cfg->{'align'} || undef()
$cfg->{'align'}
Truth table50%1/2
A
A= $cfg->{'align'}
| |||||||||||||||||||||||||||||
| 65 | 1 | ▶ | $self->{'_opts'}->{'indent'} = $cfg->{'indent'} || 0; | ||||||||||||||||||||||||||
|
Condition50%1/2
$cfg->{'indent'} || 0
MC/DC0%0/1
$cfg->{'indent'} || 0
$cfg->{'indent'}
Truth table50%1/2
A
A= $cfg->{'indent'}
| |||||||||||||||||||||||||||||
| 66 | 1 | ▶ | $self->{'_opts'}->{'font'} = $cfg->{'font'} || undef(); | ||||||||||||||||||||||||||
|
Condition50%1/2
$cfg->{'font'} || undef()
MC/DC0%0/1
$cfg->{'font'} || undef()
$cfg->{'font'}
Truth table50%1/2
A
A= $cfg->{'font'}
| |||||||||||||||||||||||||||||
| 67 | 1 | ▶ | $self->{'_opts'}->{'colour'} = $cfg->{'colour'} || $cfg->{'color'} || undef(); | ||||||||||||||||||||||||||
|
Condition40%2/5
$cfg->{'colour'} || $cfg->{'color'} || undef()
$cfg->{"colour"} or $cfg->{"color"}
MC/DC0%0/2
$cfg->{'colour'} || $cfg->{'color'} || undef()
$cfg->{"colour"}
$cfg->{"color"}
Truth table33%1/3
A or B
A= $cfg->{"colour"}B= $cfg->{"color"}
| |||||||||||||||||||||||||||||
| 68 | 1 | ▶ | $self->{'_opts'}->{'delay'} = $cfg->{'delay'} || 0; | ||||||||||||||||||||||||||
|
Condition50%1/2
$cfg->{'delay'} || 0
MC/DC0%0/1
$cfg->{'delay'} || 0
$cfg->{'delay'}
Truth table50%1/2
A
A= $cfg->{'delay'}
| |||||||||||||||||||||||||||||
| 69 | 1 | ▶ | $self->{'_opts'}->{'lines'} = $cfg->{'lines'} || 0; | ||||||||||||||||||||||||||
|
Condition50%1/2
$cfg->{'lines'} || 0
MC/DC0%0/1
$cfg->{'lines'} || 0
$cfg->{'lines'}
Truth table50%1/2
A
A= $cfg->{'lines'}
| |||||||||||||||||||||||||||||
| 70 | 1 | ▶ | $self->{'_opts'}->{'shadow'} = $cfg->{'shadow'} || 0; | ||||||||||||||||||||||||||
|
Condition50%1/2
$cfg->{'shadow'} || 0
MC/DC0%0/1
$cfg->{'shadow'} || 0
$cfg->{'shadow'}
Truth table50%1/2
A
A= $cfg->{'shadow'}
| |||||||||||||||||||||||||||||
| 71 | 1 | ▶ | $self->{'_opts'}->{'age'} = $cfg->{'age'} || 0; | ||||||||||||||||||||||||||
|
Condition50%1/2
$cfg->{'age'} || 0
MC/DC0%0/1
$cfg->{'age'} || 0
$cfg->{'age'}
Truth table50%1/2
A
A= $cfg->{'age'}
| |||||||||||||||||||||||||||||
| 72 | 1 | ▶ | $self->{'_opts'}->{'wait'} = ($cfg->{'wait'}) ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | 1 | ▶ | $self->{'_opts'}->{'length'} = $cfg->{'wait'} || 40; | ||||||||||||||||||||||||||
|
Condition50%1/2
$cfg->{'wait'} || 40
MC/DC0%0/1
$cfg->{'wait'} || 40
$cfg->{'wait'}
Truth table50%1/2
A
A= $cfg->{'wait'}
| |||||||||||||||||||||||||||||
| 74 | 1 | ▶ | $self->{'_opts'}->{'bar'} = $cfg->{'bar'} || "-"; | ||||||||||||||||||||||||||
|
Condition50%1/2
$cfg->{'bar'} || '-'
MC/DC0%0/1
$cfg->{'bar'} || '-'
$cfg->{'bar'}
Truth table50%1/2
A
A= $cfg->{'bar'}
| |||||||||||||||||||||||||||||
| 75 | 1 | ▶ | $self->{'_opts'}->{'mark'} = $cfg->{'mark'} || "|"; | ||||||||||||||||||||||||||
|
Condition50%1/2
$cfg->{'mark'} || '|'
MC/DC0%0/1
$cfg->{'mark'} || '|'
$cfg->{'mark'}
Truth table50%1/2
A
A= $cfg->{'mark'}
| |||||||||||||||||||||||||||||
| 76 | 1 | ▶ | unless (-x $self->{'_opts'}->{'bin'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | 1 | croak("the osd_cat binary could not be found at: ".$self->{'_opts'}->{'bin'}); | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | $self->{'_opts'}->{'trust-input'} = | ||||||||||||||||||||||||||||
| 81 | ( exists $cfg->{'trust-input'} | ||||||||||||||||||||||||||||
| 82 | 0 | ▶ | && $cfg->{'trust-input'}==1 | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $cfg->{"trust-input"} and $cfg->{"trust-input"} == 1
MC/DC0%0/2
exists $cfg->{"trust-input"} and $cfg->{"trust-input"} == 1
exists $cfg->{"trust-input"}
$cfg->{"trust-input"} == 1
Truth table0%0/3
A and B
A= exists $cfg->{"trust-input"}B= $cfg->{"trust-input"} == 1
| |||||||||||||||||||||||||||||
| 83 | ) ? 1 : 0; | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | return($self); | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||||||||||||||||||||||||||||
| 89 | #: Internal Methods | ||||||||||||||||||||||||||||
| 90 | #: | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 1 | my $SIG_CODE = {}; | |||||||||||||||||||||||||||
| 93 | sub _del_display { | ||||||||||||||||||||||||||||
| 94 | 0 | ▶ | my $CODE = $SIG_CODE->{$$}; | ||||||||||||||||||||||||||
|
Subroutine
_del_display: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 95 | 0 | ▶ | unless (not ref($CODE)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 96 | 0 | delete($CODE->{'_DISPLAY'}); | |||||||||||||||||||||||||||
| 97 | 0 | $SIG_CODE->{$$} = ""; | |||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | sub _gen_opt_str { | ||||||||||||||||||||||||||||
| 101 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||
|
Subroutine
_gen_opt_str: not called CC=23 SCAR=63.1
| |||||||||||||||||||||||||||||
| 102 | 0 | my $args = shift(); | |||||||||||||||||||||||||||
| 103 | 0 | my $string = ""; | |||||||||||||||||||||||||||
| 104 | 0 | ▶ | if ($args->{'pos'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 105 | 0 | ▶ | my $pos = ($args->{'pos'} =~ /^top|middle|bottom$/i) ? lc($args->{'pos'}) : 'top'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 106 | 0 | $string .= " --pos='".$pos."'"; | |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | 0 | ▶ | if ($args->{'offset'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | 0 | ▶ | my $offset = ($args->{'offset'} =~ /^\d+$/) ? $args->{'offset'} : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 110 | 0 | $string .= " --offset='".$offset."'"; | |||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | 0 | ▶ | if ($args->{'align'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 113 | 0 | ▶ | my $align = ($args->{'align'} =~ /^left|center|right$/i) ? lc($args->{'align'}) : 'left'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 114 | 0 | $string .= " --align='".$align."'"; | |||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||
| 116 | 0 | ▶ | if ($args->{'indent'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | 0 | ▶ | my $indent = ($args->{'indent'} =~ /^\d+$/) ? $args->{'indent'} : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 118 | 0 | $string .= " --indent='".$indent."'"; | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | 0 | ▶ | if ($args->{'font'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 121 | 0 | ▶ | my $font = $args->{'font'} || "-*-fixed-*-*-*-*-*-*-*-*-*-*-*-*"; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args->{'font'} || '-*-fixed-*-*-*-*-*-*-*-*-*-*-*-*'
MC/DC0%0/1
$args->{'font'} || '-*-fixed-*-*-*-*-*-*-*-*-*-*-*-*'
$args->{'font'}
Truth table0%0/2
A
A= $args->{'font'}
| |||||||||||||||||||||||||||||
| 122 | 0 | $string .= " --font='".$font."'"; | |||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | 0 | ▶ | if ($args->{'colour'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 125 | 0 | ▶ | my $colour = $args->{'colour'} || "green"; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args->{'colour'} || 'green'
MC/DC0%0/1
$args->{'colour'} || 'green'
$args->{'colour'}
Truth table0%0/2
A
A= $args->{'colour'}
| |||||||||||||||||||||||||||||
| 126 | 0 | $string .= " --color='".$colour."'"; | |||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||
| 128 | 0 | ▶ | if ($args->{'delay'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 129 | 0 | ▶ | my $delay = ($args->{'delay'} =~ /^\d+$/) ? $args->{'delay'} : 5; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 130 | 0 | $string .= " --delay='".$delay."'"; | |||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||
| 132 | 0 | ▶ | if ($args->{'lines'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 133 | 0 | ▶ | my $lines = ($args->{'lines'} =~ /^\d+$/) ? $args->{'lines'} : 5; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 134 | 0 | $string .= " --lines='".$lines."'"; | |||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||
| 136 | 0 | ▶ | if ($args->{'shadow'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 137 | 0 | ▶ | my $shadow = ($args->{'shadow'} =~ /^\d+$/) ? $args->{'shadow'} : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | 0 | $string .= " --shadow='".$shadow."'"; | |||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | 0 | ▶ | if ($args->{'age'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 141 | 0 | ▶ | my $age = ($args->{'age'} =~ /^\d+$/) ? $args->{'age'} : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | 0 | $string .= " --age='".$age."'"; | |||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||
| 144 | 0 | ▶ | if ($args->{'wait'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 145 | 0 | $string .= " --wait"; | |||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||
| 147 | 0 | $self->_debug("xosd: ".$string,3); | |||||||||||||||||||||||||||
| 148 | 0 | ▶ | return($string||" "); | ||||||||||||||||||||||||||
|
Condition0%0/2
$string || ' '
MC/DC0%0/1
$string || ' '
$string
Truth table0%0/2
A
A= $string
| |||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||||||||||||||||||||||||||||
| 152 | #: Public Methods | ||||||||||||||||||||||||||||
| 153 | #: | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | sub line { | ||||||||||||||||||||||||||||
| 156 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||
|
Subroutine
line: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 157 | 0 | my $args = $self->_merge_attrs(@_); | |||||||||||||||||||||||||||
| 158 | 0 | my $opts = $self->_gen_opt_str($args); | |||||||||||||||||||||||||||
| 159 | 0 | ▶ | if (open(XOSD,"| ".$self->{'_opts'}->{'bin'}.$opts." -")) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 160 | 0 | ▶ | print XOSD ($args->{'text'}||'')."\n"; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args->{'text'} || ''
MC/DC0%0/1
$args->{'text'} || ''
$args->{'text'}
Truth table0%0/2
A
A= $args->{'text'}
| |||||||||||||||||||||||||||||
| 161 | 0 | close(XOSD); | |||||||||||||||||||||||||||
| 162 | } else { | ||||||||||||||||||||||||||||
| 163 | 0 | croak("failed to open osd_cat output pipe!"); | |||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | sub file { | ||||||||||||||||||||||||||||
| 168 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||
|
Subroutine
file: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 169 | 0 | my $args = $self->_merge_attrs(@_); | |||||||||||||||||||||||||||
| 170 | 0 | my $opts = $self->_gen_opt_str($args); | |||||||||||||||||||||||||||
| 171 | 0 | ▶ | if (-r $args->{'file'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 172 | 0 | ▶ | if (open(FILE,"<".$args->{'file'})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 173 | 0 | local $/; | |||||||||||||||||||||||||||
| 174 | 0 | my $text = <FILE>; | |||||||||||||||||||||||||||
| 175 | 0 | close(FILE); | |||||||||||||||||||||||||||
| 176 | 0 | $text =~ s!\t! !g; | |||||||||||||||||||||||||||
| 177 | 0 | ▶ | if (open(XOSD,"| ".$self->{'_opts'}->{'bin'}.$opts." -")) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 178 | 0 | ▶ | print XOSD ($text||'')."\n"; | ||||||||||||||||||||||||||
|
Condition0%0/2
$text || ''
MC/DC0%0/1
$text || ''
$text
Truth table0%0/2
A
A= $text
| |||||||||||||||||||||||||||||
| 179 | 0 | close(XOSD); | |||||||||||||||||||||||||||
| 180 | } else { | ||||||||||||||||||||||||||||
| 181 | 0 | croak("failed to open osd_cat output pipe!"); | |||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | sub gauge { | ||||||||||||||||||||||||||||
| 188 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||
|
Subroutine
gauge: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||
| 189 | 0 | my $args = $self->_merge_attrs(@_); | |||||||||||||||||||||||||||
| 190 | 0 | my $opts = $self->_gen_opt_str($args); | |||||||||||||||||||||||||||
| 191 | 0 | ▶ | my $length = $args->{'length'} || 40; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args->{'length'} || 40
MC/DC0%0/1
$args->{'length'} || 40
$args->{'length'}
Truth table0%0/2
A
A= $args->{'length'}
| |||||||||||||||||||||||||||||
| 192 | 0 | ▶ | my $bar = ($args->{'bar'} || "-") x $length; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args->{'bar'} || '-'
MC/DC0%0/1
$args->{'bar'} || '-'
$args->{'bar'}
Truth table0%0/2
A
A= $args->{'bar'}
| |||||||||||||||||||||||||||||
| 193 | 0 | ▶ | my $percent = $args->{'percent'} || '0'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args->{'percent'} || '0'
MC/DC0%0/1
$args->{'percent'} || '0'
$args->{'percent'}
Truth table0%0/2
A
A= $args->{'percent'}
| |||||||||||||||||||||||||||||
| 194 | 0 | ▶ | $percent = (($percent <= 100 && $percent >= 0) ? $percent : 0 ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$percent <= 100 and $percent >= 0
MC/DC0%0/2
$percent <= 100 and $percent >= 0
$percent <= 100
$percent >= 0
Truth table0%0/3
A and B
A= $percent <= 100B= $percent >= 0
| |||||||||||||||||||||||||||||
| 195 | 0 | my $perc = int((($length / 100) * $percent)); | |||||||||||||||||||||||||||
| 196 | 0 | ▶ | substr($bar,($perc||0),1,($args->{'mark'}||"|")); | ||||||||||||||||||||||||||
|
Condition0%0/4
$perc || 0
$args->{'mark'} || '|'
MC/DC0%0/1
$perc || 0
$perc
MC/DC0%0/1
$args->{'mark'} || '|'
$args->{'mark'}
Truth table0%0/2
A
A= $perc
Truth table0%0/2
A
A= $args->{'mark'}
| |||||||||||||||||||||||||||||
| 197 | 0 | ▶ | my $text = $args->{'text'} ? $args->{'text'}."\n" : ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 198 | 0 | $text .= $percent."% ".$bar."\n"; | |||||||||||||||||||||||||||
| 199 | 0 | ▶ | if (open(XOSD,"| ".$self->{'_opts'}->{'bin'}.$opts." -")) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 200 | 0 | print XOSD $text; | |||||||||||||||||||||||||||
| 201 | 0 | close(XOSD); | |||||||||||||||||||||||||||
| 202 | } else { | ||||||||||||||||||||||||||||
| 203 | 0 | croak("failed to open osd_cat output pipe!"); | |||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | sub display_start { | ||||||||||||||||||||||||||||
| 208 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||
|
Subroutine
display_start: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 209 | 0 | my $args = $self->_merge_attrs(@_); | |||||||||||||||||||||||||||
| 210 | 0 | my $opts = $self->_gen_opt_str($args); | |||||||||||||||||||||||||||
| 211 | 0 | ▶ | $self->{'_DISPLAY'} ||= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"_DISPLAY"} ||= {}
MC/DC0%0/1
$self->{"_DISPLAY"} ||= {}
$self->{"_DISPLAY"}
Truth table0%0/2
A
A= $self->{"_DISPLAY"}
| |||||||||||||||||||||||||||||
| 212 | 0 | $self->{'_DISPLAY'}->{'ARGS'} = $args; | |||||||||||||||||||||||||||
| 213 | 0 | ▶ | return(0) if defined $self->{'_DISPLAY'}->{'FH'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 214 | 0 | my $command = $self->{'_opts'}->{'bin'}.$opts." -"; | |||||||||||||||||||||||||||
| 215 | 0 | $self->{'_DISPLAY'}->{'FH'} = new FileHandle; | |||||||||||||||||||||||||||
| 216 | 0 | $self->{'_DISPLAY'}->{'FH'}->open("| $command"); | |||||||||||||||||||||||||||
| 217 | 0 | my $rv = $? >> 8; | |||||||||||||||||||||||||||
| 218 | 0 | $self->{'_DISPLAY'}->{'FH'}->autoflush(1); | |||||||||||||||||||||||||||
| 219 | 0 | my $this_rv; | |||||||||||||||||||||||||||
| 220 | 0 | ▶ | if ($rv && $rv >= 1) { $this_rv = 0; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$rv and $rv >= 1
MC/DC0%0/2
$rv and $rv >= 1
$rv
$rv >= 1
Truth table0%0/3
A and B
A= $rvB= $rv >= 1
| |||||||||||||||||||||||||||||
| 221 | 0 | else { $this_rv = 1; } | |||||||||||||||||||||||||||
| 222 | 0 | return($this_rv); | |||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||
| 224 | sub display_text { | ||||||||||||||||||||||||||||
| 225 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||
|
Subroutine
display_text: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 226 | 0 | my $mesg; | |||||||||||||||||||||||||||
| 227 | 0 | ▶ | if (@_ > 1) { $mesg = join("\n",@_); } | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 228 | 0 | elsif (ref($_[0]) eq "ARRAY") { $mesg = join("\n",@{$_[0]}); } | |||||||||||||||||||||||||||
| 229 | 0 | ▶ | else { $mesg = $_[0] || return(0); } | ||||||||||||||||||||||||||
|
Condition0%0/2
$_[0] || (return 0)
MC/DC0%0/1
$_[0] || (return 0)
$_[0]
Truth table0%0/2
A
A= $_[0]
| |||||||||||||||||||||||||||||
| 230 | 0 | ▶ | return(0) unless $self->{'_DISPLAY'}->{'FH'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 231 | 0 | my $fh = $self->{'_DISPLAY'}->{'FH'}; | |||||||||||||||||||||||||||
| 232 | 0 | $SIG_CODE->{$$} = $self; local $SIG{'PIPE'} = \&_del_gauge; | |||||||||||||||||||||||||||
| 233 | 0 | print $fh $mesg."\n"; | |||||||||||||||||||||||||||
| 234 | 0 | ▶ | return(((defined $self->{'_DISPLAY'}->{'FH'}) ? 1 : 0)); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||
| 236 | sub display_gauge { | ||||||||||||||||||||||||||||
| 237 | 0 | ▶ | my $self = $_[0]; | ||||||||||||||||||||||||||
|
Subroutine
display_gauge: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||
| 238 | 0 | ▶ | return(0) unless $self->{'_DISPLAY'}->{'FH'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 239 | 0 | my $args = $self->_merge_attrs(); | |||||||||||||||||||||||||||
| 240 | 0 | ▶ | my $length = $args->{'length'} || 40; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args->{'length'} || 40
MC/DC0%0/1
$args->{'length'} || 40
$args->{'length'}
Truth table0%0/2
A
A= $args->{'length'}
| |||||||||||||||||||||||||||||
| 241 | 0 | ▶ | my $bar = ($args->{'bar'} || "-") x $length; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args->{'bar'} || '-'
MC/DC0%0/1
$args->{'bar'} || '-'
$args->{'bar'}
Truth table0%0/2
A
A= $args->{'bar'}
| |||||||||||||||||||||||||||||
| 242 | 0 | ▶ | my $percent = $_[1] || 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
$_[1] || 0
MC/DC0%0/1
$_[1] || 0
$_[1]
Truth table0%0/2
A
A= $_[1]
| |||||||||||||||||||||||||||||
| 243 | 0 | ▶ | $percent = (($percent <= 100 && $percent >= 0) ? $percent : 0 ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$percent <= 100 and $percent >= 0
MC/DC0%0/2
$percent <= 100 and $percent >= 0
$percent <= 100
$percent >= 0
Truth table0%0/3
A and B
A= $percent <= 100B= $percent >= 0
| |||||||||||||||||||||||||||||
| 244 | 0 | my $perc = int((($length / 100) * $percent)); | |||||||||||||||||||||||||||
| 245 | 0 | ▶ | substr($bar,($perc||0),1,($args->{'mark'}||"|")); | ||||||||||||||||||||||||||
|
Condition0%0/4
$perc || 0
$args->{'mark'} || '|'
MC/DC0%0/1
$perc || 0
$perc
MC/DC0%0/1
$args->{'mark'} || '|'
$args->{'mark'}
Truth table0%0/2
A
A= $perc
Truth table0%0/2
A
A= $args->{'mark'}
| |||||||||||||||||||||||||||||
| 246 | 0 | ▶ | my $text = $_[2] ? $_[2]."\n" : ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 247 | 0 | $text .= $percent."% ".$bar."\n"; | |||||||||||||||||||||||||||
| 248 | 0 | my $fh = $self->{'_DISPLAY'}->{'FH'}; | |||||||||||||||||||||||||||
| 249 | 0 | $SIG_CODE->{$$} = $self; local $SIG{'PIPE'} = \&_del_gauge; | |||||||||||||||||||||||||||
| 250 | 0 | print $fh $text; | |||||||||||||||||||||||||||
| 251 | 0 | ▶ | return(((defined $self->{'_DISPLAY'}->{'FH'}) ? 1 : 0)); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||
| 253 | sub display_stop { | ||||||||||||||||||||||||||||
| 254 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||
|
Subroutine
display_stop: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 255 | 0 | ▶ | return(0) unless $self->{'_DISPLAY'}->{'FH'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 256 | 0 | my $args = $self->{'_DISPLAY'}->{'ARGS'}; | |||||||||||||||||||||||||||
| 257 | 0 | my $fh = $self->{'_DISPLAY'}->{'FH'}; | |||||||||||||||||||||||||||
| 258 | 0 | $SIG_CODE->{$$} = $self; local $SIG{'PIPE'} = \&_del_gauge; | |||||||||||||||||||||||||||
| 259 | 0 | $self->{'_DISPLAY'}->{'FH'}->close(); | |||||||||||||||||||||||||||
| 260 | 0 | delete($self->{'_DISPLAY'}->{'FH'}); | |||||||||||||||||||||||||||
| 261 | 0 | delete($self->{'_DISPLAY'}->{'ARGS'}); | |||||||||||||||||||||||||||
| 262 | 0 | delete($self->{'_DISPLAY'}->{'PERCENT'}); | |||||||||||||||||||||||||||
| 263 | 0 | delete($self->{'_DISPLAY'}); | |||||||||||||||||||||||||||
| 264 | 0 | return(1); | |||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | # #$d->tail( file => "/tmp/xosdtail.log", delay => '3' ); | ||||||||||||||||||||||||||||
| 268 | # sub tail { | ||||||||||||||||||||||||||||
| 269 | # my $self = shift(); | ||||||||||||||||||||||||||||
| 270 | # my $args = $self->_merge_attrs(@_); | ||||||||||||||||||||||||||||
| 271 | # my $opts = $self->_gen_opt_str($args); | ||||||||||||||||||||||||||||
| 272 | # if (-r $args->{'file'}) { | ||||||||||||||||||||||||||||
| 273 | # my $tail_cmnd = $self->{'_opts'}->{'tail'}.' -f '.$args->{'file'}; | ||||||||||||||||||||||||||||
| 274 | # system($tail_cmnd." | ".$self->{'_opts'}->{'bin'}.$opts." -"); | ||||||||||||||||||||||||||||
| 275 | # } else { | ||||||||||||||||||||||||||||
| 276 | # $self->line( @_, text => "couldn't open file: ".($args->{'file'}||'NULL') ); | ||||||||||||||||||||||||||||
| 277 | # } | ||||||||||||||||||||||||||||
| 278 | # } | ||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | # sub tailbg { | ||||||||||||||||||||||||||||
| 281 | # my $self = shift(); | ||||||||||||||||||||||||||||
| 282 | # my $args = $self->_merge_attrs(@_); | ||||||||||||||||||||||||||||
| 283 | # my $opts = $self->_gen_opt_str($args); | ||||||||||||||||||||||||||||
| 284 | # if (-r $args->{'file'}) { | ||||||||||||||||||||||||||||
| 285 | # my $tail_cmnd = $self->{'_opts'}->{'tail'}.' -f '.$args->{'file'}; | ||||||||||||||||||||||||||||
| 286 | # my $xosd_cmnd = $self->{'_opts'}->{'bin'}.$opts." -"; | ||||||||||||||||||||||||||||
| 287 | # # system($tail_cmnd." | ".$self->{'_opts'}->{'bin'}.$opts." - &"); | ||||||||||||||||||||||||||||
| 288 | # # $self->{'forkpid'} = $self->command_forked($tail_cmnd." | ".$self->{'_opts'}->{'bin'}.$opts." -"); | ||||||||||||||||||||||||||||
| 289 | # # $self->{'forkpid'} = $self->command_forked($self->{'_opts'}->{'tail'},' -f '.$args->{'file'}. " | ".$self->{'_opts'}->{'bin'}.$opts." -"); | ||||||||||||||||||||||||||||
| 290 | # $self->{'forkpid'} = $self->tailbg_forked($tail_cmnd,$xosd_cmnd); | ||||||||||||||||||||||||||||
| 291 | # print "pid: ".$self->{'forkpid'}."\n"; | ||||||||||||||||||||||||||||
| 292 | # return(1) if $self->{'forkpid'}; | ||||||||||||||||||||||||||||
| 293 | # return(0); | ||||||||||||||||||||||||||||
| 294 | # } else { | ||||||||||||||||||||||||||||
| 295 | # $self->line( @_, text => "couldn't open file: ".($args->{'file'}||'NULL') ); | ||||||||||||||||||||||||||||
| 296 | # } | ||||||||||||||||||||||||||||
| 297 | # } | ||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | # sub command_forked { | ||||||||||||||||||||||||||||
| 301 | # my $self = shift(); | ||||||||||||||||||||||||||||
| 302 | # if (my $pid = fork()) { return($pid); } | ||||||||||||||||||||||||||||
| 303 | # else { exec(@_); } | ||||||||||||||||||||||||||||
| 304 | # } | ||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | # sub tailbg_forked { | ||||||||||||||||||||||||||||
| 307 | # my $self = shift(); | ||||||||||||||||||||||||||||
| 308 | # my $tail = shift(); | ||||||||||||||||||||||||||||
| 309 | # my $osdc = shift(); | ||||||||||||||||||||||||||||
| 310 | # if (my $pid = fork()) { return($pid); } | ||||||||||||||||||||||||||||
| 311 | # else { | ||||||||||||||||||||||||||||
| 312 | # # here we open the tail and read | ||||||||||||||||||||||||||||
| 313 | # # while reading, print to an open osd_cat | ||||||||||||||||||||||||||||
| 314 | # my $TSIGP = $SIG{'PIPE'}; | ||||||||||||||||||||||||||||
| 315 | # $SIG{'PIPE'} = "IGNORE"; | ||||||||||||||||||||||||||||
| 316 | # if (open(TAIL,$tail." |")) { | ||||||||||||||||||||||||||||
| 317 | # unless (open(OSDC,"| ".$osdc)) { | ||||||||||||||||||||||||||||
| 318 | # close(TAIL); | ||||||||||||||||||||||||||||
| 319 | # return(); | ||||||||||||||||||||||||||||
| 320 | # } | ||||||||||||||||||||||||||||
| 321 | # my $TP = $|; | ||||||||||||||||||||||||||||
| 322 | # $| = 1; | ||||||||||||||||||||||||||||
| 323 | # while (my $line = <TAIL>) { | ||||||||||||||||||||||||||||
| 324 | # print OSDC $line; | ||||||||||||||||||||||||||||
| 325 | # } | ||||||||||||||||||||||||||||
| 326 | # $| = $TP; | ||||||||||||||||||||||||||||
| 327 | # close(OSDC); | ||||||||||||||||||||||||||||
| 328 | # close(TAIL); | ||||||||||||||||||||||||||||
| 329 | # } | ||||||||||||||||||||||||||||
| 330 | # $SIG{'PIPE'} = $TSIGP; | ||||||||||||||||||||||||||||
| 331 | # } | ||||||||||||||||||||||||||||
| 332 | # } | ||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | # sub tailbg_end { | ||||||||||||||||||||||||||||
| 335 | # my $self = shift(); | ||||||||||||||||||||||||||||
| 336 | # my $args = $self->_merge_attrs(@_); | ||||||||||||||||||||||||||||
| 337 | # if ($self->{'forkpid'}) { | ||||||||||||||||||||||||||||
| 338 | # print "pid: ".$self->{'forkpid'}."\n"; | ||||||||||||||||||||||||||||
| 339 | # if (kill(15,$self->{'forkpid'})) { | ||||||||||||||||||||||||||||
| 340 | # print "killed: ".$self->{'forkpid'}."\n"; | ||||||||||||||||||||||||||||
| 341 | # } else { | ||||||||||||||||||||||||||||
| 342 | # print "maimed: ".$self->{'forkpid'}."\n"; | ||||||||||||||||||||||||||||
| 343 | # } | ||||||||||||||||||||||||||||
| 344 | # } | ||||||||||||||||||||||||||||
| 345 | # } | ||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||
| 347 | 1 | 1; | |||||||||||||||||||||||||||