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