]> skyeroc.xyz Git - dgamelaunch/commitdiff
Selecting a game to watch with an uppercase letter attempts to change the
authorJilles Tjoelker <jilles@stack.nl>
Thu, 4 Mar 2004 14:38:02 +0000 (14:38 +0000)
committerJilles Tjoelker <jilles@stack.nl>
Thu, 4 Mar 2004 14:38:02 +0000 (14:38 +0000)
window size to the game's via the \033[8;<r>;<c>t sequence. Block SIGWINCH
before sending this sequence and unblock it after calling initcurses() again.

git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@267 db0b04b0-f4d1-0310-9a6d-de3e77497b0e

Changelog
dgamelaunch.c

index 321f5c2dc0d21dcb76d103c870c3661077919a70..3f12a1af65d16bbe545b51bb64cc8d5d5cd3eb73 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -5,6 +5,9 @@
          clients and force them to 80x24.
        * Pass window size to watchers via inprogress file; show it on the
          list.
+       * Selecting a game to watch with an uppercase letter attempts to
+         change the window size to the game's via the \033[8;<r>;<c>t
+         sequence.
 
 1.4.3 (2004/02/28)
        * Make ttyplay use the 'strip' value it remembered from last view.
index 21a033d991b510c9268d1c447752544397ba4b23..bb104ce01733ef1399959dfb65974ec58ca601a6 100644 (file)
@@ -306,10 +306,11 @@ drawbanner (unsigned int start_line, unsigned int howmany)
 void
 inprogressmenu ()
 {
-  int i, menuchoice, len = 20, offset = 0;
+  int i, menuchoice, len = 20, offset = 0, doresizewin = 0;
   time_t ctime;
   struct dg_game **games;
   char ttyrecname[130], *replacestr = NULL;
+  sigset_t oldmask, toblock;
 
   games = populate_games (&len);
 
@@ -321,7 +322,7 @@ inprogressmenu ()
                 "During playback, hit 'q' to return here, 'm' to send mail (requires login),");
       mvaddstr (4, 1,
                 "'s' to toggle graphic-set stripping for DEC, IBM, and none.");
-      mvaddstr (5, 1, "The following games are in progress:");
+      mvaddstr (5, 1, "The following games are in progress: (use uppercase to try to change size)");
 
       /* clean old games and list good ones */
       i = 0;
@@ -345,7 +346,7 @@ inprogressmenu ()
                 "Watch which game? (any key refreshes, 'q' quits, '>'/'<' for more/less) => ");
       refresh ();
 
-      switch ((menuchoice = tolower (getch ())))
+      switch ((menuchoice = getch ()))
         {
         case '>':
           if ((offset + 14) >= len)
@@ -361,11 +362,17 @@ inprogressmenu ()
             offset -= 14;
           break;
 
-        case 'q':
+       case 'q': case 'Q':
           return;
 
         default:
-          if ((menuchoice - 97) >= 0 && (menuchoice - 97) < i)
+         doresizewin = 0;
+         if (isupper (menuchoice))
+           {
+             doresizewin = 1;
+             menuchoice = tolower (menuchoice);
+           }
+          if ((menuchoice - 'a') >= 0 && (menuchoice - 'a') < i)
             {
               /* valid choice has been made */
               snprintf (ttyrecname, 130, "%sttyrec/%s", myconfig->dglroot,
@@ -383,8 +390,24 @@ inprogressmenu ()
               clear ();
               refresh ();
               endwin ();
+             if (doresizewin)
+               {
+                 /*
+                  * Let curses deal with the resize later. Perhaps this is
+                  * not the best way.
+                  */
+                 sigemptyset (&toblock);
+                 sigaddset (&toblock, SIGWINCH);
+                 sigprocmask (SIG_BLOCK, &toblock, &oldmask);
+                 printf ("\033[8;%d;%dt",
+                   games[menuchoice - 97 + offset]->ws_row,
+                   games[menuchoice - 97 + offset]->ws_col);
+                 fflush (stdout);
+               }
               ttyplay_main (ttyrecname, 1);
               initcurses ();
+             if (doresizewin)
+               sigprocmask (SIG_SETMASK, &oldmask, NULL);
             }
         }