blib/lib/Term/Fabulous/Widget/FileDialog/FolderLine.pm untested

filter: Statementstmt 0.0% 0 / 46 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod n/a totaltotal 0.0% 0 / 58 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Term::Fabulous::Widget::FileDialog::FolderLine;
2  
3 use v5.32;
4 use warnings;
5 use feature 'signatures';
6 no warnings 'experimental::signatures';
7  
8 use Object::Pad 0.825;
9  
10 use Term::Fabulous::Widget::Display;
11  
12 our $VERSION = '0.05';
13  
14 class Term::Fabulous::Widget::FileDialog::FolderLine
15 :isa(Term::Fabulous::Widget::Display)
16 :strict(params)
17 {
18 use Clay::XS qw(sizing_grow);
19 use Term::Fabulous::Check qw(string);
20 use Term::Fabulous::Unicode qw(fit_columns);
21  
22 use constant CUT => '...';
23  
24 field $label :param = 'Folder: ';
25 field $path :param = '';
26  
27 ADJUST {
28 $label = string( $self, label => $label );
29 $path = string( $self, path => $path );
30 }
31  
32 method path (@new) {
33 return $path unless @new;
34 $path = string( $self, path => $new[0] );
35 $self->mark_changed;
36 return $path;
37 }
38  
39 method natural_size () {
40 return ( sizing_grow(), 1 );
41 }
42  
43 # The label, then as much of the end of the path as fits.
44 method paint () {
45 my $color = $self->color_attr( $self->family_look( text => 'color' ) );
46 my $x = $self->paint_text( 0, 0, $label, $color, undef );
47 $self->paint_text( $x, 0, fit_columns( $path, $self->columns - $x, mark => CUT, cut => 'start' ), $color, undef );
48 return;
49 }
50 }
51  
52 1;
53  
54 __END__