Created
April 22, 2013 06:26
-
-
Save Gottox/5432821 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -upr ttyrec-1.0.8/ttyplay.c ttyrec-1.0.8.patched/ttyplay.c | |
--- ttyrec-1.0.8/ttyplay.c 2006-06-11 17:52:50.000000000 +0200 | |
+++ ttyrec-1.0.8.patched/ttyplay.c 2013-04-21 22:23:07.000000000 +0200 | |
@@ -132,6 +132,26 @@ ttywait (struct timeval prev, struct tim | |
return speed; | |
} | |
+int dropCommands = 0; | |
+double | |
+ttyspacewait (struct timeval prev, struct timeval cur, double speed) | |
+{ | |
+ char c = '0'; | |
+ if(dropCommands != 0) { | |
+ dropCommands--; | |
+ return 0; | |
+ } | |
+ | |
+ while(strchr("\n ", c = fgetc(stdin)) == NULL) { | |
+ if(c < '0' || c > '9') { | |
+ dropCommands = 0; | |
+ continue; | |
+ } | |
+ dropCommands = dropCommands * 10 + (c - '0'); | |
+ } | |
+ return 0; /* Speed isn't important. */ | |
+} | |
+ | |
double | |
ttynowait (struct timeval prev, struct timeval cur, double speed) | |
{ | |
@@ -241,6 +261,8 @@ usage (void) | |
printf("Usage: ttyplay [OPTION] [FILE]\n"); | |
printf(" -s SPEED Set speed to SPEED [1.0]\n"); | |
printf(" -n No wait mode\n"); | |
+ printf(" -t type mode. space or enter for next sequence\n"); | |
+ printf(" -d STEPS drop STEPS steps before pausing in type mode"); | |
printf(" -p Peek another person's ttyrecord\n"); | |
exit(EXIT_FAILURE); | |
} | |
@@ -270,7 +292,7 @@ main (int argc, char **argv) | |
set_progname(argv[0]); | |
while (1) { | |
- int ch = getopt(argc, argv, "s:np"); | |
+ int ch = getopt(argc, argv, "s:nptd:"); | |
if (ch == EOF) { | |
break; | |
} | |
@@ -282,9 +304,19 @@ main (int argc, char **argv) | |
} | |
sscanf(optarg, "%lf", &speed); | |
break; | |
+ case 'd': | |
+ if (optarg == NULL) { | |
+ perror("-d option requires an argument"); | |
+ exit(EXIT_FAILURE); | |
+ } | |
+ dropCommands = atoi(optarg); | |
+ break; | |
case 'n': | |
wait_func = ttynowait; | |
break; | |
+ case 't': | |
+ wait_func = ttyspacewait; | |
+ break; | |
case 'p': | |
process = ttypeek; | |
break; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment