fpini.pas 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  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. {$i globdir.inc}
  15. uses
  16. FPUtils;
  17. procedure InitDirs;
  18. procedure InitINIFile;
  19. procedure CheckINIFile;
  20. function ReadINIFile: boolean;
  21. function WriteINIFile(FromSaveAs : boolean) : boolean;
  22. implementation
  23. uses
  24. Dos,Objects,Drivers,
  25. {$ifdef FVISION}
  26. FVConsts,
  27. {$else}
  28. Commands,
  29. {$endif}
  30. Version,
  31. {$ifdef USE_EXTERNAL_COMPILER}
  32. fpintf, { superseeds version_string of version unit }
  33. {$endif USE_EXTERNAL_COMPILER}
  34. WConsts,WUtils,WINI,WViews,{$ifndef EDITORS}WEditor,WCEdit{$else}Editors{$endif},
  35. {$ifndef NODEBUG}FPDebug,{$endif}FPConst,FPVars,
  36. FPIntf,FPTools,FPSwitch,FPString;
  37. const
  38. { INI file sections }
  39. secFiles = 'Files';
  40. secRun = 'Run';
  41. secCompile = 'Compile';
  42. secColors = 'Colors';
  43. secHelp = 'Help';
  44. secEditor = 'Editor';
  45. secBreakpoint = 'Breakpoints';
  46. secWatches = 'Watches';
  47. secHighlight = 'Highlight';
  48. secMouse = 'Mouse';
  49. secSearch = 'Search';
  50. secTools = 'Tools';
  51. secSourcePath = 'SourcePath';
  52. secPreferences = 'Preferences';
  53. secMisc = 'Misc';
  54. { INI file tags }
  55. ieRecentFile = 'RecentFile';
  56. (* ieOpenFile = 'OpenFile';
  57. ieOpenFileCount = 'OpenFileCount'; *)
  58. ieRunParameters = 'Parameters';
  59. ieDebuggeeRedir = 'DebugRedirection';
  60. iePrimaryFile = 'PrimaryFile';
  61. ieCompileMode = 'CompileMode';
  62. iePalette = 'Palette';
  63. ieHelpFiles = 'Files';
  64. ieDefaultTabSize = 'DefaultTabSize';
  65. ieDefaultIndentSize = 'DefaultIndentSize';
  66. ieDefaultEditorFlags='DefaultFlags';
  67. ieDefaultSaveExt = 'DefaultSaveExt';
  68. ieOpenExts = 'OpenExts';
  69. ieHighlightExts = 'Exts';
  70. ieTabsPattern = 'NeedsTabs';
  71. ieDoubleClickDelay = 'DoubleDelay';
  72. ieReverseButtons = 'ReverseButtons';
  73. ieAltClickAction = 'AltClickAction';
  74. ieCtrlClickAction = 'CtrlClickAction';
  75. ieFindFlags = 'FindFlags';
  76. ieToolName = 'Title';
  77. ieToolProgram = 'Program';
  78. ieToolParams = 'Params';
  79. ieToolHotKey = 'HotKey';
  80. ieBreakpointTyp = 'Type';
  81. ieBreakpointCount = 'Count';
  82. ieBreakpointState = 'State';
  83. ieBreakpointName = 'Name';
  84. ieBreakpointFile = 'FileName';
  85. ieBreakpointLine = 'LineNumber';
  86. ieBreakpointCond = 'Condition';
  87. ieWatchCount = 'Count';
  88. ieWatchName = 'Watch';
  89. ieSourceList = 'SourceList';
  90. { ieVideoMode = 'VideoMode';}
  91. ieAutoSave = 'AutoSaveFlags';
  92. ieMiscOptions = 'MiscOptions';
  93. ieDesktopLocation = 'DesktopLocation';
  94. ieDesktopFlags = 'DesktopFileFlags';
  95. ieCenterDebuggerRow= 'CenterCurrentLineWhileDebugging';
  96. ieShowReadme = 'ShowReadme';
  97. Procedure InitDirs;
  98. begin
  99. StartupDir:=CompleteDir(FExpand('.'));
  100. {$ifndef unix}
  101. IDEDir:=CompleteDir(DirOf(system.Paramstr(0)));
  102. {$else}
  103. SystemIDEDir:='/usr/lib/fpc/'+version_string+'/ide/text';
  104. IDEdir:=CompleteDir(FExpand('~/.fp'));
  105. If Not ExistsDir(IDEdir) Then
  106. begin
  107. IDEDir:=SystemIDEDir;
  108. if Not ExistsDir(IDEDir) then
  109. begin
  110. if DirOf(system.paramstr(0))<>'' then
  111. IDEDir:=CompleteDir(DirOf(system.ParamStr(0)))
  112. else
  113. IDEDir:=StartupDir;
  114. end;
  115. end;
  116. {$endif}
  117. end;
  118. procedure InitINIFile;
  119. var S: string;
  120. begin
  121. S:=LocateFile(INIFileName);
  122. if S<>'' then
  123. IniFileName:=S;
  124. IniFileName:=FExpand(IniFileName);
  125. end;
  126. procedure CheckINIFile;
  127. var IniDir,CurDir: DirStr;
  128. INI: PINIFile;
  129. const Btns : array[1..2] of string = (btn_config_copyexisting,btn_config_createnew);
  130. begin
  131. IniDir:=DirOf(IniFileName); CurDir:=GetCurDir;
  132. if CompareText(IniDir,CurDir)<>0 then
  133. if not ExistsFile(CurDir+DirInfoName) then
  134. if ConfirmBox(FormatStrStr(msg_doyouwanttocreatelocalconfigfile,IniDir),nil,false)=cmYes then
  135. begin
  136. if (not ExistsFile(IniFileName)) or
  137. (ChoiceBox(msg_configcopyexistingorcreatenew,nil,
  138. Btns,false)=cmUserBtn2) then
  139. begin
  140. { create new config here }
  141. IniFileName:=CurDir+IniName;
  142. SwitchesPath:=CurDir+SwitchesName;
  143. end
  144. else
  145. begin
  146. { copy config here }
  147. if CopyFile(IniFileName,CurDir+IniName)=false then
  148. ErrorBox(FormatStrStr(msg_errorwritingfile,CurDir+IniName),nil)
  149. else
  150. IniFileName:=CurDir+IniName;
  151. if CopyFile(SwitchesPath,CurDir+SwitchesName)=false then
  152. ErrorBox(FormatStrStr(msg_errorwritingfile,CurDir+SwitchesName),nil)
  153. else
  154. SwitchesPath:=CurDir+SwitchesName;
  155. end;
  156. end
  157. else
  158. begin
  159. New(INI, Init(CurDir+DirInfoName));
  160. INI^.SetEntry(MainSectionName,'Comment','Do NOT delete this file!!!');
  161. if INI^.Update=false then
  162. ErrorBox(FormatStrStr(msg_errorwritingfile,INI^.GetFileName),nil);
  163. Dispose(INI, Done);
  164. end;
  165. end;
  166. function PaletteToStr(S: string): string;
  167. var C: string;
  168. I: integer;
  169. begin
  170. C:='';
  171. for I:=1 to length(S) do
  172. begin
  173. Insert('#$'+IntToHex(ord(S[I]),2),C,Length(C)+1);
  174. end;
  175. PaletteToStr:=C;
  176. end;
  177. function StrToPalette(S: string): string;
  178. var I,P,X: integer;
  179. C: string;
  180. Hex: boolean;
  181. OK: boolean;
  182. begin
  183. C:=''; I:=1;
  184. OK:=S<>'';
  185. while OK and (I<=length(S)) and (S[I]='#') do
  186. begin
  187. Inc(I); Hex:=false;
  188. if S[I]='$' then begin Inc(I); Hex:=true; end;
  189. P:=Pos('#',copy(S,I,High(S))); if P>0 then P:=I+P-1 else P:=length(S)+1;
  190. if Hex=false then
  191. begin
  192. X:=StrToInt(copy(S,I,P-I));
  193. OK:=(LastStrToIntResult=0) and (0<=X) and (X<=High(S));
  194. end
  195. else
  196. begin
  197. X:=HexToInt(copy(S,I,P-I));
  198. OK:=(LastHexToIntResult=0) and (0<=X) and (X<=255);
  199. end;
  200. if OK then C:=C+chr(X);
  201. Inc(I,P-I);
  202. end;
  203. StrToPalette:=C;
  204. end;
  205. {$ifndef NODEBUG}
  206. procedure WriteOneWatchEntry(I : Longint;INIFile : PINIFile);
  207. var
  208. PW : PWatch;
  209. S : String;
  210. begin
  211. Str(I,S);
  212. PW:=WatchesCollection^.At(I);
  213. With PW^ do
  214. begin
  215. INIFile^.SetEntry(secWatches,ieWatchName+S,GetStr(expr));
  216. end;
  217. end;
  218. procedure WriteOneBreakPointEntry(I : longint;INIFile : PINIFile);
  219. var PB : PBreakpoint;
  220. S : String;
  221. begin
  222. Str(I,S);
  223. PB:=BreakpointsCollection^.At(I);
  224. If assigned(PB) then
  225. With PB^ do
  226. Begin
  227. INIFile^.SetEntry(secBreakpoint,ieBreakpointTyp+S,BreakpointTypeStr[typ]);
  228. INIFile^.SetEntry(secBreakpoint,ieBreakpointState+S,BreakpointStateStr[state]);
  229. if typ=bt_file_line then
  230. begin
  231. INIFile^.SetEntry(secBreakpoint,ieBreakpointFile+S,FileName^);
  232. INIFile^.SetIntEntry(secBreakpoint,ieBreakpointLine+S,Line);
  233. end
  234. else
  235. INIFile^.SetEntry(secBreakpoint,ieBreakpointName+S,Name^);
  236. if assigned(Conditions) then
  237. INIFile^.SetEntry(secBreakpoint,ieBreakpointCond+S,Conditions^);
  238. end;
  239. end;
  240. procedure ReadOneWatchEntry(I : Longint;INIFile : PINIFile);
  241. var
  242. PW : PWatch;
  243. S : String;
  244. begin
  245. Str(I,S);
  246. PW:=new(PWatch,Init(INIFile^.GetEntry(secWatches,ieWatchName+S,'')));
  247. WatchesCollection^.Insert(PW);
  248. end;
  249. procedure ReadOneBreakPointEntry(i : longint;INIFile : PINIFile);
  250. var PB : PBreakpoint;
  251. S,S2,SC : string;
  252. Line : longint;
  253. typ : BreakpointType;
  254. state : BreakpointState;
  255. begin
  256. Str(I,S2);
  257. typ:=bt_invalid;
  258. S:=INIFile^.GetEntry(secBreakpoint,ieBreakpointTyp+S2,BreakpointTypeStr[typ]);
  259. for typ:=low(BreakpointType) to high(BreakpointType) do
  260. If pos(BreakpointTypeStr[typ],S)>0 then break;
  261. state:=bs_deleted;
  262. S:=INIFile^.GetEntry(secBreakpoint,ieBreakpointState+S2,BreakpointStateStr[state]);
  263. for state:=low(BreakpointState) to high(BreakpointState) do
  264. If pos(BreakpointStateStr[state],S)>0 then break;
  265. case typ of
  266. bt_invalid :;
  267. bt_file_line :
  268. begin
  269. S:=INIFile^.GetEntry(secBreakpoint,ieBreakpointFile+S2,'');
  270. Line:=INIFile^.GetIntEntry(secBreakpoint,ieBreakpointLine+S2,0);
  271. end;
  272. else
  273. begin
  274. S:=INIFile^.GetEntry(secBreakpoint,ieBreakpointName+S2,'');
  275. end;
  276. end;
  277. SC:=INIFile^.GetEntry(secBreakpoint,ieBreakpointCond+S2,'');
  278. if (typ=bt_function) and (S<>'') then
  279. new(PB,init_function(S))
  280. else if (typ=bt_file_line) and (S<>'') then
  281. new(PB,init_file_line(S,Line))
  282. else
  283. new(PB,init_type(typ,S));
  284. If assigned(PB) then
  285. begin
  286. PB^.state:=state;
  287. If SC<>'' then
  288. PB^.conditions:=NewStr(SC);
  289. BreakpointsCollection^.Insert(PB);
  290. end;
  291. end;
  292. {$endif NODEBUG}
  293. function ReadINIFile: boolean;
  294. var INIFile: PINIFile;
  295. S,PS,S1,S2,S3: string;
  296. I,P: integer;
  297. BreakPointCount,WatchesCount:longint;
  298. OK: boolean;
  299. ts : TSwitchMode;
  300. W: word;
  301. begin
  302. OK:=ExistsFile(IniFileName);
  303. if OK then
  304. begin
  305. New(INIFile, Init(IniFileName));
  306. { Files }
  307. OpenExts:=INIFile^.GetEntry(secFiles,ieOpenExts,OpenExts);
  308. RecentFileCount:=High(RecentFiles);
  309. for I:=Low(RecentFiles) to High(RecentFiles) do
  310. begin
  311. S:=INIFile^.GetEntry(secFiles,ieRecentFile+IntToStr(I),'');
  312. if (S='') and (RecentFileCount>I-1) then RecentFileCount:=I-1;
  313. with RecentFiles[I] do
  314. begin
  315. P:=Pos(',',S); if P=0 then P:=length(S)+1;
  316. FileName:=copy(S,1,P-1); Delete(S,1,P);
  317. P:=Pos(',',S); if P=0 then P:=length(S)+1;
  318. LastPos.X:=Max(0,StrToInt(copy(S,1,P-1))); Delete(S,1,P);
  319. P:=Pos(',',S); if P=0 then P:=length(S)+1;
  320. LastPos.Y:=Max(0,StrToInt(copy(S,1,P-1))); Delete(S,1,P);
  321. end;
  322. end;
  323. { Run }
  324. { First read the primary file, which can also set the parameters which can
  325. be overruled with the parameter loading }
  326. SetPrimaryFile(INIFile^.GetEntry(secCompile,iePrimaryFile,PrimaryFile));
  327. SetRunParameters(INIFile^.GetEntry(secRun,ieRunParameters,GetRunParameters));
  328. {$ifndef GABOR}
  329. DebuggeeTTY := INIFile^.GetEntry(secRun,ieDebuggeeRedir,DebuggeeTTY);
  330. {$endif}
  331. { Compile }
  332. S:=INIFile^.GetEntry(secCompile,ieCompileMode,'');
  333. for ts:=low(TSwitchMode) to high(TSwitchMode) do
  334. begin
  335. if SwitchesModeStr[ts]=S then
  336. SwitchesMode:=ts;
  337. end;
  338. { Help }
  339. S:=INIFile^.GetEntry(secHelp,ieHelpFiles,'');
  340. repeat
  341. P:=Pos(';',S); if P=0 then P:=length(S)+1;
  342. PS:=copy(S,1,P-1);
  343. if PS<>'' then HelpFiles^.Insert(NewStr(PS));
  344. Delete(S,1,P);
  345. until S='';
  346. { Editor }
  347. {$ifndef EDITORS}
  348. DefaultTabSize:=INIFile^.GetIntEntry(secEditor,ieDefaultTabSize,DefaultTabSize);
  349. DefaultIndentSize:=INIFile^.GetIntEntry(secEditor,ieDefaultIndentSize,DefaultIndentSize);
  350. DefaultCodeEditorFlags:=INIFile^.GetIntEntry(secEditor,ieDefaultEditorFlags,DefaultCodeEditorFlags);
  351. DefaultSaveExt:=INIFile^.GetEntry(secEditor,ieDefaultSaveExt,DefaultSaveExt);
  352. {$endif}
  353. { Highlight }
  354. HighlightExts:=INIFile^.GetEntry(secHighlight,ieHighlightExts,HighlightExts);
  355. TabsPattern:=INIFile^.GetEntry(secHighlight,ieTabsPattern,TabsPattern);
  356. { SourcePath }
  357. SourceDirs:=INIFile^.GetEntry(secSourcePath,ieSourceList,SourceDirs);
  358. { Mouse }
  359. DoubleDelay:=INIFile^.GetIntEntry(secMouse,ieDoubleClickDelay,DoubleDelay);
  360. MouseReverse:=boolean(INIFile^.GetIntEntry(secMouse,ieReverseButtons,byte(MouseReverse)));
  361. AltMouseAction:=INIFile^.GetIntEntry(secMouse,ieAltClickAction,AltMouseAction);
  362. CtrlMouseAction:=INIFile^.GetIntEntry(secMouse,ieCtrlClickAction,CtrlMouseAction);
  363. { Search }
  364. FindFlags:=INIFile^.GetIntEntry(secSearch,ieFindFlags,FindFlags);
  365. { Breakpoints }
  366. {$ifndef NODEBUG}
  367. BreakpointCount:=INIFile^.GetIntEntry(secBreakpoint,ieBreakpointCount,0);
  368. for i:=1 to BreakpointCount do
  369. ReadOneBreakPointEntry(i-1,INIFile);
  370. WatchesCount:=INIFile^.GetIntEntry(secWatches,ieWatchCount,0);
  371. for i:=1 to WatchesCount do
  372. ReadOneWatchEntry(i-1,INIFile);
  373. {$endif}
  374. { Tools }
  375. for I:=1 to MaxToolCount do
  376. begin
  377. S:=IntToStr(I);
  378. S1:=INIFile^.GetEntry(secTools,ieToolName+S,'');
  379. if S1='' then Break; { !!! }
  380. S2:=INIFile^.GetEntry(secTools,ieToolProgram+S,'');
  381. S3:=INIFile^.GetEntry(secTools,ieToolParams+S,'');
  382. W:=Max(0,Min(65535,INIFile^.GetIntEntry(secTools,ieToolHotKey+S,0)));
  383. AddTool(S1,S2,S3,W);
  384. end;
  385. { Colors }
  386. S:=AppPalette;
  387. PS:=StrToPalette(INIFile^.GetEntry(secColors,iePalette+'_1_40',PaletteToStr(copy(S,1,40))));
  388. PS:=PS+StrToPalette(INIFile^.GetEntry(secColors,iePalette+'_41_80',PaletteToStr(copy(S,41,40))));
  389. PS:=PS+StrToPalette(INIFile^.GetEntry(secColors,iePalette+'_81_120',PaletteToStr(copy(S,81,40))));
  390. PS:=PS+StrToPalette(INIFile^.GetEntry(secColors,iePalette+'_121_160',PaletteToStr(copy(S,121,40))));
  391. PS:=PS+StrToPalette(INIFile^.GetEntry(secColors,iePalette+'_161_200',PaletteToStr(copy(S,161,40))));
  392. PS:=PS+StrToPalette(INIFile^.GetEntry(secColors,iePalette+'_201_240',PaletteToStr(copy(S,201,40))));
  393. if length(PS)<length(CIDEAppColor) then
  394. PS:=PS+copy(CIDEAppColor,length(PS)+1,255);
  395. AppPalette:=PS;
  396. (* { Open files }
  397. for I:=INIFile^.GetIntEntry(secFiles,ieOpenFileCount,0) downto 1 do
  398. begin
  399. S:=INIFile^.GetEntry(secFiles,ieOpenFile+IntToStr(I),'');
  400. if (S='') then
  401. break;
  402. P:=Pos(',',S); if P=0 then P:=length(S)+1;
  403. S1:=copy(S,1,P-1);
  404. Delete(S,1,P);
  405. P:=Pos(',',S);
  406. if P=0 then P:=length(S)+1;
  407. X:=Max(0,StrToInt(copy(S,1,P-1)));
  408. Delete(S,1,P);
  409. P:=Pos(',',S);
  410. if P=0 then P:=length(S)+1;
  411. Y:=Max(0,StrToInt(copy(S,1,P-1)));
  412. Delete(S,1,P);
  413. P:=Pos(',',S);
  414. if P=0 then P:=length(S)+1;
  415. R.A.X:=Max(0,StrToInt(copy(S,1,P-1)));
  416. Delete(S,1,P);
  417. P:=Pos(',',S);
  418. if P=0 then P:=length(S)+1;
  419. R.A.Y:=Max(0,StrToInt(copy(S,1,P-1)));
  420. Delete(S,1,P);
  421. P:=Pos(',',S);
  422. if P=0 then P:=length(S)+1;
  423. R.B.X:=Max(0,StrToInt(copy(S,1,P-1)));
  424. Delete(S,1,P);
  425. P:=Pos(',',S);
  426. if P=0 then P:=length(S)+1;
  427. R.B.Y:=Max(0,StrToInt(copy(S,1,P-1)));
  428. if (R.A.X<R.B.X) and (R.A.Y<R.B.Y) then
  429. TryToOpenFile(@R,S1,X,Y,false)
  430. else
  431. TryToOpenFile(nil,S1,X,Y,false);
  432. { remove it because otherwise we allways keep old files }
  433. INIFile^.DeleteEntry(secFiles,ieOpenFile+IntToStr(I));
  434. end;
  435. *)
  436. { Desktop }
  437. DesktopFileFlags:=INIFile^.GetIntEntry(secPreferences,ieDesktopFlags,DesktopFileFlags);
  438. { Debugger }
  439. IniCenterDebuggerRow:=INIFile^.GetIntEntry(secPreferences,ieCenterDebuggerRow,1)<>0;
  440. { Preferences }
  441. AutoSaveOptions:=INIFile^.GetIntEntry(secPreferences,ieAutoSave,AutoSaveOptions);
  442. MiscOptions:=INIFile^.GetIntEntry(secPreferences,ieMiscOptions,MiscOptions);
  443. DesktopLocation:=INIFile^.GetIntEntry(secPreferences,ieDesktopLocation,DesktopLocation);
  444. { Misc }
  445. ShowReadme:=INIFile^.GetIntEntry(secMisc,ieShowReadme,{integer(ShowReadme)}1)<>0;
  446. Dispose(INIFile, Done);
  447. end;
  448. ReadINIFile:=OK;
  449. end;
  450. function WriteINIFile (FromSaveAs : boolean): boolean;
  451. var INIFile: PINIFile;
  452. S: string;
  453. S1,S2,S3: string;
  454. W: word;
  455. BreakPointCount,WatchesCount:longint;
  456. I(*,OpenFileCount*): integer;
  457. OK: boolean;
  458. procedure ConcatName(P: PString); {$ifndef FPC}far;{$endif}
  459. begin
  460. if (S<>'') then S:=S+';';
  461. S:=S+P^;
  462. end;
  463. begin
  464. {$ifdef Unix}
  465. if not FromSaveAs and (DirOf(IniFileName)=DirOf(SystemIDEDir)) then
  466. begin
  467. IniFileName:=FExpand('~/.fp/'+IniName);
  468. If not ExistsDir(DirOf(IniFileName)) then
  469. MkDir(FExpand('~/.fp'));
  470. end;
  471. {$endif Unix}
  472. New(INIFile, Init(IniFileName));
  473. { Files }
  474. { avoid keeping old files }
  475. INIFile^.DeleteSection(secFiles);
  476. INIFile^.SetEntry(secFiles,ieOpenExts,'"'+OpenExts+'"');
  477. for I:=1 to High(RecentFiles) do
  478. begin
  479. if I<=RecentFileCount then
  480. with RecentFiles[I] do S:=FileName+','+IntToStr(LastPos.X)+','+IntToStr(LastPos.Y)
  481. else
  482. S:='';
  483. INIFile^.SetEntry(secFiles,ieRecentFile+IntToStr(I),S);
  484. end;
  485. (*
  486. PW:=FirstEditorWindow;
  487. PPW:=PW;
  488. I:=1;
  489. while assigned(PW) do
  490. begin
  491. If PW^.HelpCtx=hcSourceWindow then
  492. begin
  493. With PW^.editor^ do
  494. S:=FileName+','+IntToStr(CurPos.X)+','+IntToStr(CurPos.Y);
  495. PW^.GetBounds(R);
  496. S:=S+','+IntToStr(R.A.X)+','+IntToStr(R.A.Y)+','+
  497. IntToStr(R.B.X)+','+IntToStr(R.B.Y);
  498. INIFile^.SetEntry(secFiles,ieOpenFile+IntToStr(I),S);
  499. Inc(I);
  500. OpenFileCount:=I-1;
  501. end;
  502. PW:=PSourceWindow(PW^.next);
  503. While assigned(PW) and (PW<>PPW) and (PW^.HelpCtx<>hcSourceWindow) do
  504. PW:=PSourceWindow(PW^.next);
  505. If PW=PPW then
  506. break;
  507. end;
  508. INIFile^.SetIntEntry(secFiles,ieOpenFileCount,OpenFileCount);
  509. *)
  510. { Run }
  511. INIFile^.SetEntry(secRun,ieRunParameters,GetRunParameters);
  512. {$ifndef GABOR}
  513. { If DebuggeeTTY<>'' then }
  514. INIFile^.SetEntry(secRun,ieDebuggeeRedir,DebuggeeTTY);
  515. {$endif}
  516. { Compile }
  517. INIFile^.SetEntry(secCompile,iePrimaryFile,PrimaryFile);
  518. INIFile^.SetEntry(secCompile,ieCompileMode,SwitchesModeStr[SwitchesMode]);
  519. { Help }
  520. S:='';
  521. HelpFiles^.ForEach(@ConcatName);
  522. INIFile^.SetEntry(secHelp,ieHelpFiles,'"'+S+'"');
  523. { Editor }
  524. {$ifndef EDITORS}
  525. INIFile^.SetIntEntry(secEditor,ieDefaultTabSize,DefaultTabSize);
  526. INIFile^.SetIntEntry(secEditor,ieDefaultIndentSize,DefaultIndentSize);
  527. INIFile^.SetIntEntry(secEditor,ieDefaultEditorFlags,DefaultCodeEditorFlags);
  528. INIFile^.SetEntry(secEditor,ieDefaultSaveExt,DefaultSaveExt);
  529. {$endif}
  530. { Highlight }
  531. INIFile^.SetEntry(secHighlight,ieHighlightExts,'"'+HighlightExts+'"');
  532. INIFile^.SetEntry(secHighlight,ieTabsPattern,'"'+TabsPattern+'"');
  533. { SourcePath }
  534. INIFile^.SetEntry(secSourcePath,ieSourceList,'"'+SourceDirs+'"');
  535. { Mouse }
  536. INIFile^.SetIntEntry(secMouse,ieDoubleClickDelay,DoubleDelay);
  537. INIFile^.SetIntEntry(secMouse,ieReverseButtons,byte(MouseReverse));
  538. INIFile^.SetIntEntry(secMouse,ieAltClickAction,AltMouseAction);
  539. INIFile^.SetIntEntry(secMouse,ieCtrlClickAction,CtrlMouseAction);
  540. { Search }
  541. INIFile^.SetIntEntry(secSearch,ieFindFlags,FindFlags);
  542. { Breakpoints }
  543. {$ifndef NODEBUG}
  544. BreakPointCount:=BreakpointsCollection^.Count;
  545. INIFile^.SetIntEntry(secBreakpoint,ieBreakpointCount,BreakpointCount);
  546. for i:=1 to BreakpointCount do
  547. WriteOneBreakPointEntry(I-1,INIFile);
  548. WatchesCount:=WatchesCollection^.Count;
  549. INIFile^.SetIntEntry(secWatches,ieWatchCount,WatchesCount);
  550. for i:=1 to WatchesCount do
  551. WriteOneWatchEntry(I-1,INIFile);
  552. {$endif}
  553. { Tools }
  554. INIFile^.DeleteSection(secTools);
  555. for I:=1 to GetToolCount do
  556. begin
  557. S:=IntToStr(I);
  558. GetToolParams(I-1,S1,S2,S3,W);
  559. if S1<>'' then S1:='"'+S1+'"';
  560. if S2<>'' then S2:='"'+S2+'"';
  561. if S3<>'' then S3:='"'+S3+'"';
  562. INIFile^.SetEntry(secTools,ieToolName+S,S1);
  563. INIFile^.SetEntry(secTools,ieToolProgram+S,S2);
  564. INIFile^.SetEntry(secTools,ieToolParams+S,S3);
  565. INIFile^.SetIntEntry(secTools,ieToolHotKey+S,W);
  566. end;
  567. { Colors }
  568. if AppPalette<>CIDEAppColor then
  569. begin
  570. { this has a bug. if a different palette has been read on startup, and
  571. then changed back to match the default, this will not update it in the
  572. ini file, eg. the original (non-default) will be left unmodified... }
  573. S:=AppPalette;
  574. INIFile^.SetEntry(secColors,iePalette+'_1_40',PaletteToStr(copy(S,1,40)));
  575. INIFile^.SetEntry(secColors,iePalette+'_41_80',PaletteToStr(copy(S,41,40)));
  576. INIFile^.SetEntry(secColors,iePalette+'_81_120',PaletteToStr(copy(S,81,40)));
  577. INIFile^.SetEntry(secColors,iePalette+'_121_160',PaletteToStr(copy(S,121,40)));
  578. INIFile^.SetEntry(secColors,iePalette+'_161_200',PaletteToStr(copy(S,161,40)));
  579. INIFile^.SetEntry(secColors,iePalette+'_201_240',PaletteToStr(copy(S,201,40)));
  580. end;
  581. { Desktop }
  582. INIFile^.SetIntEntry(secPreferences,ieDesktopFlags,DesktopFileFlags);
  583. INIFile^.SetIntEntry(secPreferences,ieCenterDebuggerRow,byte(IniCenterDebuggerRow));
  584. { Preferences }
  585. INIFile^.SetIntEntry(secPreferences,ieAutoSave,AutoSaveOptions);
  586. INIFile^.SetIntEntry(secPreferences,ieMiscOptions,MiscOptions);
  587. INIFile^.SetIntEntry(secPreferences,ieDesktopLocation,DesktopLocation);
  588. { Misc }
  589. INIFile^.SetIntEntry(secMisc,ieShowReadme,integer(ShowReadme));
  590. OK:=INIFile^.Update;
  591. Dispose(INIFile, Done);
  592. WriteINIFile:=OK;
  593. end;
  594. end.
  595. {
  596. $Log$
  597. Revision 1.8 2002-10-23 18:01:50 hajny
  598. * mistyping fixed
  599. Revision 1.7 2002/10/18 17:58:48 hajny
  600. * added missing include
  601. Revision 1.6 2002/09/07 15:40:43 peter
  602. * old logs removed and tabs fixed
  603. Revision 1.5 2002/08/13 07:12:08 pierre
  604. * use normal strings for ChoiceBox function
  605. Revision 1.4 2002/04/02 14:06:50 pierre
  606. * avoid a problem if resetting debuggee redirection
  607. }