Move the terminal resize to when you're watching the game.
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@501 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
This commit is contained in:
parent
5c0a1876fb
commit
f07d814c27
|
@ -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("<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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
17
ttyplay.c
17
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue