1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
#!/usr/bin/perl
use v5.26;
use warnings;
use Test2::V0;
use Tickit::Test;
use Tickit::Console;
use Tickit::Widget::Static;
use Tickit::Widget::HBox;
my $win = mk_window;
my $console = Tickit::Console->new;
$console->set_window( $win );
# A particularly silly layout
my $tab = $console->add_tab(
name => "Silly",
make_widget => sub {
my ( $scroller ) = @_;
my $hbox = Tickit::Widget::HBox->new(
spacing => 2,
);
$hbox->add( Tickit::Widget::Static->new( text => "Left" ) );
$hbox->add( $scroller, expand => 1 );
$hbox->add( Tickit::Widget::Static->new( text => "Right" ) );
return $hbox;
},
);
flush_tickit;
is_display( [ [TEXT("Left"), BLANK(71), TEXT("Right")],
BLANKLINES(22),
[TEXT("[",fg=>7,bg=>4), TEXT("Silly",fg=>14,bg=>4), TEXT("]",fg=>7,bg=>4), BLANK(73,bg=>4)],
BLANKLINE() ],
'Display initially with make_widget' );
$tab->append_line( "One" );
$tab->append_line( "Two" );
$tab->append_line( "Three" );
flush_tickit;
is_display( [ [TEXT("Left"), BLANK(2), TEXT("One"), BLANK(66), TEXT("Right")],
[BLANK(6), TEXT("Two"), BLANK(71) ],
[BLANK(6), TEXT("Three"), BLANK(69) ],
BLANKLINES(20),
[TEXT("[",fg=>7,bg=>4), TEXT("Silly",fg=>14,bg=>4), TEXT("]",fg=>7,bg=>4), BLANK(73,bg=>4)],
BLANKLINE() ],
'Display after ->append_line on tab with custom widget' );
done_testing;
|