@@ -17,11 +17,9 @@ interface
1717
1818
1919uses
20- // Delphi
21- Graphics,
2220 // Project
2321 ActiveText.UMain, ActiveText.URTFRenderer, Hiliter.UGlobals, UEncodings,
24- UIStringList, USnippetDoc, URTFBuilder, URTFStyles, URTFUtils ;
22+ UIStringList, USnippetDoc, URTFBuilder, URTFStyles;
2523
2624
2725type
@@ -128,9 +126,9 @@ implementation
128126
129127uses
130128 // Delphi
131- SysUtils ,
129+ Graphics ,
132130 // Project
133- Hiliter.UHiliters, UColours, UConsts, UPreferences, UStrUtils ;
131+ Hiliter.UHiliters, UColours, UConsts, UGraphicUtils, UPreferences ;
134132
135133
136134{ TRTFSnippetDoc }
@@ -316,9 +314,35 @@ procedure TRTFSnippetDoc.InitStyles;
316314
317315procedure TRTFSnippetDoc.RenderCompilerInfo (const Heading: string;
318316 const Info: TCompileDocInfoArray);
317+
318+ // Calculate length of longest compiler name, in twips, when rendered on font
319+ // to be used to display them
320+ function MaxCompilerNameLenInTwips : SmallInt;
321+ var
322+ CompilerInfo: TCompileDocInfo; // info about each compiler
323+ CompilerNames: IStringList; // list of all compiler names
324+ Font: TFont; // font in which compile info displayed
325+ begin
326+ Font := TFont.Create;
327+ try
328+ Font.Name := MainFontName;
329+ Font.Size := ParaFontSize;
330+ CompilerNames := TIStringList.Create;
331+ for CompilerInfo in Info do
332+ CompilerNames.Add(CompilerInfo.Compiler);
333+ Result := MaxStringWidthTwips(CompilerNames.ToArray, Font);
334+ finally
335+ Font.Free;
336+ end ;
337+ end ;
338+
319339var
320- Idx: Integer; // loops compiler information table
340+ CompilerInfo: TCompileDocInfo; // info about each compiler
341+ TabStop: SmallInt; // tab stop where compile result displayed
321342begin
343+ // Calculate tab stop where compile results are displayed
344+ TabStop := (MaxCompilerNameLenInTwips div IndentDelta) * IndentDelta + IndentDelta;
345+ // Display heading
322346 fBuilder.SetFontStyle([fsBold]);
323347 fBuilder.SetParaSpacing(
324348 TRTFParaSpacing.Create(ParaSpacing, ParaSpacing / 3 )
@@ -328,13 +352,15 @@ procedure TRTFSnippetDoc.RenderCompilerInfo(const Heading: string;
328352 fBuilder.EndPara;
329353 fBuilder.ClearParaFormatting;
330354 fBuilder.SetFontSize(ParaFontSize);
331- for Idx := Low(Info) to High(Info) do
355+ // Display compiler table
356+ fBuilder.SetTabStops([TabStop]);
357+ for CompilerInfo in Info do
332358 begin
333- fBuilder.AddText(Info[Idx] .Compiler);
359+ fBuilder.AddText(CompilerInfo .Compiler);
334360 fBuilder.AddText(TAB);
335361 fBuilder.BeginGroup;
336362 fBuilder.SetFontStyle([fsItalic]);
337- fBuilder.AddText(Info[Idx] .Result);
363+ fBuilder.AddText(CompilerInfo .Result);
338364 fBuilder.EndGroup;
339365 fBuilder.EndPara;
340366 end ;
0 commit comments