fpini.pas 21 KB

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