fpini.pas 26 KB

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