From a96dbb3faa90c31e846ca6dda485b85866e97ae4 Mon Sep 17 00:00:00 2001 From: Scott Duensing Date: Thu, 26 Feb 2026 21:18:15 -0600 Subject: [PATCH] Fix scroll rendering artifacts by removing ScrollDC ScrollDC shifted buffer pixels during parsing before dirty rows were rendered, causing unrendered garbage to propagate into non-dirty rows on successive scrolls. Replace with FAllDirty to repaint all rows from cell data after any scroll. With batched TextOut this costs ~250 GDI calls per scroll instead of the old 12,000, so the overhead is minimal. Co-Authored-By: Claude Opus 4.6 --- delphi/KPANSI.PAS | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/delphi/KPANSI.PAS b/delphi/KPANSI.PAS index 903974e..f509ffe 100644 --- a/delphi/KPANSI.PAS +++ b/delphi/KPANSI.PAS @@ -101,7 +101,6 @@ type procedure RecalcCellSize; procedure RedrawBuffers; procedure ResizeScreen; - procedure ScrollBufs(N: Integer); procedure SetCols(Value: Integer); procedure SetCursorVisible(Value: Boolean); procedure SetRows(Value: Integer); @@ -761,24 +760,6 @@ begin end; -procedure TKPAnsi.ScrollBufs(N: Integer); -var - R: TRect; - I: Integer; - ScrollY: Integer; -begin - if FBufDC[0] = 0 then - Exit; - ScrollY := N * FCellHeight; - R.Left := 0; - R.Top := 0; - R.Right := FBufW; - R.Bottom := FBufH; - for I := 0 to 1 do - ScrollDC(FBufDC[I], 0, -ScrollY, R, R, 0, nil); -end; - - procedure TKPAnsi.DeleteChars(N: Integer); var Line: PTermLine; @@ -864,8 +845,7 @@ begin GetMem(Line, SizeOf(TTermLineRec)); AllocLine(Line); FScreen.Insert(0, Line); - ScrollBufs(-1); - FDirtyRow[0] := True; + FAllDirty := True; end; @@ -885,8 +865,7 @@ begin AllocLine(Line); FScreen.Add(Line); UpdateScrollbar; - ScrollBufs(1); - FDirtyRow[FRows - 1] := True; + FAllDirty := True; end;