]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
scriptreplay: make Up/Down keys use a percentage instead of fixed amount
authorBenno Schulenberg <bensberg@telfort.nl>
Mon, 24 Feb 2025 13:08:36 +0000 (14:08 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 25 Feb 2025 07:50:57 +0000 (08:50 +0100)
Using a fixed 0.1 amount made each subsequent Down-arrow key slow things
down _more_, and each subsequent Up-arrow key speed things up _less_.
It's nicer when each subsequent keystroke has the same relative effect.

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
term-utils/scriptreplay.c

index 0e1444ca1d8754223fe7a4a156903c516e8b5087..5751e1b5206fd3c52c8ca9592afcde8692536c5c 100644 (file)
@@ -76,8 +76,8 @@ usage(void)
        fputs(USAGE_SEPARATOR, out);
        fputs(_("Key bindings:\n"), out);
        fputs(_(" space        toggles between pause and play\n"), out);
-       fputs(_(" up-arrow     increases the time divisor with 0.1\n"), out);
-       fputs(_(" down-arrow   decreases the time divisor with 0.1\n"), out);
+       fputs(_(" up-arrow     increases playback speed with ten percent\n"), out);
+       fputs(_(" down-arrow   decreases playback speed with ten percent\n"), out);
 
        fprintf(out, USAGE_MAN_TAIL("scriptreplay(1)"));
        exit(EXIT_SUCCESS);
@@ -343,10 +343,10 @@ main(int argc, char *argv[])
                        if (ch == '[') {
                                ch = fgetc(stdin);
                                if (ch == 'A') { /* Up arrow */
-                                       divi += 0.1;
+                                       divi *= 1.1;
                                        replay_set_delay_div(setup, divi);
                                } else if (ch == 'B') { /* Down arrow */
-                                       divi -= 0.1;
+                                       divi *= 0.9;
                                        if (divi < 0.1)
                                                divi = 0.1;
                                        replay_set_delay_div(setup, divi);