AnalogTerm2: Adjust cursor, overstrike and underline attributes
authorMatthew Mondor <mmondor@pulsar-zone.net>
Mon, 10 Apr 2023 20:48:40 +0000 (20:48 +0000)
committerMatthew Mondor <mmondor@pulsar-zone.net>
Mon, 10 Apr 2023 20:48:40 +0000 (20:48 +0000)
for when custom leading is used (-l <n>).

mmsoftware/analogterm2/src/draw.c

index 9ee15ae..ca9af74 100644 (file)
@@ -23,6 +23,7 @@
 
 
 #include <err.h>
+#include <math.h>
 #include <signal.h>
 #include <stdbool.h>
 #include <stdio.h>
@@ -256,10 +257,14 @@ static void
 draw_lines(state_t *st, screen_t *sc, int low, int high)
 {
        uint32_t *scanptr1, *scanptr2, *scanptr1_next;
-       int row;
+       int row, srow, urow;
 
        color = st->monocolor;
 
+       /* Row to underline or strike if the attribute is enabled */
+       srow = (int)ceil(((double)FONT_HEIGHT) / 2.0);
+       urow = (FONT_HEIGHT - 1) + (cfg_leading > 0 ? 1 : 0);
+
        if (high < low || low < 0 || high >= cfg_text_height) {
                /* Invalid */
                sc->update_x = sc->update_y = sc->update_w = sc->update_h = 0;
@@ -397,12 +402,12 @@ draw_lines(state_t *st, screen_t *sc, int low, int high)
        /* Process mode phase 2 */
        if ((m & TMODE_INVISIBLE) != 0)
                p = 0;
-       if (grow == 8 && (m & (TMODE_UNDERLINE | TMODE_DUNDERLINE)) != 0) {
+       if (grow == urow && (m & (TMODE_UNDERLINE | TMODE_DUNDERLINE)) != 0) {
                p = 1;
                level = olevel = INTENSITY_DIM / 2;
                if ((m & TMODE_DUNDERLINE) != 0)
                        level = olevel = INTENSITY_NORMAL;
-       } else if (grow == 5 && (m & TMODE_STRIKE) != 0)
+       } else if (grow == srow && (m & TMODE_STRIKE) != 0)
                p = 1;
        if (iblink) {
                if (!p)
@@ -423,7 +428,7 @@ draw_lines(state_t *st, screen_t *sc, int low, int high)
        }
 
                /* Inverse for XOR cursor */
-               if (cursor_xor == col && grow < FONT_HEIGHT &&
+               if (cursor_xor == col && grow <= urow &&
                    ((st->cursor_mode == CMODE_BLOCK) ||
                     (st->cursor_mode == CMODE_LINE &&
                      grow >= (FONT_HEIGHT - 2)) ||