wok-next annotate busybox/stuff/1.26/scriptreplay.u @ rev 19590

Synchronize my host updates with the wok-next...
author Aleksej Bobylev <al.bobylev@gmail.com>
date Sat Jan 21 11:59:37 2017 +0200 (2017-01-21)
parents
children
rev   line source
al@19590 1 --- busybox-1.26/util-linux/scriptreplay.c
al@19590 2 +++ busybox-1.26/util-linux/scriptreplay.c
al@19590 3 @@ -8,10 +8,20 @@
al@19590 4 *
al@19590 5 */
al@19590 6
al@19590 7 +//config:config SCRIPTREPLAY_HOTKEYS
al@19590 8 +//config: bool "speed control hotkeys"
al@19590 9 +//config: default n
al@19590 10 +//config: depends on SCRIPTREPLAY
al@19590 11 +//config: help
al@19590 12 +//config: Tune replay speed with + - = space return hotkeys.
al@19590 13 +
al@19590 14 //usage:#define scriptreplay_trivial_usage
al@19590 15 //usage: "timingfile [typescript [divisor]]"
al@19590 16 //usage:#define scriptreplay_full_usage "\n\n"
al@19590 17 //usage: "Play back typescripts, using timing information"
al@19590 18 +//usage: IF_SCRIPTREPLAY_HOTKEYS(
al@19590 19 +//usage: " and + - = space return hotkeys"
al@19590 20 +//usage: )
al@19590 21
al@19590 22 #include "libbb.h"
al@19590 23
al@19590 24 @@ -21,6 +31,10 @@
al@19590 25 const char *script = "typescript";
al@19590 26 double delay, factor = 1000000.0;
al@19590 27 int fd;
al@19590 28 +#if ENABLE_SCRIPTREPLAY_HOTKEYS
al@19590 29 + int timeout = -1;
al@19590 30 + char buffer[KEYCODE_BUFFER_SIZE];
al@19590 31 +#endif
al@19590 32 unsigned long count;
al@19590 33 FILE *tfp;
al@19590 34
al@19590 35 @@ -38,6 +52,21 @@
al@19590 36 while (fscanf(tfp, "%lf %lu\n", &delay, &count) == 2) {
al@19590 37 usleep(delay * factor);
al@19590 38 bb_copyfd_exact_size(fd, STDOUT_FILENO, count);
al@19590 39 +#if ENABLE_SCRIPTREPLAY_HOTKEYS
al@19590 40 + switch (read_key(0, buffer, timeout)) {
al@19590 41 + case ' ':
al@19590 42 + timeout = INT_MAX;
al@19590 43 + break;
al@19590 44 + case '=':
al@19590 45 + factor = 1000000.0/2;
al@19590 46 + case '-':
al@19590 47 + factor *= 4;
al@19590 48 + case '+':
al@19590 49 + factor /= 2;
al@19590 50 + default :
al@19590 51 + timeout = -1;
al@19590 52 + }
al@19590 53 +#endif
al@19590 54 }
al@19590 55 if (ENABLE_FEATURE_CLEAN_UP) {
al@19590 56 close(fd);