mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 02:59:06 +02:00
Synedit: Highlight matching double quotes
git-svn-id: trunk@18037 -
This commit is contained in:
parent
21cbba66db
commit
c7540c1b04
@ -9374,7 +9374,7 @@ function TCustomSynEdit.FindMatchingBracket(PhysStartBracket: TPoint;
|
|||||||
// returns physical (screen) position of end bracket
|
// returns physical (screen) position of end bracket
|
||||||
const
|
const
|
||||||
// keep the ' last
|
// keep the ' last
|
||||||
Brackets: array[0..6] of char = ('(', ')', '[', ']', '{', '}', '''');
|
Brackets: array[0..7] of char = ('(', ')', '[', ']', '{', '}', '''', '"');
|
||||||
type
|
type
|
||||||
TokenPos = Record X: Integer; Attr: Integer; end;
|
TokenPos = Record X: Integer; Attr: Integer; end;
|
||||||
var
|
var
|
||||||
@ -9461,19 +9461,19 @@ var
|
|||||||
CaretXY := LogicalToPhysicalPos(Result)
|
CaretXY := LogicalToPhysicalPos(Result)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure DoFindMatchingQuote;
|
procedure DoFindMatchingQuote(q: char);
|
||||||
var
|
var
|
||||||
Test: char;
|
Test: char;
|
||||||
Len: integer;
|
Len: integer;
|
||||||
begin
|
begin
|
||||||
StartPt:=Point(PosX,PosY);
|
StartPt:=Point(PosX,PosY);
|
||||||
GetHighlighterAttriAtRowColEx(StartPt, s1, BracketKind, TmpStart, TmpAttr);
|
GetHighlighterAttriAtRowColEx(StartPt, s1, BracketKind, TmpStart, TmpAttr);
|
||||||
if (TmpStart = PosX) and (Length(s1)>0) and (s1[Length(s1)] = '''') then begin
|
if (TmpStart = PosX) and (Length(s1)>0) and (s1[Length(s1)] = q) then begin
|
||||||
PosX := PosX + Length(s1) - 1;
|
PosX := PosX + Length(s1) - 1;
|
||||||
DoMatchingBracketFound;
|
DoMatchingBracketFound;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
if (TmpStart + Length(s1) - 1 = PosX) and (Length(s1)>0) and (s1[1] = '''') then begin
|
if (TmpStart + Length(s1) - 1 = PosX) and (Length(s1)>0) and (s1[1] = q) then begin
|
||||||
PosX := PosX - Length(s1) + 1;
|
PosX := PosX - Length(s1) + 1;
|
||||||
DoMatchingBracketFound;
|
DoMatchingBracketFound;
|
||||||
exit;
|
exit;
|
||||||
@ -9484,7 +9484,7 @@ var
|
|||||||
while PosX > 1 do begin
|
while PosX > 1 do begin
|
||||||
Dec(PosX);
|
Dec(PosX);
|
||||||
Test := Line[PosX];
|
Test := Line[PosX];
|
||||||
if (Test = '''') and IsContextBracket then begin
|
if (Test = q) and IsContextBracket then begin
|
||||||
DoMatchingBracketFound;
|
DoMatchingBracketFound;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
@ -9494,7 +9494,7 @@ var
|
|||||||
while PosX < Len do begin
|
while PosX < Len do begin
|
||||||
Inc(PosX);
|
Inc(PosX);
|
||||||
Test := Line[PosX];
|
Test := Line[PosX];
|
||||||
if (Test = '''') and IsContextBracket then begin
|
if (Test = q) and IsContextBracket then begin
|
||||||
DoMatchingBracketFound;
|
DoMatchingBracketFound;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
@ -9584,8 +9584,8 @@ var
|
|||||||
for i := Low(Brackets) to High(Brackets) do begin
|
for i := Low(Brackets) to High(Brackets) do begin
|
||||||
if Test = Brackets[i] then begin
|
if Test = Brackets[i] then begin
|
||||||
// this is the bracket, get the matching one and the direction
|
// this is the bracket, get the matching one and the direction
|
||||||
if Brackets[i] = '''' then
|
if Brackets[i] in ['''', '"'] then
|
||||||
DoFindMatchingQuote
|
DoFindMatchingQuote(Brackets[i])
|
||||||
else
|
else
|
||||||
DoFindMatchingBracket(i);
|
DoFindMatchingBracket(i);
|
||||||
exit;
|
exit;
|
||||||
|
@ -92,7 +92,7 @@ end;
|
|||||||
procedure TSynEditMarkupBracket.FindMatchingBracketPair(PhysCaret: TPoint;
|
procedure TSynEditMarkupBracket.FindMatchingBracketPair(PhysCaret: TPoint;
|
||||||
var StartBracket, EndBracket: TPoint);
|
var StartBracket, EndBracket: TPoint);
|
||||||
const
|
const
|
||||||
Brackets: set of Char = ['(',')','{','}','[',']', '''' ];
|
Brackets: set of Char = ['(',')','{','}','[',']', '''', '"' ];
|
||||||
var
|
var
|
||||||
StartLine: string;
|
StartLine: string;
|
||||||
LogCaretXY: TPoint;
|
LogCaretXY: TPoint;
|
||||||
|
Loading…
Reference in New Issue
Block a user