X-Git-Url: http://git.shiar.net/descalc.git/blobdiff_plain/b2aba05a22d1f4036008c2d12874ddc9eb98edc0..7d9af85556b0e64c70e3641764b7b49a306723f3:/08_stdout.pm diff --git a/08_stdout.pm b/08_stdout.pm new file mode 100644 index 0000000..ededf36 --- /dev/null +++ b/08_stdout.pm @@ -0,0 +1,44 @@ +# console output for DCT, by Shiar + +# 1.10.1 200410140120 - print everything to STDOUT +# .2 - use escape sequences for clear/reposition/invert +# .3 - try to get width/height from environment vars +# .4 - never clear screen (just let it scroll) +# .5 200410142200 - startup message omitted (now shown by main) + +use strict; +use warnings; + +return 0 if $set{display}; +$set{display} = "stdout"; + +push @{$hook{init}}, sub { +# print "\ec"; # reset (clear screen, go home) +# print "\e[4mDCT $::VERSION\e[24m "; # print intro (underlined) + END { print "\n"; } + + $set{height} = $ENV{LINES}-2 if $ENV{LINES} and $ENV{LINES}>=3; + $set{width} = $ENV{COLUMNS} if $ENV{COLUMNS}; +}; # init + +push @{$hook{showerror}}, sub { + print "\n\a\e[7m$_[0]\e[27m"; # bell and reverse video +}; # showerror + +push @{$hook{showstack}}, sub { + for (reverse 0..@stack-1) { + print "\n$_: ", showval($stack[$_], $set{base}); + } # show stack + print "\n> "; # prompt +}; # showstack + +push @{$hook{showentry}}, sub { + print "\e[3G\e[K", $_[0]; # cursor to column #3; erase line +}; # showentry + +return { + author => "Shiar", + title => "console output", + version => "1.10.4", +}; +