wok view busybox/stuff/busybox-1.30-scriptreplay.u @ rev 21721

updated ptpython (0.28 -> 2.0.4)
author Hans-G?nter Theisgen
date Wed Jun 12 14:57:36 2019 +0100 (2019-06-12)
parents
children
line source
1 --- busybox-1.30/util-linux/scriptreplay.c
2 +++ busybox-1.30/util-linux/scriptreplay.c
3 @@ -17,10 +17,20 @@
5 //kbuild:lib-$(CONFIG_SCRIPTREPLAY) += scriptreplay.o
7 +//config:config SCRIPTREPLAY_HOTKEYS
8 +//config: bool "speed control hotkeys"
9 +//config: default n
10 +//config: depends on SCRIPTREPLAY
11 +//config: help
12 +//config: Tune replay speed with + - = space return hotkeys.
13 +
14 //usage:#define scriptreplay_trivial_usage
15 //usage: "TIMINGFILE [TYPESCRIPT [DIVISOR]]"
16 //usage:#define scriptreplay_full_usage "\n\n"
17 //usage: "Play back typescripts, using timing information"
18 +//usage: IF_SCRIPTREPLAY_HOTKEYS(
19 +//usage: " and + - = space return hotkeys"
20 +//usage: )
22 #include "libbb.h"
24 @@ -30,6 +40,10 @@
25 const char *script = "typescript";
26 double delay, factor = 1000000.0;
27 int fd;
28 +#if ENABLE_SCRIPTREPLAY_HOTKEYS
29 + int timeout = -1;
30 + char buffer[KEYCODE_BUFFER_SIZE];
31 +#endif
32 unsigned long count;
33 FILE *tfp;
35 @@ -47,6 +61,21 @@
36 while (fscanf(tfp, "%lf %lu\n", &delay, &count) == 2) {
37 usleep(delay * factor);
38 bb_copyfd_exact_size(fd, STDOUT_FILENO, count);
39 +#if ENABLE_SCRIPTREPLAY_HOTKEYS
40 + switch (read_key(0, buffer, timeout)) {
41 + case ' ':
42 + timeout = INT_MAX;
43 + break;
44 + case '=':
45 + factor = 1000000.0/2;
46 + case '-':
47 + factor *= 4;
48 + case '+':
49 + factor /= 2;
50 + default :
51 + timeout = -1;
52 + }
53 +#endif
54 }
55 if (ENABLE_FEATURE_CLEAN_UP) {
56 close(fd);