Changeset 61
- Timestamp:
- Jul 17, 2012, 9:15:42 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 7 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Compiler/Target/Delphi/UProducerPascal.pas
r58 r61 57 57 {$IFDEF Windows} 58 58 CompilerPath := 'c:\Program Files\Embarcadero\RAD Studio\9.0\bin\DCC32.EXE'; 59 CompilerParameters := '"%0:s"'; 59 60 {$ENDIF} 60 61 {$IFDEF Linux} -
trunk/Compiler/UProducer.pas
r59 r61 6 6 7 7 uses 8 USourceCode, Classes, SysUtils, StrUtils, SpecializedList; 8 USourceCode, Classes, SysUtils, StrUtils, SpecializedList, Process, 9 FileUtil, Forms; 9 10 10 11 type 11 12 12 13 TWriteTargetEvent = function (Name: string; const Code: string): Boolean of object; 14 TStringEvent = procedure (Value: string) of object; 13 15 14 16 { TProducer } … … 16 18 TProducer = class 17 19 private 20 FOnProcessOutput: TStringEvent; 18 21 FOnWriteTarget: TWriteTargetEvent; 19 22 public 23 Process: TProcess; 20 24 TextSource: TStringList; 21 25 IndentationLength: Integer; 22 26 Indentation: Integer; 23 27 CompilerPath: string; 28 CompilerParameters: string; 24 29 procedure Emit(AText: string); 25 30 procedure EmitLn(AText: string = ''); 26 31 procedure AssignToStringList(Target: TStringList); virtual; abstract; 27 32 procedure Produce(Module: TModule); virtual; abstract; 33 procedure ExternalExecute(CommandLine: string); 28 34 constructor Create; 29 35 destructor Destroy; override; 30 36 property OnWriteTarget: TWriteTargetEvent read FOnWriteTarget write FOnWriteTarget; 37 property OnProcessOutput: TStringEvent read FOnProcessOutput write FOnProcessOutput; 31 38 end; 32 39 … … 41 48 end; 42 49 50 procedure TProducer.ExternalExecute(CommandLine: string); 51 var 52 Buffer: string; 53 Count: Integer; 54 Text: string; 55 Line: string; 56 begin 57 if not FileExistsUTF8(CompilerPath) then Exit; 58 Text := ''; 59 try 60 Process := TProcess.Create(nil); 61 //if Path <> '' then 62 // Process.CurrentDirectory := Path; 63 //Path := ''; 64 //if Environment <> '' then 65 // Process.Environment.Text := Environment; 66 //Environment := ''; 67 Process.CommandLine := CommandLine; 68 Process.Options := [poUsePipes, poNoConsole]; 69 Process.Execute; 70 Application.ProcessMessages; 71 while Process.Running or (Process.Output.NumBytesAvailable > 0) or 72 (Process.Stderr.NumBytesAvailable > 0) do 73 begin 74 if Process.Output.NumBytesAvailable > 0 then begin 75 SetLength(Buffer, 1000); 76 Count := Process.Output.Read(Buffer[1], Length(Buffer)); 77 SetLength(Buffer, Count); 78 Text := Text + Buffer; 79 while Pos(LineEnding, Text) > 0 do begin 80 Line := Copy(Text, 1, Pos(LineEnding, Text) - 1); 81 Delete(Text, 1, Length(Line) + Length(LineEnding)); 82 if Assigned(FOnProcessOutput) then 83 FOnProcessOutput(Line); 84 end; 85 end; 86 87 if Process.Stderr.NumBytesAvailable > 0 then begin 88 SetLength(Buffer, 1000); 89 Count := Process.Stderr.Read(Buffer[1], Length(Buffer)); 90 SetLength(Buffer, Count); 91 Text := Text + Buffer; 92 while Pos(LineEnding, Text) > 0 do begin 93 Line := Copy(Text, 1, Pos(LineEnding, Text) - 1); 94 Delete(Text, 1, Length(Line) + Length(LineEnding)); 95 if Assigned(FOnProcessOutput) then 96 FOnProcessOutput(Line); 97 end; 98 end; 99 Sleep(10); 100 Application.ProcessMessages; 101 end; 102 finally 103 if Assigned(FOnProcessOutput) then 104 FOnProcessOutput(Text); 105 FreeAndNil(Process); 106 end; 107 end; 108 43 109 constructor TProducer.Create; 44 110 begin 45 111 TextSource := TStringList.Create; 46 112 IndentationLength := 2; 113 CompilerParameters := '%0:s'; 47 114 end; 48 115 -
trunk/IDE/Forms/UFormMain.lfm
r60 r61 116 116 Top = 26 117 117 Width = 200 118 ActivePage = TabSheet TargetProject118 ActivePage = TabSheetExternalProducer 119 119 Align = alRight 120 TabIndex = 2120 TabIndex = 3 121 121 TabOrder = 3 122 122 TabPosition = tpRight … … 129 129 object TabSheetTargetProject: TTabSheet 130 130 Caption = 'Target project' 131 end 132 object TabSheetExternalProducer: TTabSheet 133 Caption = 'External producer' 131 134 end 132 135 end -
trunk/IDE/Forms/UFormMain.lrt
r50 r61 3 3 TFORMMAIN.TABSHEETCODETREE.CAPTION=Code Tree 4 4 TFORMMAIN.TABSHEETTARGETPROJECT.CAPTION=Target project 5 TFORMMAIN.TABSHEETEXTERNALPRODUCER.CAPTION=External producer 5 6 TFORMMAIN.TABSHEETMESSAGES.CAPTION=Messages 6 7 TFORMMAIN.TABSHEETBREAKPOINTS.CAPTION=Breakpoints -
trunk/IDE/Forms/UFormMain.pas
r60 r61 90 90 Splitter2: TSplitter; 91 91 Splitter3: TSplitter; 92 TabSheetExternalProducer: TTabSheet; 92 93 TabSheetProject: TTabSheet; 93 94 TabSheetCodeTree: TTabSheet; … … 143 144 procedure UpdateMenu; 144 145 procedure UpdateTitle; 146 procedure ProducerProcessOutput(Text: string); 145 147 public 146 148 procedure LoadFromRegistry(Root: HKEY; Key: string); … … 162 164 UCore, UFormMessages, UFormSourceCode, UFormProject, UCommon, UFormAbout, UFormOptions, 163 165 UFormTargets, UTarget, UExecutor, UFormProjectNew, 164 UFormTargetProject ;166 UFormTargetProject, UFormExternalProducerOutput; 165 167 166 168 { TFormMain } … … 189 191 Compiler.Compile; 190 192 TargetProject.Files.LoadFromList(Compiler.TargetFiles.Files); 193 TargetProject.MainSource := TProjectFile(TargetProject.Files.First); 191 194 FormTargetProject.UpdateInterface; 195 196 FormExternalProducerOutput.Memo1.Clear; 197 if Assigned(Compiler.Target.Producer) then 198 with Compiler.Target.Producer do begin 199 FormExternalProducerOutput.Memo1.Lines.Add(CompilerPath + ' ' + Format(CompilerParameters, [TargetProject.MainSource.AbsoluteFileName])); 200 ExternalExecute(CompilerPath + ' ' + Format(CompilerParameters, [TargetProject.MainSource.AbsoluteFileName])); 201 end; 192 202 end; 193 203 FormProject.TreeViewProjectChange(Self, FormProject.TreeViewProject.Selected); … … 344 354 FormTargetCode.Align := alClient; 345 355 FormTargetCode.Show; 356 FormExternalProducerOutput.ManualDock(TabSheetExternalProducer, nil, alClient); 357 FormExternalProducerOutput.Align := alClient; 358 FormExternalProducerOutput.Show; 346 359 PageControlRight.TabIndex := 0; 347 360 PageControlBottom.TabIndex := 0; … … 446 459 end; 447 460 461 procedure TFormMain.ProducerProcessOutput(Text: string); 462 begin 463 FormExternalProducerOutput.Memo1.Lines.Add(Text); 464 end; 465 448 466 procedure TFormMain.FormClose(Sender: TObject; var Action: TCloseAction); 449 467 begin … … 453 471 454 472 procedure TFormMain.FormCreate(Sender: TObject); 455 begin 473 var 474 I: Integer; 475 begin 476 with Core.Compiler.Targets do 477 for I := 0 to Count - 1 do 478 with TTarget(Items[I]) do 479 if Assigned(Producer) then 480 Producer.OnProcessOutput := ProducerProcessOutput; 456 481 end; 457 482 … … 517 542 if FormProjectNew.ShowModal = mrOk then begin 518 543 if Assigned(FormProjectNew.ListView1.Selected) then begin 519 Core.ProjectNew; 544 if TProjectTemplate(FormProjectNew.ListView1.Selected.Data).IsProject then 545 Core.ProjectNew; 520 546 TProjectTemplate(FormProjectNew.ListView1.Selected.Data).InitProject(Core.Project); 521 547 end; -
trunk/IDE/Forms/UFormProject.lfm
r57 r61 19 19 TabOrder = 0 20 20 OnChange = TreeViewProjectChange 21 OnDblClick = TreeViewProjectDblClick 21 22 Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw] 22 23 end -
trunk/IDE/Forms/UFormProject.pas
r56 r61 29 29 procedure AShowExecute(Sender: TObject); 30 30 procedure TreeViewProjectChange(Sender: TObject; Node: TTreeNode); 31 procedure TreeViewProjectDblClick(Sender: TObject); 31 32 private 32 33 procedure UpdateProjectFiles(Node: TTreeNode; Files: TProjectFileList); … … 46 47 UCore, UFormMain, UFormSourceCode, UFormTargetCode, UFormCodeTree; 47 48 49 resourcestring 50 SRenameSourceFile = 'Rename source file'; 51 SEnterNewFileName = 'Enter new file name'; 52 48 53 { TFormProject } 49 54 … … 54 59 if Assigned(Node) then begin 55 60 if TProjectFile(Node.Data) is TProjectFile then begin 56 ProjectFile := TProjectFile(Node.Data);57 SynEditSource.Lines.Assign(TProjectFile(Node.Data).Source);61 TreeViewProject.PopupMenu := PopupMenuFile; 62 AShow.Execute; 58 63 (* if FileExists(TProjectFile(Node.Data).ProducedFileName) then 59 64 CompiledForm.SynEdit1.Lines.LoadFromFile(FileName) else … … 78 83 //CodeTreeForm.TreeView1.Assign(TProducerTreeView(Compiler.Producer).TreeView); 79 84 *) 80 end; 85 end else 86 TreeViewProject.PopupMenu := nil; 81 87 end; 88 end; 89 90 procedure TFormProject.TreeViewProjectDblClick(Sender: TObject); 91 begin 92 AShow.Execute; 82 93 end; 83 94 … … 95 106 procedure TFormProject.ADeleteExecute(Sender: TObject); 96 107 begin 97 108 if Assigned(TreeViewProject.Selected) then 109 Core.Project.Files.Remove(TreeViewProject.Selected.Data); 110 UpdateProjectTree; 98 111 end; 99 112 100 113 procedure TFormProject.ARenameExecute(Sender: TObject); 114 var 115 NewName: string; 101 116 begin 102 117 if Assigned(TreeViewProject.Selected) then begin 118 NewName := TProjectFile(TreeViewProject.Selected.Data).FileName; 119 if InputQuery(SRenameSourceFile, SEnterNewFileName, NewName) then 120 TProjectFile(TreeViewProject.Selected.Data).FileName := NewName; 121 UpdateProjectTree; 122 end; 103 123 end; 104 124 105 125 procedure TFormProject.AShowExecute(Sender: TObject); 106 126 begin 107 127 if Assigned(TreeViewProject.Selected) then 128 FormSourceCode.SynEditSource.Lines.Assign(TProjectFile(TreeViewProject.Selected.Data).Source); 108 129 end; 109 130 -
trunk/IDE/Forms/UFormProjectNew.pas
r57 r61 74 74 with Core do 75 75 for I := 0 to ProjectTemplates.Count - 1 do 76 with TProjectTemplate(ProjectTemplates[I]) do begin 76 with TProjectTemplate(ProjectTemplates[I]) do 77 if (not Assigned(Core.Project) and IsProject) or Assigned(Core.Project) then begin 77 78 NewItem := ListView1.Items.Add; 78 79 NewItem.Caption := Name; -
trunk/IDE/Languages/Transpascal.cs.po
r60 r61 108 108 msgstr "Cesta překladače:" 109 109 110 #: tformexternalproduceroutput.caption 111 msgctxt "tformexternalproduceroutput.caption" 112 msgid "External producer" 113 msgstr "Vnější generátor" 114 110 115 #: tformmain.aabout.caption 111 116 msgctxt "tformmain.aabout.caption" … … 319 324 msgstr "Strom kódu" 320 325 326 #: tformmain.tabsheetexternalproducer.caption 327 msgctxt "tformmain.tabsheetexternalproducer.caption" 328 msgid "External producer" 329 msgstr "Vnější generátor" 330 321 331 #: tformmain.tabsheetmessages.caption 322 332 msgctxt "tformmain.tabsheetmessages.caption" … … 460 470 msgctxt "tformtargetoptions.buttonexecutorselect.caption" 461 471 msgid "Select..." 462 msgstr " "472 msgstr "Výběr..." 463 473 464 474 #: tformtargetoptions.buttonproducerselect.caption 465 475 msgctxt "tformtargetoptions.buttonproducerselect.caption" 466 476 msgid "Select..." 467 msgstr " "477 msgstr "Výběr..." 468 478 469 479 #: tformtargetoptions.caption 470 480 msgctxt "tformtargetoptions.caption" 471 481 msgid "Target options" 472 msgstr " "482 msgstr "Volby cíle" 473 483 474 484 #: tformtargetoptions.label1.caption 475 485 msgid "Name:" 476 msgstr " "486 msgstr "Jméno:" 477 487 478 488 #: tformtargetoptions.label2.caption … … 483 493 #: tformtargetoptions.label3.caption 484 494 msgid "Executor path:" 485 msgstr " "495 msgstr "Cesta vykonávače:" 486 496 487 497 #: tformtargetoptions.labelname.caption 488 498 msgid " " 489 msgstr " "499 msgstr " " 490 500 491 501 #: tformtargetproject.caption … … 501 511 msgctxt "tformtargets.atargetoptions.hint" 502 512 msgid "Target options" 503 msgstr " "513 msgstr "Volby cíle" 504 514 505 515 #: tformtargets.caption … … 514 524 515 525 #: tformtargets.listview1.columns[1].caption 516 #, fuzzy517 526 #| msgid "Execution path" 518 527 msgctxt "tformtargets.listview1.columns[1].caption" 519 528 msgid "Compiler path" 520 msgstr "Cesta vykonání"529 msgstr "Cesta překladače" 521 530 522 531 #: tformtargets.listview1.columns[2].caption 523 532 msgid "Executor path" 524 msgstr " "533 msgstr "Cesta vykonávače" 525 534 526 535 #: tmainform.aabout.caption … … 845 854 msgstr "Nový projekt" 846 855 856 #: uformproject.senternewfilename 857 msgid "Enter new file name" 858 msgstr "Zadejte nové jméno souboru" 859 860 #: uformproject.srenamesourcefile 861 msgid "Rename source file" 862 msgstr "Přejmenování zdrojového souboru" 863 847 864 #: uformtargets.scompileroptions 848 865 msgctxt "uformtargets.scompileroptions" … … 865 882 msgstr "Nový projekt" 866 883 884 #: uprojecttemplates.sconsoleapplication 885 msgid "Console application" 886 msgstr "Konzolová aplikace" 887 888 #: uprojecttemplates.sguiapplication 889 msgid "GUI application" 890 msgstr "GUI aplikace" 891 892 #: uprojecttemplates.spackage 893 msgid "Package" 894 msgstr "Balíček" 895 896 #: uprojecttemplates.sunit 897 msgid "Unit" 898 msgstr "Jednotka" 899 -
trunk/IDE/Languages/Transpascal.po
r60 r61 100 100 msgstr "" 101 101 102 #: tformexternalproduceroutput.caption 103 msgctxt "tformexternalproduceroutput.caption" 104 msgid "External producer" 105 msgstr "" 106 102 107 #: tformmain.aabout.caption 103 108 msgctxt "TFORMMAIN.AABOUT.CAPTION" … … 310 315 msgstr "" 311 316 317 #: tformmain.tabsheetexternalproducer.caption 318 msgctxt "TFORMMAIN.TABSHEETEXTERNALPRODUCER.CAPTION" 319 msgid "External producer" 320 msgstr "" 321 312 322 #: tformmain.tabsheetmessages.caption 313 323 msgctxt "TFORMMAIN.TABSHEETMESSAGES.CAPTION" … … 833 843 msgstr "" 834 844 845 #: uformproject.senternewfilename 846 msgid "Enter new file name" 847 msgstr "" 848 849 #: uformproject.srenamesourcefile 850 msgid "Rename source file" 851 msgstr "" 852 835 853 #: uformtargets.scompileroptions 836 854 msgctxt "uformtargets.scompileroptions" … … 853 871 msgstr "" 854 872 873 #: uprojecttemplates.sconsoleapplication 874 msgid "Console application" 875 msgstr "" 876 877 #: uprojecttemplates.sguiapplication 878 msgid "GUI application" 879 msgstr "" 880 881 #: uprojecttemplates.spackage 882 msgid "Package" 883 msgstr "" 884 885 #: uprojecttemplates.sunit 886 msgid "Unit" 887 msgstr "" 888 -
trunk/IDE/Transpascal.lpi
r60 r61 106 106 </Item7> 107 107 </RequiredPackages> 108 <Units Count="1 7">108 <Units Count="18"> 109 109 <Unit0> 110 110 <Filename Value="Transpascal.lpr"/> … … 166 166 <IsPartOfProject Value="True"/> 167 167 <ComponentName Value="FormCodeTree"/> 168 <HasResources Value="True"/> 168 169 <ResourceBaseClass Value="Form"/> 169 170 <UnitName Value="UFormCodeTree"/> … … 228 229 <UnitName Value="UFormTargetOptions"/> 229 230 </Unit16> 231 <Unit17> 232 <Filename Value="Forms\UFormExternalProducerOutput.pas"/> 233 <IsPartOfProject Value="True"/> 234 <ComponentName Value="FormExternalProducerOutput"/> 235 <ResourceBaseClass Value="Form"/> 236 <UnitName Value="UFormExternalProducerOutput"/> 237 </Unit17> 230 238 </Units> 231 239 </ProjectOptions> -
trunk/IDE/Transpascal.lpr
r60 r61 14 14 UFormAbout, UFormOptions, UFormTargets, 15 15 UFormProjectNew, UProjectTemplates, UFormTargetProject, UCore, 16 UFormTargetOptions ;16 UFormTargetOptions, UFormExternalProducerOutput; 17 17 18 18 {$R *.res} … … 32 32 33 33 Application.Initialize; 34 Application.CreateForm(TCore, Core); 34 35 Application.CreateForm(TFormMain, FormMain); 35 36 Application.CreateForm(TFormProject, FormProject); … … 43 44 Application.CreateForm(TFormProjectNew, FormProjectNew); 44 45 Application.CreateForm(TFormTargetProject, FormTargetProject); 45 Application.CreateForm(TCore, Core);46 46 Application.CreateForm(TFormTargetOptions, FormTargetOptions); 47 Application.CreateForm(TFormExternalProducerOutput, FormExternalProducerOutput 48 ); 47 49 Application.Run; 48 50 end. -
trunk/IDE/UProject.pas
r57 r61 98 98 Name: string; 99 99 Description: TStringList; 100 IsProject: Boolean; 100 101 procedure InitProject(var Project: TProject); virtual; 101 102 constructor Create; virtual; -
trunk/IDE/UProjectTemplates.pas
r54 r61 41 41 implementation 42 42 43 resourcestring 44 SConsoleApplication = 'Console application'; 45 SUnit = 'Unit'; 46 SPackage = 'Package'; 47 SGUIApplication = 'GUI application'; 48 43 49 { TProjectTemplateUnit } 44 50 … … 46 52 begin 47 53 inherited Create; 48 Name := 'Unit'; 54 Name := SUnit; 55 IsProject := False; 49 56 end; 50 57 … … 64 71 Add('end.'); 65 72 end; 66 Project.MainSource := NewFile;67 73 end; 68 74 … … 72 78 begin 73 79 inherited Create; 74 Name := 'Package'; 80 Name := SPackage; 81 IsProject := True; 75 82 end; 76 83 … … 97 104 begin 98 105 inherited Create; 99 Name := 'GUI application'; 106 Name := SGUIApplication; 107 IsProject := True; 100 108 end; 101 109 … … 128 136 begin 129 137 inherited Create; 130 Name := 'Console application'; 138 Name := SConsoleApplication; 139 IsProject := True; 131 140 end; 132 141
Note:
See TracChangeset
for help on using the changeset viewer.