AnalogTerm2: Add the -l option for custom additional leading.
authorMatthew Mondor <mmondor@pulsar-zone.net>
Sat, 1 Apr 2023 12:00:01 +0000 (12:00 +0000)
committerMatthew Mondor <mmondor@pulsar-zone.net>
Sat, 1 Apr 2023 12:00:01 +0000 (12:00 +0000)
mmsoftware/analogterm2/src/config.c
mmsoftware/analogterm2/src/config.h
mmsoftware/analogterm2/src/draw.c
mmsoftware/analogterm2/src/main.c
mmsoftware/analogterm2/src/screen.c

index 095e177..3170317 100644 (file)
@@ -41,6 +41,7 @@ bool  cfg_condensed;
 bool   cfg_stderr;
 bool   cfg_sleep;
 bool   cfg_slowscroll;
+int    cfg_leading;
 
 
 void
@@ -74,6 +75,8 @@ cfg_setdefaults(void)
        cfg_stderr = false;
        cfg_sleep = false;
        cfg_slowscroll = SLOW_SCROLL;
+
+       cfg_leading = EXTRA_LEADING;
 }
 
 int 
index d21dec3..34451d5 100644 (file)
@@ -93,7 +93,7 @@ extern bool cfg_cursordisable;
 
 
 /*
- *
+ * Reset cursor timer when printing, not only for user input.
  */
 
 #define CURSOR_PRINTRESET      false
@@ -243,6 +243,16 @@ extern bool cfg_slowscroll;
 
 
 /*
+ * Add extra leading between lines in pixels.
+ * This will affect the vertical connection of graphics characters but can
+ * also improve the readability of normal text.
+ */
+#define EXTRA_LEADING          0
+
+extern int cfg_leading;
+
+
+/*
  * The XShm extention allows to accelerate graphics when the client is running
  * on the same system as the X11 server.
  */
index 13ec8c6..2709d7f 100644 (file)
@@ -28,6 +28,7 @@
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
+#include <string.h>
 #include <sys/time.h>
 
 #include <state.h>
@@ -73,6 +74,7 @@ static uint32_t               *row_modes = NULL;
 static bool            *row_selected = NULL;
 static int             scanjmp = 0;
 static int             blink_ticks = 0;
+static uint8_t         empty[FONT_WIDTH];
 
 /* Exported as a general utility */
 bool                   draw_blink_state = true;
@@ -86,6 +88,8 @@ draw_init(state_t *st, screen_t *sc)
        struct sigaction act;
        struct itimerval itv;
 
+       (void)memset(empty, 0, FONT_WIDTH);
+
        state = st;
        screen = sc;
        color = cfg_color;
@@ -266,8 +270,9 @@ draw_lines(state_t *st, screen_t *sc, int low, int high)
        sc->update_w = scanjmp;
 
        /* XXX May want to adjust instead of always resetting */
-       sc->update_y = low * FONT_HEIGHT * 2;
-       sc->update_h = ((high + 1) * (FONT_HEIGHT * 2)) - sc->update_y;
+       sc->update_y = low * (FONT_HEIGHT + cfg_leading) * 2;
+       sc->update_h = ((high + 1) * ((FONT_HEIGHT + cfg_leading) * 2))
+           - sc->update_y;
 
        /* scanptr2 points to the odd scanline below scanptr1 */
        scanptr1 = &sc->pixels[sc->update_y * scanjmp];
@@ -333,7 +338,7 @@ draw_lines(state_t *st, screen_t *sc, int low, int high)
                        else
                                row_selected[col] = false;
                }
-               for (grow = 0; grow < FONT_HEIGHT; grow++) {
+               for (grow = 0; grow < (FONT_HEIGHT + cfg_leading); grow++) {
                        bool lastbg = false;
 
                        scanptr1_next = &scanptr1[scanjmp * 2];
@@ -343,7 +348,9 @@ draw_lines(state_t *st, screen_t *sc, int low, int high)
 
                        for (col = 0; col < cfg_text_width; col++) {
                                uint8_t (*cf)[FONT_WIDTH] = row_glyphs[col],
-                                   *cb = cf[grow], rev, last = 0;
+                                   *cb = (grow < FONT_HEIGHT ? cf[grow] :
+                                         empty),
+                                   rev, last = 0;
                                uint32_t m = row_modes[col];
                                int bit, level, olevel, iblink, fgcolor,
                                    bgcolor;
@@ -416,7 +423,7 @@ draw_lines(state_t *st, screen_t *sc, int low, int high)
        }
 
                /* Inverse for XOR cursor */
-               if (cursor_xor == col &&
+               if (cursor_xor == col && grow < FONT_HEIGHT &&
                    ((st->cursor_mode == CMODE_BLOCK) ||
                     (st->cursor_mode == CMODE_LINE &&
                      grow >= (FONT_HEIGHT - 2)) ||
index dbcd97e..6e7e05f 100644 (file)
@@ -171,7 +171,7 @@ usage(void)
            "\nUsage: %s [-8|-u] [-w <cols>] [-h <rows>] [-E <n>] [-s]\n"
            "    [-C <color>] [-c] [-W] [-b] [-B <microseconds>] [-P]\n"
            "    [-m <mode>] [-M] [-d] [-D] [-S] [-p <parameters>]\n"
-           "    [-e <command> [<arguments>]]\n\n"
+           "    [-l <pixels>] [-e <command> [<arguments>]]\n\n"
            "Where:\n"
            " -8 / -u - 8-bit mode (Latin-1), unicode+UTF-8.  8-bit mode is\n"
            "           automatically enabled by default if the LANG\n"
@@ -203,6 +203,8 @@ usage(void)
            "      before exiting.  This is useful to view the output of\n"
            "      custom commands.\n"
            " -p - Analog scanline parameters.  These are described below.\n"
+           " -l - Add extra leading pixels between lines.  This will also\n"
+           "      affect the vertical connectivity of graphics characters.\n"
            " -e - Execute command and its arguments instead of $SHELL.\n"
            "      Must be the last AnalogTerm2 argument if used, because\n"
            "      other arguments will be passed to the command.\n"
@@ -246,7 +248,7 @@ main(int argc, char **argv, char **envp)
        cfg_unicode = !locale_8bit();
 
        progname = strdup(argv[0]);
-       while ((ch = getopt(argc, argv, "?8uw:h:E:scC:Wr:bB:Pm:MdDSp:e:"))
+       while ((ch = getopt(argc, argv, "?8uw:h:E:scC:Wr:bB:Pm:MdDSp:l:e:"))
            != -1) {
                switch (ch) {
                case '8':
@@ -328,6 +330,10 @@ main(int argc, char **argv, char **envp)
                case 'p':
                        cfg_setparams(optarg);
                        break;
+               case 'l':
+                       if ((i = atoi(optarg)) >= -1 && i <= FONT_HEIGHT)
+                               cfg_leading = i;
+                       break;
                case 'e':
                        {
                                int l;
index ebe8533..3e87408 100644 (file)
@@ -151,9 +151,10 @@ screen_init(void)
        else
                width = ((cfg_text_width * FONT_WIDTH) * 2) + 1;
 #ifdef EXPAND_Y
-       height = ((int)((cfg_text_height * FONT_HEIGHT) * 2.5) + 1);
+       height = ((int)((cfg_text_height * (FONT_HEIGHT + cfg_leading)) * 2.5)
+           + 1);
 #else
-       height = (cfg_text_height * FONT_HEIGHT) * 2;
+       height = (cfg_text_height * (FONT_HEIGHT + cfg_leading)) * 2;
 #endif
 
        s->pixels_width = width;