X-Git-Url: http://git.shiar.net/descalc.git/blobdiff_plain/b2aba05a22d1f4036008c2d12874ddc9eb98edc0..7d9af85556b0e64c70e3641764b7b49a306723f3:/05_curses.pm diff --git a/05_curses.pm b/05_curses.pm new file mode 100644 index 0000000..73e0d01 --- /dev/null +++ b/05_curses.pm @@ -0,0 +1,56 @@ +# ncurses output for DCT, by Shiar + +# 1.10.1 200410140120 - all output functions seperated from main + +use strict; +use warnings; + +use Curses; + +return 0 if $set{display}; +$set{display} = "curses"; + +push @{$hook{init}}, sub { + initscr; + END { endwin; } # restore terminal on quit + + $set{height} = $LINES-2 if $LINES>=3; + $set{width} = $COLS if $COLS; +}; # init + +push @{$hook{showerror}}, sub { + attron(A_REVERSE); + addstr(0, 0, shift); + attroff(A_REVERSE); + clrtoeol; + refresh; + + ReadKey; # wait for confirm + 1 while defined ReadKey(-1); # clear key buffer +}; # showerror + +push @{$hook{showstack}}, sub { + for (0..@stack-1) { + addstr($set{height}-$_, 1, "$_: ".showval($stack[$_], $set{base})); + clrtoeol; + } # show stack + clrtoeol($set{height}-@stack, 1); +}; # showstack + +push @{$hook{refresh}}, sub { + clear; + addstr($set{height}+1, 0, "> "); # prompt +}; # refresh + +push @{$hook{showentry}}, sub { + addstr($set{height}+1, 2, $_[0]); + clrtoeol; + refresh; +}; # showentry + +return { + author => "Shiar", + title => "curses output", + version => "1.10.1", +}; +