mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 19:49:18 +02:00
SynEdit, fix drawing of Frame-Highlights
git-svn-id: trunk@18071 -
This commit is contained in:
parent
d5955b6de5
commit
6e84e44ae3
@ -3085,6 +3085,8 @@ var
|
|||||||
' "',copy(TokenAccu.s,1,TokenAccu.Len),'"');}
|
' "',copy(TokenAccu.s,1,TokenAccu.Len),'"');}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
LastFSX, LastFEX: integer;
|
||||||
procedure DrawHiLightMarkupToken(attr: TSynHighlighterAttributes;
|
procedure DrawHiLightMarkupToken(attr: TSynHighlighterAttributes;
|
||||||
sToken: PChar; nTokenByteLen: integer);
|
sToken: PChar; nTokenByteLen: integer);
|
||||||
var
|
var
|
||||||
@ -3185,6 +3187,20 @@ var
|
|||||||
else FG := DefaultBGCol;
|
else FG := DefaultBGCol;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
if assigned(MarkupInfo) and
|
||||||
|
((MarkupInfo.StartX <> LastFSX) or (MarkupInfo.EndX <> LastFEX)) and
|
||||||
|
((TokenAccu.FC <> clNone) or (FC <> clNone))
|
||||||
|
then begin
|
||||||
|
// force Paint
|
||||||
|
PaintHighlightToken(FALSE);
|
||||||
|
TokenAccu.Len := 0;
|
||||||
|
// Set Frame Boundaries
|
||||||
|
LastFSX := MarkupInfo.StartX;
|
||||||
|
LastFEX := MarkupInfo.EndX;
|
||||||
|
FTextDrawer.FrameStartX := ScreenColumnToXValue(MarkupInfo.StartX);
|
||||||
|
FTextDrawer.FrameEndX := ScreenColumnToXValue(MarkupInfo.EndX+1);
|
||||||
|
end;
|
||||||
|
|
||||||
// Add to TokenAccu
|
// Add to TokenAccu
|
||||||
AddHighlightToken(sToken, SubTokenByteLen,
|
AddHighlightToken(sToken, SubTokenByteLen,
|
||||||
PhysicalStartPos, PhysicalEndPos, FG, BG, FC, Style);
|
PhysicalStartPos, PhysicalEndPos, FG, BG, FC, Style);
|
||||||
@ -3218,6 +3234,10 @@ var
|
|||||||
CurLine := FirstLine-1;
|
CurLine := FirstLine-1;
|
||||||
while CurLine<LastLine do begin
|
while CurLine<LastLine do begin
|
||||||
inc(CurLine);
|
inc(CurLine);
|
||||||
|
FTextDrawer.FrameStartX := -1;
|
||||||
|
FTextDrawer.FrameEndX := -1;
|
||||||
|
LastFSX := -1;
|
||||||
|
LastFEX := -1;
|
||||||
|
|
||||||
fMarkupManager.PrepareMarkupForRow(fTextView.TextIndex[CurLine]+1);
|
fMarkupManager.PrepareMarkupForRow(fTextView.TextIndex[CurLine]+1);
|
||||||
// Get the line.
|
// Get the line.
|
||||||
|
@ -370,6 +370,11 @@ begin
|
|||||||
sMask := c.StyleMask + (fsNot(c.StyleMask) * c.Style); // Styles to be taken from c
|
sMask := c.StyleMask + (fsNot(c.StyleMask) * c.Style); // Styles to be taken from c
|
||||||
Result.Style:= (Result.Style * fsNot(sMask)) + (c.Style * sMask);
|
Result.Style:= (Result.Style * fsNot(sMask)) + (c.Style * sMask);
|
||||||
Result.StyleMask:= (Result.StyleMask * fsNot(sMask)) + (c.StyleMask * sMask);
|
Result.StyleMask:= (Result.StyleMask * fsNot(sMask)) + (c.StyleMask * sMask);
|
||||||
|
if c.FrameColor <> clNone then begin
|
||||||
|
// Only frames need start/end info => copy *here* to separate fields if needed
|
||||||
|
Result.StartX := C.StartX;
|
||||||
|
Result.EndX := C.EndX;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -213,7 +213,11 @@ begin
|
|||||||
Result := nil;
|
Result := nil;
|
||||||
if ((FBracketHighlightPos.y = aRow) and (FBracketHighlightPos.x = aCol))
|
if ((FBracketHighlightPos.y = aRow) and (FBracketHighlightPos.x = aCol))
|
||||||
or ((FBracketHighlightAntiPos.y = aRow) and (FBracketHighlightAntiPos.x = aCol))
|
or ((FBracketHighlightAntiPos.y = aRow) and (FBracketHighlightAntiPos.x = aCol))
|
||||||
then Result := MarkupInfo;
|
then begin
|
||||||
|
Result := MarkupInfo;
|
||||||
|
MarkupInfo.StartX := aCol;
|
||||||
|
MarkupInfo.EndX := aCol;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSynEditMarkupBracket.GetNextMarkupColAfterRowCol(const aRow, aCol: Integer) : Integer;
|
function TSynEditMarkupBracket.GetNextMarkupColAfterRowCol(const aRow, aCol: Integer) : Integer;
|
||||||
|
@ -99,6 +99,8 @@ begin
|
|||||||
if (aRow <> FCtrlMouseLine) or ((aCol < FCurX1) or (aCol >= FCurX2))
|
if (aRow <> FCtrlMouseLine) or ((aCol < FCurX1) or (aCol >= FCurX2))
|
||||||
then exit;
|
then exit;
|
||||||
Result := MarkupInfo;
|
Result := MarkupInfo;
|
||||||
|
MarkupInfo.StartX := FCurX1;
|
||||||
|
MarkupInfo.EndX := FCurX2;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSynEditMarkupCtrlMouseLink.GetNextMarkupColAfterRowCol(const aRow, aCol: Integer) : Integer;
|
function TSynEditMarkupCtrlMouseLink.GetNextMarkupColAfterRowCol(const aRow, aCol: Integer) : Integer;
|
||||||
|
@ -482,6 +482,14 @@ begin
|
|||||||
then exit;
|
then exit;
|
||||||
|
|
||||||
//debugLN('+++>MARUP *ON* ',dbgs(@result),' / ',dbgs(ARow), ' at index ', dbgs(Pos));
|
//debugLN('+++>MARUP *ON* ',dbgs(@result),' / ',dbgs(ARow), ' at index ', dbgs(Pos));
|
||||||
|
if fMatches.Point[Pos-1].y < aRow then
|
||||||
|
MarkupInfo.StartX := -1
|
||||||
|
else
|
||||||
|
MarkupInfo.StartX := fMatches.Point[Pos-1].x;
|
||||||
|
if fMatches.Point[Pos].y > aRow then
|
||||||
|
MarkupInfo.EndX := -1
|
||||||
|
else
|
||||||
|
MarkupInfo.EndX := fMatches.Point[Pos].x-1;
|
||||||
result := MarkupInfo;
|
result := MarkupInfo;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -129,6 +129,8 @@ begin
|
|||||||
then nSelEnd := p2.x;
|
then nSelEnd := p2.x;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
MarkupInfo.StartX := nSelStart;
|
||||||
|
MarkupInfo.EndX := nSelEnd;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSynEditMarkupSelection.GetMarkupAttributeAtRowCol(const aRow, aCol : Integer) : TSynSelectedColor;
|
function TSynEditMarkupSelection.GetMarkupAttributeAtRowCol(const aRow, aCol : Integer) : TSynSelectedColor;
|
||||||
|
@ -177,6 +177,8 @@ end;
|
|||||||
function TSynEditMarkupSpecialLine.GetMarkupAttributeAtRowCol(const ARow, ACol : Integer): TSynSelectedColor;
|
function TSynEditMarkupSpecialLine.GetMarkupAttributeAtRowCol(const ARow, ACol : Integer): TSynSelectedColor;
|
||||||
begin
|
begin
|
||||||
Result := nil;
|
Result := nil;
|
||||||
|
MarkupInfo.StartX := -1;
|
||||||
|
MarkupInfo.EndX := -1;
|
||||||
if FSpecialLine then
|
if FSpecialLine then
|
||||||
Result := MarkupInfo;
|
Result := MarkupInfo;
|
||||||
end;
|
end;
|
||||||
|
@ -67,6 +67,8 @@ type
|
|||||||
// StyleMask = 0 => Invert where Style Bit = 1
|
// StyleMask = 0 => Invert where Style Bit = 1
|
||||||
FStyleMask: TFontStyles;
|
FStyleMask: TFontStyles;
|
||||||
FOnChange: TNotifyEvent;
|
FOnChange: TNotifyEvent;
|
||||||
|
// 0 or -1 start/end before/after line // 1 first char
|
||||||
|
FStartX, FEndX: Integer;
|
||||||
procedure SetBG(Value: TColor);
|
procedure SetBG(Value: TColor);
|
||||||
procedure SetFG(Value: TColor);
|
procedure SetFG(Value: TColor);
|
||||||
procedure SetFrameColor(const AValue: TColor);
|
procedure SetFrameColor(const AValue: TColor);
|
||||||
@ -86,6 +88,8 @@ type
|
|||||||
property FrameColor: TColor read FFrameColor write SetFrameColor default clNone;
|
property FrameColor: TColor read FFrameColor write SetFrameColor default clNone;
|
||||||
property Style: TFontStyles read FStyle write SetStyle default [];
|
property Style: TFontStyles read FStyle write SetStyle default [];
|
||||||
property StyleMask: TFontStyles read fStyleMask write SetStyleMask default [];
|
property StyleMask: TFontStyles read fStyleMask write SetStyleMask default [];
|
||||||
|
property StartX: Integer read FStartX write FStartX;
|
||||||
|
property EndX: Integer read FEndX write FEndX;
|
||||||
property OnChange: TNotifyEvent read fOnChange write fOnChange;
|
property OnChange: TNotifyEvent read fOnChange write fOnChange;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -286,6 +290,8 @@ begin
|
|||||||
FFrameColor := Source.FFrameColor;
|
FFrameColor := Source.FFrameColor;
|
||||||
FStyle := Source.FStyle;
|
FStyle := Source.FStyle;
|
||||||
FStyleMask := Source.FStyleMask;
|
FStyleMask := Source.FStyleMask;
|
||||||
|
FStartX := Source.FStartX;
|
||||||
|
FEndX := Source.FEndX;
|
||||||
DoChange; {TODO: only if really changed}
|
DoChange; {TODO: only if really changed}
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -297,6 +303,8 @@ begin
|
|||||||
FFrameColor := clNone;
|
FFrameColor := clNone;
|
||||||
FStyle := [];
|
FStyle := [];
|
||||||
FStyleMask := [];
|
FStyleMask := [];
|
||||||
|
FStartX := -1;
|
||||||
|
FEndX := -1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSynSelectedColor.IsEnabled: boolean;
|
function TSynSelectedColor.IsEnabled: boolean;
|
||||||
|
@ -211,6 +211,7 @@ type
|
|||||||
FColor: TColor;
|
FColor: TColor;
|
||||||
FBkColor: TColor;
|
FBkColor: TColor;
|
||||||
FFrameColor: TColor;
|
FFrameColor: TColor;
|
||||||
|
FFrameStartX, FFrameEndX: Integer;
|
||||||
FCharExtra: Integer;
|
FCharExtra: Integer;
|
||||||
|
|
||||||
// Begin/EndDrawing calling count
|
// Begin/EndDrawing calling count
|
||||||
@ -256,6 +257,9 @@ type
|
|||||||
property ForeColor: TColor write SetForeColor;
|
property ForeColor: TColor write SetForeColor;
|
||||||
property BackColor: TColor write SetBackColor;
|
property BackColor: TColor write SetBackColor;
|
||||||
property FrameColor: TColor write SetFrameColor;
|
property FrameColor: TColor write SetFrameColor;
|
||||||
|
property FrameStartX: Integer read FFrameStartX write FFrameStartX;
|
||||||
|
property FrameEndX: Integer read FFrameEndX write FFrameEndX;
|
||||||
|
|
||||||
property Style: TFontStyles write SetStyle;
|
property Style: TFontStyles write SetStyle;
|
||||||
property CharExtra: Integer read FCharExtra write SetCharExtra;
|
property CharExtra: Integer read FCharExtra write SetCharExtra;
|
||||||
{$IFDEF SYN_LAZARUS}
|
{$IFDEF SYN_LAZARUS}
|
||||||
@ -1217,7 +1221,7 @@ var
|
|||||||
NeedDistArray: Boolean;
|
NeedDistArray: Boolean;
|
||||||
DistArray: PInteger;
|
DistArray: PInteger;
|
||||||
Pen, OldPen: HPen;
|
Pen, OldPen: HPen;
|
||||||
Points: array[0..4] of TPoint;
|
old : TPoint;
|
||||||
begin
|
begin
|
||||||
{$IFDEF SYN_LAZARUS}
|
{$IFDEF SYN_LAZARUS}
|
||||||
NeedDistArray:= (FCharExtra > 0) or not MonoSpace;
|
NeedDistArray:= (FCharExtra > 0) or not MonoSpace;
|
||||||
@ -1241,18 +1245,24 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
if FFrameColor <> clNone then
|
if FFrameColor <> clNone then
|
||||||
begin
|
begin
|
||||||
with ARect do
|
|
||||||
begin
|
|
||||||
Points[0] := TopLeft;
|
|
||||||
Points[1] := Point(Right - 1, Top);
|
|
||||||
Points[2] := Point(Right - 1, Bottom - 1);
|
|
||||||
Points[3] := Point(Left, Bottom - 1);
|
|
||||||
Points[4] := TopLeft;
|
|
||||||
end;
|
|
||||||
|
|
||||||
Pen := CreateColorPen(FFrameColor);
|
Pen := CreateColorPen(FFrameColor);
|
||||||
OldPen := SelectObject(FDC, Pen);
|
OldPen := SelectObject(FDC, Pen);
|
||||||
Polyline(FDC, @Points, 5);
|
MoveToEx(FDC, ARect.Left, ARect.Top, @old);
|
||||||
|
if ARect.Right = FFrameEndX then begin
|
||||||
|
LineTo(FDC, ARect.Right-1, ARect.Top);
|
||||||
|
LineTo(FDC, ARect.Right-1, ARect.Bottom-1);
|
||||||
|
end else begin
|
||||||
|
// Last point of the line may not be drawn, so paint one more
|
||||||
|
LineTo(FDC, ARect.Right, ARect.Top);
|
||||||
|
MoveToEx(FDC, ARect.Right-1, ARect.Bottom-1, @old);
|
||||||
|
end;
|
||||||
|
if ARect.Left = FFrameStartX then begin
|
||||||
|
LineTo(FDC, ARect.Left, ARect.Bottom-1);
|
||||||
|
LineTo(FDC, ARect.Left, ARect.Top);
|
||||||
|
end else begin
|
||||||
|
MoveToEx(FDC, ARect.Left, ARect.Bottom-1, @old);
|
||||||
|
LineTo(FDC, ARect.Right, ARect.Bottom-1);
|
||||||
|
end;
|
||||||
DeleteObject(SelectObject(FDC, OldPen));
|
DeleteObject(SelectObject(FDC, OldPen));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user