我有20个不同的单词。如何在SynEdit中用不同颜色的单词高亮显示行?如果无法突出显示行,则只需突出显示单词即可。
非常感谢!
发布于 2011-07-17 08:56:50
要突出显示一行,必须使用OnSpecialLineColors事件。您可以创建一个函数来查找行中的单词(请查看此问题Is There An Efficient Whole Word Search Function in Delphi?),然后绘制此行
检查此代码
procedure TFrmMain.SynEditCodeSpecialLineColors(Sender: TObject;
Line: integer; var Special: boolean; var FG, BG: TColor);
begin
If LineContainsWord(Line) then //here check if the word is in the line
begin
FG := clYellow; //Text Color
BG := clBlue; //BackGround
Special := True; //Must be true
end;
end;https://stackoverflow.com/questions/6721178
复制相似问题