mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 21:41:35 +02:00
SynEdit: fixes caret sometimes invisible on last line (bug #12680). Adds caret visible on partial visible line.
git-svn-id: trunk@18016 -
This commit is contained in:
parent
57b43172d7
commit
bb49ada1b7
@ -1421,7 +1421,7 @@ begin
|
|||||||
if (Shift = ShortCutShift) and (Key = ShortCutKey) then
|
if (Shift = ShortCutShift) and (Key = ShortCutKey) then
|
||||||
with sender as TCustomSynEdit do begin
|
with sender as TCustomSynEdit do begin
|
||||||
if not ReadOnly and (Shift = ShortCutShift) and (Key = ShortCutKey) then begin
|
if not ReadOnly and (Shift = ShortCutShift) and (Key = ShortCutKey) then begin
|
||||||
p := ClientToScreen(Point(CaretXPix, CaretYPix + LineHeight));
|
p := ClientToScreen(Point(CaretXPix, CaretYPix + LineHeight + 1));
|
||||||
Form.CurrentEditor := Sender as TCustomSynEdit;
|
Form.CurrentEditor := Sender as TCustomSynEdit;
|
||||||
Execute(GetPreviousToken(Sender as TCustomSynEdit), p.x, p.y);
|
Execute(GetPreviousToken(Sender as TCustomSynEdit), p.x, p.y);
|
||||||
// eat it
|
// eat it
|
||||||
|
@ -1243,13 +1243,12 @@ end;
|
|||||||
function TCustomSynEdit.RowToScreenRow(PhysicalRow: integer): integer;
|
function TCustomSynEdit.RowToScreenRow(PhysicalRow: integer): integer;
|
||||||
// returns -1 for lines above visible screen (<TopLine)
|
// returns -1 for lines above visible screen (<TopLine)
|
||||||
// 0 for the first line
|
// 0 for the first line
|
||||||
// Max(0,LinesInWindow-1) for the last fully visible line
|
// 0 to LinesInWindow for visible lines (incl last partial visble line)
|
||||||
// and returns LinesInWindow for lines below visible screen including the
|
// and returns LinesInWindow+1 for lines below visible screen
|
||||||
// partially visible line at the bottom
|
|
||||||
begin
|
begin
|
||||||
Result := fTextView.TextIndexToScreenLine(PhysicalRow-1);
|
Result := fTextView.TextIndexToScreenLine(PhysicalRow-1);
|
||||||
if Result < -1 then Result := -1;
|
if Result < -1 then Result := -1;
|
||||||
if Result > LinesInWindow then Result := LinesInWindow;
|
if Result > LinesInWindow+1 then Result := LinesInWindow+1;
|
||||||
// DebugLn(['=== Row TO ScreenRow In:',PhysicalRow,' out:',Result]);
|
// DebugLn(['=== Row TO ScreenRow In:',PhysicalRow,' out:',Result]);
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -1257,14 +1256,14 @@ end;
|
|||||||
function TCustomSynEdit.RowColumnToPixels(
|
function TCustomSynEdit.RowColumnToPixels(
|
||||||
{$IFDEF SYN_LAZARUS}const {$ENDIF}RowCol: TPoint): TPoint;
|
{$IFDEF SYN_LAZARUS}const {$ENDIF}RowCol: TPoint): TPoint;
|
||||||
// converts screen position (1,1) based
|
// converts screen position (1,1) based
|
||||||
// to client area coordinate
|
// to client area coordinate (0,0 based on canvas)
|
||||||
begin
|
begin
|
||||||
Result:=RowCol;
|
Result:=RowCol;
|
||||||
Result.X := (Result.X - 1) * fCharWidth + fTextOffset;
|
Result.X := (Result.X - 1) * fCharWidth + fTextOffset;
|
||||||
{$IFDEF SYN_LAZARUS}
|
{$IFDEF SYN_LAZARUS}
|
||||||
Result.Y := RowToScreenRow(RowCol.Y) * fTextHeight + 1;
|
Result.Y := RowToScreenRow(RowCol.Y) * fTextHeight;
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
Result.Y := (Result.Y - fTopLine) * fTextHeight + 1;
|
Result.Y := (Result.Y - fTopLine) * fTextHeight;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -4513,28 +4512,20 @@ begin
|
|||||||
if eoAlwaysVisibleCaret in fOptions2 then
|
if eoAlwaysVisibleCaret in fOptions2 then
|
||||||
MoveCaretToVisibleArea;
|
MoveCaretToVisibleArea;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
CX := CaretXPix + FCaretOffset.X;
|
CX := CaretXPix;
|
||||||
CY := CaretYPix + FCaretOffset.Y;
|
CY := CaretYPix;
|
||||||
if (CX >= fGutterWidth)
|
if (CX >= fGutterWidth)
|
||||||
and (CX < ClientWidth{$IFDEF SYN_LAZARUS}-ScrollBarWidth{$ENDIF})
|
and (CX < ClientWidth{$IFDEF SYN_LAZARUS}-ScrollBarWidth{$ENDIF})
|
||||||
and (CY >= 0)
|
and (CY >= 0)
|
||||||
and (CY <= ClientHeight{$IFDEF SYN_LAZARUS}-ScrollBarWidth-fTextHeight{$ENDIF})
|
and (CY <{=} ClientHeight{$IFDEF SYN_LAZARUS}-ScrollBarWidth{-fTextHeight}{$ENDIF})
|
||||||
then begin
|
then begin
|
||||||
{$IFDEF SYN_LAZARUS}
|
SetCaretPosEx(Handle ,CX + FCaretOffset.X, CY + FCaretOffset.Y);
|
||||||
SetCaretPosEx(Handle,CX,CY);
|
|
||||||
{$ELSE}
|
|
||||||
SetCaretPos(CX, CY);
|
|
||||||
{$ENDIF}
|
|
||||||
//DebugLn(' [TCustomSynEdit.UpdateCaret] ShowCaret ',Name);
|
//DebugLn(' [TCustomSynEdit.UpdateCaret] ShowCaret ',Name);
|
||||||
ShowCaret;
|
ShowCaret;
|
||||||
end else begin
|
end else begin
|
||||||
//DebugLn(' [TCustomSynEdit.UpdateCaret] HideCaret ',Name);
|
//DebugLn(' [TCustomSynEdit.UpdateCaret] HideCaret ',Name);
|
||||||
HideCaret;
|
HideCaret;
|
||||||
{$IFDEF SYN_LAZARUS}
|
SetCaretPosEx(Handle ,CX + FCaretOffset.X, CY + FCaretOffset.Y);
|
||||||
SetCaretPosEx(Handle,CX, CY);
|
|
||||||
{$ELSE}
|
|
||||||
SetCaretPos(CX, CY);
|
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
{$IFDEF SYN_LAZARUS}
|
{$IFDEF SYN_LAZARUS}
|
||||||
if assigned(fMarkupBracket) then fMarkupBracket.InvalidateBracketHighlight;
|
if assigned(fMarkupBracket) then fMarkupBracket.InvalidateBracketHighlight;
|
||||||
@ -6301,24 +6292,24 @@ begin
|
|||||||
begin
|
begin
|
||||||
cw := fCharWidth;
|
cw := fCharWidth;
|
||||||
ch := 2;
|
ch := 2;
|
||||||
FCaretOffset := Point(0, fTextHeight - 2);
|
FCaretOffset := Point(0, fTextHeight - 1);
|
||||||
end;
|
end;
|
||||||
ctHalfBlock:
|
ctHalfBlock:
|
||||||
begin
|
begin
|
||||||
cw := fCharWidth;
|
cw := fCharWidth;
|
||||||
ch := (fTextHeight - 2) div 2;
|
ch := (fTextHeight - 2) div 2;
|
||||||
FCaretOffset := Point(0, ch);
|
FCaretOffset := Point(0, ch + 1);
|
||||||
end;
|
end;
|
||||||
ctBlock:
|
ctBlock:
|
||||||
begin
|
begin
|
||||||
cw := fCharWidth;
|
cw := fCharWidth;
|
||||||
ch := fTextHeight - 2;
|
ch := fTextHeight - 2;
|
||||||
FCaretOffset := Point(0, 0);
|
FCaretOffset := Point(0, 1);
|
||||||
end;
|
end;
|
||||||
else begin // ctVerticalLine
|
else begin // ctVerticalLine
|
||||||
cw := 2;
|
cw := 2;
|
||||||
ch := fTextHeight - 2;
|
ch := fTextHeight - 2;
|
||||||
FCaretOffset := Point(-1, 0);
|
FCaretOffset := Point(-1, 1);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
Exclude(fStateFlags, sfCaretVisible);
|
Exclude(fStateFlags, sfCaretVisible);
|
||||||
|
Loading…
Reference in New Issue
Block a user