AnalogTerm2:
authorMatthew Mondor <mmondor@pulsar-zone.net>
Sun, 9 Apr 2023 18:41:05 +0000 (18:41 +0000)
committerMatthew Mondor <mmondor@pulsar-zone.net>
Sun, 9 Apr 2023 18:41:05 +0000 (18:41 +0000)
- Add support for DEC Private Mode reverse video DECSCNM.
  The xterm termcap/terminfo database implement the visual bell
  flash feature using this with NUL padding for delay.
- Explicitly ignore NUL padding for now.  This is sometimes used
  to implement delays.
- For the visual bell to work, implement a timer telling how long
  the reversed video should be enabled when it is quickly toggled.
  This allows the user to configure the length of the flash.

mmsoftware/analogterm2/TODO.txt
mmsoftware/analogterm2/src/config.c
mmsoftware/analogterm2/src/config.h
mmsoftware/analogterm2/src/draw.c
mmsoftware/analogterm2/src/main.c
mmsoftware/analogterm2/src/state.c
mmsoftware/analogterm2/src/state.h

index dbc763f..2977257 100644 (file)
@@ -1,3 +1,7 @@
+- xterm and urxvt appear to set the tty(4) termios ospeed/ispeed so that
+  baudrate be displayed as 38400 by stty(1).  Verify what they do, if it
+  serves a purpose and if they observe any delay for NUL character padding at
+  application input.  stty's "speed" dispay seems to be ispeed not ospeed.
 - Maybe support explicit or implicit login shell mode except for -e
 - Now that glyphs can be modified it is obviously a suboptimal method.
   General font loading could work, it may be worth checking older standard
@@ -24,7 +28,7 @@
   https://en.wikipedia.org/wiki/Box-drawing_character
 - Overwrite/clear selections before freeing them
 - ≣ † ☆ ツ ⌘›🍺∴ ( ͡° ͜ʖ ͡°)   ƒ   ︵  ₂   😈  θ  ƒ  ›  ʼ  ƒ ∂  ʻ  μ  ›  ∫   ◇ ♪
-  ► ə β ə ſ ρ ə ∴ ♪ 😱 † 😳 ›
+  ► ə β ə ſ ρ ə ∴ ♪ 😱 † 😳 › ▛
 - Verify if dead key support is incomplete for ISO-8859-4 and ISO-8859-10.
   There were special characters that were unicode since the start but also
   could have punctuation.  And others that used two at a time...  It might
index 3170317..9b08cf6 100644 (file)
@@ -28,7 +28,7 @@ static const struct eparam_s eparams[] = {
 
 int    cfg_color, cfg_monocolor;
 bool   cfg_mono;
-int    cfg_refreshspeed, cfg_blinkspeed, cfg_cursormode;
+int    cfg_refreshspeed, cfg_blinkspeed, cfg_cursormode, cfg_flashtime;
 bool   cfg_cursorblink, cfg_cursordisable, cfg_cursorbright,
        cfg_cursorprintreset;
 int    cfg_intmin, cfg_intstep, cfg_intfg, cfg_intscan, cfg_intbg;
@@ -55,6 +55,7 @@ cfg_setdefaults(void)
        cfg_refreshspeed = REFRESH_SPEED;
        cfg_blinkspeed = BLINK_SPEED;
        cfg_cursormode = CURSOR_MODE;
+       cfg_flashtime = FLASH_TIME;
        cfg_cursorblink = CURSOR_BLINK;
        cfg_cursorbright = CURSOR_BRIGHT;
        cfg_cursordisable = CURSOR_DISABLE;
index 34451d5..8607e2b 100644 (file)
@@ -253,6 +253,16 @@ extern int cfg_leading;
 
 
 /*
+ * Default minimum delay before DEC Private reverse video mode is disabled
+ * when enabled.  This is used for the flash of the visual bell.
+ */
+
+#define FLASH_TIME             8
+
+extern int cfg_flashtime;
+
+
+/*
  * The XShm extention allows to accelerate graphics when the client is running
  * on the same system as the X11 server.
  */
index 2709d7f..9ee15ae 100644 (file)
@@ -451,6 +451,13 @@ draw_lines(state_t *st, screen_t *sc, int low, int high)
                         p = (p == 0 ? INTENSITY_DIM : INTENSITY_DIM / 3);
                }
 
+               if (st->reverse_video || st->reverse_video_timer > 0) {
+                       if (p < INTENSITY_MIN)
+                               p = INTENSITY_MIN;
+                       else
+                               p = 0;
+               }
+
                /*
                 * Draw pixel or background.
                 * p serves as a boolean as well as an intensity level from 1
index 6e7e05f..7e1095d 100644 (file)
@@ -75,6 +75,11 @@ x11_process(screen_t *screen, tty_t *ttys, state_t *state)
        Time time = -1;
        struct timeval tv;
 
+       if (state->reverse_video_timer > 0) {
+               if (--state->reverse_video_timer == 0)
+                       state->text_updateall = true;
+       }
+
        if (state->blink_update)
                draw_blink_update();
        if (!state->scroll_slow && refresh_expired)
@@ -171,7 +176,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"
-           "    [-l <pixels>] [-e <command> [<arguments>]]\n\n"
+           "    [-l <pixels>] [-f <delay>] [-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"
@@ -205,6 +210,8 @@ usage(void)
            " -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"
+           " -f - Number of frames to keep reverse video on for the flash\n"
+           "      of the visual bell.  May not be visible with 0.\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"
@@ -248,7 +255,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:l:e:"))
+       while ((ch = getopt(argc, argv, "?8uw:h:E:scC:Wr:bB:Pm:MdDSp:l:f:e:"))
            != -1) {
                switch (ch) {
                case '8':
@@ -334,6 +341,10 @@ main(int argc, char **argv, char **envp)
                        if ((i = atoi(optarg)) >= -1 && i <= FONT_HEIGHT)
                                cfg_leading = i;
                        break;
+               case 'f':
+                       if ((i = atoi(optarg)) >= 0 && i <= 100)
+                               cfg_flashtime = i;
+                       break;
                case 'e':
                        {
                                int l;
index e63fb06..9de5071 100644 (file)
@@ -222,6 +222,8 @@ state_reset(state_t *st)
        st->cursor_disabled = false;
        st->cursor_bright = cfg_cursorbright;
        st->quotedpaste = false;
+       st->reverse_video = false;
+       st->reverse_video_timer = 0;
        st->monocolor = cfg_color;
        st->mode = 0;
        st->scroll_top = 0;
@@ -553,6 +555,14 @@ state_emul_printc(state_t *st, uint8_t c)
        int start, end;
        uint32_t uc = (uint32_t)-1;
 
+       /*
+        * Ignore any input padding.
+        * XXX We may want to delay.  If so, verify if it should be
+        * user-defined or check tty(4) for ospeed/ispeed.
+        */
+       if (c == '\0')
+               return;
+
        /* Load local shadow variables from master state */
        state->mode = st->mode;
        state->cursor_x = st->cursor_x;
@@ -954,6 +964,12 @@ state_emul_printc(state_t *st, uint8_t c)
                                case 4: /* Smooth (slow) scroll (DECSCLM) */
                                        st->scroll_slow = true;
                                        break;
+                               case 5: /* Reverse video (DECSCNM) */
+                                       st->reverse_video = true;
+                                       st->reverse_video_timer =
+                                           cfg_flashtime;
+                                       st->text_updateall = true;
+                                       break;
                                case 12:
                                case 13: /* FALLTHROUGH
                                          * Start blinking cursor
@@ -1144,6 +1160,10 @@ endh:
                                case 4: /* Fast/jump scroll (DECSCLM) */
                                        st->scroll_slow = false;  
                                        break;
+                               case 5: /* Normal (vs reverse) vid (DECSCNM) */
+                                       st->reverse_video = false;
+                                       st->text_updateall = true;
+                                       break;
                                case 6:
                                        /* Normal cursor mode (DECOM cnorm) */
                                        /* User-configured as default */
index 04e2028..20a841c 100644 (file)
@@ -53,6 +53,8 @@ struct state_s {
        bool blink_update;
        bool cursor_blink, cursor_disabled, cursor_bright;
        bool quotedpaste;
+       bool reverse_video;
+       int reverse_video_timer;
        int monocolor;
        int cursor_mode, cursor_x, cursor_y;
        int saved_cursor_x, saved_cursor_y;