AnalogTerm2: Add -2 option for 2-pixel skip smooth scrolling.
authorMatthew Mondor <mmondor@pulsar-zone.net>
Wed, 26 Apr 2023 14:45:30 +0000 (14:45 +0000)
committerMatthew Mondor <mmondor@pulsar-zone.net>
Wed, 26 Apr 2023 14:45:30 +0000 (14:45 +0000)
mmsoftware/analogterm2/src/config.c
mmsoftware/analogterm2/src/config.h
mmsoftware/analogterm2/src/draw.c
mmsoftware/analogterm2/src/main.c

index 6e1b739..6120875 100644 (file)
@@ -67,7 +67,7 @@ bool  cfg_condensed;
 bool   cfg_stderr;
 bool   cfg_sleep;
 bool   cfg_slowscroll, cfg_smoothscroll;
-int    cfg_jumpscrolllines;
+int    cfg_jumpscrolllines, cfg_smoothscrollskip;
 int    cfg_leading;
 int    cfg_inputsleep, cfg_inputsleepskip;
 bool   cfg_uppercaseview;
@@ -107,6 +107,7 @@ cfg_setdefaults(void)
        cfg_sleep = false;
        cfg_slowscroll = SLOW_SCROLL;
        cfg_smoothscroll = SMOOTH_SCROLL;
+       cfg_smoothscrollskip = SMOOTH_SCROLL_SKIP;
        cfg_jumpscrolllines = JUMP_SCROLL_LINES;
 
        cfg_leading = EXTRA_LEADING;
index 886c1e2..9504d6f 100644 (file)
@@ -265,13 +265,15 @@ extern bool cfg_unicode;
  * JUMP_SCROLL_LINES specifies how many lines of scrolling to allow at a time
  * before forcing a refresh.  SMOOTH_SCROLL means that pixel-level smooth
  * scrolling should be enabled when SLOW_SCROLL is also enabled.
+ * SMOOTH_SCROLL_SKIP configures how many vertical pixels to scroll per frame.
  */
 #define SLOW_SCROLL            false
 #define SMOOTH_SCROLL          false
+#define SMOOTH_SCROLL_SKIP     1
 #define JUMP_SCROLL_LINES      8
 
 extern bool cfg_slowscroll, cfg_smoothscroll;
-extern int  cfg_jumpscrolllines;
+extern int  cfg_jumpscrolllines, cfg_smoothscrollskip;
 
 
 /*
index c09b8f3..0b5361d 100644 (file)
@@ -339,8 +339,7 @@ draw_lines(state_t *st, screen_t *sc, int low, int high)
         * If done, disable and request one last full refresh.
         */
        if (st->smoothscroll_offset > 0) {
-               /* XXX Skip could be configurable */
-               if (--st->smoothscroll_offset <= 0) {
+               if ((st->smoothscroll_offset -= cfg_smoothscrollskip) <= 0) {
                        st->smoothscroll_offset = 0;
                        st->text_updateall = true;
                }
index db8eb02..d6e2500 100644 (file)
@@ -202,13 +202,14 @@ usage(void)
 
        errno = EINVAL;
        fprintf(stderr,
-           "\nUsage: %s [-1] [-8|-u] [-w <cols>] [-h <rows>] [-E <n>] [-s]\n"
-           "    [-C <col>] [-c] [-W] [-b] [-r <ms>] [-B <ticks>[,<ticks>]]\n"
-           "    [-j <n>] [-P] [-m <mode>] [-M] [-d] [-D] [-S]\n"
-           "    [-p <parameters>] [-l <pixels>] [-f <delay>] [-U] [-z <ms>]\n"
-           "    [-Z <skip>] [-e <command> [<arguments>]]\n\n"
+           "\nUsage: %s [-1 | -2] [-8|-u] [-w <cols>] [-h <rows>] [-E <n>]\n"
+           "    [-s] [-C <col>] [-c] [-W] [-b] [-r <ms>]\n"
+           "    [-B <ticks>[,<ticks>]] [-j <n>] [-P] [-m <mode>] [-M] [-d]\n"
+           "    [-D] [-S] [-p <parameters>] [-l <pixels>] [-f <delay>]\n"
+           "    [-U] [-z <ms>] [-Z <skip>] [-e <command> [<arguments>]]\n\n"
            "Where:\n"
            " -1 - Activate slow and smooth scrolling at startup.\n"
+           " -2 - Like -1 but scrolls at 2x speed (2 pixels per frame).\n"
            " -8 / -u - 8-bit mode (Latin-1), unicode+UTF-8.  8-bit mode is\n"
            "           automatically enabled by default if the LANG\n"
            "           environment variable is \"C\" or contains \"8859\".\n"
@@ -318,11 +319,15 @@ main(int argc, char **argv, char **envp)
 
        progname = strdup(argv[0]);
        while ((ch = getopt(argc, argv,
-           "?18uw:h:E:scC:Wr:bB:j:Pm:MdDSp:l:f:Uz:Z:e:")) != -1) {
+           "?128uw:h:E:scC:Wr:bB:j:Pm:MdDSp:l:f:Uz:Z:e:")) != -1) {
                switch (ch) {
                case '1':
                        cfg_slowscroll = cfg_smoothscroll = true;
                        break;
+               case '2':
+                       cfg_slowscroll = cfg_smoothscroll = true;
+                       cfg_smoothscrollskip = 2;
+                       break;
                case '8':
                        cfg_unicode = false;
                        break;