groffstudio

Diff
Login

Diff

Differences From Artifact [b7fbc951e8]:

To Artifact [5cfb67d430]:


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44


45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, StdCtrls,
  ExtCtrls, Buttons, ExtendedNotebook, SynEdit, fphttpclient,
  RegExpr, LCLIntf, LCLType, IniPropStorage, Process, Helpers, fileinfo,
  {$IF DEFINED(WINDOWS)}
  winpeimagereader, opensslsockets,
  {$ELSEIF DEFINED(DARWIN)}
  machoreader, ssockets, sslsockets, sslbase, opensslsockets,
  {$ELSEIF DEFINED(LINUX)}
  elfreader,
  {$ENDIF}
  BuildOutputWindow;

type

  { TMainForm }

  TMainForm = class(TForm)
    btnSaveGroff: TButton;
    btnLoadGroff: TButton;
    btnBuild: TButton;
    btnDownloadGroffWindows: TButton;
    btnSaveSettings: TButton;


    chkUpdateCheckOnStart: TCheckBox;
    chkLogFile: TCheckBox;
    chkAutoSaveBuildSettings: TCheckBox;
    chkPdfMark: TCheckBox;
    chkRefer: TCheckBox;
    chkChem: TCheckBox;
    chkGrn: TCheckBox;
    chkTbl: TCheckBox;
    chkPic: TCheckBox;
    chkEqn: TCheckBox;
    cmbMacro: TComboBox;
    edtGroffInstalledVersion: TEdit;
    edtGroffstudioInstalledVersion: TEdit;
    edtOnlineGroffVersionWindows: TEdit;
    ExtendedNotebook1: TExtendedNotebook;
    GroupBox1: TGroupBox;
    GroupBox2: TGroupBox;







|
|



















>
>



<
<
<
<
<
<
<







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49







50
51
52
53
54
55
56

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, StdCtrls,
  ExtCtrls, Buttons, ExtendedNotebook, SynEdit, fphttpclient, RegExpr, LCLIntf,
  LCLType, IniPropStorage, ComboEx, Process, Helpers, fileinfo,
  {$IF DEFINED(WINDOWS)}
  winpeimagereader, opensslsockets,
  {$ELSEIF DEFINED(DARWIN)}
  machoreader, ssockets, sslsockets, sslbase, opensslsockets,
  {$ELSEIF DEFINED(LINUX)}
  elfreader,
  {$ENDIF}
  BuildOutputWindow;

type

  { TMainForm }

  TMainForm = class(TForm)
    btnSaveGroff: TButton;
    btnLoadGroff: TButton;
    btnBuild: TButton;
    btnDownloadGroffWindows: TButton;
    btnSaveSettings: TButton;
    chkBoxExtras: TCheckComboBox;
    chkBoxPreprocessors: TCheckComboBox;
    chkUpdateCheckOnStart: TCheckBox;
    chkLogFile: TCheckBox;
    chkAutoSaveBuildSettings: TCheckBox;







    cmbMacro: TComboBox;
    edtGroffInstalledVersion: TEdit;
    edtGroffstudioInstalledVersion: TEdit;
    edtOnlineGroffVersionWindows: TEdit;
    ExtendedNotebook1: TExtendedNotebook;
    GroupBox1: TGroupBox;
    GroupBox2: TGroupBox;
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
    procedure btnSaveGroffClick(Sender: TObject);
    procedure btnSaveSettingsClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure lblFossilRepoClick(Sender: TObject);
    procedure lblGithubRepoClick(Sender: TObject);
    procedure lblWebsiteClick(Sender: TObject);
    procedure rdPdfChange(Sender: TObject);
    procedure rdPsChange(Sender: TObject);
    procedure SynEdit1Change(Sender: TObject);
{$IFDEF DARWIN}
    procedure GetSocketHandler(Sender: TObject; const UseSSL: Boolean; out AHandler: TSocketHandler);
{$ENDIF}
  private
    var currentGroffFilePath: String;
    var currentGroffFileName: String;







<
<







91
92
93
94
95
96
97


98
99
100
101
102
103
104
    procedure btnSaveGroffClick(Sender: TObject);
    procedure btnSaveSettingsClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure lblFossilRepoClick(Sender: TObject);
    procedure lblGithubRepoClick(Sender: TObject);
    procedure lblWebsiteClick(Sender: TObject);


    procedure SynEdit1Change(Sender: TObject);
{$IFDEF DARWIN}
    procedure GetSocketHandler(Sender: TObject; const UseSSL: Boolean; out AHandler: TSocketHandler);
{$ENDIF}
  private
    var currentGroffFilePath: String;
    var currentGroffFileName: String;
143
144
145
146
147
148
149

150



151
152
153
154
155
156
157
  GroffHelpers: TGroffHelpers;
  ResStream: TResourceStream;
  {$IFDEF DARWIN}
  HTTPClient: TFPHttpClient;
  {$ENDIF}
begin
  // What's the current running groff version?

  if RunCommand('troff', ['--version'], GroffOutputVersion) then



  begin
    edtGroffInstalledVersion.Text := GroffOutputVersion;
    if pos('GNU', GroffOutputVersion) = 0 then
       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;







>
|
>
>
>







136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
  GroffHelpers: TGroffHelpers;
  ResStream: TResourceStream;
  {$IFDEF DARWIN}
  HTTPClient: TFPHttpClient;
  {$ENDIF}
begin
  // What's the current running groff version?
  {$IFDEF WINDOWS}
  if RunCommand('cmd', ['/c', 'troff --version'], GroffOutputVersion, [], swoHIDE) then
  {$ELSE}
  if RunCommand('/bin/sh', ['-c', 'troff --version'], GroffOutputVersion, [], swoHIDE) then
  {$ENDIF}
  begin
    edtGroffInstalledVersion.Text := GroffOutputVersion;
    if pos('GNU', GroffOutputVersion) = 0 then
       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;
186
187
188
189
190
191
192
193
194
195
196
197
198

199
200
201
202
203
204
205
206
  chkUpdateCheckOnStart.Checked := updateCheck;
{$ENDIF}

  if storeBuildSettings then
  begin
       chkLogFile.Checked := iniStorage.ReadBoolean('BuildLogFile', False);
       cmbMacro.Text := iniStorage.ReadString('BuildChosenMacro', '[ select ]');
       chkChem.Checked := iniStorage.ReadBoolean('BuildUseChem', False);
       chkEqn.Checked := iniStorage.ReadBoolean('BuildUseEqn', False);
       chkGrn.Checked := iniStorage.ReadBoolean('BuildUseGrn', False);
       chkPic.Checked := iniStorage.ReadBoolean('BuildUsePic', False);
       chkRefer.Checked := iniStorage.ReadBoolean('BuildUseRefer', False);
       chkTbl.Checked := iniStorage.ReadBoolean('BuildUseTbl', False);

       chkPdfMark.Checked := iniStorage.ReadBoolean('BuildUsePdfMark', False);
       rdPs.Checked := iniStorage.ReadBoolean('BuildToPostscript', False);
       rdPdf.Checked := iniStorage.ReadBoolean('BuildToPDF', False);
  end;

  // What's the latest available version?
  FileVerInfo := TFileVersionInfo.Create(nil);








|
|
|
|
|
|
>
|







183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
  chkUpdateCheckOnStart.Checked := updateCheck;
{$ENDIF}

  if storeBuildSettings then
  begin
       chkLogFile.Checked := iniStorage.ReadBoolean('BuildLogFile', False);
       cmbMacro.Text := iniStorage.ReadString('BuildChosenMacro', '[ select ]');
       chkBoxPreprocessors.Checked[0] := iniStorage.ReadBoolean('BuildUseChem', False);
       chkBoxPreprocessors.Checked[1] := iniStorage.ReadBoolean('BuildUseEqn', False);
       chkBoxPreprocessors.Checked[2] := iniStorage.ReadBoolean('BuildUseGrn', False);
       chkBoxPreprocessors.Checked[3] := iniStorage.ReadBoolean('BuildUsePic', False);
       chkBoxPreprocessors.Checked[4] := iniStorage.ReadBoolean('BuildUseRefer', False);
       chkBoxPreprocessors.Checked[5] := iniStorage.ReadBoolean('BuildUseTbl', False);
       chkBoxExtras.Checked[0] := iniStorage.ReadBoolean('BuildUseHdtbl', False);
       chkBoxExtras.Checked[1] := iniStorage.ReadBoolean('BuildUsePdfMark', False);
       rdPs.Checked := iniStorage.ReadBoolean('BuildToPostscript', False);
       rdPdf.Checked := iniStorage.ReadBoolean('BuildToPDF', False);
  end;

  // What's the latest available version?
  FileVerInfo := TFileVersionInfo.Create(nil);

296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
end;

procedure TMainForm.lblWebsiteClick(Sender: TObject);
begin
  OpenURL('https://groff.tuxproject.de');
end;

procedure TMainForm.rdPdfChange(Sender: TObject);
begin
  chkPdfMark.Enabled := True;
end;

procedure TMainForm.rdPsChange(Sender: TObject);
begin
  chkPdfMark.Enabled := False;
end;

procedure TMainForm.SynEdit1Change(Sender: TObject);
begin
  // Set the "Changed" mark:
  MainStatusBar.Panels[0].Text := '* ' + currentGroffFileName;
  unsavedChanges := True;
end;








<
<
<
<
<
<
<
<
<
<







294
295
296
297
298
299
300










301
302
303
304
305
306
307
end;

procedure TMainForm.lblWebsiteClick(Sender: TObject);
begin
  OpenURL('https://groff.tuxproject.de');
end;











procedure TMainForm.SynEdit1Change(Sender: TObject);
begin
  // Set the "Changed" mark:
  MainStatusBar.Panels[0].Text := '* ' + currentGroffFileName;
  unsavedChanges := True;
end;

338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356


357
358
359
360
361
362
363
364
365
366
367
368
  BuildWindow := TBuildStatusWindow.Create(Application);
  BuildWindow.Show;

  // Build the parameters:
  buildOpts := 'groff';

  // - Macro:
  if cmbMacro.SelText <> '' then buildOpts := buildOpts + ' -' + cmbMacro.SelText;

  // - Enforce UTF-8:
  buildOpts := buildOpts + ' -Kutf8';

  // - Preprocessors:
  if chkChem.Checked then   buildOpts := buildOpts + ' -chem';
  if chkEqn.Checked then    buildOpts := buildOpts + ' -eqn';
  if chkGrn.Checked then    buildOpts := buildOpts + ' -grn';
  if chkPic.Checked then    buildOpts := buildOpts + ' -pic';
  if chkRefer.Checked then  buildOpts := buildOpts + ' -refer';
  if chkTbl.Checked then    buildOpts := buildOpts + ' -tbl';



  // - PDF-specifics:
  if rdPdf.Checked then begin
    buildOpts := buildOpts + ' -Tpdf';
    if chkPdfMark.Checked then buildOpts := buildOpts + ' -mpdfmark';
    outputFileName := currentGroffFilePath + '.pdf';
  end
  else outputFileName := currentGroffFilePath + '.ps';

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







|





|
|
|
|
|
|
>
>




|







326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
  BuildWindow := TBuildStatusWindow.Create(Application);
  BuildWindow.Show;

  // Build the parameters:
  buildOpts := 'groff';

  // - Macro:
  if LeftStr(cmbMacro.Text, 1) = 'm' then buildOpts := buildOpts + ' -' + cmbMacro.Text;

  // - Enforce UTF-8:
  buildOpts := buildOpts + ' -Kutf8';

  // - Preprocessors:
  if chkBoxPreprocessors.Checked[0] then   buildOpts := buildOpts + ' -chem';
  if chkBoxPreprocessors.Checked[1] then   buildOpts := buildOpts + ' -eqn';
  if chkBoxPreprocessors.Checked[2] then   buildOpts := buildOpts + ' -grn';
  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;
435
436
437
438
439
440
441
442
443
444
445
446
447

448
449
450
451
452
453
454
455
end;

procedure TMainForm.btnSaveSettingsClick(Sender: TObject);
begin
  // Store the build settings:
  iniStorage.WriteString('BuildChosenMacro', cmbMacro.Text);
  iniStorage.WriteBoolean('BuildLogFile', chkLogFile.Checked);
  iniStorage.WriteBoolean('BuildUseChem', chkChem.Checked);
  iniStorage.WriteBoolean('BuildUseEqn', chkEqn.Checked);
  iniStorage.WriteBoolean('BuildUseGrn', chkGrn.Checked);
  iniStorage.WriteBoolean('BuildUsePic', chkPic.Checked);
  iniStorage.WriteBoolean('BuildUseRefer', chkRefer.Checked);
  iniStorage.WriteBoolean('BuildUseTbl', chkTbl.Checked);

  iniStorage.WriteBoolean('BuildUsePdfMark', chkPdfMark.Checked);
  iniStorage.WriteBoolean('BuildToPostscript', rdPs.Checked);
  iniStorage.WriteBoolean('BuildToPDF', rdPDF.Checked);

  // Store the IDE settings:
  iniStorage.WriteBoolean('AutoSaveBuildSettings', chkAutoSaveBuildSettings.Checked);
  iniStorage.WriteBoolean('AutoUpdateCheck', chkUpdateCheckOnStart.Checked);








|
|
|
|
|
|
>
|







425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
end;

procedure TMainForm.btnSaveSettingsClick(Sender: TObject);
begin
  // Store the build settings:
  iniStorage.WriteString('BuildChosenMacro', cmbMacro.Text);
  iniStorage.WriteBoolean('BuildLogFile', chkLogFile.Checked);
  iniStorage.WriteBoolean('BuildUseChem', chkBoxPreprocessors.Checked[0]);
  iniStorage.WriteBoolean('BuildUseEqn', chkBoxPreprocessors.Checked[1]);
  iniStorage.WriteBoolean('BuildUseGrn', chkBoxPreprocessors.Checked[2]);
  iniStorage.WriteBoolean('BuildUsePic', chkBoxPreprocessors.Checked[3]);
  iniStorage.WriteBoolean('BuildUseRefer', chkBoxPreprocessors.Checked[4]);
  iniStorage.WriteBoolean('BuildUseTbl', chkBoxPreprocessors.Checked[5]);
  iniStorage.WriteBoolean('BuildUseHdtbl', chkBoxExtras.Checked[0]);
  iniStorage.WriteBoolean('BuildUsePdfMark', chkBoxExtras.Checked[1]);
  iniStorage.WriteBoolean('BuildToPostscript', rdPs.Checked);
  iniStorage.WriteBoolean('BuildToPDF', rdPDF.Checked);

  // Store the IDE settings:
  iniStorage.WriteBoolean('AutoSaveBuildSettings', chkAutoSaveBuildSettings.Checked);
  iniStorage.WriteBoolean('AutoUpdateCheck', chkUpdateCheckOnStart.Checked);