X-Git-Url: http://git.shiar.net/descalc.git/blobdiff_plain/7db84757c6ba80836bc8c2cc9de326f16862a2cd:/05_disp_curses.pm..4e1d9535fda6685e53ce570ca4e4cd6c260f55d3:/03_disp_curses.pm diff --git a/05_disp_curses.pm b/03_disp_curses.pm similarity index 69% rename from 05_disp_curses.pm rename to 03_disp_curses.pm index e88f667..8f94960 100644 --- a/05_disp_curses.pm +++ b/03_disp_curses.pm @@ -1,5 +1,6 @@ # ncurses output for DCT, by Shiar +# 1.12.0 200410312200 - define main loop (get input from Term::ReadKey) # 1.11.0 200410152225 - uses class in filename instead of $set{display} check # 1.10.0 200410140120 - all output functions seperated from main @@ -7,10 +8,16 @@ use strict; use warnings; use Curses; +use Term::ReadKey; push @{$hook{init}}, sub { initscr; - END { endwin; } # restore terminal on quit + ReadMode 3; # cbreak mode + + END { + ReadMode 0; + endwin; + } # restore terminal on quit $set{height} = $LINES-2 if $LINES>=3; $set{width} = $COLS if $COLS; @@ -46,9 +53,22 @@ push @{$hook{showentry}}, sub { refresh; }; # showentry +$hook{main} = sub { + while (1) { + draw(); + + my $key = ReadKey; # wait for user input + if ($key eq chr 27) { + $key .= $_ while defined ($_ = ReadKey(-1)); # read additional keys + } # escape sequence + + onkey($key); + } # input loop +}; # main + return { author => "Shiar", title => "curses output", - version => "1.11", + version => "1.12", };