AnalogTerm2: Tweak bright cursor support, add custom sequences.
authorMatthew Mondor <mmondor@pulsar-zone.net>
Tue, 28 Mar 2023 04:50:48 +0000 (04:50 +0000)
committerMatthew Mondor <mmondor@pulsar-zone.net>
Tue, 28 Mar 2023 04:50:48 +0000 (04:50 +0000)
mmsoftware/analogterm2/src/draw.c
mmsoftware/analogterm2/src/main.c
mmsoftware/analogterm2/src/state.c

index 06c8b37..13ec8c6 100644 (file)
@@ -423,7 +423,8 @@ draw_lines(state_t *st, screen_t *sc, int low, int high)
                     (st->cursor_mode == CMODE_BAR && bit < 2))) {
                        if (st->cursor_bright) {
                                intensity = INTENSITY_MAX;
-                               fgcolor = color = COLOR_WHITE;
+                               fgcolor = color =
+                                   (cfg_mono ? st->monocolor : COLOR_WHITE);
                        } else
                                color = st->monocolor;
                        if ((m & (TMODE_INVERSE | TMODE_BGCOLOR)) != 0)
index 7904456..dbcd97e 100644 (file)
@@ -195,6 +195,8 @@ usage(void)
            " -P - If the cursor is blinking, reset its timer for printing.\n"
            " -m - Set default cursor style (0 = block, 1 = line, 2 = bar).\n"
            " -M - Enable very visible cursor mode by default.\n"
+           "      Can also be controlled with the escape sequences \n"
+           "      [?658467;65541h and [?658467;65542h.\n"
            " -d - Log emulator debug messages to stderr.\n"
            " -D - Toggle if the cursor can be disabled or not.\n"
            " -S - Wait in a sleeping loop until the user closes the window\n"
index a5bdc62..e63fb06 100644 (file)
@@ -956,7 +956,7 @@ state_emul_printc(state_t *st, uint8_t c)
                                        break;
                                case 12:
                                case 13: /* FALLTHROUGH
-                                         * Start blinking cursor.
+                                         * Start blinking cursor
                                          * We don't allow applications to
                                          * change it with sequence 12, only
                                          * the user with 13.
@@ -967,7 +967,6 @@ state_emul_printc(state_t *st, uint8_t c)
                                case 25: /* Show cursor (DECTCEM, cvvis) */
                                        /* XXX "Very visible" vs cnorm */
                                        st->cursor_disabled = false;
-                                       st->cursor_bright = true;
                                        break;
                                case 2004: /* Bracketed paste mode */
                                        st->quotedpaste = true;
@@ -1009,6 +1008,14 @@ state_emul_printc(state_t *st, uint8_t c)
                                                        font_reset(st);
                                                        st->text_updateall =
                                                            true;
+                                               } else if (p == 65541) {
+                                                       cfg_cursorbright =
+                                                           st->cursor_bright
+                                                           = true;
+                                               } else if (p == 65542) {
+                                                       cfg_cursorbright =
+                                                           st->cursor_bright
+                                                           = false;
                                                }
                                        } else if (state->curparam == 2 &&
                                                   state->csiparam[1] ==
@@ -1139,7 +1146,10 @@ endh:
                                        break;
                                case 6:
                                        /* Normal cursor mode (DECOM cnorm) */
-                                       
+                                       /* User-configured as default */
+                                       st->cursor_mode = cfg_cursormode;
+                                       st->cursor_blink = cfg_cursorblink;
+                                       st->cursor_bright = cfg_cursorbright;
                                        break;
                                case 12:
                                case 13: /* FALLTHROUGH
@@ -1453,28 +1463,34 @@ endh:
                                        st->cursor_mode = CMODE_BLOCK;
                                        if (cfg_cursorblink)
                                                st->cursor_blink = true;
+                                       st->cursor_bright = true; /* XXX */
                                        break;
                                case 2:
                                        st->cursor_mode = CMODE_BLOCK;
                                        st->cursor_blink = false;
+                                       st->cursor_bright = cfg_cursorbright;
                                        break;
                                case 3:
                                        st->cursor_mode = CMODE_LINE;
                                        if (cfg_cursorblink)
                                                st->cursor_blink = true;
+                                       st->cursor_bright = cfg_cursorbright;
                                        break;
                                case 4:
                                        st->cursor_mode = CMODE_LINE;
                                        st->cursor_blink = false;
+                                       st->cursor_bright = cfg_cursorbright;
                                        break;
                                case 5:
                                        st->cursor_mode = CMODE_BAR;
                                        if (cfg_cursorblink)
                                                st->cursor_blink = true;
+                                       st->cursor_bright = cfg_cursorbright;
                                        break;
                                case 6:
                                        st->cursor_mode = CMODE_BAR;
                                        st->cursor_blink = false;
+                                       st->cursor_bright = cfg_cursorbright;
                                        break;
                                }
                        }