release 1.10.6
[descalc.git] / 08_stdout.pm
1 # console output for DCT, by Shiar
2
3 # 1.10.1 200410140120 - print everything to STDOUT
4 #     .2              - use escape sequences for clear/reposition/invert
5 #     .3              - try to get width/height from environment vars
6 #     .4              - never clear screen (just let it scroll)
7 #     .5 200410142200 - startup message omitted (now shown by main)
8
9 use strict;
10 use warnings;
11
12 return 0 if $set{display};
13 $set{display} = "stdout";
14
15 push @{$hook{init}}, sub {
16 #       print "\ec";  # reset (clear screen, go home)
17 #       print "\e[4mDCT $::VERSION\e[24m ";  # print intro (underlined)
18         END { print "\n"; }
19
20         $set{height} = $ENV{LINES}-2 if $ENV{LINES} and $ENV{LINES}>=3;
21         $set{width} = $ENV{COLUMNS} if $ENV{COLUMNS};
22 }; # init
23
24 push @{$hook{showerror}}, sub {
25         print "\n\a\e[7m$_[0]\e[27m";  # bell and reverse video
26 }; # showerror
27
28 push @{$hook{showstack}}, sub {
29         for (reverse 0..@stack-1) {
30                 print "\n$_: ", showval($stack[$_], $set{base});
31         } # show stack
32         print "\n> ";  # prompt
33 }; # showstack
34
35 push @{$hook{showentry}}, sub {
36         print "\e[3G\e[K", $_[0];  # cursor to column #3; erase line
37 }; # showentry
38
39 return {
40         author  => "Shiar",
41         title   => "console output",
42         version => "1.10.4",
43 };
44