That page is not about the SynEdit in Lazarus.
SynEdit is an independent open-source (GPL/MPL) project currently in Version 2.x
And originally based on a project called mwedit.
Lazarus forked it's own SynEdit of the original project, when the original project was at Version 1.1 or 1.2.
Since then both projects have added many features. However the Lazarus fork is no longer compatible with the original (and there are no plans to get it back there)
---
A printer component for SynEdit has been long on my list, but unfortunately not yet been started.
One of the issues is, that when printing, you must wrap long lines (which you do not do on screen (another feature...))
If you want to look at doing something, I guess your best bet is TSynCustomExporter in Syneditexport.pas
There also is a html exporter (but I have no idea how well it works...). SynExporter may need maintenance itself (all i know is it compiles, but that says nothing, sorry)
Look at the methods ExportAll, ExportRange.
The main part as to how to get the higghlight info is:
(I removed some code, that did cut the 1st and last line. Using partial lines may give very unexpected results)
Highlighter.ResetRange; // important for very first line
for i := Start.Y to Stop.Y do begin
Line := ALines[i - 1];
Highlighter.SetLine(Line, i);
while not Highlighter.GetEOL do begin
Attri := Highlighter.GetTokenAttribute;
Token := ReplaceReservedChars(Highlighter.GetToken, IsSpace);
SetTokenAttribute(IsSpace, Attri);
FormatToken(Token);
Highlighter.Next;
end;
FormatNewLine;
end;
A better approach may be to copy the code from SynEdit.PaintLines
// 0 base line number
fHighlighter.StartAtLineIndex(CurTextIndex);
while not fHighlighter.GetEol do begin
// pchar and len to next text segment
fHighlighter.GetTokenEx(sToken,nTokenLen);
// color of next text segment
attr := fHighlighter.GetTokenAttribute;
// output it
DrawHiLightMarkupToken(attr,sToken,nTokenLen);
// Let the highlighter scan the next token.
fHighlighter.Next;
end;
end;
- loop through all lines
- replace DrawHiLightMarkupToken with your code to output text to the printer
attr contains Fore/Back/Frame-color, as well as TextStyle (ignore stylemask)
Note: the highlighter only returns the highlights for pascal.
all editing attributes (such as block selection, highlight of current word, etc) are not included in this. And should not, since you do not highlight the selection in print.
--
Maybe i find some more time...
---
For SynEdit/Highlighter related stuff also see here:
http://wiki.lazarus.freepascal.org/SynEdit_Highlighter [It does not (yet?) have anything on printing, but other re-occurring questions...]