1 # console output for DCT, by Shiar
3 # 1.12.0 200411032130 - handle input via Term::ReadKey; define main loop
4 # 1.11.0 200410152225 - class in file name, so check is not needed anymore
5 # 1.10.1 200410142200 - startup message omitted (now shown by main)
6 # 1.10.0 200410140120 - never clear screen (just let it scroll)
7 # - try to get width/height from environment vars
8 # - use escape sequences for clear/reposition/invert
9 # - print everything to STDOUT
16 push @{$hook{init}}, sub {
17 ReadMode 3; # cbreak mode
19 # print "\ec"; # reset (clear screen, go home)
20 # print "\e[4mDCT $::VERSION\e[24m "; # print intro (underlined)
26 $set{height} = $ENV{LINES}-2 if $ENV{LINES} and $ENV{LINES}>=3;
27 $set{width} = $ENV{COLUMNS} if $ENV{COLUMNS};
30 push @{$hook{showerror}}, sub {
31 print "\n\a\e[7m$_[0]\e[27m"; # bell and reverse video
34 push @{$hook{showstack}}, sub {
35 for (reverse 0..@stack-1) {
36 print "\n$_: ", showval($stack[$_], $set{base});
38 print "\n> "; # prompt
41 push @{$hook{showentry}}, sub {
42 print "\e[3G\e[K", $_[0]; # cursor to column #3; erase line
49 my $key = ReadKey; # wait for user input
51 $key .= $_ while defined ($_ = ReadKey(-1)); # read additional keys
59 title => "console output",