Changeset 233 for branches/xpascal/Forms
- Timestamp:
- Jun 26, 2023, 6:08:23 PM (17 months ago)
- Location:
- branches/xpascal/Forms
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/xpascal/Forms/FormMain.lfm
r230 r233 10 10 Menu = MainMenu1 11 11 OnActivate = FormActivate 12 OnClose = FormClose 12 13 OnCreate = FormCreate 13 14 OnDestroy = FormDestroy … … 49 50 object MainMenu1: TMainMenu 50 51 Left = 744 51 Top = 7 6052 Top = 759 52 53 object MenuItemFile: TMenuItem 53 54 Caption = 'File' 55 object MenuItem10: TMenuItem 56 Action = AFileOpen 57 end 54 58 object MenuItem6: TMenuItem 55 59 Action = AExit … … 129 133 OnExecute = AConsoleExecute 130 134 end 135 object AFileOpen: TAction 136 Caption = 'Open...' 137 OnExecute = AFileOpenExecute 138 end 139 end 140 object OpenDialog1: TOpenDialog 141 DefaultExt = '.pas' 142 Filter = 'Pascal file (.pas)|*.pas|Any file|*.*' 143 Left = 536 144 Top = 759 145 end 146 object ApplicationInfo1: TApplicationInfo 147 Identification = 1 148 VersionMajor = 1 149 VersionMinor = 0 150 VersionBugFix = 0 151 AuthorsName = 'Chronosoft' 152 EmailContact = 'robie@centrum.cz' 153 AppName = 'xPascal' 154 Description = 'Pascal mutli language transpiler and interpreter' 155 RegistryKey = '\Software\xpascal' 156 RegistryRoot = rrKeyCurrentUser 157 License = 'CC0' 158 Left = 348 159 Top = 274 131 160 end 132 161 end -
branches/xpascal/Forms/FormMain.lrj
r230 r233 13 13 {"hash":209392028,"name":"tformmain.ageneratexml.caption","sourcebytes":[71,101,110,101,114,97,116,101,32,88,77,76],"value":"Generate XML"}, 14 14 {"hash":371876,"name":"tformmain.atest.caption","sourcebytes":[84,101,115,116],"value":"Test"}, 15 {"hash":174433893,"name":"tformmain.aconsole.caption","sourcebytes":[67,111,110,115,111,108,101],"value":"Console"} 15 {"hash":174433893,"name":"tformmain.aconsole.caption","sourcebytes":[67,111,110,115,111,108,101],"value":"Console"}, 16 {"hash":107745630,"name":"tformmain.afileopen.caption","sourcebytes":[79,112,101,110,46,46,46],"value":"Open..."}, 17 {"hash":239474242,"name":"tformmain.applicationinfo1.description","sourcebytes":[80,97,115,99,97,108,32,109,117,116,108,105,32,108,97,110,103,117,97,103,101,32,116,114,97,110,115,112,105,108,101,114,32,97,110,100,32,105,110,116,101,114,112,114,101,116,101,114],"value":"Pascal mutli language transpiler and interpreter"} 16 18 ]} -
branches/xpascal/Forms/FormMain.pas
r230 r233 4 4 5 5 uses 6 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Menus, 7 ActnList, ExtCtrls, SynHighlighterPas, SynEdit, Source, Optimizer, 8 Generator, FormSource, FormMessages, FormOutput, FormConsole, FormEx; 6 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Menus, LazFileUtils, 7 ActnList, ExtCtrls, SynHighlighterPas, SynEdit, Source, Optimizer, RegistryEx, 8 Generator, FormSource, FormMessages, FormOutput, FormConsole, FormEx, 9 ApplicationInfo; 9 10 10 11 type … … 15 16 ACompile: TAction; 16 17 AConsole: TAction; 18 AFileOpen: TAction; 19 ApplicationInfo1: TApplicationInfo; 17 20 ATest: TAction; 18 21 AGenerateXml: TAction; … … 25 28 MainMenu1: TMainMenu; 26 29 MenuItem1: TMenuItem; 30 MenuItem10: TMenuItem; 27 31 MenuItem2: TMenuItem; 28 32 MenuItem3: TMenuItem; … … 36 40 MenuItemGenerate: TMenuItem; 37 41 MenuItemFile: TMenuItem; 42 OpenDialog1: TOpenDialog; 38 43 PanelOutput: TPanel; 39 44 PanelSource: TPanel; … … 43 48 procedure AConsoleExecute(Sender: TObject); 44 49 procedure AExitExecute(Sender: TObject); 50 procedure AFileOpenExecute(Sender: TObject); 45 51 procedure AGenerateCSharpExecute(Sender: TObject); 46 52 procedure AGeneratePascalExecute(Sender: TObject); … … 51 57 procedure ARunExecute(Sender: TObject); 52 58 procedure FormActivate(Sender: TObject); 59 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 53 60 procedure FormCreate(Sender: TObject); 54 61 procedure FormDestroy(Sender: TObject); 55 62 procedure FormShow(Sender: TObject); 56 63 private 64 LastFileName: string; 57 65 Prog: TProgram; 58 66 Initialized: Boolean; … … 61 69 FormOutput: TFormOutput; 62 70 FormConsole: TFormConsole; 71 procedure LoadFromRegistry; 72 procedure SaveToRegistry; 73 procedure ProjectOpen(FileName: string); 63 74 procedure Generate(GeneratorClass: TGeneratorClass); 64 75 procedure ExecutorOutput(Text: string); … … 87 98 if not Initialized then begin 88 99 Initialized := True; 89 FormSource.SynEditSource.Lines.LoadFromFile('Examples' + DirectorySeparator + 90 'Example.pas'); 91 ARun.Execute; 100 ProjectOpen(LastFileName); 101 //ARun.Execute; 92 102 end; 93 103 end; … … 104 114 procedure TFormMain.FormShow(Sender: TObject); 105 115 begin 116 LoadFromRegistry; 106 117 FormMessages := TFormMessages.Create(nil); 107 118 FormMessages.Show; … … 119 130 end; 120 131 132 procedure TFormMain.LoadFromRegistry; 133 begin 134 with TRegistryEx.Create do 135 try 136 CurrentContext := ApplicationInfo1.GetRegistryContext; 137 LastFileName := ReadStringWithDefault('LastFileName', 'Examples' + DirectorySeparator + 'Example.pas'); 138 finally 139 Free; 140 end; 141 end; 142 143 procedure TFormMain.SaveToRegistry; 144 begin 145 with TRegistryEx.Create do 146 try 147 CurrentContext := ApplicationInfo1.GetRegistryContext; 148 WriteString('LastFileName', LastFileName); 149 finally 150 Free; 151 end; 152 end; 153 154 procedure TFormMain.ProjectOpen(FileName: string); 155 begin 156 LastFileName := FileName; 157 FormSource.SynEditSource.Lines.LoadFromFile(FileName); 158 end; 159 121 160 procedure TFormMain.Generate(GeneratorClass: TGeneratorClass); 122 161 var … … 130 169 FormOutput.SetText(Generator.Output); 131 170 TargetFileName := 'Generated' + DirectorySeparator + 132 Generator.Name + DirectorySeparator + 'Example'+ Generator.FileExt;171 Generator.Name + DirectorySeparator + ExtractFileNameOnly(LastFileName) + Generator.FileExt; 133 172 ForceDirectories(ExtractFileDir(TargetFileName)); 134 173 FormOutput.SynEditOutput.Lines.SaveToFile(TargetFileName); … … 141 180 begin 142 181 Close; 182 end; 183 184 procedure TFormMain.AFileOpenExecute(Sender: TObject); 185 begin 186 OpenDialog1.InitialDir := ExtractFileDir(LastFileName); 187 OpenDialog1.FileName := ExtractFileName(LastFileName); 188 if OpenDialog1.Execute then begin 189 ProjectOpen(OpenDialog1.FileName); 190 end; 143 191 end; 144 192 … … 224 272 end; 225 273 274 procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction); 275 begin 276 FormConsole.Terminated := True; 277 SaveToRegistry; 278 end; 279 226 280 procedure TFormMain.FormCreate(Sender: TObject); 227 281 begin … … 248 302 begin 249 303 ACompile.Execute; 250 FormOutput.SynEditOutput.Highlighter := nil; 251 FormOutput.SynEditOutput.Lines.Clear; 304 FormConsole.Memo1.Lines.Clear; 252 305 if Assigned(Prog) then begin 253 306 Executor := TExecutor.Create;
Note:
See TracChangeset
for help on using the changeset viewer.