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;
int max_height = -1;
int selected = -1;
+ int resizex = -1;
+ int resizey = -1;
+
char *selectedgame = NULL;
int abs_max_height;
clear ();
break;
- case '1':
- doresizewin = (doresizewin ? 0 : 1);
- break;
-
case 13:
case 10:
case KEY_ENTER:
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("<Anonymous> [watching %s]", chosen_name);
- ttyplay_main (ttyrecname, 1);
+ ttyplay_main (ttyrecname, 1, resizex, resizey);
if (loggedin)
setproctitle("%s", me->username);
else
setproctitle("<Anonymous>");
initcurses ();
- if (doresizewin)
- sigprocmask (SIG_SETMASK, &oldmask, NULL);
}
}
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.
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)
{
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)
{
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;
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);
if (old_sigwinch != SIG_ERR)
signal(SIGWINCH, old_sigwinch);
+ term_resizex = term_resizey = -1;
+
return 0;
}
#include <stdio.h>
#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);