~vcs-imports/putty/master

« back to all changes in this revision

Viewing changes to terminal/terminal.c

  • Committer: Simon Tatham
  • Date: 2023-09-25 19:43:55 UTC
  • Revision ID: git-v1:6a6efd36aa846c581446afab8c48210cfa4300db
Further reorganisations of seen_disp_event().

Shortly after the previous commit I spotted another definitely missing
display update: if you send the byte 0x7F, aka 'destructive
backspace', then the display didn't update immediately.

That was two in a row, so I did an eyeball review of the whole
terminal state machine to the best of my ability. Found a couple more
borderline ones, but also, found that the entire VT52 sub-state-
machine had a blanket seen_disp_event which really _shouldn't_ have
been there, because half the VT52 sequences aren't actually display-
modifying updates.

To make this _slightly_ less error-prone, I've sunk a number of
seen_disp_update calls into subroutines that aren't the top-level
term_out(). For example, erase_lots(), scroll(), move() and
swap_screen() now all call seen_disp_update within themselves, so
their call sites don't all have to remember to.

There are probably further bugs after this upheaval, but I think it's
moving in generally the right direction.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2529
2529
         */
2530
2530
        erase_lots(term, false, true, true);
2531
2531
    }
 
2532
 
 
2533
    seen_disp_event(term);
2532
2534
}
2533
2535
 
2534
2536
/*
2710
2712
            }
2711
2713
        }
2712
2714
    }
 
2715
 
 
2716
    seen_disp_event(term);
2713
2717
}
2714
2718
 
2715
2719
/*
2739
2743
    term->curs.x = x;
2740
2744
    term->curs.y = y;
2741
2745
    term->wrapnext = false;
 
2746
    seen_disp_event(term);
2742
2747
}
2743
2748
 
2744
2749
/*
2777
2782
        term->cset_attr[term->cset] = term->save_csattr;
2778
2783
        term->sco_acs = term->save_sco_acs;
2779
2784
        set_erase_char(term);
 
2785
        seen_disp_event(term);
2780
2786
    }
2781
2787
}
2782
2788
 
2935
2941
     * application has explicitly thrown them away). */
2936
2942
    if (erasing_lines_from_top && !(term->alt_which))
2937
2943
        term->tempsblines = 0;
 
2944
 
 
2945
    seen_disp_event(term);
2938
2946
}
2939
2947
 
2940
2948
/*
3844
3852
                copy_termchar(scrlineptr(term->curs.y),
3845
3853
                              term->curs.x, &term->erase_char);
3846
3854
            }
 
3855
            seen_disp_event(term);
3847
3856
        } else
3848
3857
        /* Or normal C0 controls. */
3849
3858
        if ((c & ~0x1F) == 0 && term->termstate < DO_CTRLS) {
4108
4117
                  case '8':             /* DECRC: restore cursor */
4109
4118
                    compatibility(VT100);
4110
4119
                    save_cursor(term, false);
4111
 
                    seen_disp_event(term);
4112
4120
                    break;
4113
4121
                  case '=':             /* DECKPAM: Keypad application mode */
4114
4122
                    compatibility(VT100);
4782
4790
                        break;
4783
4791
                      case 'u':       /* restore cursor */
4784
4792
                        save_cursor(term, false);
4785
 
                        seen_disp_event(term);
4786
4793
                        break;
4787
4794
                      case 't': /* DECSLPP: set page size - ie window height */
4788
4795
                        /*
4955
4962
                        scroll(term, term->marg_t, term->marg_b,
4956
4963
                               def(term->esc_args[0], 1), true);
4957
4964
                        term->wrapnext = false;
4958
 
                        seen_disp_event(term);
4959
4965
                        break;
4960
4966
                      case 'T':         /* SD: Scroll down */
4961
4967
                        CLAMP(term->esc_args[0], term->rows);
4963
4969
                        scroll(term, term->marg_t, term->marg_b,
4964
4970
                               -def(term->esc_args[0], 1), true);
4965
4971
                        term->wrapnext = false;
4966
 
                        seen_disp_event(term);
4967
4972
                        break;
4968
4973
                      case ANSI('|', '*'): /* DECSNLS */
4969
4974
                        /*
5439
5444
                break;
5440
5445
              case VT52_ESC:
5441
5446
                term->termstate = TOPLEVEL;
5442
 
                seen_disp_event(term);
5443
5447
                switch (c) {
5444
5448
                  case 'A':
5445
5449
                    move(term, term->curs.x, term->curs.y - 1, 1);
5503
5507
                    move(term, 0, 0, 0);
5504
5508
                    break;
5505
5509
                  case 'I':
5506
 
                    if (term->curs.y == 0)
 
5510
                    if (term->curs.y == 0) {
5507
5511
                        scroll(term, 0, term->rows - 1, -1, true);
5508
 
                    else if (term->curs.y > 0)
 
5512
                    } else if (term->curs.y > 0) {
5509
5513
                        term->curs.y--;
 
5514
                        seen_disp_event(term);
 
5515
                    }
5510
5516
                    term->wrapnext = false;
5511
5517
                    break;
5512
5518
                  case 'J':
5597
5603
                  case 'e':
5598
5604
                    /* compatibility(ATARI) */
5599
5605
                    term->cursor_on = true;
 
5606
                    seen_disp_event(term);
5600
5607
                    break;
5601
5608
                  case 'f':
5602
5609
                    /* compatibility(ATARI) */
5603
5610
                    term->cursor_on = false;
 
5611
                    seen_disp_event(term);
5604
5612
                    break;
5605
5613
                    /* case 'j': Save cursor position - broken on ST */
5606
5614
                    /* case 'k': Restore cursor position */