Changeset 66
- Timestamp:
- Oct 18, 2010, 10:00:00 AM (14 years ago)
- Location:
- branches/Transpascal
- Files:
-
- 6 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Transpascal/Forms/UMainForm.lfm
r63 r66 79 79 Action = AProjectOpen 80 80 end 81 object MenuItemOpenRecent: TMenuItem 82 Caption = 'Open recent' 83 end 81 84 object MenuItem4: TMenuItem 82 85 Action = AProjectSave … … 108 111 Caption = 'Open...' 109 112 Hint = 'Open project' 113 OnExecute = AProjectOpenExecute 110 114 end 111 115 object AProjectSave: TAction … … 118 122 Caption = 'Save as...' 119 123 Hint = 'Save project with custom name' 124 OnExecute = AProjectSaveAsExecute 120 125 end 121 126 object AProjectClose: TAction … … 145 150 top = 56 146 151 end 152 object OpenDialog1: TOpenDialog 153 Filter = 'Project file (*.*)|*.tppr|Any file (*.*)|*.*' 154 left = 115 155 top = 52 156 end 157 object SaveDialog1: TSaveDialog 158 Filter = 'Project file (*.*)|*.tppr|Any file (*.*)|*.*' 159 left = 115 160 top = 104 161 end 147 162 end -
branches/Transpascal/Forms/UMainForm.pas
r64 r66 7 7 uses 8 8 SysUtils, Variants, Classes, Graphics, Controls, Forms, 9 Dialogs, StdCtrls, UCompiler, UProducerAsm8051, 9 Dialogs, StdCtrls, UCompiler, UProducerAsm8051, Registry, 10 10 UProducerC, ComCtrls, ExtCtrls, SynEdit, SynHighlighterPas, UProducerTreeView, 11 11 UProducerPascal, Contnrs, UProject, FileUtil, Menus, ActnList, UCoolDocking, 12 UCompiledForm, UCodeTreeForm ;12 UCompiledForm, UCodeTreeForm, URegistry, ULastOpenedList, UApplicationInfo; 13 13 14 14 const 15 ProjectDir = '../../Project/'; 15 RegistryRootKey = HKEY_CURRENT_USER; 16 RegistryKey = 'Software\Transpascal'; 16 17 17 18 type … … 40 41 MenuItem8: TMenuItem; 41 42 DockPanel: TPanel; 43 MenuItemOpenRecent: TMenuItem; 44 OpenDialog1: TOpenDialog; 45 SaveDialog1: TSaveDialog; 42 46 Splitter3: TSplitter; 43 47 ToolBar1: TToolBar; 48 procedure AProjectOpenExecute(Sender: TObject); 49 procedure AProjectSaveAsExecute(Sender: TObject); 44 50 procedure ComboBox1Change(Sender: TObject); 45 51 procedure ComboBoxTargetSelectionChange(Sender: TObject); … … 50 56 procedure FormDestroy(Sender: TObject); 51 57 private 58 LastOpenedFiles: TLastOpenedList; 59 ReopenLastOpenedFile: Boolean; 60 procedure OpenRecentClick(Sender: TObject); 52 61 procedure LoadErrorMessages; 53 procedure UpdateProjectTree;54 procedure UpdateProjectGroup(Node: TTreeNode; Group: TProjectGroup);55 62 procedure DockInit; 63 procedure LoadFromRegistry; 64 procedure SaveToRegistry; 65 procedure OpenProject(FileName: string); 56 66 public 57 67 Project: TProject; … … 96 106 Compiler.Init; 97 107 Compiler.Parser.OnGetSource := GetSource; 108 if Project.Items.Count > 0 then 98 109 with TProjectFile(Project.Items[0]) do begin 99 110 Compiler.Compile(Parent.GetDir + Name, Source); … … 117 128 end; 118 129 119 procedure TMainForm.UpdateProjectTree;120 var121 NewNode: TTreeNode;122 begin123 with ProjectManager, TreeViewProject, Items do begin124 BeginUpdate;125 Clear;126 NewNode := AddChild(nil, Project.Name);127 UpdateProjectGroup(NewNode, Project);128 NewNode.Expand(True);129 EndUpdate;130 TreeViewProject.TopItem.Items[0].Selected := True;131 end;132 end;133 134 procedure TMainForm.UpdateProjectGroup(Node: TTreeNode; Group: TProjectGroup);135 var136 I: Integer;137 NewNode: TTreeNode;138 begin139 with ProjectManager do140 for I := 0 to Group.Items.Count - 1 do begin141 NewNode := TreeViewProject.Items.AddChild(Node,142 TProjectNode(Group.Items[I]).Name);143 NewNode.Data := Pointer(Group.Items[I]);144 if TProjectNode(Group.Items[I]) is TProjectGroup then145 UpdateProjectGroup(NewNode, TProjectGroup(Group.Items[I]));146 end;147 end;148 149 130 function TMainForm.GetSource(Name: string; Source: TStringList): Boolean; 150 131 var … … 195 176 end; 196 177 178 procedure TMainForm.LoadFromRegistry; 179 begin 180 with TRegistryEx.Create do 181 try 182 RootKey := HKEY_CURRENT_USER; 183 OpenKey(RegistryKey, True); 184 ReopenLastOpenedFile := ReadBoolWithDefault('ReopenLastOpenedFile', True); 185 finally 186 Free; 187 end; 188 LastOpenedFiles.LoadFromRegistry(RegistryRootKey, RegistryKey); 189 end; 190 191 procedure TMainForm.SaveToRegistry; 192 begin 193 with TRegistryEx.Create do 194 try 195 RootKey := RegistryRootKey; 196 OpenKey(RegistryKey, True); 197 WriteBool('ReopenLastOpenedFile', ReopenLastOpenedFile); 198 finally 199 Free; 200 end; 201 LastOpenedFiles.SaveToRegistry(RegistryRootKey, RegistryKey); 202 LastOpenedFiles.ReloadMenu; 203 end; 204 205 procedure TMainForm.OpenProject(FileName: string); 206 begin 207 Project.LoadFromFile(FileName); 208 LastOpenedFiles.Add(FileName); 209 LastOpenedFiles.ReloadMenu; 210 ProjectManager.UpdateProjectTree; 211 Caption := ApplicationInfo.Name + ' - ' + Project.Name; 212 end; 213 197 214 procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction); 198 215 begin 199 216 Project.Save; 217 SaveToRegistry; 200 218 end; 201 219 … … 204 222 Compiler := TCompiler.Create; 205 223 Project := TProject.Create; 224 LastOpenedFiles := TLastOpenedList.Create; 225 LastOpenedFiles.MenuItem := MenuItemOpenRecent; 226 LastOpenedFiles.ClickAction := OpenRecentClick; 206 227 end; 207 228 208 229 procedure TMainForm.FormDestroy(Sender: TObject); 209 230 begin 231 LastOpenedFiles.Free; 210 232 Project.Free; 211 233 Compiler.Free; 212 234 end; 213 235 236 procedure TMainForm.OpenRecentClick(Sender: TObject); 237 begin 238 if Sender is TMenuItem then 239 OpenProject(StringReplace(TMenuItem(Sender).Caption, '&', '', [rfReplaceAll])); 240 end; 241 214 242 procedure TMainForm.FormShow(Sender: TObject); 215 243 var 216 244 NewProjectFile: TProjectFile; 217 245 begin 246 LoadFromRegistry; 218 247 DockInit; 219 248 220 Project.RootDir := '../../Project/'; 221 Project.Name := 'Project'; 222 223 NewProjectFile := TProjectFile.Create; 224 NewProjectFile.Parent := Project; 225 NewProjectFile.Name := 'Project.pas'; 226 Project.Items.Add(NewProjectFile); 227 228 NewProjectFile := TProjectFile.Create; 229 NewProjectFile.Parent := Project; 230 NewProjectFile.Name := 'System.pas'; 231 Project.Items.Add(NewProjectFile); 232 233 NewProjectFile := TProjectFile.Create; 234 NewProjectFile.Parent := Project; 235 NewProjectFile.Name := 'MemoryManager.pas'; 236 Project.Items.Add(NewProjectFile); 237 238 Project.Load; 239 UpdateProjectTree; 249 if ReopenLastOpenedFile and (LastOpenedFiles.Count > 0) then begin 250 OpenProject(LastOpenedFiles[0]); 251 end; 240 252 241 253 WindowState := wsMaximized; 254 end; 255 256 procedure TMainForm.ComboBox1Change(Sender: TObject); 257 begin 242 258 ButtonCompileClick(Self); 243 259 end; 244 260 245 procedure TMainForm.ComboBox1Change(Sender: TObject); 261 procedure TMainForm.AProjectOpenExecute(Sender: TObject); 262 begin 263 if OpenDialog1.Execute then begin 264 OpenProject(OpenDialog1.FileName); 265 end; 266 end; 267 268 procedure TMainForm.AProjectSaveAsExecute(Sender: TObject); 269 begin 270 if SaveDialog1.Execute then begin 271 Project.SaveToFile(SaveDialog1.FileName); 272 end; 273 end; 274 275 procedure TMainForm.ComboBoxTargetSelectionChange(Sender: TObject); 246 276 begin 247 277 ButtonCompileClick(Self); 248 278 end; 249 279 250 procedure TMainForm.ComboBoxTargetSelectionChange(Sender: TObject);251 begin252 ButtonCompileClick(Self);253 end;254 255 280 end. -
branches/Transpascal/Forms/UProjectManager.pas
r63 r66 15 15 procedure TreeViewProjectChange(Sender: TObject; Node: TTreeNode); 16 16 private 17 { private declarations }17 procedure UpdateProjectGroup(Node: TTreeNode; Group: TProjectGroup); 18 18 public 19 { public declarations }20 end; 19 procedure UpdateProjectTree; 20 end; 21 21 22 22 var … … 69 69 end; 70 70 71 procedure TProjectManager.UpdateProjectTree; 72 var 73 NewNode: TTreeNode; 74 begin 75 with MainForm, TreeViewProject, Items do begin 76 BeginUpdate; 77 Clear; 78 NewNode := AddChild(nil, Project.Name); 79 UpdateProjectGroup(NewNode, Project); 80 NewNode.Expand(True); 81 EndUpdate; 82 TreeViewProject.TopItem.Items[0].Selected := True; 83 end; 84 end; 85 86 procedure TProjectManager.UpdateProjectGroup(Node: TTreeNode; Group: TProjectGroup); 87 var 88 I: Integer; 89 NewNode: TTreeNode; 90 begin 91 with MainForm do 92 for I := 0 to Group.Items.Count - 1 do begin 93 NewNode := TreeViewProject.Items.AddChild(Node, 94 TProjectNode(Group.Items[I]).Name); 95 NewNode.Data := Pointer(Group.Items[I]); 96 if TProjectNode(Group.Items[I]) is TProjectGroup then 97 UpdateProjectGroup(NewNode, TProjectGroup(Group.Items[I])); 98 end; 99 end; 100 101 102 71 103 end. 72 104 -
branches/Transpascal/Transpascal.lpi
r65 r66 46 46 </Item4> 47 47 </RequiredPackages> 48 <Units Count="3 3">48 <Units Count="37"> 49 49 <Unit0> 50 50 <Filename Value="Transpascal.lpr"/> 51 51 <IsPartOfProject Value="True"/> 52 52 <UnitName Value="Transpascal"/> 53 <EditorIndex Value="1 3"/>53 <EditorIndex Value="14"/> 54 54 <WindowIndex Value="0"/> 55 55 <TopLine Value="4"/> 56 <CursorPos X="45" Y="1 7"/>57 <UsageCount Value="17 1"/>56 <CursorPos X="45" Y="18"/> 57 <UsageCount Value="173"/> 58 58 <Loaded Value="True"/> 59 59 <DefaultSyntaxHighlighter Value="Delphi"/> … … 66 66 <ResourceBaseClass Value="Form"/> 67 67 <UnitName Value="UMainForm"/> 68 <IsVisibleTab Value="True"/> 68 69 <EditorIndex Value="10"/> 69 70 <WindowIndex Value="0"/> 70 71 <TopLine Value="1"/> 71 <CursorPos X=" 22" Y="15"/>72 <UsageCount Value="17 1"/>72 <CursorPos X="77" Y="12"/> 73 <UsageCount Value="173"/> 73 74 <Loaded Value="True"/> 74 75 <LoadedDesigner Value="True"/> … … 82 83 <TopLine Value="1"/> 83 84 <CursorPos X="1" Y="6"/> 84 <UsageCount Value="17 1"/>85 <UsageCount Value="173"/> 85 86 <DefaultSyntaxHighlighter Value="Delphi"/> 86 87 </Unit2> … … 216 217 <EditorIndex Value="6"/> 217 218 <WindowIndex Value="0"/> 218 <TopLine Value=" 126"/>219 <CursorPos X=" 6" Y="1"/>220 <UsageCount Value="4 3"/>219 <TopLine Value="212"/> 220 <CursorPos X="1" Y="225"/> 221 <UsageCount Value="45"/> 221 222 <Loaded Value="True"/> 222 223 <DefaultSyntaxHighlighter Value="Delphi"/> … … 236 237 <TopLine Value="1"/> 237 238 <CursorPos X="33" Y="1"/> 238 <UsageCount Value="1 4"/>239 <UsageCount Value="15"/> 239 240 <Loaded Value="True"/> 240 241 </Unit21> … … 246 247 <TopLine Value="81"/> 247 248 <CursorPos X="20" Y="82"/> 248 <UsageCount Value="1 2"/>249 <UsageCount Value="13"/> 249 250 <Loaded Value="True"/> 250 251 </Unit22> … … 256 257 <TopLine Value="173"/> 257 258 <CursorPos X="4" Y="192"/> 258 <UsageCount Value="1 1"/>259 <UsageCount Value="12"/> 259 260 <Loaded Value="True"/> 260 261 </Unit23> … … 262 263 <Filename Value="Compiler\Analyze\UParser.pas"/> 263 264 <UnitName Value="UParser"/> 264 <IsVisibleTab Value="True"/>265 265 <EditorIndex Value="5"/> 266 266 <WindowIndex Value="0"/> 267 <TopLine Value=" 1099"/>268 <CursorPos X="4 6" Y="1119"/>269 <UsageCount Value="1 2"/>267 <TopLine Value="495"/> 268 <CursorPos X="43" Y="512"/> 269 <UsageCount Value="13"/> 270 270 <Loaded Value="True"/> 271 271 </Unit24> … … 286 286 <EditorIndex Value="2"/> 287 287 <WindowIndex Value="0"/> 288 <TopLine Value=" 31"/>289 <CursorPos X=" 15" Y="40"/>290 <UsageCount Value="2 7"/>288 <TopLine Value="71"/> 289 <CursorPos X="20" Y="76"/> 290 <UsageCount Value="29"/> 291 291 <Loaded Value="True"/> 292 292 <LoadedDesigner Value="True"/> … … 303 303 <TopLine Value="7"/> 304 304 <CursorPos X="32" Y="16"/> 305 <UsageCount Value="2 7"/>305 <UsageCount Value="29"/> 306 306 <Loaded Value="True"/> 307 307 <LoadedDesigner Value="True"/> … … 314 314 <ResourceBaseClass Value="Form"/> 315 315 <UnitName Value="UMessagesForm"/> 316 <EditorIndex Value="1 1"/>316 <EditorIndex Value="12"/> 317 317 <WindowIndex Value="0"/> 318 318 <TopLine Value="1"/> 319 319 <CursorPos X="36" Y="9"/> 320 <UsageCount Value="2 7"/>320 <UsageCount Value="29"/> 321 321 <Loaded Value="True"/> 322 322 <LoadedDesigner Value="True"/> … … 334 334 <TopLine Value="5"/> 335 335 <CursorPos X="28" Y="21"/> 336 <UsageCount Value="2 6"/>336 <UsageCount Value="28"/> 337 337 <Loaded Value="True"/> 338 338 <LoadedDesigner Value="True"/> … … 345 345 <ResourceBaseClass Value="Form"/> 346 346 <UnitName Value="UCodeTreeForm"/> 347 <EditorIndex Value="1 2"/>347 <EditorIndex Value="13"/> 348 348 <WindowIndex Value="0"/> 349 349 <TopLine Value="1"/> 350 350 <CursorPos X="1" Y="1"/> 351 <UsageCount Value="2 6"/>351 <UsageCount Value="28"/> 352 352 <Loaded Value="True"/> 353 353 <LoadedDesigner Value="True"/> … … 361 361 <TopLine Value="350"/> 362 362 <CursorPos X="3" Y="355"/> 363 <UsageCount Value="1 2"/>363 <UsageCount Value="13"/> 364 364 <Loaded Value="True"/> 365 365 </Unit31> … … 371 371 <TopLine Value="316"/> 372 372 <CursorPos X="14" Y="329"/> 373 <UsageCount Value="1 2"/>373 <UsageCount Value="13"/> 374 374 <Loaded Value="True"/> 375 375 </Unit32> 376 <Unit33> 377 <Filename Value="E:\Programy\Lazarus\lcl\include\customform.inc"/> 378 <EditorIndex Value="11"/> 379 <WindowIndex Value="0"/> 380 <TopLine Value="1756"/> 381 <CursorPos X="35" Y="1768"/> 382 <UsageCount Value="10"/> 383 <Loaded Value="True"/> 384 </Unit33> 385 <Unit34> 386 <Filename Value="Common\URegistry.pas"/> 387 <IsPartOfProject Value="True"/> 388 <UnitName Value="URegistry"/> 389 <UsageCount Value="21"/> 390 </Unit34> 391 <Unit35> 392 <Filename Value="Common\ULastOpenedList.pas"/> 393 <IsPartOfProject Value="True"/> 394 <UnitName Value="ULastOpenedList"/> 395 <UsageCount Value="21"/> 396 <DefaultSyntaxHighlighter Value="Delphi"/> 397 </Unit35> 398 <Unit36> 399 <Filename Value="UApplicationInfo.pas"/> 400 <IsPartOfProject Value="True"/> 401 <UnitName Value="UApplicationInfo"/> 402 <UsageCount Value="20"/> 403 <DefaultSyntaxHighlighter Value="Delphi"/> 404 </Unit36> 376 405 </Units> 377 <JumpHistory Count="30" HistoryIndex="2 6">406 <JumpHistory Count="30" HistoryIndex="29"> 378 407 <Position1> 379 <Filename Value=" Compiler\Analyze\UParser.pas"/>380 <Caret Line="1 074" Column="1" TopLine="1067"/>408 <Filename Value="UProject.pas"/> 409 <Caret Line="163" Column="3" TopLine="160"/> 381 410 </Position1> 382 411 <Position2> 383 <Filename Value=" Compiler\Analyze\UParser.pas"/>384 <Caret Line="1 075" Column="1" TopLine="1067"/>412 <Filename Value="UProject.pas"/> 413 <Caret Line="140" Column="1" TopLine="136"/> 385 414 </Position2> 386 415 <Position3> 387 <Filename Value=" Compiler\Analyze\UParser.pas"/>388 <Caret Line=" 1076" Column="1" TopLine="1067"/>416 <Filename Value="UProject.pas"/> 417 <Caret Line="225" Column="1" TopLine="212"/> 389 418 </Position3> 390 419 <Position4> 391 <Filename Value=" Compiler\Analyze\UParser.pas"/>392 <Caret Line="1 077" Column="1" TopLine="1067"/>420 <Filename Value="UProject.pas"/> 421 <Caret Line="138" Column="1" TopLine="125"/> 393 422 </Position4> 394 423 <Position5> 395 <Filename Value=" Compiler\Analyze\UParser.pas"/>396 <Caret Line="1 078" Column="1" TopLine="1067"/>424 <Filename Value="UProject.pas"/> 425 <Caret Line="139" Column="1" TopLine="125"/> 397 426 </Position5> 398 427 <Position6> 399 <Filename Value=" Compiler\Analyze\UParser.pas"/>400 <Caret Line="1 089" Column="1" TopLine="1067"/>428 <Filename Value="UProject.pas"/> 429 <Caret Line="143" Column="1" TopLine="125"/> 401 430 </Position6> 402 431 <Position7> 403 <Filename Value=" Compiler\USourceCode.pas"/>404 <Caret Line=" 723" Column="1" TopLine="710"/>432 <Filename Value="UProject.pas"/> 433 <Caret Line="144" Column="1" TopLine="125"/> 405 434 </Position7> 406 435 <Position8> 407 <Filename Value=" Compiler\Analyze\UParser.pas"/>408 <Caret Line="1 074" Column="1" TopLine="1067"/>436 <Filename Value="Forms\UMainForm.pas"/> 437 <Caret Line="192" Column="47" TopLine="186"/> 409 438 </Position8> 410 439 <Position9> 411 <Filename Value=" Compiler\Analyze\UParser.pas"/>412 <Caret Line="1 075" Column="1" TopLine="1067"/>440 <Filename Value="Forms\UMainForm.pas"/> 441 <Caret Line="193" Column="35" TopLine="186"/> 413 442 </Position9> 414 443 <Position10> 415 <Filename Value=" Compiler\Analyze\UParser.pas"/>416 <Caret Line=" 1076" Column="1" TopLine="1067"/>444 <Filename Value="Forms\UMainForm.pas"/> 445 <Caret Line="56" Column="30" TopLine="39"/> 417 446 </Position10> 418 447 <Position11> 419 <Filename Value=" Compiler\Analyze\UParser.pas"/>420 <Caret Line="1 077" Column="1" TopLine="1067"/>448 <Filename Value="Forms\UMainForm.pas"/> 449 <Caret Line="15" Column="40" TopLine="1"/> 421 450 </Position11> 422 451 <Position12> 423 <Filename Value=" Compiler\Analyze\UParser.pas"/>424 <Caret Line=" 1079" Column="1" TopLine="1067"/>452 <Filename Value="Forms\UMainForm.pas"/> 453 <Caret Line="9" Column="60" TopLine="1"/> 425 454 </Position12> 426 455 <Position13> 427 <Filename Value=" Compiler\Analyze\UParser.pas"/>428 <Caret Line=" 1080" Column="1" TopLine="1067"/>456 <Filename Value="Forms\UMainForm.pas"/> 457 <Caret Line="56" Column="20" TopLine="47"/> 429 458 </Position13> 430 459 <Position14> 431 <Filename Value=" Compiler\Analyze\UParser.pas"/>432 <Caret Line="1 081" Column="1" TopLine="1067"/>460 <Filename Value="Forms\UMainForm.pas"/> 461 <Caret Line="15" Column="31" TopLine="1"/> 433 462 </Position14> 434 463 <Position15> 435 <Filename Value=" Compiler\Analyze\UParser.pas"/>436 <Caret Line=" 1094" Column="1" TopLine="1075"/>464 <Filename Value="Forms\UMainForm.pas"/> 465 <Caret Line="201" Column="17" TopLine="188"/> 437 466 </Position15> 438 467 <Position16> 439 <Filename Value=" Compiler\Analyze\UParser.pas"/>440 <Caret Line="1 160" Column="1" TopLine="1147"/>468 <Filename Value="Forms\UMainForm.pas"/> 469 <Caret Line="15" Column="3" TopLine="1"/> 441 470 </Position16> 442 471 <Position17> 443 <Filename Value=" Compiler\Analyze\UParser.pas"/>444 <Caret Line="1 085" Column="13" TopLine="1072"/>472 <Filename Value="Forms\UMainForm.pas"/> 473 <Caret Line="184" Column="44" TopLine="171"/> 445 474 </Position17> 446 475 <Position18> 447 <Filename Value=" Compiler\Analyze\UParser.pas"/>448 <Caret Line="1 079" Column="1" TopLine="1072"/>476 <Filename Value="Forms\UMainForm.pas"/> 477 <Caret Line="191" Column="26" TopLine="178"/> 449 478 </Position18> 450 479 <Position19> 451 <Filename Value=" Compiler\Analyze\UParser.pas"/>452 <Caret Line="1 080" Column="1" TopLine="1072"/>480 <Filename Value="Forms\UMainForm.pas"/> 481 <Caret Line="198" Column="32" TopLine="184"/> 453 482 </Position19> 454 483 <Position20> 455 <Filename Value=" Compiler\Analyze\UParser.pas"/>456 <Caret Line="1 081" Column="1" TopLine="1063"/>484 <Filename Value="Forms\UMainForm.pas"/> 485 <Caret Line="190" Column="17" TopLine="180"/> 457 486 </Position20> 458 487 <Position21> 459 <Filename Value=" Compiler\Analyze\UParser.pas"/>460 <Caret Line=" 1086" Column="25" TopLine="1077"/>488 <Filename Value="Forms\UMainForm.pas"/> 489 <Caret Line="60" Column="47" TopLine="42"/> 461 490 </Position21> 462 491 <Position22> 463 <Filename Value=" Compiler\Analyze\UParser.pas"/>464 <Caret Line=" 1079" Column="1" TopLine="1074"/>492 <Filename Value="Forms\UMainForm.pas"/> 493 <Caret Line="65" Column="45" TopLine="47"/> 465 494 </Position22> 466 495 <Position23> 467 <Filename Value=" Compiler\Analyze\UParser.pas"/>468 <Caret Line=" 1080" Column="1" TopLine="1074"/>496 <Filename Value="Forms\UMainForm.pas"/> 497 <Caret Line="255" Column="12" TopLine="246"/> 469 498 </Position23> 470 499 <Position24> 471 <Filename Value=" Compiler\Analyze\UParser.pas"/>472 <Caret Line=" 1081" Column="1" TopLine="1074"/>500 <Filename Value="Forms\UMainForm.pas"/> 501 <Caret Line="223" Column="38" TopLine="217"/> 473 502 </Position24> 474 503 <Position25> 475 <Filename Value=" Compiler\Analyze\UParser.pas"/>476 <Caret Line=" 1088" Column="1" TopLine="1074"/>504 <Filename Value="Forms\UMainForm.pas"/> 505 <Caret Line="246" Column="45" TopLine="233"/> 477 506 </Position25> 478 507 <Position26> 479 <Filename Value=" Compiler\Analyze\UParser.pas"/>480 <Caret Line=" 1090" Column="1" TopLine="1074"/>508 <Filename Value="Forms\UMainForm.pas"/> 509 <Caret Line="245" Column="44" TopLine="233"/> 481 510 </Position26> 482 511 <Position27> 483 <Filename Value=" Compiler\Analyze\UParser.pas"/>484 <Caret Line=" 1091" Column="1" TopLine="1074"/>512 <Filename Value="Forms\UMainForm.pas"/> 513 <Caret Line="63" Column="40" TopLine="45"/> 485 514 </Position27> 486 515 <Position28> 487 <Filename Value=" Compiler\Analyze\UParser.pas"/>488 <Caret Line=" 1102" Column="21" TopLine="1092"/>516 <Filename Value="Forms\UMainForm.pas"/> 517 <Caret Line="247" Column="1" TopLine="233"/> 489 518 </Position28> 490 519 <Position29> 491 <Filename Value=" Compiler\USourceCode.pas"/>492 <Caret Line=" 192" Column="4" TopLine="173"/>520 <Filename Value="Forms\UMainForm.pas"/> 521 <Caret Line="230" Column="39" TopLine="213"/> 493 522 </Position29> 494 523 <Position30> 495 <Filename Value="Compiler\ USourceCode.pas"/>496 <Caret Line=" 193" Column="16" TopLine="180"/>524 <Filename Value="Compiler\Analyze\UParser.pas"/> 525 <Caret Line="507" Column="31" TopLine="495"/> 497 526 </Position30> 498 527 </JumpHistory> … … 502 531 <PathDelim Value="\"/> 503 532 <SearchPaths> 504 <OtherUnitFiles Value="Forms "/>533 <OtherUnitFiles Value="Forms;Common"/> 505 534 <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> 506 535 </SearchPaths> -
branches/Transpascal/Transpascal.lpr
r62 r66 9 9 Forms, CoolDocking, Interfaces, SysUtils, 10 10 UMainForm in 'UMainForm.pas' {MainForm}, 11 UTextSource in 'UTextSource.pas', UProject, TranspascalCompiler, 12 UProjectManager, UCodeForm, UMessagesForm, UCompiledForm, UCodeTreeForm; 11 UTextSource in 'UTextSource.pas', UProject, UApplicationInfo, URegistry, 12 ULastOpenedList, TranspascalCompiler, UProjectManager, UCodeForm, 13 UMessagesForm, UCompiledForm, UCodeTreeForm; 13 14 14 15 {$R *.res} -
branches/Transpascal/UProject.pas
r60 r66 6 6 7 7 uses 8 Classes, SysUtils, Contnrs, Dialogs ;8 Classes, SysUtils, Contnrs, Dialogs, DOM, XMLWrite, XMLRead; 9 9 10 10 type … … 15 15 Parent: TProjectNode; 16 16 Name: string; 17 procedure SaveToXMLNode(Node: TDOMNode); virtual; 18 procedure LoadFromXMLNode(Node: TDOMNode); virtual; 17 19 procedure Load; virtual; 18 20 procedure Save; virtual; … … 26 28 constructor Create; 27 29 destructor Destroy; override; 30 procedure SaveToXMLNode(Node: TDOMNode); override; 31 procedure LoadFromXMLNode(Node: TDOMNode); override; 28 32 procedure Load; override; 29 33 procedure Save; override; … … 38 42 procedure Load; override; 39 43 procedure Save; override; 44 procedure SaveToXMLNode(Node: TDOMNode); override; 45 procedure LoadFromXMLNode(Node: TDOMNode); override; 40 46 function SearchFile(FileName: string): TProjectFile; 41 47 end; … … 43 49 TProject = class(TProjectGroup) 44 50 RootDir: string; 51 procedure LoadFromFile(FileName: string); 52 procedure SaveToFile(FileName: string); 45 53 function GetDir(IncludeRoot: Boolean = False): string; override; 54 procedure Load; override; 55 procedure Save; override; 56 procedure SaveToXMLNode(Node: TDOMNode); override; 57 procedure LoadFromXMLNode(Node: TDOMNode); override; 58 procedure Clear; 46 59 end; 47 60 … … 77 90 for I := 0 to Items.Count - 1 do 78 91 TProjectNode(Items[I]).Save; 92 end; 93 94 procedure TProjectGroup.SaveToXMLNode(Node: TDOMNode); 95 begin 96 inherited SaveToXMLNode(Node); 79 97 end; 80 98 … … 111 129 end; 112 130 131 procedure TProjectFile.SaveToXMLNode(Node: TDOMNode); 132 begin 133 inherited SaveToXMLNode(Node); 134 end; 135 136 procedure TProjectFile.LoadFromXMLNode(Node: TDOMNode); 137 begin 138 inherited LoadFromXMLNode(Node); 139 Load; 140 end; 141 113 142 procedure TProjectFile.Load; 114 143 begin … … 125 154 { TProjectNode } 126 155 156 procedure TProjectNode.SaveToXMLNode(Node: TDOMNode); 157 begin 158 159 end; 160 161 procedure TProjectNode.LoadFromXMLNode(Node: TDOMNode); 162 begin 163 Name := UTF8Encode(string(TDOMElement(Node).GetAttribute('Name'))); 164 end; 165 127 166 procedure TProjectNode.Load; 128 167 begin … … 143 182 { TProject } 144 183 184 procedure TProject.LoadFromFile(FileName: string); 185 var 186 Doc: TXMLDocument; 187 NewNode: TDOMNode; 188 NewSubNode: TDOMNode; 189 I: Integer; 190 Text: string; 191 begin 192 try 193 Clear; 194 RootDir := ExtractFileDir(FileName) + '/'; 195 Name := ExtractFileName(FileName); 196 Name := Copy(Name, 1, Length(Name) - Length(ExtractFileExt(FileName))); 197 198 ReadXMLFile(Doc, UTF8Decode(FileName)); 199 200 NewNode := Doc.DocumentElement.FindNode('Files'); 201 if Assigned(NewNode) then 202 LoadFromXMLNode(NewNode); 203 finally 204 Doc.Free; 205 end; 206 end; 207 208 procedure TProjectGroup.LoadFromXMLNode(Node: TDOMNode); 209 var 210 Child: TDOMNode; 211 ProjectNode: TProjectNode; 212 NodeType: string; 213 begin 214 Name := UTF8Encode(TDOMElement(Node).GetAttribute('Name')); 215 Child := Node.FirstChild; 216 while Assigned(Child) do begin 217 NodeType := TDOMElement(Child).GetAttribute('Type'); 218 if NodeType = 'Folder' then 219 ProjectNode := TProjectGroup.Create 220 else if NodeType = 'File' then 221 ProjectNode := TProjectFile.Create 222 else ProjectNode := nil; 223 if Assigned(ProjectNode) then begin 224 ProjectNode.Parent := Self; 225 ProjectNode.LoadFromXMLNode(Child); 226 Items.Add(ProjectNode); 227 end; 228 229 Child := Child.NextSibling; 230 end; 231 end; 232 233 procedure TProject.SaveToFile(FileName: string); 234 begin 235 236 end; 237 145 238 function TProject.GetDir(IncludeRoot: Boolean): string; 146 239 begin … … 148 241 end; 149 242 243 procedure TProject.Load; 244 begin 245 inherited Load; 246 end; 247 248 procedure TProject.Save; 249 begin 250 inherited Save; 251 end; 252 253 procedure TProject.SaveToXMLNode(Node: TDOMNode); 254 begin 255 inherited SaveToXMLNode(Node); 256 end; 257 258 procedure TProject.LoadFromXMLNode(Node: TDOMNode); 259 begin 260 inherited LoadFromXMLNode(Node); 261 end; 262 263 procedure TProject.Clear; 264 begin 265 Items.Clear; 266 end; 267 150 268 end. 151 269
Note:
See TracChangeset
for help on using the changeset viewer.