diff --git a/dgamelaunch.c b/dgamelaunch.c index b54b06f..b1eb954 100644 --- a/dgamelaunch.c +++ b/dgamelaunch.c @@ -372,7 +372,7 @@ void inprogressmenu (int gameid) { const char *selectorchars = "abcdefghijklmnoprstuvwxyzABCDEFGHIJKLMNOPRSTUVWXYZ"; - int i, menuchoice, len = 20, offset = 0, doresizewin = 0; + int i, menuchoice, len = 20, offset = 0; static dg_sortmode sortmode = NUM_SORTMODES; time_t ctime; struct dg_game **games = NULL; @@ -383,6 +383,9 @@ inprogressmenu (int gameid) int max_height = -1; int selected = -1; + int resizex = -1; + int resizey = -1; + char *selectedgame = NULL; int abs_max_height; @@ -559,10 +562,6 @@ inprogressmenu (int gameid) clear (); break; - case '1': - doresizewin = (doresizewin ? 0 : 1); - break; - case 13: case 10: case KEY_ENTER: @@ -608,32 +607,19 @@ watchgame: 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[idx]->ws_row, - games[idx]->ws_col); - fflush (stdout); - } + + resizey = games[idx]->ws_row; + resizex = games[idx]->ws_col; if (loggedin) setproctitle("%s [watching %s]", me->username, chosen_name); else setproctitle(" [watching %s]", chosen_name); - ttyplay_main (ttyrecname, 1); + ttyplay_main (ttyrecname, 1, resizex, resizey); if (loggedin) setproctitle("%s", me->username); else setproctitle(""); initcurses (); - if (doresizewin) - sigprocmask (SIG_SETMASK, &oldmask, NULL); } } diff --git a/examples/dgl_menu_watchmenu_help.txt b/examples/dgl_menu_watchmenu_help.txt index 22feb71..dfde163 100644 --- a/examples/dgl_menu_watchmenu_help.txt +++ b/examples/dgl_menu_watchmenu_help.txt @@ -13,10 +13,10 @@ While watching a game --------------------- - q returns back to the watching menu. + q return back to the watching menu. m send mail to the player (requires login). s toggle charset stripping between DEC/IBM/none. - + r resize your terminal to match the player's terminal. Press 'q' or space to return to the watching menu. diff --git a/ttyplay.c b/ttyplay.c index c269f46..5a9c7a7 100644 --- a/ttyplay.c +++ b/ttyplay.c @@ -61,6 +61,9 @@ int stripped = NO_GRAPHICS; static int got_sigwinch = 0; +static int term_resizex = -1; +static int term_resizey = -1; + void ttyplay_sigwinch_func(int sig) { @@ -247,6 +250,10 @@ ttypread (FILE * fp, Header * h, char **buf, int pread) case 'q': return READ_EOF; break; + case 'r': + if (term_resizex > 0 && term_resizey > 0) + printf ("\033[8;%d;%dt", term_resizey, term_resizex); + break; case 's': switch (stripped) { @@ -445,7 +452,7 @@ ttypeek (FILE * fp, double speed) int -ttyplay_main (char *ttyfile, int mode) +ttyplay_main (char *ttyfile, int mode, int resizex, int resizey) { double speed = 1.0; ReadFunc read_func = ttyread; @@ -465,6 +472,12 @@ ttyplay_main (char *ttyfile, int mode) new.c_cc[VTIME] = 0; tcsetattr (0, TCSANOW, &new); /* Make it current */ + + if (resizex > 0 && resizey > 0) { + term_resizex = resizex; + term_resizey = resizey; + } + got_sigwinch = 0; old_sigwinch = signal(SIGWINCH, ttyplay_sigwinch_func); @@ -479,5 +492,7 @@ ttyplay_main (char *ttyfile, int mode) if (old_sigwinch != SIG_ERR) signal(SIGWINCH, old_sigwinch); + term_resizex = term_resizey = -1; + return 0; } diff --git a/ttyplay.h b/ttyplay.h index 1dd36e8..27e1a6c 100644 --- a/ttyplay.h +++ b/ttyplay.h @@ -4,7 +4,7 @@ #include #include "ttyrec.h" -int ttyplay_main (char *ttyfile, int mode); +int ttyplay_main (char *ttyfile, int mode, int resizex, int resizey); typedef double (*WaitFunc) (struct timeval prev, struct timeval cur, double speed);