1 # s-lang output for DCT, by Shiar
3 # 1.12.0 200411032145 - define main loop
4 # - use slang key reading functions
5 # 1.11.0 200410291300 -
10 use Term::Slang qw(:all);
12 push @{$hook{init}}, sub {
13 SLtt_get_terminfo and exit;
14 SLang_init_tty(-1, 0, 1);
17 END { SLsmg_reset_smg; SLang_reset_tty; } # shutdown display system
19 # where are $SLtt_Screen_Rows and $SLtt_Screen_Cols?
20 ($set{height}, $set{width}) = SLtt_get_screen_size;
24 push @{$hook{showerror}}, sub {
26 SLsmg_draw_box(0, 0, 3, length($error)+4);
28 SLsmg_write_string(" $error ");
31 SLang_getkey; # wait for confirm
32 SLang_getkey while SLang_input_pending(0)==1; # clear key buffer
35 push @{$hook{showstack}}, sub {
37 SLsmg_gotorc($set{height}-$_, 1);
38 SLsmg_write_string("$_: ".showval($stack[$_], $set{base})); # prompt
41 SLsmg_gotorc($set{height}-@stack, 1);
45 push @{$hook{refresh}}, sub {
47 SLsmg_gotorc($set{height}+1, 0);
48 SLsmg_write_string("> "); # prompt
51 push @{$hook{showentry}}, sub {
52 SLsmg_gotorc($set{height}+1, 2);
53 SLsmg_write_string($_[0]);
62 my $key = chr SLang_getkey; # wait for user input
64 $key .= chr SLang_getkey while SLang_input_pending(0)==1; # read additional keys
66 # error(join " ", map ord, split //, $key); #debug
73 title => "slang output",