fpini.pas 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809
  1. {
  2. $Id$
  3. This file is part of the Free Pascal Integrated Development Environment
  4. Copyright (c) 1998 by Berczi Gabor
  5. Write/Read Options to INI File
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. unit FPIni;
  13. interface
  14. uses
  15. FPUtils;
  16. procedure InitDirs;
  17. procedure InitINIFile;
  18. procedure CheckINIFile;
  19. function ReadINIFile: boolean;
  20. function WriteINIFile(FromSaveAs : boolean) : boolean;
  21. implementation
  22. uses
  23. Dos,Objects,Drivers,Commands,
  24. Version,
  25. {$ifdef USE_EXTERNAL_COMPILER}
  26. fpintf, { superseeds version_string of version unit }
  27. {$endif USE_EXTERNAL_COMPILER}
  28. WConsts,WUtils,WINI,WViews,{$ifndef EDITORS}WEditor,WCEdit{$else}Editors{$endif},
  29. {$ifndef NODEBUG}FPDebug,{$endif}FPConst,FPVars,
  30. FPIntf,FPTools,FPSwitch,FPString;
  31. const
  32. { INI file sections }
  33. secFiles = 'Files';
  34. secRun = 'Run';
  35. secCompile = 'Compile';
  36. secColors = 'Colors';
  37. secHelp = 'Help';
  38. secEditor = 'Editor';
  39. secBreakpoint = 'Breakpoints';
  40. secWatches = 'Watches';
  41. secHighlight = 'Highlight';
  42. secMouse = 'Mouse';
  43. secSearch = 'Search';
  44. secTools = 'Tools';
  45. secSourcePath = 'SourcePath';
  46. secPreferences = 'Preferences';
  47. secMisc = 'Misc';
  48. { INI file tags }
  49. ieRecentFile = 'RecentFile';
  50. (* ieOpenFile = 'OpenFile';
  51. ieOpenFileCount = 'OpenFileCount'; *)
  52. ieRunParameters = 'Parameters';
  53. ieDebuggeeRedir = 'DebugRedirection';
  54. iePrimaryFile = 'PrimaryFile';
  55. ieCompileMode = 'CompileMode';
  56. iePalette = 'Palette';
  57. ieHelpFiles = 'Files';
  58. ieDefaultTabSize = 'DefaultTabSize';
  59. ieDefaultIndentSize = 'DefaultIndentSize';
  60. ieDefaultEditorFlags='DefaultFlags';
  61. ieDefaultSaveExt = 'DefaultSaveExt';
  62. ieOpenExts = 'OpenExts';
  63. ieHighlightExts = 'Exts';
  64. ieTabsPattern = 'NeedsTabs';
  65. ieDoubleClickDelay = 'DoubleDelay';
  66. ieReverseButtons = 'ReverseButtons';
  67. ieAltClickAction = 'AltClickAction';
  68. ieCtrlClickAction = 'CtrlClickAction';
  69. ieFindFlags = 'FindFlags';
  70. ieToolName = 'Title';
  71. ieToolProgram = 'Program';
  72. ieToolParams = 'Params';
  73. ieToolHotKey = 'HotKey';
  74. ieBreakpointTyp = 'Type';
  75. ieBreakpointCount = 'Count';
  76. ieBreakpointState = 'State';
  77. ieBreakpointName = 'Name';
  78. ieBreakpointFile = 'FileName';
  79. ieBreakpointLine = 'LineNumber';
  80. ieBreakpointCond = 'Condition';
  81. ieWatchCount = 'Count';
  82. ieWatchName = 'Watch';
  83. ieSourceList = 'SourceList';
  84. { ieVideoMode = 'VideoMode';}
  85. ieAutoSave = 'AutoSaveFlags';
  86. ieMiscOptions = 'MiscOptions';
  87. ieDesktopLocation = 'DesktopLocation';
  88. ieDesktopFlags = 'DesktopFileFlags';
  89. ieCenterDebuggerRow= 'CenterCurrentLineWhileDebugging';
  90. ieShowReadme = 'ShowReadme';
  91. Procedure InitDirs;
  92. begin
  93. StartupDir:=CompleteDir(FExpand('.'));
  94. {$ifndef unix}
  95. IDEDir:=CompleteDir(DirOf(system.Paramstr(0)));
  96. {$else}
  97. SystemIDEDir:='/usr/lib/fpc/'+version_string+'/ide/text';
  98. IDEdir:=CompleteDir(FExpand('~/.fp'));
  99. If Not ExistsDir(IDEdir) Then
  100. begin
  101. IDEDir:=SystemIDEDir;
  102. if Not ExistsDir(IDEDir) then
  103. begin
  104. if DirOf(system.paramstr(0))<>'' then
  105. IDEDir:=CompleteDir(DirOf(system.ParamStr(0)))
  106. else
  107. IDEDir:=StartupDir;
  108. end;
  109. end;
  110. {$endif}
  111. end;
  112. procedure InitINIFile;
  113. var S: string;
  114. begin
  115. S:=LocateFile(INIFileName);
  116. if S<>'' then
  117. IniFileName:=S;
  118. IniFileName:=FExpand(IniFileName);
  119. end;
  120. procedure CheckINIFile;
  121. var IniDir,CurDir: DirStr;
  122. INI: PINIFile;
  123. const Btns : array[1..2] of longstring = (btn_config_copyexisting,btn_config_createnew);
  124. begin
  125. IniDir:=DirOf(IniFileName); CurDir:=GetCurDir;
  126. if CompareText(IniDir,CurDir)<>0 then
  127. if not ExistsFile(CurDir+DirInfoName) then
  128. if ConfirmBox(FormatStrStr(msg_doyouwanttocreatelocalconfigfile,IniDir),nil,false)=cmYes then
  129. begin
  130. if (not ExistsFile(IniFileName)) or
  131. (ChoiceBox(msg_configcopyexistingorcreatenew,nil,
  132. Btns,false)=cmUserBtn2) then
  133. begin
  134. { create new config here }
  135. IniFileName:=CurDir+IniName;
  136. SwitchesPath:=CurDir+SwitchesName;
  137. end
  138. else
  139. begin
  140. { copy config here }
  141. if CopyFile(IniFileName,CurDir+IniName)=false then
  142. ErrorBox(FormatStrStr(msg_errorwritingfile,CurDir+IniName),nil)
  143. else
  144. IniFileName:=CurDir+IniName;
  145. if CopyFile(SwitchesPath,CurDir+SwitchesName)=false then
  146. ErrorBox(FormatStrStr(msg_errorwritingfile,CurDir+SwitchesName),nil)
  147. else
  148. SwitchesPath:=CurDir+SwitchesName;
  149. end;
  150. end
  151. else
  152. begin
  153. New(INI, Init(CurDir+DirInfoName));
  154. INI^.SetEntry(MainSectionName,'Comment','Do NOT delete this file!!!');
  155. if INI^.Update=false then
  156. ErrorBox(FormatStrStr(msg_errorwritingfile,INI^.GetFileName),nil);
  157. Dispose(INI, Done);
  158. end;
  159. end;
  160. function PaletteToStr(S: string): string;
  161. var C: string;
  162. I: integer;
  163. begin
  164. C:='';
  165. for I:=1 to length(S) do
  166. begin
  167. C:=C+'#$'+IntToHex(ord(S[I]),2);
  168. end;
  169. PaletteToStr:=C;
  170. end;
  171. function StrToPalette(S: string): string;
  172. var I,P,X: integer;
  173. C: string;
  174. Hex: boolean;
  175. OK: boolean;
  176. begin
  177. C:=''; I:=1;
  178. OK:=S<>'';
  179. while OK and (I<=length(S)) and (S[I]='#') do
  180. begin
  181. Inc(I); Hex:=false;
  182. if S[I]='$' then begin Inc(I); Hex:=true; end;
  183. P:=Pos('#',copy(S,I,High(S))); if P>0 then P:=I+P-1 else P:=length(S)+1;
  184. if Hex=false then
  185. begin
  186. X:=StrToInt(copy(S,I,P-I));
  187. OK:=(LastStrToIntResult=0) and (0<=X) and (X<=High(S));
  188. end
  189. else
  190. begin
  191. X:=HexToInt(copy(S,I,P-I));
  192. OK:=(LastHexToIntResult=0) and (0<=X) and (X<=255);
  193. end;
  194. if OK then C:=C+chr(X);
  195. Inc(I,P-I);
  196. end;
  197. StrToPalette:=C;
  198. end;
  199. {$ifndef NODEBUG}
  200. procedure WriteOneWatchEntry(I : Longint;INIFile : PINIFile);
  201. var
  202. PW : PWatch;
  203. S : String;
  204. begin
  205. Str(I,S);
  206. PW:=WatchesCollection^.At(I);
  207. With PW^ do
  208. begin
  209. INIFile^.SetEntry(secWatches,ieWatchName+S,GetStr(expr));
  210. end;
  211. end;
  212. procedure WriteOneBreakPointEntry(I : longint;INIFile : PINIFile);
  213. var PB : PBreakpoint;
  214. S : String;
  215. begin
  216. Str(I,S);
  217. PB:=BreakpointsCollection^.At(I);
  218. If assigned(PB) then
  219. With PB^ do
  220. Begin
  221. INIFile^.SetEntry(secBreakpoint,ieBreakpointTyp+S,BreakpointTypeStr[typ]);
  222. INIFile^.SetEntry(secBreakpoint,ieBreakpointState+S,BreakpointStateStr[state]);
  223. if typ=bt_file_line then
  224. begin
  225. INIFile^.SetEntry(secBreakpoint,ieBreakpointFile+S,FileName^);
  226. INIFile^.SetIntEntry(secBreakpoint,ieBreakpointLine+S,Line);
  227. end
  228. else
  229. INIFile^.SetEntry(secBreakpoint,ieBreakpointName+S,Name^);
  230. if assigned(Conditions) then
  231. INIFile^.SetEntry(secBreakpoint,ieBreakpointCond+S,Conditions^);
  232. end;
  233. end;
  234. procedure ReadOneWatchEntry(I : Longint;INIFile : PINIFile);
  235. var
  236. PW : PWatch;
  237. S : String;
  238. begin
  239. Str(I,S);
  240. PW:=new(PWatch,Init(INIFile^.GetEntry(secWatches,ieWatchName+S,'')));
  241. WatchesCollection^.Insert(PW);
  242. end;
  243. procedure ReadOneBreakPointEntry(i : longint;INIFile : PINIFile);
  244. var PB : PBreakpoint;
  245. S,S2,SC : string;
  246. Line : longint;
  247. typ : BreakpointType;
  248. state : BreakpointState;
  249. begin
  250. Str(I,S2);
  251. typ:=bt_invalid;
  252. S:=INIFile^.GetEntry(secBreakpoint,ieBreakpointTyp+S2,BreakpointTypeStr[typ]);
  253. for typ:=low(BreakpointType) to high(BreakpointType) do
  254. If pos(BreakpointTypeStr[typ],S)>0 then break;
  255. state:=bs_deleted;
  256. S:=INIFile^.GetEntry(secBreakpoint,ieBreakpointState+S2,BreakpointStateStr[state]);
  257. for state:=low(BreakpointState) to high(BreakpointState) do
  258. If pos(BreakpointStateStr[state],S)>0 then break;
  259. case typ of
  260. bt_invalid :;
  261. bt_file_line :
  262. begin
  263. S:=INIFile^.GetEntry(secBreakpoint,ieBreakpointFile+S2,'');
  264. Line:=INIFile^.GetIntEntry(secBreakpoint,ieBreakpointLine+S2,0);
  265. end;
  266. else
  267. begin
  268. S:=INIFile^.GetEntry(secBreakpoint,ieBreakpointName+S2,'');
  269. end;
  270. end;
  271. SC:=INIFile^.GetEntry(secBreakpoint,ieBreakpointCond+S2,'');
  272. if (typ=bt_function) and (S<>'') then
  273. new(PB,init_function(S))
  274. else if (typ=bt_file_line) and (S<>'') then
  275. new(PB,init_file_line(S,Line))
  276. else
  277. new(PB,init_type(typ,S));
  278. If assigned(PB) then
  279. begin
  280. PB^.state:=state;
  281. If SC<>'' then
  282. PB^.conditions:=NewStr(SC);
  283. BreakpointsCollection^.Insert(PB);
  284. end;
  285. end;
  286. {$endif NODEBUG}
  287. function ReadINIFile: boolean;
  288. var INIFile: PINIFile;
  289. S,PS,S1,S2,S3: string;
  290. I,P: integer;
  291. BreakPointCount,WatchesCount:longint;
  292. OK: boolean;
  293. ts : TSwitchMode;
  294. W: word;
  295. begin
  296. OK:=ExistsFile(IniFileName);
  297. if OK then
  298. begin
  299. New(INIFile, Init(IniFileName));
  300. { Files }
  301. OpenExts:=INIFile^.GetEntry(secFiles,ieOpenExts,OpenExts);
  302. RecentFileCount:=High(RecentFiles);
  303. for I:=Low(RecentFiles) to High(RecentFiles) do
  304. begin
  305. S:=INIFile^.GetEntry(secFiles,ieRecentFile+IntToStr(I),'');
  306. if (S='') and (RecentFileCount>I-1) then RecentFileCount:=I-1;
  307. with RecentFiles[I] do
  308. begin
  309. P:=Pos(',',S); if P=0 then P:=length(S)+1;
  310. FileName:=copy(S,1,P-1); Delete(S,1,P);
  311. P:=Pos(',',S); if P=0 then P:=length(S)+1;
  312. LastPos.X:=Max(0,StrToInt(copy(S,1,P-1))); Delete(S,1,P);
  313. P:=Pos(',',S); if P=0 then P:=length(S)+1;
  314. LastPos.Y:=Max(0,StrToInt(copy(S,1,P-1))); Delete(S,1,P);
  315. end;
  316. end;
  317. { Run }
  318. { First read the primary file, which can also set the parameters which can
  319. be overruled with the parameter loading }
  320. SetPrimaryFile(INIFile^.GetEntry(secCompile,iePrimaryFile,PrimaryFile));
  321. SetRunParameters(INIFile^.GetEntry(secRun,ieRunParameters,GetRunParameters));
  322. {$ifndef GABOR}
  323. DebuggeeTTY := INIFile^.GetEntry(secRun,ieDebuggeeRedir,DebuggeeTTY);
  324. {$endif}
  325. { Compile }
  326. S:=INIFile^.GetEntry(secCompile,ieCompileMode,'');
  327. for ts:=low(TSwitchMode) to high(TSwitchMode) do
  328. begin
  329. if SwitchesModeStr[ts]=S then
  330. SwitchesMode:=ts;
  331. end;
  332. { Help }
  333. S:=INIFile^.GetEntry(secHelp,ieHelpFiles,'');
  334. repeat
  335. P:=Pos(';',S); if P=0 then P:=length(S)+1;
  336. PS:=copy(S,1,P-1);
  337. if PS<>'' then HelpFiles^.Insert(NewStr(PS));
  338. Delete(S,1,P);
  339. until S='';
  340. { Editor }
  341. {$ifndef EDITORS}
  342. DefaultTabSize:=INIFile^.GetIntEntry(secEditor,ieDefaultTabSize,DefaultTabSize);
  343. DefaultIndentSize:=INIFile^.GetIntEntry(secEditor,ieDefaultIndentSize,DefaultIndentSize);
  344. DefaultCodeEditorFlags:=INIFile^.GetIntEntry(secEditor,ieDefaultEditorFlags,DefaultCodeEditorFlags);
  345. DefaultSaveExt:=INIFile^.GetEntry(secEditor,ieDefaultSaveExt,DefaultSaveExt);
  346. {$endif}
  347. { Highlight }
  348. HighlightExts:=INIFile^.GetEntry(secHighlight,ieHighlightExts,HighlightExts);
  349. TabsPattern:=INIFile^.GetEntry(secHighlight,ieTabsPattern,TabsPattern);
  350. { SourcePath }
  351. SourceDirs:=INIFile^.GetEntry(secSourcePath,ieSourceList,SourceDirs);
  352. { Mouse }
  353. DoubleDelay:=INIFile^.GetIntEntry(secMouse,ieDoubleClickDelay,DoubleDelay);
  354. MouseReverse:=boolean(INIFile^.GetIntEntry(secMouse,ieReverseButtons,byte(MouseReverse)));
  355. AltMouseAction:=INIFile^.GetIntEntry(secMouse,ieAltClickAction,AltMouseAction);
  356. CtrlMouseAction:=INIFile^.GetIntEntry(secMouse,ieCtrlClickAction,CtrlMouseAction);
  357. { Search }
  358. FindFlags:=INIFile^.GetIntEntry(secSearch,ieFindFlags,FindFlags);
  359. { Breakpoints }
  360. {$ifndef NODEBUG}
  361. BreakpointCount:=INIFile^.GetIntEntry(secBreakpoint,ieBreakpointCount,0);
  362. for i:=1 to BreakpointCount do
  363. ReadOneBreakPointEntry(i-1,INIFile);
  364. WatchesCount:=INIFile^.GetIntEntry(secWatches,ieWatchCount,0);
  365. for i:=1 to WatchesCount do
  366. ReadOneWatchEntry(i-1,INIFile);
  367. {$endif}
  368. { Tools }
  369. for I:=1 to MaxToolCount do
  370. begin
  371. S:=IntToStr(I);
  372. S1:=INIFile^.GetEntry(secTools,ieToolName+S,'');
  373. if S1='' then Break; { !!! }
  374. S2:=INIFile^.GetEntry(secTools,ieToolProgram+S,'');
  375. S3:=INIFile^.GetEntry(secTools,ieToolParams+S,'');
  376. W:=Max(0,Min(65535,INIFile^.GetIntEntry(secTools,ieToolHotKey+S,0)));
  377. AddTool(S1,S2,S3,W);
  378. end;
  379. { Colors }
  380. S:=AppPalette;
  381. PS:=StrToPalette(INIFile^.GetEntry(secColors,iePalette+'_1_40',PaletteToStr(copy(S,1,40))));
  382. PS:=PS+StrToPalette(INIFile^.GetEntry(secColors,iePalette+'_41_80',PaletteToStr(copy(S,41,40))));
  383. PS:=PS+StrToPalette(INIFile^.GetEntry(secColors,iePalette+'_81_120',PaletteToStr(copy(S,81,40))));
  384. PS:=PS+StrToPalette(INIFile^.GetEntry(secColors,iePalette+'_121_160',PaletteToStr(copy(S,121,40))));
  385. PS:=PS+StrToPalette(INIFile^.GetEntry(secColors,iePalette+'_161_200',PaletteToStr(copy(S,161,40))));
  386. PS:=PS+StrToPalette(INIFile^.GetEntry(secColors,iePalette+'_201_240',PaletteToStr(copy(S,201,40))));
  387. if length(PS)<length(CIDEAppColor) then
  388. PS:=PS+copy(CIDEAppColor,length(PS)+1,255);
  389. AppPalette:=PS;
  390. (* { Open files }
  391. for I:=INIFile^.GetIntEntry(secFiles,ieOpenFileCount,0) downto 1 do
  392. begin
  393. S:=INIFile^.GetEntry(secFiles,ieOpenFile+IntToStr(I),'');
  394. if (S='') then
  395. break;
  396. P:=Pos(',',S); if P=0 then P:=length(S)+1;
  397. S1:=copy(S,1,P-1);
  398. Delete(S,1,P);
  399. P:=Pos(',',S);
  400. if P=0 then P:=length(S)+1;
  401. X:=Max(0,StrToInt(copy(S,1,P-1)));
  402. Delete(S,1,P);
  403. P:=Pos(',',S);
  404. if P=0 then P:=length(S)+1;
  405. Y:=Max(0,StrToInt(copy(S,1,P-1)));
  406. Delete(S,1,P);
  407. P:=Pos(',',S);
  408. if P=0 then P:=length(S)+1;
  409. R.A.X:=Max(0,StrToInt(copy(S,1,P-1)));
  410. Delete(S,1,P);
  411. P:=Pos(',',S);
  412. if P=0 then P:=length(S)+1;
  413. R.A.Y:=Max(0,StrToInt(copy(S,1,P-1)));
  414. Delete(S,1,P);
  415. P:=Pos(',',S);
  416. if P=0 then P:=length(S)+1;
  417. R.B.X:=Max(0,StrToInt(copy(S,1,P-1)));
  418. Delete(S,1,P);
  419. P:=Pos(',',S);
  420. if P=0 then P:=length(S)+1;
  421. R.B.Y:=Max(0,StrToInt(copy(S,1,P-1)));
  422. if (R.A.X<R.B.X) and (R.A.Y<R.B.Y) then
  423. TryToOpenFile(@R,S1,X,Y,false)
  424. else
  425. TryToOpenFile(nil,S1,X,Y,false);
  426. { remove it because otherwise we allways keep old files }
  427. INIFile^.DeleteEntry(secFiles,ieOpenFile+IntToStr(I));
  428. end;
  429. *)
  430. { Desktop }
  431. DesktopFileFlags:=INIFile^.GetIntEntry(secPreferences,ieDesktopFlags,DesktopFileFlags);
  432. { Debugger }
  433. IniCenterDebuggerRow:=INIFile^.GetIntEntry(secPreferences,ieCenterDebuggerRow,1)<>0;
  434. { Preferences }
  435. AutoSaveOptions:=INIFile^.GetIntEntry(secPreferences,ieAutoSave,AutoSaveOptions);
  436. MiscOptions:=INIFile^.GetIntEntry(secPreferences,ieMiscOptions,MiscOptions);
  437. DesktopLocation:=INIFile^.GetIntEntry(secPreferences,ieDesktopLocation,DesktopLocation);
  438. { Misc }
  439. ShowReadme:=INIFile^.GetIntEntry(secMisc,ieShowReadme,{integer(ShowReadme)}1)<>0;
  440. Dispose(INIFile, Done);
  441. end;
  442. ReadINIFile:=OK;
  443. end;
  444. function WriteINIFile (FromSaveAs : boolean): boolean;
  445. var INIFile: PINIFile;
  446. S: string;
  447. S1,S2,S3: string;
  448. W: word;
  449. BreakPointCount,WatchesCount:longint;
  450. I(*,OpenFileCount*): integer;
  451. OK: boolean;
  452. procedure ConcatName(P: PString); {$ifndef FPC}far;{$endif}
  453. begin
  454. if (S<>'') then S:=S+';';
  455. S:=S+P^;
  456. end;
  457. begin
  458. {$ifdef Unix}
  459. if not FromSaveAs and (DirOf(IniFileName)=DirOf(SystemIDEDir)) then
  460. begin
  461. IniFileName:=FExpand('~/.fp/'+IniName);
  462. If not ExistsDir(DirOf(IniFileName)) then
  463. MkDir(FExpand('~/.fp'));
  464. end;
  465. {$endif Unix}
  466. New(INIFile, Init(IniFileName));
  467. { Files }
  468. { avoid keeping old files }
  469. INIFile^.DeleteSection(secFiles);
  470. INIFile^.SetEntry(secFiles,ieOpenExts,'"'+OpenExts+'"');
  471. for I:=1 to High(RecentFiles) do
  472. begin
  473. if I<=RecentFileCount then
  474. with RecentFiles[I] do S:=FileName+','+IntToStr(LastPos.X)+','+IntToStr(LastPos.Y)
  475. else
  476. S:='';
  477. INIFile^.SetEntry(secFiles,ieRecentFile+IntToStr(I),S);
  478. end;
  479. (*
  480. PW:=FirstEditorWindow;
  481. PPW:=PW;
  482. I:=1;
  483. while assigned(PW) do
  484. begin
  485. If PW^.HelpCtx=hcSourceWindow then
  486. begin
  487. With PW^.editor^ do
  488. S:=FileName+','+IntToStr(CurPos.X)+','+IntToStr(CurPos.Y);
  489. PW^.GetBounds(R);
  490. S:=S+','+IntToStr(R.A.X)+','+IntToStr(R.A.Y)+','+
  491. IntToStr(R.B.X)+','+IntToStr(R.B.Y);
  492. INIFile^.SetEntry(secFiles,ieOpenFile+IntToStr(I),S);
  493. Inc(I);
  494. OpenFileCount:=I-1;
  495. end;
  496. PW:=PSourceWindow(PW^.next);
  497. While assigned(PW) and (PW<>PPW) and (PW^.HelpCtx<>hcSourceWindow) do
  498. PW:=PSourceWindow(PW^.next);
  499. If PW=PPW then
  500. break;
  501. end;
  502. INIFile^.SetIntEntry(secFiles,ieOpenFileCount,OpenFileCount);
  503. *)
  504. { Run }
  505. INIFile^.SetEntry(secRun,ieRunParameters,GetRunParameters);
  506. {$ifndef GABOR}
  507. If DebuggeeTTY<>'' then
  508. INIFile^.SetEntry(secRun,ieDebuggeeRedir,DebuggeeTTY);
  509. {$endif}
  510. { Compile }
  511. INIFile^.SetEntry(secCompile,iePrimaryFile,PrimaryFile);
  512. INIFile^.SetEntry(secCompile,ieCompileMode,SwitchesModeStr[SwitchesMode]);
  513. { Help }
  514. S:='';
  515. HelpFiles^.ForEach(@ConcatName);
  516. INIFile^.SetEntry(secHelp,ieHelpFiles,'"'+S+'"');
  517. { Editor }
  518. {$ifndef EDITORS}
  519. INIFile^.SetIntEntry(secEditor,ieDefaultTabSize,DefaultTabSize);
  520. INIFile^.SetIntEntry(secEditor,ieDefaultIndentSize,DefaultIndentSize);
  521. INIFile^.SetIntEntry(secEditor,ieDefaultEditorFlags,DefaultCodeEditorFlags);
  522. INIFile^.SetEntry(secEditor,ieDefaultSaveExt,DefaultSaveExt);
  523. {$endif}
  524. { Highlight }
  525. INIFile^.SetEntry(secHighlight,ieHighlightExts,'"'+HighlightExts+'"');
  526. INIFile^.SetEntry(secHighlight,ieTabsPattern,'"'+TabsPattern+'"');
  527. { SourcePath }
  528. INIFile^.SetEntry(secSourcePath,ieSourceList,'"'+SourceDirs+'"');
  529. { Mouse }
  530. INIFile^.SetIntEntry(secMouse,ieDoubleClickDelay,DoubleDelay);
  531. INIFile^.SetIntEntry(secMouse,ieReverseButtons,byte(MouseReverse));
  532. INIFile^.SetIntEntry(secMouse,ieAltClickAction,AltMouseAction);
  533. INIFile^.SetIntEntry(secMouse,ieCtrlClickAction,CtrlMouseAction);
  534. { Search }
  535. INIFile^.SetIntEntry(secSearch,ieFindFlags,FindFlags);
  536. { Breakpoints }
  537. {$ifndef NODEBUG}
  538. BreakPointCount:=BreakpointsCollection^.Count;
  539. INIFile^.SetIntEntry(secBreakpoint,ieBreakpointCount,BreakpointCount);
  540. for i:=1 to BreakpointCount do
  541. WriteOneBreakPointEntry(I-1,INIFile);
  542. WatchesCount:=WatchesCollection^.Count;
  543. INIFile^.SetIntEntry(secWatches,ieWatchCount,WatchesCount);
  544. for i:=1 to WatchesCount do
  545. WriteOneWatchEntry(I-1,INIFile);
  546. {$endif}
  547. { Tools }
  548. INIFile^.DeleteSection(secTools);
  549. for I:=1 to GetToolCount do
  550. begin
  551. S:=IntToStr(I);
  552. GetToolParams(I-1,S1,S2,S3,W);
  553. if S1<>'' then S1:='"'+S1+'"';
  554. if S2<>'' then S2:='"'+S2+'"';
  555. if S3<>'' then S3:='"'+S3+'"';
  556. INIFile^.SetEntry(secTools,ieToolName+S,S1);
  557. INIFile^.SetEntry(secTools,ieToolProgram+S,S2);
  558. INIFile^.SetEntry(secTools,ieToolParams+S,S3);
  559. INIFile^.SetIntEntry(secTools,ieToolHotKey+S,W);
  560. end;
  561. { Colors }
  562. if AppPalette<>CIDEAppColor then
  563. begin
  564. { this has a bug. if a different palette has been read on startup, and
  565. then changed back to match the default, this will not update it in the
  566. ini file, eg. the original (non-default) will be left unmodified... }
  567. S:=AppPalette;
  568. INIFile^.SetEntry(secColors,iePalette+'_1_40',PaletteToStr(copy(S,1,40)));
  569. INIFile^.SetEntry(secColors,iePalette+'_41_80',PaletteToStr(copy(S,41,40)));
  570. INIFile^.SetEntry(secColors,iePalette+'_81_120',PaletteToStr(copy(S,81,40)));
  571. INIFile^.SetEntry(secColors,iePalette+'_121_160',PaletteToStr(copy(S,121,40)));
  572. INIFile^.SetEntry(secColors,iePalette+'_161_200',PaletteToStr(copy(S,161,40)));
  573. INIFile^.SetEntry(secColors,iePalette+'_201_240',PaletteToStr(copy(S,201,40)));
  574. end;
  575. { Desktop }
  576. INIFile^.SetIntEntry(secPreferences,ieDesktopFlags,DesktopFileFlags);
  577. INIFile^.SetIntEntry(secPreferences,ieCenterDebuggerRow,byte(IniCenterDebuggerRow));
  578. { Preferences }
  579. INIFile^.SetIntEntry(secPreferences,ieAutoSave,AutoSaveOptions);
  580. INIFile^.SetIntEntry(secPreferences,ieMiscOptions,MiscOptions);
  581. INIFile^.SetIntEntry(secPreferences,ieDesktopLocation,DesktopLocation);
  582. { Misc }
  583. INIFile^.SetIntEntry(secMisc,ieShowReadme,integer(ShowReadme));
  584. OK:=INIFile^.Update;
  585. Dispose(INIFile, Done);
  586. WriteINIFile:=OK;
  587. end;
  588. end.
  589. {
  590. $Log$
  591. Revision 1.1 2001-08-04 11:30:23 peter
  592. * ide works now with both compiler versions
  593. Revision 1.1.2.8 2001/03/08 16:39:22 pierre
  594. use external compiler version if compiler external
  595. Revision 1.1.2.7 2000/12/20 14:27:49 pierre
  596. * fp.ini for unix
  597. Revision 1.1.2.6 2000/12/09 17:41:20 florian
  598. * IndentSize is stored in the .INI file now
  599. Revision 1.1.2.5 2000/11/13 16:59:09 pierre
  600. * some function in double removed from fputils unit
  601. Revision 1.1.2.4 2000/10/18 21:53:27 pierre
  602. * several Gabor fixes
  603. Revision 1.1.2.3 2000/10/06 22:52:35 pierre
  604. * fixes for linux GDB tty command
  605. Revision 1.1.2.2 2000/08/16 18:46:14 peter
  606. [*] double clicking on a droplistbox caused GPF (due to invalid recurson)
  607. [*] Make, Build now possible even in Compiler Messages Window
  608. [+] when started in a new dir the IDE now ask whether to create a local
  609. config, or to use the one located in the IDE dir
  610. Revision 1.1.2.1 2000/07/20 11:02:15 michael
  611. + Fixes from gabor. See fixes.txt
  612. Revision 1.1 2000/07/13 09:48:34 michael
  613. + Initial import
  614. Revision 1.30 2000/06/22 09:07:12 pierre
  615. * Gabor changes: see fixes.txt
  616. Revision 1.29 2000/06/16 08:50:41 pierre
  617. + new bunch of Gabor's changes
  618. Revision 1.28 2000/03/21 23:30:22 pierre
  619. adapted to wcedit addition by Gabor
  620. Revision 1.27 2000/03/13 20:38:02 pierre
  621. IniPath removed and IniFileName moved to fpvars unit
  622. Revision 1.26 2000/02/04 00:08:35 pierre
  623. + IniCenterDebuggerRow
  624. Revision 1.25 1999/11/05 13:47:19 pierre
  625. * Breakpoint conditions were not reloaded correctly
  626. Revision 1.24 1999/09/16 14:34:59 pierre
  627. + TBreakpoint and TWatch registering
  628. + WatchesCollection and BreakpointsCollection stored in desk file
  629. * Syntax highlighting was broken
  630. Revision 1.23 1999/09/13 16:24:43 peter
  631. + clock
  632. * backspace unident like tp7
  633. Revision 1.22 1999/09/07 09:21:54 pierre
  634. + Watches saved
  635. Revision 1.21 1999/08/03 20:22:33 peter
  636. + TTab acts now on Ctrl+Tab and Ctrl+Shift+Tab...
  637. + Desktop saving should work now
  638. - History saved
  639. - Clipboard content saved
  640. - Desktop saved
  641. - Symbol info saved
  642. * syntax-highlight bug fixed, which compared special keywords case sensitive
  643. (for ex. 'asm' caused asm-highlighting, while 'ASM' didn't)
  644. * with 'whole words only' set, the editor didn't found occourences of the
  645. searched text, if the text appeared previously in the same line, but didn't
  646. satisfied the 'whole-word' condition
  647. * ^QB jumped to (SelStart.X,SelEnd.X) instead of (SelStart.X,SelStart.Y)
  648. (ie. the beginning of the selection)
  649. * when started typing in a new line, but not at the start (X=0) of it,
  650. the editor inserted the text one character more to left as it should...
  651. * TCodeEditor.HideSelection (Ctrl-K+H) didn't update the screen
  652. * Shift shouldn't cause so much trouble in TCodeEditor now...
  653. * Syntax highlight had problems recognizing a special symbol if it was
  654. prefixed by another symbol character in the source text
  655. * Auto-save also occours at Dos shell, Tool execution, etc. now...
  656. Revision 1.20 1999/06/28 12:36:51 pierre
  657. * avoid keeping old open file names
  658. Revision 1.19 1999/04/07 21:55:48 peter
  659. + object support for browser
  660. * html help fixes
  661. * more desktop saving things
  662. * NODEBUG directive to exclude debugger
  663. Revision 1.18 1999/03/23 15:11:31 peter
  664. * desktop saving things
  665. * vesa mode
  666. * preferences dialog
  667. Revision 1.17 1999/03/12 01:13:58 peter
  668. * flag if trytoopen should look for other extensions
  669. + browser tab in the tools-compiler
  670. Revision 1.16 1999/03/08 14:58:09 peter
  671. + prompt with dialogs for tools
  672. Revision 1.15 1999/03/05 17:53:02 pierre
  673. + saving and opening of open files on exit
  674. Revision 1.14 1999/03/01 15:41:55 peter
  675. + Added dummy entries for functions not yet implemented
  676. * MenuBar didn't update itself automatically on command-set changes
  677. * Fixed Debugging/Profiling options dialog
  678. * TCodeEditor converts spaces to tabs at save only if efUseTabChars is
  679. set
  680. * efBackSpaceUnindents works correctly
  681. + 'Messages' window implemented
  682. + Added '$CAP MSG()' and '$CAP EDIT' to available tool-macros
  683. + Added TP message-filter support (for ex. you can call GREP thru
  684. GREP2MSG and view the result in the messages window - just like in TP)
  685. * A 'var' was missing from the param-list of THelpFacility.TopicSearch,
  686. so topic search didn't work...
  687. * In FPHELP.PAS there were still context-variables defined as word instead
  688. of THelpCtx
  689. * StdStatusKeys() was missing from the statusdef for help windows
  690. + Topic-title for index-table can be specified when adding a HTML-files
  691. Revision 1.13 1999/02/22 02:15:14 peter
  692. + default extension for save in the editor
  693. + Separate Text to Find for the grep dialog
  694. * fixed redir crash with tp7
  695. Revision 1.12 1999/02/19 18:43:46 peter
  696. + open dialog supports mask list
  697. Revision 1.11 1999/02/10 09:53:14 pierre
  698. * better storing of breakpoints
  699. Revision 1.10 1999/02/05 13:08:42 pierre
  700. + new breakpoint types added
  701. Revision 1.9 1999/02/05 12:11:55 pierre
  702. + SourceDir that stores directories for sources that the
  703. compiler should not know about
  704. Automatically asked for addition when a new file that
  705. needed filedialog to be found is in an unknown directory
  706. Stored and retrieved from INIFile
  707. + Breakpoints conditions added to INIFile
  708. * Breakpoints insterted and removed at debin and end of debug session
  709. Revision 1.8 1999/02/04 17:52:38 pierre
  710. * bs_invalid renamed bs_deleted
  711. Revision 1.7 1999/02/04 17:19:24 peter
  712. * linux fixes
  713. Revision 1.6 1999/02/04 13:32:04 pierre
  714. * Several things added (I cannot commit them independently !)
  715. + added TBreakpoint and TBreakpointCollection
  716. + added cmResetDebugger,cmGrep,CmToggleBreakpoint
  717. + Breakpoint list in INIFile
  718. * Select items now also depend of SwitchMode
  719. * Reading of option '-g' was not possible !
  720. + added search for -Fu args pathes in TryToOpen
  721. + added code for automatic opening of FileDialog
  722. if source not found
  723. Revision 1.5 1999/01/21 11:54:15 peter
  724. + tools menu
  725. + speedsearch in symbolbrowser
  726. * working run command
  727. Revision 1.4 1999/01/04 11:49:45 peter
  728. * 'Use tab characters' now works correctly
  729. + Syntax highlight now acts on File|Save As...
  730. + Added a new class to syntax highlight: 'hex numbers'.
  731. * There was something very wrong with the palette managment. Now fixed.
  732. + Added output directory (-FE<xxx>) support to 'Directories' dialog...
  733. * Fixed some possible bugs in Running/Compiling, and the compilation/run
  734. process revised
  735. Revision 1.1 1998/12/28 15:47:45 peter
  736. + Added user screen support, display & window
  737. + Implemented Editor,Mouse Options dialog
  738. + Added location of .INI and .CFG file
  739. + Option (INI) file managment implemented (see bottom of Options Menu)
  740. + Switches updated
  741. + Run program
  742. }