mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-14 07:59:35 +02:00
* Extended NodeJS project source
git-svn-id: trunk@56769 -
This commit is contained in:
parent
d6ff18f283
commit
410e9e94ac
@ -1,8 +1,35 @@
|
||||
object Form2: TForm2
|
||||
object NodeJSProjectOptionsForm: TNodeJSProjectOptionsForm
|
||||
Left = 710
|
||||
Height = 240
|
||||
Top = 270
|
||||
Width = 320
|
||||
Caption = 'Form2'
|
||||
Caption = 'NodeJS project options'
|
||||
ClientHeight = 240
|
||||
ClientWidth = 320
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '1.9.0.0'
|
||||
object CBUseNodeJSApplication: TCheckBox
|
||||
Left = 16
|
||||
Height = 22
|
||||
Top = 8
|
||||
Width = 188
|
||||
Caption = 'Use NodeJSApplication object'
|
||||
TabOrder = 0
|
||||
end
|
||||
object BPNode: TButtonPanel
|
||||
Left = 6
|
||||
Height = 42
|
||||
Top = 192
|
||||
Width = 308
|
||||
OKButton.Name = 'OKButton'
|
||||
OKButton.DefaultCaption = True
|
||||
HelpButton.Name = 'HelpButton'
|
||||
HelpButton.DefaultCaption = True
|
||||
CloseButton.Name = 'CloseButton'
|
||||
CloseButton.DefaultCaption = True
|
||||
CancelButton.Name = 'CancelButton'
|
||||
CancelButton.DefaultCaption = True
|
||||
TabOrder = 1
|
||||
ShowButtons = [pbOK, pbCancel]
|
||||
end
|
||||
end
|
||||
|
@ -5,22 +5,47 @@ unit frmpas2jsnodejsprojectoptions;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Forms, Controls, Graphics, Dialogs;
|
||||
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ButtonPanel;
|
||||
|
||||
type
|
||||
TForm2 = class(TForm)
|
||||
|
||||
{ TNodeJSProjectOptionsForm }
|
||||
|
||||
TNodeJSProjectOptionsForm = class(TForm)
|
||||
BPNode: TButtonPanel;
|
||||
CBUseNodeJSApplication: TCheckBox;
|
||||
private
|
||||
function GetB(AIndex: Integer): Boolean;
|
||||
procedure SetB(AIndex: Integer; AValue: Boolean);
|
||||
|
||||
public
|
||||
|
||||
Property UseNodeJSApplication : Boolean Index 0 Read GetB Write SetB;
|
||||
end;
|
||||
|
||||
var
|
||||
Form2: TForm2;
|
||||
NodeJSProjectOptionsForm: TNodeJSProjectOptionsForm;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
{ TNodeJSProjectOptionsForm }
|
||||
|
||||
function TNodeJSProjectOptionsForm.GetB(AIndex: Integer): Boolean;
|
||||
begin
|
||||
Case Aindex of
|
||||
0 : Result:=CBUseNodeJSApplication.Checked;
|
||||
else
|
||||
Result:=False;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TNodeJSProjectOptionsForm.SetB(AIndex: Integer; AValue: Boolean);
|
||||
begin
|
||||
Case Aindex of
|
||||
0 : CBUseNodeJSApplication.Checked:=AValue;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
@ -9,7 +9,7 @@ interface
|
||||
|
||||
uses
|
||||
PJSDsgnRegister, PJSDsgnOptsFrame, frmpas2jsbrowserprojectoptions,
|
||||
PJSDsgnOptions, LazarusPackageIntf;
|
||||
PJSDsgnOptions, frmpas2jsnodejsprojectoptions, LazarusPackageIntf;
|
||||
|
||||
implementation
|
||||
|
||||
|
@ -20,6 +20,7 @@ const
|
||||
PJSDefaultHTTPServer = '$MakeExe(IDE,simpleserver)';
|
||||
PJSDefaultStartAtPort = 3000; // Simpleserver default
|
||||
PJSDefaultBrowser = '$MakeExe(IDE,firefox)';
|
||||
PJSDefaultNodeJS = '$MakeExe(IDE,nodejs)';
|
||||
|
||||
Type
|
||||
{ TPas2jsOptions }
|
||||
@ -29,6 +30,7 @@ Type
|
||||
FBrowserFileName: String;
|
||||
FChangeStamp: int64;
|
||||
FHTTPServerFileName: string;
|
||||
FNodeJSFileName : String;
|
||||
FSavedStamp: int64;
|
||||
FCompilerFilename: string;
|
||||
FCompilerFilenameStamp: int64;
|
||||
@ -39,6 +41,7 @@ Type
|
||||
procedure SetHTTPServerFileName(AValue: string);
|
||||
procedure SetModified(AValue: boolean);
|
||||
procedure SetCompilerFilename(AValue: string);
|
||||
procedure SetNodeJSFileName(AValue: string);
|
||||
procedure SetStartAtPort(AValue: Word);
|
||||
public
|
||||
constructor Create;
|
||||
@ -52,6 +55,7 @@ Type
|
||||
public
|
||||
property CompilerFilename: string read FCompilerFilename write SetCompilerFilename;
|
||||
Property HTTPServerFileName : string Read FHTTPServerFileName Write SetHTTPServerFileName;
|
||||
Property NodeJSFileName : string Read FNodeJSFileName Write SetNodeJSFileName;
|
||||
Property BrowserFileName : String Read FBrowserFileName Write SetBrowserFileName;
|
||||
Property StartAtPort : Word Read FStartAtPort Write SetStartAtPort;
|
||||
property ChangeStamp: int64 read FChangeStamp;
|
||||
@ -64,6 +68,7 @@ var
|
||||
function GetStandardPas2jsExe: string;
|
||||
function GetStandardHTTPServer: string;
|
||||
function GetStandardBrowser: string;
|
||||
function GetStandardNodeJS: string;
|
||||
function GetPas2jsQuality(Filename: string; out Msg: string): boolean;
|
||||
|
||||
implementation
|
||||
@ -75,6 +80,14 @@ begin
|
||||
Result:='pas2js';
|
||||
end;
|
||||
|
||||
function GetStandardNodeJS: string;
|
||||
|
||||
begin
|
||||
Result:='$MakeExe(IDE,nodejs)';
|
||||
if not IDEMacros.SubstituteMacros(Result) then
|
||||
Result:='nodejs';
|
||||
end;
|
||||
|
||||
function GetStandardHTTPServer: string;
|
||||
|
||||
begin
|
||||
@ -159,10 +172,21 @@ begin
|
||||
IDEMacros.IncreaseBaseStamp;
|
||||
end;
|
||||
|
||||
procedure TPas2jsOptions.SetNodeJSFileName(AValue: string);
|
||||
begin
|
||||
if FNodeJSFileName=AValue then Exit;
|
||||
FNodeJSFileName:=AValue;
|
||||
Modified;
|
||||
end;
|
||||
|
||||
constructor TPas2jsOptions.Create;
|
||||
|
||||
begin
|
||||
FChangeStamp:=LUInvalidChangeStamp64;
|
||||
FCompilerFilename:=PJSDefaultCompiler;
|
||||
FHTTPServerFileName:=PJSDefaultHTTPServer;
|
||||
FNodeJSFileName:=PJSDefaultNodeJS;
|
||||
FBrowserFileName:=PJSDefaultBrowser;
|
||||
end;
|
||||
|
||||
destructor TPas2jsOptions.Destroy;
|
||||
@ -199,17 +223,36 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
Const
|
||||
KeyCompiler = 'compiler/value';
|
||||
KeyHTTPServer = 'webserver/value';
|
||||
KeyBrowser = 'webbrowser/value';
|
||||
KeyNodeJS = 'nodejs/value';
|
||||
KeyStartPortAt = 'webserver/startatport/value';
|
||||
|
||||
procedure TPas2jsOptions.LoadFromConfig(Cfg: TConfigStorage);
|
||||
|
||||
begin
|
||||
CompilerFilename:=Cfg.GetValue('compiler/value',PJSDefaultCompiler);
|
||||
CompilerFilename:=Cfg.GetValue(KeyCompiler ,PJSDefaultCompiler);
|
||||
HTTPServerFileName:=Cfg.GetValue(KeyHTTPServer,PJSDefaultHTTPServer);
|
||||
BrowserFileName:=Cfg.GetValue(KeyBrowser,PJSDefaultBrowser);
|
||||
NodeJSFileName:=Cfg.GetValue(KeyNodeJS,PJSDefaultNodeJS);
|
||||
StartAtPort :=Cfg.GetValue(KeyStartPortAt,PJSDefaultStartAtPort);
|
||||
Modified:=false;
|
||||
end;
|
||||
|
||||
procedure TPas2jsOptions.SaveToConfig(Cfg: TConfigStorage);
|
||||
|
||||
begin
|
||||
Cfg.SetDeleteValue('compiler/value',CompilerFilename,PJSDefaultCompiler);
|
||||
Cfg.SetDeleteValue(KeyCompiler,CompilerFilename,PJSDefaultCompiler);
|
||||
Cfg.SetDeleteValue(KeyHTTPServer,HTTPServerFileName,PJSDefaultHTTPServer);
|
||||
Cfg.SetDeleteValue(KeyStartPortAt,StartAtPort,PJSDefaultStartAtPort);
|
||||
Cfg.SetDeleteValue(KeyNodeJS,NodeJSFileName,PJSDefaultNodeJS);
|
||||
Cfg.SetDeleteValue(KeyBrowser,BrowserFileName,PJSDefaultBrowser);
|
||||
Modified:=false;
|
||||
end;
|
||||
|
||||
|
||||
function TPas2jsOptions.GetParsedCompilerFilename: string;
|
||||
begin
|
||||
if FCompilerFilenameStamp<>IDEMacros.BaseTimeStamp then begin
|
||||
|
@ -13,9 +13,9 @@ object Pas2jsOptionsFrame: TPas2jsOptionsFrame
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = Owner
|
||||
Left = 6
|
||||
Height = 13
|
||||
Height = 17
|
||||
Top = 6
|
||||
Width = 157
|
||||
Width = 160
|
||||
BorderSpacing.Left = 6
|
||||
BorderSpacing.Top = 6
|
||||
Caption = 'Pas2JS command executable'
|
||||
@ -29,9 +29,9 @@ object Pas2jsOptionsFrame: TPas2jsOptionsFrame
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = Pas2jsPathBrowseButton
|
||||
Left = 6
|
||||
Height = 27
|
||||
Top = 19
|
||||
Width = 394
|
||||
Height = 29
|
||||
Top = 23
|
||||
Width = 396
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
ItemHeight = 0
|
||||
TabOrder = 0
|
||||
@ -42,10 +42,10 @@ object Pas2jsOptionsFrame: TPas2jsOptionsFrame
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = Pas2jsPathComboBox
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 400
|
||||
Height = 27
|
||||
Top = 19
|
||||
Width = 21
|
||||
Left = 402
|
||||
Height = 29
|
||||
Top = 23
|
||||
Width = 19
|
||||
Anchors = [akTop, akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Right = 6
|
||||
@ -60,9 +60,9 @@ object Pas2jsOptionsFrame: TPas2jsOptionsFrame
|
||||
AnchorSideTop.Control = Pas2jsPathComboBox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 13
|
||||
Top = 54
|
||||
Width = 163
|
||||
Height = 17
|
||||
Top = 60
|
||||
Width = 170
|
||||
BorderSpacing.Left = 6
|
||||
BorderSpacing.Top = 8
|
||||
Caption = 'Simple HTTP Server command'
|
||||
@ -76,8 +76,8 @@ object Pas2jsOptionsFrame: TPas2jsOptionsFrame
|
||||
AnchorSideBottom.Control = HTTPServerComboBox
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 402
|
||||
Height = 27
|
||||
Top = 67
|
||||
Height = 29
|
||||
Top = 77
|
||||
Width = 19
|
||||
Anchors = [akTop, akRight, akBottom]
|
||||
BorderSpacing.Right = 6
|
||||
@ -91,8 +91,8 @@ object Pas2jsOptionsFrame: TPas2jsOptionsFrame
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = HTTPServerBrowseButton
|
||||
Left = 6
|
||||
Height = 27
|
||||
Top = 67
|
||||
Height = 29
|
||||
Top = 77
|
||||
Width = 396
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
ItemHeight = 0
|
||||
@ -103,8 +103,8 @@ object Pas2jsOptionsFrame: TPas2jsOptionsFrame
|
||||
AnchorSideTop.Control = ServerPortLabel
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 23
|
||||
Top = 115
|
||||
Height = 27
|
||||
Top = 131
|
||||
Width = 74
|
||||
MaxValue = 65353
|
||||
MinValue = 1024
|
||||
@ -116,9 +116,9 @@ object Pas2jsOptionsFrame: TPas2jsOptionsFrame
|
||||
AnchorSideTop.Control = HTTPServerComboBox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 13
|
||||
Top = 102
|
||||
Width = 114
|
||||
Height = 17
|
||||
Top = 114
|
||||
Width = 116
|
||||
BorderSpacing.Left = 6
|
||||
BorderSpacing.Top = 8
|
||||
Caption = 'Standard server port'
|
||||
@ -130,8 +130,8 @@ object Pas2jsOptionsFrame: TPas2jsOptionsFrame
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = BBrowserBrowseButton
|
||||
Left = 6
|
||||
Height = 27
|
||||
Top = 157
|
||||
Height = 29
|
||||
Top = 181
|
||||
Width = 396
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
ItemHeight = 0
|
||||
@ -143,9 +143,9 @@ object Pas2jsOptionsFrame: TPas2jsOptionsFrame
|
||||
AnchorSideTop.Control = ServerPortSpinEdit
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 13
|
||||
Top = 144
|
||||
Width = 258
|
||||
Height = 17
|
||||
Top = 164
|
||||
Width = 260
|
||||
BorderSpacing.Left = 6
|
||||
BorderSpacing.Top = 6
|
||||
Caption = 'Browser to launch when opening project HTML'
|
||||
@ -158,8 +158,8 @@ object Pas2jsOptionsFrame: TPas2jsOptionsFrame
|
||||
AnchorSideBottom.Control = BrowserComboBox
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 402
|
||||
Height = 27
|
||||
Top = 157
|
||||
Height = 29
|
||||
Top = 181
|
||||
Width = 19
|
||||
Anchors = [akTop, akRight, akBottom]
|
||||
BorderSpacing.Right = 6
|
||||
@ -167,4 +167,47 @@ object Pas2jsOptionsFrame: TPas2jsOptionsFrame
|
||||
OnClick = BBrowserBrowseButtonClick
|
||||
TabOrder = 6
|
||||
end
|
||||
object BrowserLabel1: TLabel
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = BrowserComboBox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 17
|
||||
Top = 216
|
||||
Width = 106
|
||||
BorderSpacing.Left = 6
|
||||
BorderSpacing.Top = 6
|
||||
Caption = 'Node.js executable'
|
||||
ParentColor = False
|
||||
end
|
||||
object NodeJSComboBox: TComboBox
|
||||
AnchorSideLeft.Control = BrowserLabel1
|
||||
AnchorSideTop.Control = BrowserLabel1
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = NodeJSBrowseButton
|
||||
Left = 6
|
||||
Height = 29
|
||||
Top = 233
|
||||
Width = 396
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
ItemHeight = 0
|
||||
TabOrder = 7
|
||||
Text = 'NodeJSComboBox'
|
||||
end
|
||||
object NodeJSBrowseButton: TButton
|
||||
AnchorSideTop.Control = NodeJSComboBox
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = NodeJSComboBox
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 402
|
||||
Height = 29
|
||||
Top = 233
|
||||
Width = 19
|
||||
Anchors = [akTop, akRight, akBottom]
|
||||
BorderSpacing.Right = 6
|
||||
Caption = '...'
|
||||
OnClick = NodeJSBrowseButtonClick
|
||||
TabOrder = 8
|
||||
end
|
||||
end
|
||||
|
@ -19,7 +19,10 @@ Type
|
||||
|
||||
TPas2jsOptionsFrame = class(TAbstractIDEOptionsEditor)
|
||||
BBrowserBrowseButton: TButton;
|
||||
NodeJSBrowseButton: TButton;
|
||||
BrowserComboBox: TComboBox;
|
||||
NodeJSComboBox: TComboBox;
|
||||
BrowserLabel1: TLabel;
|
||||
HTTPServerBrowseButton: TButton;
|
||||
HTTPServerComboBox: TComboBox;
|
||||
HTTPServerCmdLabel: TLabel;
|
||||
@ -31,6 +34,7 @@ Type
|
||||
ServerPortSpinEdit: TSpinEdit;
|
||||
procedure BBrowserBrowseButtonClick(Sender: TObject);
|
||||
procedure HTTPServerBrowseButtonClick(Sender: TObject);
|
||||
procedure NodeJSBrowseButtonClick(Sender: TObject);
|
||||
procedure Pas2jsPathBrowseButtonClick(Sender: TObject);
|
||||
private
|
||||
function CheckCompiler(Buttons: TMsgDlgButtons): boolean;
|
||||
@ -92,7 +96,29 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TPas2jsOptionsFrame.NodeJSBrowseButtonClick(Sender: TObject);
|
||||
var
|
||||
OpenDialog: TOpenDialog;
|
||||
AFilename: String;
|
||||
|
||||
begin
|
||||
OpenDialog:=TOpenDialog.Create(nil);
|
||||
try
|
||||
//InputHistories.ApplyFileDialogSettings(OpenDialog);
|
||||
OpenDialog.Options:=OpenDialog.Options+[ofPathMustExist];
|
||||
OpenDialog.Title:='Select browser executable';
|
||||
if OpenDialog.Execute then begin
|
||||
AFilename:=CleanAndExpandFilename(OpenDialog.Filename);
|
||||
SetComboBoxText(NodeJSComboBox,AFilename,cstFilename,30);
|
||||
PJSOptions.NodeJSFileName:=AFileName;
|
||||
end;
|
||||
finally
|
||||
OpenDialog.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TPas2jsOptionsFrame.BBrowserBrowseButtonClick(Sender: TObject);
|
||||
|
||||
var
|
||||
OpenDialog: TOpenDialog;
|
||||
AFilename: String;
|
||||
@ -162,6 +188,7 @@ begin
|
||||
SetComboBoxText(Pas2jsPathComboBox,PJSOptions.CompilerFilename,cstFilename,30);
|
||||
SetComboBoxText(HTTPServerComboBox,PJSOptions.HTTPServerFileName,cstFilename,30);
|
||||
SetComboBoxText(BrowserComboBox,PJSOptions.BrowserFileName,cstFilename,30);
|
||||
SetComboBoxText(NodeJSComboBox,PJSOptions.NodejsFileName,cstFilename,30);
|
||||
ServerPortSpinEdit.Value:=PJSOptions.StartAtPort;
|
||||
end;
|
||||
|
||||
@ -170,6 +197,7 @@ begin
|
||||
PJSOptions.CompilerFilename:=Pas2jsPathComboBox.Text;
|
||||
PJSOptions.HTTPServerFileName:=HTTPServerComboBox.Text;
|
||||
PJSOptions.BrowserFileName:=BrowserComboBox.Text;
|
||||
PJSOptions.NodeJSFileName:=NodeJSComboBox.Text;
|
||||
PJSOptions.StartAtPort:=ServerPortSpinEdit.Value;
|
||||
If PJSOptions.Modified then
|
||||
PJSOptions.Save;
|
||||
|
@ -57,14 +57,23 @@ type
|
||||
end;
|
||||
|
||||
{ TProjectPas2JSNodeJSApp }
|
||||
TNodeJSApplicationOption = (naoUseNodeJSApp); // Use NodeJS app object
|
||||
TNodeJSApplicationOptions = set of TNodeJSApplicationOption;
|
||||
|
||||
TProjectPas2JSNodeJSApp = class(TProjectDescriptor)
|
||||
private
|
||||
FOptions: TNodeJSApplicationOptions;
|
||||
protected
|
||||
function CreateProjectSource: String; virtual;
|
||||
function ShowOptionsDialog: TModalResult; virtual;
|
||||
public
|
||||
constructor Create; override;
|
||||
Function DoInitDescriptor : TModalResult; override;
|
||||
function GetLocalizedName: string; override;
|
||||
function GetLocalizedDescription: string; override;
|
||||
function InitProject(AProject: TLazProject): TModalResult; override;
|
||||
function CreateStartFiles(AProject: TLazProject): TModalResult; override;
|
||||
property Options : TNodeJSApplicationOptions Read FOptions Write FOptions;
|
||||
end;
|
||||
|
||||
var
|
||||
@ -74,7 +83,7 @@ procedure Register;
|
||||
|
||||
implementation
|
||||
|
||||
uses frmpas2jsbrowserprojectoptions;
|
||||
uses frmpas2jsnodejsprojectoptions, frmpas2jsbrowserprojectoptions;
|
||||
|
||||
procedure Register;
|
||||
|
||||
@ -91,6 +100,106 @@ end;
|
||||
|
||||
{ TProjectPas2JSNodeJSApp }
|
||||
|
||||
function TProjectPas2JSNodeJSApp.CreateProjectSource: String;
|
||||
Var
|
||||
Src : TStrings;
|
||||
units : string;
|
||||
|
||||
Procedure Add(aLine : String);
|
||||
|
||||
begin
|
||||
Src.Add(aLine);
|
||||
end;
|
||||
|
||||
Procedure AddLn(aLine : String);
|
||||
|
||||
begin
|
||||
if (Aline<>'') then
|
||||
Aline:=Aline+';';
|
||||
Add(Aline);
|
||||
end;
|
||||
|
||||
|
||||
begin
|
||||
Units:='';
|
||||
if naoUseNodeJSApp in Options then
|
||||
Units:=Units+' nodejsapp,' ;
|
||||
Units:=Units+' JS, Classes, SysUtils, nodeJS';
|
||||
Src:=TStringList.Create;
|
||||
try
|
||||
// create program source
|
||||
AddLn('program Project1');
|
||||
AddLn('');
|
||||
Add('{$mode objfpc}');
|
||||
Add('');
|
||||
Add('uses');
|
||||
AddLn(units) ;
|
||||
Add('');
|
||||
if naoUseNodeJSApp in Options then
|
||||
begin
|
||||
Add('Type');
|
||||
Add(' TMyApplication = Class(TNodeJSApplication)');
|
||||
AddLn(' procedure doRun; override');
|
||||
AddLn(' end');
|
||||
Add('');
|
||||
AddLn('Procedure TMyApplication.doRun');
|
||||
Add('');
|
||||
Add('begin');
|
||||
Add(' // Your code here');
|
||||
AddLn(' Terminate');
|
||||
AddLn('end');
|
||||
Add('');
|
||||
Add('var');
|
||||
AddLn(' Application : TMyApplication');
|
||||
Add('');
|
||||
end;
|
||||
Add('begin');
|
||||
if Not (naoUseNodeJSApp in Options) then
|
||||
Add(' // Your code here')
|
||||
else
|
||||
begin
|
||||
AddLn(' Application:=TMyApplication.Create(Nil)');
|
||||
AddLn(' Application.Initialize');
|
||||
AddLn(' Application.Run');
|
||||
AddLn(' Application.Free');
|
||||
end;
|
||||
Add('end.');
|
||||
Result:=Src.Text;
|
||||
finally
|
||||
Src.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TProjectPas2JSNodeJSApp.ShowOptionsDialog: TModalResult;
|
||||
|
||||
Function Co(o : TNodeJSApplicationOption) : boolean;
|
||||
|
||||
begin
|
||||
Result:=O in Options;
|
||||
end;
|
||||
|
||||
Procedure So(Value : Boolean; o : TNodeJSApplicationOption);
|
||||
|
||||
begin
|
||||
if Value then
|
||||
Include(Foptions,O);
|
||||
end;
|
||||
|
||||
|
||||
begin
|
||||
With TNodeJSProjectOptionsForm.Create(Nil) do
|
||||
try
|
||||
UseNodeJSApplication:=CO(naoUseNodeJSApp);
|
||||
Result:=ShowModal;
|
||||
if Result=mrOK then
|
||||
begin
|
||||
SO(UseNodeJSApplication,naoUseNodeJSApp);
|
||||
end;
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TProjectPas2JSNodeJSApp.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
@ -98,6 +207,11 @@ begin
|
||||
Flags:=DefaultProjectNoApplicationFlags-[pfRunnable];
|
||||
end;
|
||||
|
||||
function TProjectPas2JSNodeJSApp.DoInitDescriptor: TModalResult;
|
||||
begin
|
||||
Result:=ShowOptionsDialog;
|
||||
end;
|
||||
|
||||
function TProjectPas2JSNodeJSApp.GetLocalizedName: string;
|
||||
begin
|
||||
Result:=pjsdNodeJSApplication;
|
||||
@ -132,20 +246,11 @@ begin
|
||||
CompOpts.SetAlternativeCompile(
|
||||
'$MakeExe(pas2js) -Jc -Jminclude -Tnodejs "-Fu$(ProjUnitPath)" $Name($(ProjFile))',true);
|
||||
RunParams:=AProject.RunParameters;
|
||||
//RunParams.UseLaunchingApplication:=True;
|
||||
//RunParams.LaunchingApplicationPathPlusParams:='$MakeExe(IDE,nodejs) "$MakeDir($(ProjPath))$NameOnly($(ProjFile)).js"';
|
||||
RunParams.UseLaunchingApplication:=True;
|
||||
RunParams.LaunchingApplicationPathPlusParams:='$MakeExe(IDE,nodejs) "$MakeDir($(ProjPath))$NameOnly($(ProjFile)).js"';
|
||||
|
||||
// create program source
|
||||
NewSource:='program Project1;'+LineEnding
|
||||
+LineEnding
|
||||
+'{$mode objfpc}'+LineEnding
|
||||
+LineEnding
|
||||
+'uses'+LineEnding
|
||||
+' NodeJS, JS, Classes, SysUtils;'+LineEnding
|
||||
+LineEnding
|
||||
+'begin'+LineEnding
|
||||
+'end.'+LineEnding
|
||||
+LineEnding;
|
||||
NewSource:=CreateProjectSource;
|
||||
AProject.MainFile.SetSourceText(NewSource,true);
|
||||
|
||||
AProject.AddPackageDependency('pas2js_rtl');
|
||||
@ -402,8 +507,8 @@ begin
|
||||
CompOpts.SetAlternativeCompile(
|
||||
'$MakeExe(pas2js) -Jirtl.js -Jc -Jminclude -Tbrowser "-Fu$(ProjUnitPath)" $Name($(ProjFile))',true);
|
||||
RunParams:=AProject.RunParameters;
|
||||
//RunParams.UseLaunchingApplication:=True;
|
||||
//RunParams.LaunchingApplicationPathPlusParams:=GetBrowserCommand(CompOpts.TargetFileName);
|
||||
RunParams.UseLaunchingApplication:=True;
|
||||
RunParams.LaunchingApplicationPathPlusParams:=GetBrowserCommand(CompOpts.TargetFileName);
|
||||
AProject.MainFile.SetSourceText(CreateProjectSource,true);
|
||||
|
||||
// create html source
|
||||
|
Loading…
Reference in New Issue
Block a user