#!/usr/bin/perl
my
@chars
=
split
//,
'Hello, world!'
;
my
$code
= tb_init();
die
sprintf
"termbox init failed, code: %d\n"
,
$code
if
$code
;
tb_select_input_mode(TB_INPUT_ESC);
tb_select_output_mode(TB_OUTPUT_NORMAL);
my
$ev
= Termbox::Event->new();
for
my
$left
( 0 .. 10 ) {
tb_clear();
my
(
$i
,
$j
) = ( 0, 0 );
for
my
$char
(
@chars
) {
tb_change_cell(
$j
+
int
(
$left
/ 2 ) + 1, 1,
$char
, TB_WHITE, TB_DEFAULT );
$j
++;
}
tb_change_cell( 0, 0, 0x250C, TB_BLUE, TB_DEFAULT );
tb_change_cell( 14 +
$left
, 0, 0x2510, TB_BLUE, TB_DEFAULT );
tb_change_cell( 0, 2, 0x2514, TB_BLUE, TB_DEFAULT );
tb_change_cell( 14 +
$left
, 2, 0x2518, TB_BLUE, TB_DEFAULT );
for
my
$i
( 1 .. 14 +
$left
- 1 ) {
tb_change_cell(
$i
, 0, 0x2500, TB_BLUE, TB_DEFAULT );
tb_change_cell(
$i
, 2, 0x2500, TB_BLUE, TB_DEFAULT );
}
for
(
my
$i
= 1;
$i
< 2; ++
$i
) {
tb_change_cell( 0,
$i
, 0x2502, TB_BLUE, TB_DEFAULT );
tb_change_cell( 14 +
$left
,
$i
, 0x2502, TB_BLUE, TB_DEFAULT );
}
tb_present();
tb_peek_event(
$ev
, 30 );
if
(
$ev
->key == TB_KEY_ESC ) {
tb_shutdown();
exit
;
}
}
while
(1) {
tb_poll_event(
$ev
);
if
(
$ev
->key == TB_KEY_ESC ) {
tb_shutdown();
exit
;
}
}