Changeset 178 for trunk/UCore.pas
- Timestamp:
- Mar 27, 2018, 11:07:44 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UCore.pas
r174 r178 40 40 procedure SetAlwaysOnTop(AValue: Boolean); 41 41 function FindFirstNonOption: string; 42 procedure WriteLnConsole(Text: string); 42 43 public 43 44 AcronymDb: TAcronymDb; … … 69 70 const 70 71 ExampleFile = 'Example acronyms.adp'; 72 DefaultOverrideFile = 'Default.txt'; 73 74 resourcestring 75 SStartMinimizedInTray = 'Start minimized in system tray'; 76 SShowThisHelp = 'Show this help'; 77 SOptions = 'options'; 78 SProjectFile = 'project file'; 71 79 72 80 … … 108 116 end; 109 117 118 procedure TCore.WriteLnConsole(Text: string); 119 begin 120 {$IFDEF WINDOWS} 121 if not IsConsole then begin 122 IsConsole := True; 123 SysInitStdIO; 124 end; 125 {$ENDIF} 126 WriteLn(Text); 127 end; 128 110 129 procedure TCore.Initialize; 111 130 var 112 131 FileNameOption: string; 113 132 ExampleFileName: string; 133 DefaultOverrideFileName: string; 134 ExamplesDir: string; 135 Lines: TStringList; 136 Output: string; 114 137 begin 115 138 if not InitializeStarted then begin … … 117 140 LoadConfig; 118 141 119 {$IFDEF 0}120 142 if Application.HasOption('h', 'help') then begin 121 WriteLn('AcronymDecoder <project file>'); 122 WriteLn(' -t --tray Start minimized in system tray'); 123 WriteLn(' -h --help Show this help'); 143 Output := 'AcronymDecoder [' + SOptions + '] <' + SProjectFile + '>' + LineEnding; 144 Output := Output + ' -t --tray ' + SStartMinimizedInTray + LineEnding; 145 Output := Output + ' -h --help ' + SShowThisHelp + LineEnding; 146 WriteLnConsole(Output); 124 147 Application.Terminate; 125 148 Exit; 126 149 end; 127 {$ENDIF}128 150 129 151 if Application.HasOption('t', 'tray') then begin … … 131 153 end; 132 154 133 ExampleFileName := ExtractFileDir(Application.ExeName) + DirectorySeparator + ExampleFile; 155 ExamplesDir := ExtractFileDir(Application.ExeName) + DirectorySeparator + 156 'Examples'; 157 {$IFDEF Linux} 158 // If installed in Linux system then use installation directory for po files 159 if Application.ExeName = '/usr/bin/' + ExtractFileNameOnly(Application.ExeName) then 160 ExamplesDir := '/usr/share/' + ExtractFileNameOnly(Application.ExeName) + 161 DirectorySeparator + 'Examples'; 162 {$ENDIF} 163 ExampleFileName := ExamplesDir + DirectorySeparator + ExampleFile; 164 165 // To override default project file put new project name to default file 166 DefaultOverrideFileName := ExamplesDir + DirectorySeparator + DefaultOverrideFile; 167 if FileExists(DefaultOverrideFileName) then begin 168 Lines := TStringList.Create; 169 Lines.LoadFromFile(DefaultOverrideFileName); 170 if Lines.Count > 0 then 171 ExampleFileName := ExamplesDir + DirectorySeparator + Lines[0]; 172 Lines.Free; 173 end; 174 134 175 FileNameOption := FindFirstNonOption; 135 176 if FileNameOption <> '' then begin … … 144 185 if FileExists(ExampleFileName) then begin 145 186 // Open default database with examples if no item is in recent openned history 146 FileNameOption := ExtractFileDir(Application.ExeName) + DirectorySeparator + ExampleFile; 147 {$IFDEF Linux} 148 // If installed in Linux system then use installation directory for po files 149 if Application.ExeName = '/usr/bin/' + ExtractFileNameOnly(Application.ExeName) then 150 FileNameOption := '/usr/share/' + ExtractFileNameOnly(Application.ExeName) + '/Examples/' + ExampleFile; 151 {$ENDIF} 152 FormMain.ProjectOpen(FileNameOption); 187 FormMain.ProjectOpen(ExampleFileName); 153 188 end else begin 154 189 // Create empty file
Note:
See TracChangeset
for help on using the changeset viewer.