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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
#!/usr/bin/perl
use v5.14;
use warnings;
use Test::More;
use Tickit::Test;
use Tickit::Pen;
my $term = mk_term lines => 3, cols => 10;
is_termlog( [],
'Termlog initially' );
is_display( [ "", "", "" ],
'Display initially' );
$term->goto( 1, 5 );
is_termlog( [ GOTO(1,5) ],
'Termlog after ->goto' );
is_cursorpos( 1, 5, 'Cursor position after ->goto' );
$term->print( "foo" );
is_termlog( [ PRINT("foo") ],
'Termlog after ->print' );
is_display( [ "", " foo", "" ],
'Display after ->print' );
is_cursorpos( 1, 8, 'Cursor position after ->print' );
$term->clear;
is_termlog( [ CLEAR ],
'Termlog after ->clear' );
is_display( [ "", "", "" ],
'Display after ->clear' );
$term->setpen( Tickit::Pen->new( fg => 3 ) );
is_termlog( [ SETPEN(fg=>3) ],
'Termlog after ->setpen' );
$term->chpen( Tickit::Pen->new( bg => 6 ) );
is_termlog( [ SETPEN(fg=>3,bg=>6) ],
'Termlog after ->chpen' );
# Now some test content for scrolling
for my $l ( 0 .. 2 ) { $term->goto( $l, 0 ); $term->print( $l x 10 ) }
drain_termlog;
is_display( [ "0000000000", "1111111111", "2222222222" ],
'Display after scroll fill' );
ok( $term->scrollrect( 0,0,3,10, +1,0 ), '$term->scrollrect down OK' );
is_termlog( [ SCROLLRECT(0,0,3,10, +1,0) ],
'Termlog after scroll 1 down' );
is_display( [ "1111111111", "2222222222", "" ],
'Display after scroll 1 down' );
ok( $term->scrollrect( 0,0,3,10, -1,0 ), '$term->scrollrect up OK' );
is_termlog( [ SCROLLRECT(0,0,3,10, -1,0) ],
'Termlog after scroll 1 up' );
is_display( [ "", "1111111111", "2222222222" ],
'Display after scroll 1 up' );
for my $l ( 0 .. 2 ) { $term->goto( $l, 0 ); $term->print( $l x 10 ) }
drain_termlog;
$term->scrollrect( 0,0,2,10, +1,0 );
is_termlog( [ SCROLLRECT(0,0,2,10, +1,0) ],
'Termlog after scroll partial 1 down' );
is_display( [ "1111111111", "", "2222222222" ],
'Display after scroll partial 1 down' );
$term->scrollrect( 0,0,2,10, -1,0 );
is_termlog( [ SCROLLRECT(0,0,2,10, -1,0) ],
'Termlog after scroll partial 1 up' );
is_display( [ "", "1111111111", "2222222222" ],
'Display after scroll partial 1 up' );
$term->scrollrect( 1,5,1,5, 0,2 );
is_termlog( [ SCROLLRECT(1,5,1,5, ,0,+2) ],
'Termlog after scroll right' );
is_display( [ "", "11111111 ", "2222222222" ],
'Display after scroll right' );
$term->scrollrect( 2,5,1,5, 0,-3 );
is_termlog( [ SCROLLRECT(2,5,1,5, ,0,-3) ],
'Termlog after scroll left' );
is_display( [ "", "11111111 ", "22222 22" ],
'Display after scroll left' );
# Now some test content for mangling
for my $l ( 0 .. 2 ) { $term->goto( $l, 0 ); $term->print( "ABCDEFGHIJ" ) }
drain_termlog;
$term->goto( 0, 3 );
$term->erasech( 5, undef );
is_display( [ "ABC IJ", "ABCDEFGHIJ", "ABCDEFGHIJ" ],
'Display after ->erasech' );
# mockterm-emulated termctls
{
$term->setctl_int( Tickit::Term::TERMCTL_CURSORVIS, 0 );
is( $term->getctl_int( Tickit::Term::TERMCTL_CURSORVIS ), 0, '$term->setctl_int TERMCTL_CURSORVIS' );
$term->setctl_int( Tickit::Term::TERMCTL_CURSORSHAPE, 2 );
is( $term->getctl_int( Tickit::Term::TERMCTL_CURSORSHAPE ), 2, '$term->setctl_int TERMCTL_CURSORSHAPE' );
}
done_testing;
|