SynEdit / Gtk2: Fixing Highlight/redraw issues with revision 19801 #1312656bf4: ScrollWindowEx for Gtk2

git-svn-id: trunk@19813 -
This commit is contained in:
martin 2009-05-05 16:10:52 +00:00
parent 0c66bbff3b
commit ed6ba36741

View File

@ -370,7 +370,7 @@ type
fTextHeight: Integer; fTextHeight: Integer;
fTextOffset: Integer; fTextOffset: Integer;
fTopLine: Integer; fTopLine: Integer;
FOldTopView: Integer; // TopView before IncPaintLock FOldTopView, FTopDelta: Integer; // TopView before IncPaintLock
fHighlighter: TSynCustomHighlighter; fHighlighter: TSynCustomHighlighter;
{$IFNDEF SYN_LAZARUS} {$IFNDEF SYN_LAZARUS}
fSelectedColor: TSynSelectedColor; fSelectedColor: TSynSelectedColor;
@ -1685,6 +1685,7 @@ begin
fTabWidth := 8; fTabWidth := 8;
fLeftChar := 1; fLeftChar := 1;
fTopLine := 1; fTopLine := 1;
FTopDelta := 0;
{$IFDEF SYN_LAZARUS} {$IFDEF SYN_LAZARUS}
FFoldedLinesView.TopLine := 1; FFoldedLinesView.TopLine := 1;
{$ELSE} {$ELSE}
@ -2098,8 +2099,10 @@ end;
procedure TCustomSynEdit.IncPaintLock; procedure TCustomSynEdit.IncPaintLock;
begin begin
if fPaintLock = 0 then if fPaintLock = 0 then begin
FOldTopView := TopView; FOldTopView := TopView;
FTopDelta := 0;
end;
inc(fPaintLock); inc(fPaintLock);
FFoldedLinesView.Lock; //DecPaintLock triggers ScanFrom, and folds must wait FFoldedLinesView.Lock; //DecPaintLock triggers ScanFrom, and folds must wait
FTrimmedLinesView.Lock; // Lock before caret FTrimmedLinesView.Lock; // Lock before caret
@ -2132,10 +2135,12 @@ begin
if LastLine >= 0 then begin if LastLine >= 0 then begin
if (LastLine < FirstLine) then SwapInt(LastLine, FirstLine); if (LastLine < FirstLine) then SwapInt(LastLine, FirstLine);
LastLine := RowToScreenRow(Min(LastLine, ScreenRowToRow(LinesInWindow)))+1; LastLine := RowToScreenRow(Min(LastLine, ScreenRowToRow(LinesInWindow)))+1;
LastLine := LastLine + FTopDelta;
end end
else else
LastLine := LinesInWindow + 1; LastLine := LinesInWindow + 1;
FirstLine := RowToScreenRow(Max(FirstLine, TopLine)); FirstLine := RowToScreenRow(Max(FirstLine, TopLine));
FirstLine := Max(0, FirstLine + FTopDelta);
{ any line visible? } { any line visible? }
if (LastLine >= FirstLine) then begin if (LastLine >= FirstLine) then begin
rcInval := Rect(0, fTextHeight * FirstLine, rcInval := Rect(0, fTextHeight * FirstLine,
@ -2175,13 +2180,14 @@ begin
if LastLine >= 0 then begin if LastLine >= 0 then begin
if (LastLine < FirstLine) then SwapInt(LastLine, FirstLine); if (LastLine < FirstLine) then SwapInt(LastLine, FirstLine);
l := RowToScreenRow(Min(LastLine, ScreenRowToRow(LinesInWindow)))+1; l := RowToScreenRow(Min(LastLine, ScreenRowToRow(LinesInWindow)))+1;
l := l + FTopDelta;
end end
else else
l := LinesInWindow + 1; l := LinesInWindow + 1;
f := RowToScreenRow(Max(FirstLine, TopLine)); f := RowToScreenRow(Max(FirstLine, TopLine));
f := Max(0, f + FTopDelta);
{ any line visible? } { any line visible? }
if (l >= f) then begin if (l >= f) then begin
If LastLine < 0 then LastLine := ScreenRowToRow(LinesInWindow + 1);
rcInval := Rect(fGutterWidth, fTextHeight * f, rcInval := Rect(fGutterWidth, fTextHeight * f,
ClientWidth-ScrollBarWidth, fTextHeight * l); ClientWidth-ScrollBarWidth, fTextHeight * l);
if sfLinesChanging in fStateFlags then if sfLinesChanging in fStateFlags then
@ -3907,6 +3913,7 @@ begin
FOldTopView := TopView; FOldTopView := TopView;
fTopLine := Value; fTopLine := Value;
FFoldedLinesView.TopTextIndex := Value-1; FFoldedLinesView.TopTextIndex := Value-1;
FTopDelta := TopView - FOldTopView;
UpdateScrollBars; UpdateScrollBars;
ScrollAfterTopLineChanged; ScrollAfterTopLineChanged;
StatusChanged([scTopLine]); StatusChanged([scTopLine]);
@ -3929,6 +3936,7 @@ begin
else else
if eoAlwaysVisibleCaret in fOptions2 then if eoAlwaysVisibleCaret in fOptions2 then
MoveCaretToVisibleArea; // Invalidate caret line, if necessary MoveCaretToVisibleArea; // Invalidate caret line, if necessary
FTopDelta := 0;
end; end;
procedure TCustomSynEdit.ShowCaret; procedure TCustomSynEdit.ShowCaret;
@ -8057,24 +8065,8 @@ procedure TCustomSynEdit.InvalidateLine(Line: integer);
var var
rcInval: TRect; rcInval: TRect;
begin begin
if Visible and (Line >= TopLine) and InvalidateLines(Line, Line);
(Line <= {$IFDEF SYN_LAZARUS}ScreenRowToRow(LinesInWindow){$ELSE} InvalidateGutterLines(Line, Line);
TopLine + LinesInWindow{$ENDIF})
and (Line <= FTheLinesView.Count) and HandleAllocated
then begin
// we invalidate gutter and text area of this line
rcInval := Rect(0, fTextHeight * RowToScreenRow(Line)
, ClientWidth{$IFDEF SYN_LAZARUS}-ScrollBarWidth{$ENDIF}, 0);
rcInval.Bottom := rcInval.Top + fTextHeight;
if sfLinesChanging in fStateFlags then
UnionRect(fInvalidateRect, fInvalidateRect, rcInval)
else begin
{$IFDEF VerboseSynEditInvalidate}
DebugLn(['TCustomSynEdit.InvalidateLines ',dbgs(rcInval)]);
{$ENDIF}
InvalidateRect(Handle, @rcInval, FALSE);
end;
end;
end; end;
function TCustomSynEdit.GetReadOnly: boolean; function TCustomSynEdit.GetReadOnly: boolean;