wok-next annotate busybox/stuff/patches/scriptreplay.u @ rev 21723

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