AnalogTerm2: Fix a cursor refresh bug in the [A implementation.
authorMatthew Mondor <mmondor@pulsar-zone.net>
Tue, 9 May 2023 05:33:16 +0000 (05:33 +0000)
committerMatthew Mondor <mmondor@pulsar-zone.net>
Tue, 9 May 2023 05:33:16 +0000 (05:33 +0000)
mmsoftware/analogterm2/TODO.txt
mmsoftware/analogterm2/src/state.c

index c3819b8..ccaea19 100644 (file)
@@ -1,3 +1,7 @@
+- The uses of lastcol in state.c are inconsistent, likely a source of bugs.
+- Interestingly despite our goto implementation attempting to remember to
+  update the last and new lines for proper refresh including of the cursor,
+  explicit extra tricks are needed, like in the [A implementation.
 - Many operations are the equivalent of newline or scroll if the end of the
   scrolling buffer or bottom are reached.  Unify those in a function or two as
   possible.
index 41f38bf..1a181ac 100644 (file)
@@ -657,6 +657,7 @@ state_emul_printc(state_t *st, uint8_t c)
                        /* NOOP */
                        break;
                case 8: /* BS */
+                       /* XXX URxvt goes up if 0 but not XTerm */
                        if (state->cursor_x > 0)
                                state->cursor_x--;
                        break;
@@ -993,8 +994,15 @@ state_emul_printc(state_t *st, uint8_t c)
                case 'A': /* Cursor up (cuu)  FALLTHROUGH */
                        if ((i = (state->curparam == -1) ? 1 :
                            state->csiparam[0]) > 0) {
+                               /*
+                                * XXX Why is this needed for proper cursor
+                                * update when our goto implementation
+                                * attempts to do the same?
+                                */
+                               state_updated(st, state->cursor_y);
                                if ((state->cursor_y -= i) < 0)
                                        state->cursor_y = 0;
+                               state_updated(st, state->cursor_y);
                        }
                        state->escstate = 0;
                        estate_ticks = 0;