Package: ttyrec Version: 1.0.6-1 Severity: wishlist Tags: patch I would find a pause button useful in ttyplay. One can sort of simulate it by pressing '-' a number of times, but (a) that's inconvenient and (b) it doesn't allow for immediately pausing playback at the current point because the playback advances each time you press '-'.
A patch implementing this is attached. I considered the space bar as the pause button by analogy with popular media players, but noted that I have a habit of pressing space to advance so thought that other people might have the same habit and be annoyed to have it broken. Instead I chose '0', to match the existing '1' binding to set the speed to 1.0. A naïve implementation simply sets the speed to 0.0 when you press '0', and arranges for a speed of 0.0 to translate to passing NULL as the select timeout. This is OK, but it still means that pressing '0' advances the recording by one position and then pauses. I use ttyplay to play back recordings of NetHack games, and in that context I often want to pause immediately, for example just as the player's inventory is displayed. I thus also adjusted the ttyplay function to repeatedly call wait_func until speed is non-zero (and ttywrite to return 1.0 rather than 0.0), which fixes this. Thanks, -- Colin Watson [EMAIL PROTECTED]
--- ttyrec-1.0.6.orig/ttyplay.c +++ ttyrec-1.0.6/ttyplay.c @@ -81,13 +81,16 @@ ttywait (struct timeval prev, struct timeval cur, double speed) { struct timeval diff = timeval_diff(prev, cur); + struct timeval *diffp = &diff; fd_set readfs; - assert(speed != 0); - diff = timeval_div(diff, speed); + if (speed == 0) + diffp = NULL; + else + diff = timeval_div(diff, speed); FD_SET(STDIN_FILENO, &readfs); - select(1, &readfs, NULL, NULL, &diff); /* skip if a user hits any key */ + select(1, &readfs, NULL, NULL, diffp); /* skip if a user hits any key */ if (FD_ISSET(0, &readfs)) { /* a user hits a character? */ char c; read(STDIN_FILENO, &c, 1); /* drain the character */ @@ -103,6 +106,9 @@ case '1': speed = 1.0; break; + case '0': + speed = 0.0; + break; } } return speed; @@ -112,7 +118,7 @@ ttynowait (struct timeval prev, struct timeval cur, double speed) { /* do nothing */ - return 0; /* Speed isn't important. */ + return 1.0; /* Speed isn't important. */ } int @@ -178,7 +184,9 @@ } if (!first_time) { - speed = wait_func(prev, h.tv, speed); + do { + speed = wait_func(prev, h.tv, speed); + } while (speed == 0.0); } first_time = 0;