release 1.14pre1
[descalc.git] / 03_disp_slang.pm
index 6d8c62d8fe2acafbaaa10a2a7e7639b6e019749f..7bac3ccc180e6b544ed2ef6d34f54b671e5e748f 100644 (file)
@@ -1,5 +1,6 @@
 # s-lang output for DCT, by Shiar
 
+# 1.14.0 200508261255 - SIGWINCH handler to redraw on screen resize
 # 1.13.0 200411042100 - menu i/o functions
 #                     - refresh hook renamed to showall
 # 1.12.0 200411032145 - define main loop
@@ -14,6 +15,12 @@ use Term::Slang qw(:all);
 use vars qw(%falias $path);
 require $path."termcommon.pm";
 
+sub setsize {
+       ($set{height}, $set{width}) = @_;
+       $set{height} -= 3;
+       $set{menushow} = int($set{width}/(4+$set{width}/20))+1;  # menu items to show simultaneously
+} # setsize
+
 push @{$hook{init}}, sub {
        SLtt_get_terminfo and exit;
        SLang_init_tty(-1, 0, 1);
@@ -22,10 +29,16 @@ push @{$hook{init}}, sub {
        
        END { SLsmg_reset_smg; SLang_reset_tty; } # shutdown display system
 
+       $SIG{WINCH} = sub {
+               #xxx: no signal until keypress?
+               setsize(SLtt_get_screen_size);  # get new screen size
+               SLsmg_reinit_smg;  # reinitialize to use new size
+               redraw(all=>1);  # queue complete refresh
+               draw();  # redraw rightnow
+       }; # window change (resize)
+
        # where are $SLtt_Screen_Rows and $SLtt_Screen_Cols?
-       ($set{height}, $set{width}) = SLtt_get_screen_size;
-       $set{height} -= 3;
-       $set{menushow} = int($set{width}/(4+$set{width}/20))+1;  # menu items to show simultaneously
+       setsize(SLtt_get_screen_size);
 }; # init
 
 push @{$hook{showerror}}, sub {
@@ -113,6 +126,6 @@ $hook{main} = sub {
 return {
        author  => "Shiar",
        title   => "slang output",
-       version => "1.13",
+       version => "1.14",
 };