SynEdit: Fix crash in highlighting code under QT (Bug #12951)

git-svn-id: trunk@18411 -
This commit is contained in:
martin 2009-01-24 15:12:04 +00:00
parent 17299353b0
commit a9764b3457
2 changed files with 30 additions and 23 deletions

View File

@ -3296,28 +3296,32 @@ var
' Range=', PtrInt(FFoldedLinesView.Ranges[CurLine]) ' Range=', PtrInt(FFoldedLinesView.Ranges[CurLine])
]); ]);
DrawHiLightMarkupToken(nil, PChar(Pointer(sLine)), Length(sLine)); DrawHiLightMarkupToken(nil, PChar(Pointer(sLine)), Length(sLine));
end else begin end
{$ELSE}
if (FFoldedLinesView.Ranges[CurLine] = nil) then begin
DrawHiLightMarkupToken(nil, PChar(Pointer(sLine)), Length(sLine));
end
{$ENDIF} {$ENDIF}
fHighlighter.SetRange(FFoldedLinesView.Ranges[CurLine]); //mh 2000-10-10 else
fHighlighter.SetLine(sLine, FFoldedLinesView.TextIndex[CurLine]); begin
// Try to concatenate as many tokens as possible to minimize the count fHighlighter.SetRange(FFoldedLinesView.Ranges[CurLine]); //mh 2000-10-10
// of ExtTextOut calls necessary. This depends on the selection state fHighlighter.SetLine(sLine, FFoldedLinesView.TextIndex[CurLine]);
// or the line having special colors. For spaces the foreground color // Try to concatenate as many tokens as possible to minimize the count
// is ignored as well. // of ExtTextOut calls necessary. This depends on the selection state
//debugln('>>>> PaintLines Line=',dbgs(CurLine),' rect=',dbgs(rcToken)); // or the line having special colors. For spaces the foreground color
while not fHighlighter.GetEol do begin // is ignored as well.
fHighlighter.GetTokenEx(sToken,nTokenLen); //debugln('>>>> PaintLines Line=',dbgs(CurLine),' rect=',dbgs(rcToken));
attr := fHighlighter.GetTokenAttribute; while not fHighlighter.GetEol do begin
// Add Markup to the token and append it to the TokenAccu fHighlighter.GetTokenEx(sToken,nTokenLen);
// record. This will paint any chars already stored if there is attr := fHighlighter.GetTokenAttribute;
// a (visible) change in the attributes. // Add Markup to the token and append it to the TokenAccu
DrawHiLightMarkupToken(attr,sToken,nTokenLen); // record. This will paint any chars already stored if there is
// Let the highlighter scan the next token. // a (visible) change in the attributes.
fHighlighter.Next; DrawHiLightMarkupToken(attr,sToken,nTokenLen);
// Let the highlighter scan the next token.
fHighlighter.Next;
end;
end; end;
{$IFDEF DEBUGSYNRANGE}
end;
{$ENDIF}
end; end;
// Draw anything that's left in the TokenAccu record. Fill to the end // Draw anything that's left in the TokenAccu record. Fill to the end
// of the invalid area with the correct colors. // of the invalid area with the correct colors.

View File

@ -1642,7 +1642,8 @@ end;
(* Lines *) (* Lines *)
function TSynEditFoldedView.GetLines(index : Integer) : String; function TSynEditFoldedView.GetLines(index : Integer) : String;
begin begin
if (index < 0) or (index > fLinesInWindow) then exit(''); if (index < 0) or (index > fLinesInWindow) then
exit(fLines[ScreenLineToTextIndex(Index)]);
Result := fLines[fTextIndexList[index]]; Result := fLines[fTextIndexList[index]];
end; end;
@ -1655,13 +1656,15 @@ end;
function TSynEditFoldedView.GetRange(Index : integer) : TSynEditRange; function TSynEditFoldedView.GetRange(Index : integer) : TSynEditRange;
begin begin
if (index < 0) or (index > fLinesInWindow) then exit(nil); if (index < 0) or (index > fLinesInWindow) then
exit(fLines.Ranges[ScreenLineToTextIndex(Index)]);
Result := fLines.Ranges[fTextIndexList[index]]; Result := fLines.Ranges[fTextIndexList[index]];
end; end;
function TSynEditFoldedView.GetTextIndex(index : Integer) : Integer; function TSynEditFoldedView.GetTextIndex(index : Integer) : Integer;
begin begin
if (index < 0) or (index > fLinesInWindow) then exit(-1); if (index < 0) or (index > fLinesInWindow) then
exit(ScreenLineToTextIndex(Index));
Result := fTextIndexList[index]; Result := fTextIndexList[index];
end; end;