diff --git a/components/synedit/synedit.pp b/components/synedit/synedit.pp index b526ec75b6..c3dc0e1a6b 100644 --- a/components/synedit/synedit.pp +++ b/components/synedit/synedit.pp @@ -3085,6 +3085,8 @@ var ' "',copy(TokenAccu.s,1,TokenAccu.Len),'"');} end; + var + LastFSX, LastFEX: integer; procedure DrawHiLightMarkupToken(attr: TSynHighlighterAttributes; sToken: PChar; nTokenByteLen: integer); var @@ -3185,6 +3187,20 @@ var else FG := DefaultBGCol; 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 AddHighlightToken(sToken, SubTokenByteLen, PhysicalStartPos, PhysicalEndPos, FG, BG, FC, Style); @@ -3218,6 +3234,10 @@ var CurLine := FirstLine-1; while CurLine 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; diff --git a/components/synedit/syneditmarkupbracket.pp b/components/synedit/syneditmarkupbracket.pp index 0d5a1027e6..6ff9b30530 100644 --- a/components/synedit/syneditmarkupbracket.pp +++ b/components/synedit/syneditmarkupbracket.pp @@ -213,7 +213,11 @@ begin Result := nil; if ((FBracketHighlightPos.y = aRow) and (FBracketHighlightPos.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; function TSynEditMarkupBracket.GetNextMarkupColAfterRowCol(const aRow, aCol: Integer) : Integer; diff --git a/components/synedit/syneditmarkupctrlmouselink.pp b/components/synedit/syneditmarkupctrlmouselink.pp index a08771a058..93eb236973 100644 --- a/components/synedit/syneditmarkupctrlmouselink.pp +++ b/components/synedit/syneditmarkupctrlmouselink.pp @@ -99,6 +99,8 @@ begin if (aRow <> FCtrlMouseLine) or ((aCol < FCurX1) or (aCol >= FCurX2)) then exit; Result := MarkupInfo; + MarkupInfo.StartX := FCurX1; + MarkupInfo.EndX := FCurX2; end; function TSynEditMarkupCtrlMouseLink.GetNextMarkupColAfterRowCol(const aRow, aCol: Integer) : Integer; diff --git a/components/synedit/syneditmarkuphighall.pp b/components/synedit/syneditmarkuphighall.pp index c4b735e855..64079c933b 100644 --- a/components/synedit/syneditmarkuphighall.pp +++ b/components/synedit/syneditmarkuphighall.pp @@ -482,6 +482,14 @@ begin then exit; //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; end; diff --git a/components/synedit/syneditmarkupselection.pp b/components/synedit/syneditmarkupselection.pp index 63f5980ea6..71ea54cda4 100644 --- a/components/synedit/syneditmarkupselection.pp +++ b/components/synedit/syneditmarkupselection.pp @@ -129,6 +129,8 @@ begin then nSelEnd := p2.x; end; end; + MarkupInfo.StartX := nSelStart; + MarkupInfo.EndX := nSelEnd; end; function TSynEditMarkupSelection.GetMarkupAttributeAtRowCol(const aRow, aCol : Integer) : TSynSelectedColor; diff --git a/components/synedit/syneditmarkupspecialline.pp b/components/synedit/syneditmarkupspecialline.pp index 1f1a2db8c7..e4fcfb3366 100644 --- a/components/synedit/syneditmarkupspecialline.pp +++ b/components/synedit/syneditmarkupspecialline.pp @@ -177,6 +177,8 @@ end; function TSynEditMarkupSpecialLine.GetMarkupAttributeAtRowCol(const ARow, ACol : Integer): TSynSelectedColor; begin Result := nil; + MarkupInfo.StartX := -1; + MarkupInfo.EndX := -1; if FSpecialLine then Result := MarkupInfo; end; diff --git a/components/synedit/syneditmiscclasses.pp b/components/synedit/syneditmiscclasses.pp index 06f00f3ce4..bfe093db09 100644 --- a/components/synedit/syneditmiscclasses.pp +++ b/components/synedit/syneditmiscclasses.pp @@ -67,6 +67,8 @@ type // StyleMask = 0 => Invert where Style Bit = 1 FStyleMask: TFontStyles; FOnChange: TNotifyEvent; + // 0 or -1 start/end before/after line // 1 first char + FStartX, FEndX: Integer; procedure SetBG(Value: TColor); procedure SetFG(Value: TColor); procedure SetFrameColor(const AValue: TColor); @@ -86,6 +88,8 @@ type property FrameColor: TColor read FFrameColor write SetFrameColor default clNone; property Style: TFontStyles read FStyle write SetStyle 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; end; @@ -286,6 +290,8 @@ begin FFrameColor := Source.FFrameColor; FStyle := Source.FStyle; FStyleMask := Source.FStyleMask; + FStartX := Source.FStartX; + FEndX := Source.FEndX; DoChange; {TODO: only if really changed} end; end; @@ -297,6 +303,8 @@ begin FFrameColor := clNone; FStyle := []; FStyleMask := []; + FStartX := -1; + FEndX := -1; end; function TSynSelectedColor.IsEnabled: boolean; diff --git a/components/synedit/syntextdrawer.pp b/components/synedit/syntextdrawer.pp index 426148cfa7..774b73e5a7 100644 --- a/components/synedit/syntextdrawer.pp +++ b/components/synedit/syntextdrawer.pp @@ -211,6 +211,7 @@ type FColor: TColor; FBkColor: TColor; FFrameColor: TColor; + FFrameStartX, FFrameEndX: Integer; FCharExtra: Integer; // Begin/EndDrawing calling count @@ -256,6 +257,9 @@ type property ForeColor: TColor write SetForeColor; property BackColor: TColor write SetBackColor; 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 CharExtra: Integer read FCharExtra write SetCharExtra; {$IFDEF SYN_LAZARUS} @@ -1217,7 +1221,7 @@ var NeedDistArray: Boolean; DistArray: PInteger; Pen, OldPen: HPen; - Points: array[0..4] of TPoint; + old : TPoint; begin {$IFDEF SYN_LAZARUS} NeedDistArray:= (FCharExtra > 0) or not MonoSpace; @@ -1241,18 +1245,24 @@ begin {$ENDIF} if FFrameColor <> clNone then 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); 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)); end; end;