groffstudio

Check-in [f5f4824b2b]
Login
Overview
Comment:[Feature] On Windows, Ghostscript replaced pdfroff. [Bugfix] The groff detection logic was not as logical as it should have been.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f5f4824b2b7945997a13dec498c7fe3afc7e216070ed0001b94c499289180400
User & Date: Cthulhux on 2024-04-30 09:41:14
Other Links: manifest | tags
Context
2024-04-30
09:42
BBCode won't work. check-in: 3698bbd77b user: Cthulhux tags: trunk
09:41
[Feature] On Windows, Ghostscript replaced pdfroff. [Bugfix] The groff detection logic was not as logical as it should have been. check-in: f5f4824b2b user: Cthulhux tags: trunk
2024-04-29
22:16
Release. check-in: 1fd5b3df6f user: Cthulhux tags: trunk, release-0.13.2
Changes

Modified CHANGES.txt from [2e230b613d] to [bbbbd207cb].








1
2
3
4
5
6
7







Version 0.13.2
2024-04-30

[Improved] Multi-threading is more standards-compliant now (thanks @Th69).

-------------------------------

>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
Version [next]

[Feature] On Windows, Ghostscript replaced pdfroff.
[Bugfix] The groff detection logic was not as logical as it should have been.

-------------------------------

Version 0.13.2
2024-04-30

[Improved] Multi-threading is more standards-compliant now (thanks @Th69).

-------------------------------

Modified README.md from [53e529d119] to [ab0da305a6].

8
9
10
11
12
13
14

15
16
17
18
19
20
21

## Features

* Written in Lazarus (Free Pascal).
  * Should be cross-platform.
  * Successfully tested on Windows 10, macOS and Linux.
* Can produce PS and PDF files.

* Can handle some macros.

## License

`groffstudio` is free software under the terms of the CDDL-1.1. Feel free to help me with development. I'll happily grant you access to the upstream repository if you are good.

## Links







>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

## Features

* Written in Lazarus (Free Pascal).
  * Should be cross-platform.
  * Successfully tested on Windows 10, macOS and Linux.
* Can produce PS and PDF files.
  * On Windows, creating PDF files requires [Ghostscript](https://www.ghostscript.com/) for the time being. On other systems, [i]groff[/i] should be able to just do it.
* Can handle some macros.

## License

`groffstudio` is free software under the terms of the CDDL-1.1. Feel free to help me with development. I'll happily grant you access to the upstream repository if you are good.

## Links

Modified src/groffstudio.lpi from [fea6e0a2b8] to [67011a15ae].

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
      <Resources Count="1">
        <Resource_0 FileName="..\LICENSE" Type="RCDATA" ResourceName="LICENSE"/>
      </Resources>
    </General>
    <VersionInfo>
      <UseVersionInfo Value="True"/>
      <AutoIncrementBuild Value="True"/>
      <MinorVersionNr Value="13"/>
      <RevisionNr Value="2"/>
      <BuildNr Value="3"/>
      <StringTable ProductName="groffstudio"/>
    </VersionInfo>
    <BuildModes>
      <Item Name="Default" Default="True"/>
    </BuildModes>
    <PublishOptions>
      <Version Value="2"/>







|
<
<







18
19
20
21
22
23
24
25


26
27
28
29
30
31
32
      <Resources Count="1">
        <Resource_0 FileName="..\LICENSE" Type="RCDATA" ResourceName="LICENSE"/>
      </Resources>
    </General>
    <VersionInfo>
      <UseVersionInfo Value="True"/>
      <AutoIncrementBuild Value="True"/>
      <MinorVersionNr Value="14"/>


      <StringTable ProductName="groffstudio"/>
    </VersionInfo>
    <BuildModes>
      <Item Name="Default" Default="True"/>
    </BuildModes>
    <PublishOptions>
      <Version Value="2"/>

Modified src/unit1.pas from [99cc82d50b] to [dbf4805b7c].

121
122
123
124
125
126
127




128
129
130
131
132
133
134

135
136
137
138
139
140
141
142


143
144





145



146
147

148

149

150
151
152
153
154
155
156
157

158
159
160
161
162
163
164
165
166
167
168
169
170
171
  end;

var
  MainForm: TMainForm;
  BuildWindow: TBuildStatusWindow;
  hasGroff: boolean;
  GroffOutputVersion: string;





implementation

{$R *.lfm}

procedure TDetectGroffThread.UpdateUI;
begin

  MainForm.edtGroffInstalledVersion.Text := GroffOutputVersion;
  if pos('GNU', GroffOutputVersion) = 0 then
  begin
    ShowMessage('groffstudio thinks that your installed version of troff is not GNU troff.'
      + LineEnding + 'If this is correct, you are advised to fix this before continuing.'
      + LineEnding +
      'If it is an error, please tell me so I can improve this detection.');
    hasGroff := True;


  end
  else





  begin



    MainForm.edtGroffInstalledVersion.Text := 'n/a';
    hasGroff := False;

    MainForm.lblTroffCommandNotFound.Visible := True;

  end;

end;

procedure TDetectGroffThread.Execute;
begin
  FreeOnTerminate := True;

  {$IFDEF WINDOWS}
  if RunCommand('cmd', ['/c', 'troff --version'], GroffOutputVersion, [], swoHIDE) then

  {$ELSE}
  if RunCommand('/bin/sh', ['-c', 'troff --version'], GroffOutputVersion,
    [], swoHIDE) then
  {$ENDIF}
  begin
    Synchronize(@UpdateUI);
  end;
end;

{ TMainForm }

procedure TMainForm.FormCreate(Sender: TObject);
var
  OnlineVersionsFile: string;







>
>
>
>







>







|
>
>


>
>
>
>
>

>
>
>
|
|
>
|
>

>







|
>

|
|

<
|
<







121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180

181

182
183
184
185
186
187
188
  end;

var
  MainForm: TMainForm;
  BuildWindow: TBuildStatusWindow;
  hasGroff: boolean;
  GroffOutputVersion: string;
  {$IFDEF WINDOWS}
  hasGhostscript: boolean;
  ps2pdfOutput: string;
  {$ENDIF}

implementation

{$R *.lfm}

procedure TDetectGroffThread.UpdateUI;
begin
  // groff:
  MainForm.edtGroffInstalledVersion.Text := GroffOutputVersion;
  if pos('GNU', GroffOutputVersion) = 0 then
  begin
    ShowMessage('groffstudio thinks that your installed version of troff is not GNU troff.'
      + LineEnding + 'If this is correct, you are advised to fix this before continuing.'
      + LineEnding +
      'If it is an error, please tell me so I can improve this detection.');
    hasGroff := False;
    MainForm.edtGroffInstalledVersion.Text := 'n/a';
    MainForm.lblTroffCommandNotFound.Visible := True;
  end
  else
    hasGroff := True;

  // ps2pdf (Windows-only):
  {$IFDEF WINDOWS}
  if pos('ps2pdf', ps2pdfOutput) = 0 then
  begin
    ShowMessage('On Windows, for creating PDF files, you need Ghostscript installed.'
    + LineEnding + 'Sadly, groffstudio could not find ps2pdf.exe in your %PATH%, so '
    + 'writing PDF files will not be supported.');
    hasGhostscript := False;
    MainForm.rdPdf.Enabled := False;
  end else begin
    hasGhostscript := True;
    MainForm.rdPdf.Enabled := True;
  end;
  {$ENDIF}
end;

procedure TDetectGroffThread.Execute;
begin
  FreeOnTerminate := True;

  {$IFDEF WINDOWS}
  RunCommand('cmd', ['/c', 'troff --version'], GroffOutputVersion, [], swoHIDE);
  RunCommand('cmd', ['/c', 'ps2pdf'], ps2pdfOutput, [], swoHIDE);
  {$ELSE}
  RunCommand('/bin/sh', ['-c', 'troff --version'], GroffOutputVersion,
    [], swoHIDE);
  {$ENDIF}

  Synchronize(@UpdateUI);

end;

{ TMainForm }

procedure TMainForm.FormCreate(Sender: TObject);
var
  OnlineVersionsFile: string;
371
372
373
374
375
376
377





378
379
380
381
382
383
384

385
386
387
388
389
390
391
392
393
394
395
396
397
398
399


















400
401
402
403
404
405
406
  if chkBoxPreprocessors.Checked[3] then  buildOpts := buildOpts + ' -pic';
  if chkBoxPreprocessors.Checked[4] then  buildOpts := buildOpts + ' -refer';
  if chkBoxPreprocessors.Checked[5] then  buildOpts := buildOpts + ' -tbl';

  if chkBoxExtras.Checked[0] then  buildOpts := buildOpts + ' -mhdtbl';

  // - PDF-specifics:





  if rdPdf.Checked then
  begin
    buildOpts := buildOpts + ' -Tpdf';
    if chkBoxExtras.Checked[1] then buildOpts := buildOpts + ' -mpdfmark';
    outputFileName := currentGroffFilePath + '.pdf';
  end
  else

    outputFileName := currentGroffFilePath + '.ps';

  // - Input file:
  buildOpts := buildOpts + ' ' + currentGroffFilePath;
  buildOpts := buildOpts + ' > ' + outputFileName;

  // - Log file:
  if chkLogFile.Checked then logFileName := currentGroffFilePath + '.log';

  // Build:
  buildSuccess := BuildWindow.BuildDocument(buildOpts, logFileName);
  if buildSuccess then
    MainStatusBar.Panels[1].Text := 'build successful'
  else
    MainStatusBar.Panels[1].Text := 'build problem';



















  FreeAndNil(BuildWindow);
end;

procedure TMainForm.btnLoadGroffClick(Sender: TObject);
var
  Reply, BoxStyle: integer;







>
>
>
>
>







>















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
  if chkBoxPreprocessors.Checked[3] then  buildOpts := buildOpts + ' -pic';
  if chkBoxPreprocessors.Checked[4] then  buildOpts := buildOpts + ' -refer';
  if chkBoxPreprocessors.Checked[5] then  buildOpts := buildOpts + ' -tbl';

  if chkBoxExtras.Checked[0] then  buildOpts := buildOpts + ' -mhdtbl';

  // - PDF-specifics:
  {$IFNDEF WINDOWS}
  // On Windows, we use a two-step program:
  // 1) Output to PostScript,
  // 2) ps2pdf to PDF.
  // This is because there is no pdfroff.exe. Requires Ghostscript.
  if rdPdf.Checked then
  begin
    buildOpts := buildOpts + ' -Tpdf';
    if chkBoxExtras.Checked[1] then buildOpts := buildOpts + ' -mpdfmark';
    outputFileName := currentGroffFilePath + '.pdf';
  end
  else
  {$ENDIF}
    outputFileName := currentGroffFilePath + '.ps';

  // - Input file:
  buildOpts := buildOpts + ' ' + currentGroffFilePath;
  buildOpts := buildOpts + ' > ' + outputFileName;

  // - Log file:
  if chkLogFile.Checked then logFileName := currentGroffFilePath + '.log';

  // Build:
  buildSuccess := BuildWindow.BuildDocument(buildOpts, logFileName);
  if buildSuccess then
    MainStatusBar.Panels[1].Text := 'build successful'
  else
    MainStatusBar.Panels[1].Text := 'build problem';

  {$IFDEF WINDOWS}
  if buildSuccess and hasGhostscript then
  begin
    // Invoke ps2pdf:
    buildOpts := 'ps2pdf';
    // outputFileName is still the .ps file. Just use it as the input name.
    buildOpts := buildOpts + ' ' + outputFileName;
    buildSuccess := BuildWindow.BuildDocument(buildOpts, logFileName);
    if buildSuccess then
    begin
      MainStatusBar.Panels[1].Text := 'build successful';
      DeleteFile(outputFileName); // get rid of the .ps file
    end
    else
      MainStatusBar.Panels[1].Text := 'build problem';
  end;
  {$ENDIF}

  FreeAndNil(BuildWindow);
end;

procedure TMainForm.btnLoadGroffClick(Sender: TObject);
var
  Reply, BoxStyle: integer;