fpdesk.pas 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199
  1. {
  2. This file is part of the Free Pascal Integrated Development Environment
  3. Copyright (c) 1998 by Berczi Gabor
  4. Desktop loading/saving routines
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. unit FPDesk;
  12. {$H-}
  13. interface
  14. const
  15. MinDesktopVersion = $000A;
  16. DesktopVersion = $000B; { <- if you change any Load&Store methods,
  17. default object properties (Options,State)
  18. then you should also change this }
  19. ResVersion = 'VERSION';
  20. ResDesktopFlags = 'FLAGS';
  21. ResVideo = 'VIDEOMODE';
  22. ResHistory = 'HISTORY';
  23. ResClipboard = 'CLIPBOARD';
  24. ResWatches = 'WATCHES';
  25. ResBreakpoints = 'BREAKPOINTS';
  26. ResDesktop = 'DESKTOP';
  27. ResSymbols = 'SYMBOLS';
  28. ResCodeComplete = 'CODECOMPLETE';
  29. ResCodeTemplates = 'CODETEMPLATES';
  30. ResLastDirectory = 'LASTDIRECTORY';
  31. ResKeys = 'KEYS';
  32. procedure InitDesktopFile;
  33. function LoadDesktop: boolean;
  34. function SaveDesktop: boolean;
  35. procedure DoneDesktopFile;
  36. function WriteSymbolsFile(const filename : string): boolean;
  37. function ReadSymbolsFile(const filename : string): boolean;
  38. implementation
  39. uses Dos,
  40. Objects,Drivers,
  41. Video,
  42. Views,App,HistList,BrowCol,
  43. WUtils,WResourc,WViews,WEditor,
  44. fpdebug, wcedit,
  45. {$ifdef Unix}
  46. FPKeys,
  47. {$endif Unix}
  48. FPConst,FPVars,FPTools,FPUtils,FPViews,FPHelp,
  49. FPCompil,FPCodCmp,FPCodTmp;
  50. type
  51. TWindowInfo =
  52. {$ifndef FPC_REQUIRES_PROPER_ALIGNMENT}
  53. packed
  54. {$endif FPC_REQUIRES_PROPER_ALIGNMENT}
  55. record
  56. HelpCtx : word;
  57. Bounds : TRect;
  58. Visible : boolean;
  59. WinNb : byte;
  60. ExtraDataSize : word;
  61. TitleLen : word;
  62. Title : packed record end;
  63. end;
  64. {$ifdef useresstrings}
  65. resourcestring
  66. {$else}
  67. const
  68. {$endif}
  69. { Desktop file messages }
  70. msg_readingdesktopfile = 'Reading desktop file...';
  71. msg_writingdesktopfile = 'Writing desktop file...';
  72. msg_readingdesktopcontents = 'Reading desktop contents...';
  73. msg_storingdesktopcontents = 'Storing desktop contents...';
  74. msg_readinghistory = 'Reading history...';
  75. msg_storinghistory = 'Storing history...';
  76. msg_readingwatches = 'Reading watches...';
  77. msg_storingwatches = 'Storing watches...';
  78. msg_readingbreakpoints = 'Reading breakpoints...';
  79. msg_storingbreakpoints = 'Storing breakpoints...';
  80. msg_readingcodecompletewordlist = 'Reading CodeComplete wordlist...';
  81. msg_storingcodecompletewordlist = 'Writing CodeComplete wordlist...';
  82. msg_readingcodetemplates = 'Reading CodeTemplates...';
  83. msg_storingcodetemplates = 'Writing CodeTemplates...';
  84. msg_readingreturntolastdir = 'Reading Last directory to return...';
  85. msg_storingreturntolastdir = 'Writing Last directory to return...';
  86. msg_readingsymbolinformation = 'Reading symbol information...';
  87. msg_storingsymbolinformation = 'Storing symbol information...';
  88. msg_failedtoreplacedesktopfile = 'Failed to replace desktop file.';
  89. msg_errorstoringversion = 'Error storing desktop file version';
  90. msg_errorloadinghistory = 'Error loading history';
  91. msg_errorstoringhistory = 'Error storing history';
  92. msg_errorloadingkeys = 'Error loading custom keys';
  93. msg_errorstoringkeys = 'Error storing custom keys';
  94. msg_errorloadingwatches = 'Error loading watches';
  95. msg_errorstoringwatches = 'Error storing watches';
  96. msg_errorloadingbreakpoints = 'Error loading breakpoints';
  97. msg_errorstoringbreakpoints = 'Error storing breakpoints';
  98. msg_errorloadingdesktop = 'Error loading desktop';
  99. msg_errorstoringdesktop = 'Error storing desktop';
  100. msg_errorreadingflags = 'Error loading flags';
  101. msg_errorwritingflags = 'Error writing flags';
  102. msg_errorreadingvideomode = 'Error reading video mode';
  103. msg_errorstoringvideomode = 'Error storing video mode';
  104. msg_errorloadingcodetemplates = 'Error loading CodeTemplates';
  105. msg_errorstoringcodetemplates = 'Error writing CodeTemplates';
  106. msg_errorloadingreturntolastdir = 'Error loading Last directory to return';
  107. msg_errorstoringreturntolastdir = 'Error writing Last directory to return';
  108. msg_errorloadingsymbolinformation = 'Error loading symbol information';
  109. msg_errorstoringsymbolinformation = 'Error storing symbol information';
  110. msg_errorloadingcodecompletewordlist = 'Error loading CodeComplete wordlist';
  111. msg_errorstoringcodecompletewordlist = 'Error writing CodeComplete wordlist';
  112. msg_invaliddesktopversionlayoutlost = 'Invalid desktop version. Desktop layout lost.';
  113. msg_saveansifile = 'Save previous screen as Ansi File';
  114. msg_click_upper_left = 'Click to select upper left corner; Escape to cancel; Enter to select (0,0)';
  115. msg_click_lower_right = 'Click to select lower right corner; Escape to cancel; Enter to select (maxX,maxY)';
  116. msg_cantopenfile = 'Can''t open %s';
  117. msg_cantcreatefile = 'Can''t create %s';
  118. msg_cantfindfile = 'Can''t find %s';
  119. msg_errorreadingfile = 'Error reading file %s';
  120. msg_loadingfile = 'Loading %s';
  121. msg_storingfile = 'Storing %s';
  122. msg_closingfile = 'Closing %s';
  123. msg_openingsourcefile = 'Opening source file... (%s)';
  124. msg_readingfileineditor = 'Reading %s into editor...';
  125. procedure InitDesktopFile;
  126. begin
  127. if DesktopLocation=dlCurrentDir then
  128. DesktopPath:=FExpand(DesktopFileName)
  129. else
  130. DesktopPath:=FExpand(DirOf(IniFilePath)+DesktopFileName);
  131. end;
  132. procedure DoneDesktopFile;
  133. begin
  134. end;
  135. function WriteVersion(F: PResourceFile): boolean;
  136. var
  137. OK: boolean;
  138. DVersion : Longword;
  139. begin
  140. F^.CreateResource(resVersion,rcBinary,0);
  141. DVersion:=DesktopVersion;
  142. OK:=F^.AddResourceEntry(resVersion,langDefault,0,DVersion,
  143. SizeOf(Longword));
  144. if OK=false then
  145. ErrorBox(msg_errorstoringversion,nil);
  146. WriteVersion:=OK;
  147. end;
  148. function ReadVersion(F: PResourceFile;var Version : Longword): boolean;
  149. var
  150. OK,test : boolean;
  151. DVersion : Longword;
  152. begin
  153. DVersion:=0;
  154. test:=F^.ReadResourceEntry(resVersion,langDefault,DVersion,
  155. sizeof(Longword));
  156. if (not test) or (DVersion=0) then
  157. DVersion:=$000A; { last version not recorded }
  158. Version:=DVersion; { return version }
  159. OK:=true; { always true, getting version should not fail }
  160. ReadVersion:=OK;
  161. end;
  162. function ReadHistory(F: PResourceFile): boolean;
  163. var S: PMemoryStream;
  164. OK: boolean;
  165. begin
  166. PushStatus(msg_readinghistory);
  167. New(S, Init(32*1024,4096));
  168. OK:=F^.ReadResourceEntryToStream(resHistory,langDefault,S^);
  169. S^.Seek(0);
  170. if OK then
  171. LoadHistory(S^);
  172. Dispose(S, Done);
  173. if OK=false then
  174. ErrorBox(msg_errorloadinghistory,nil);
  175. PopStatus;
  176. ReadHistory:=OK;
  177. end;
  178. function WriteHistory(F: PResourceFile): boolean;
  179. var S: PMemoryStream;
  180. OK: boolean;
  181. begin
  182. PushStatus(msg_storinghistory);
  183. New(S, Init(10*1024,4096));
  184. StoreHistory(S^);
  185. S^.Seek(0);
  186. F^.CreateResource(resHistory,rcBinary,0);
  187. OK:=F^.AddResourceEntryFromStream(resHistory,langDefault,0,S^,S^.GetSize);
  188. Dispose(S, Done);
  189. if OK=false then
  190. ErrorBox(msg_errorstoringhistory,nil);
  191. PopStatus;
  192. WriteHistory:=OK;
  193. end;
  194. {$ifdef Unix}
  195. function ReadKeys(F: PResourceFile): boolean;
  196. var S: PMemoryStream;
  197. OK: boolean;
  198. begin
  199. New(S, Init(32*1024,4096));
  200. OK:=F^.ReadResourceEntryToStream(resKeys,langDefault,S^);
  201. S^.Seek(0);
  202. if OK then
  203. LoadKeys(S^);
  204. Dispose(S, Done);
  205. if OK=false then
  206. ErrorBox(msg_errorloadingkeys,nil);
  207. ReadKeys:=OK;
  208. end;
  209. function WriteKeys(F: PResourceFile): boolean;
  210. var S: PMemoryStream;
  211. OK: boolean;
  212. begin
  213. New(S, Init(10*1024,4096));
  214. StoreKeys(S^);
  215. S^.Seek(0);
  216. F^.CreateResource(resKeys,rcBinary,0);
  217. OK:=F^.AddResourceEntryFromStream(resKeys,langDefault,0,S^,S^.GetSize);
  218. Dispose(S, Done);
  219. if OK=false then
  220. ErrorBox(msg_errorstoringkeys,nil);
  221. WriteKeys:=OK;
  222. end;
  223. {$endif Unix}
  224. (*function ReadClipboard(F: PResourceFile): boolean;
  225. begin
  226. ReadClipboard:=true;
  227. end;
  228. function WriteClipboard(F: PResourceFile): boolean;
  229. var S: PMemoryStream;
  230. begin
  231. if Assigned(Clipboard) then
  232. begin
  233. PushStatus('Storing clipboard content...');
  234. New(S, Init(10*1024,4096));
  235. Clipboard^.SaveToStream(S^);
  236. S^.Seek(0);
  237. F^.CreateResource(resClipboard,rcBinary,0);
  238. F^.AddResourceEntryFromStream(resClipboard,langDefault,0,S^,S^.GetSize);
  239. Dispose(S, Done);
  240. PopStatus;
  241. end;
  242. WriteClipboard:=true;
  243. end;*)
  244. function ReadWatches(F: PResourceFile): boolean;
  245. {$ifndef NODEBUG}
  246. var S: PMemoryStream;
  247. OK: boolean;
  248. OWC : PWatchesCollection;
  249. {$endif}
  250. begin
  251. {$ifndef NODEBUG}
  252. PushStatus(msg_readingwatches);
  253. New(S, Init(32*1024,4096));
  254. OK:=F^.ReadResourceEntryToStream(resWatches,langDefault,S^);
  255. S^.Seek(0);
  256. if OK then
  257. begin
  258. OWC:=WatchesCollection;
  259. WatchesCollection:=PWatchesCollection(S^.Get);
  260. OK:=(S^.Status=stOK);
  261. if OK and assigned(OWC) and assigned(WatchesCollection) then
  262. Dispose(OWC,Done)
  263. else if assigned(OWC) then
  264. WatchesCollection:=OWC;
  265. end;
  266. if OK=false then
  267. ErrorBox(msg_errorloadingwatches,nil);
  268. ReadWatches:=OK;
  269. Dispose(S, Done);
  270. PopStatus;
  271. {$else NODEBUG}
  272. ReadWatches:=true;
  273. {$endif NODEBUG}
  274. end;
  275. function WriteWatches(F: PResourceFile): boolean;
  276. var
  277. S : PMemoryStream;
  278. OK : boolean;
  279. begin
  280. {$ifndef NODEBUG}
  281. if not assigned(WatchesCollection) then
  282. {$endif NODEBUG}
  283. WriteWatches:=true
  284. {$ifndef NODEBUG}
  285. else
  286. begin
  287. PushStatus(msg_storingwatches);
  288. New(S, Init(30*1024,4096));
  289. S^.Put(WatchesCollection);
  290. S^.Seek(0);
  291. F^.CreateResource(resWatches,rcBinary,0);
  292. OK:=F^.AddResourceEntryFromStream(resWatches,langDefault,0,S^,S^.GetSize);
  293. Dispose(S, Done);
  294. if OK=false then
  295. ErrorBox(msg_errorstoringwatches,nil);
  296. PopStatus;
  297. WriteWatches:=OK;
  298. end;
  299. {$endif NODEBUG}
  300. end;
  301. function ReadBreakpoints(F: PResourceFile): boolean;
  302. {$ifndef NODEBUG}
  303. var S: PMemoryStream;
  304. OK: boolean;
  305. OBC : PBreakpointCollection;
  306. {$endif}
  307. begin
  308. {$ifndef NODEBUG}
  309. PushStatus(msg_readingbreakpoints);
  310. New(S, Init(32*1024,4096));
  311. OK:=F^.ReadResourceEntryToStream(resBreakpoints,langDefault,S^);
  312. S^.Seek(0);
  313. if OK then
  314. begin
  315. OBC:=BreakpointsCollection;
  316. BreakpointsCollection:=PBreakpointCollection(S^.get);
  317. OK:=(S^.Status=stOK);
  318. If OK and assigned(OBC) and assigned(BreakpointsCollection) then
  319. Begin
  320. Dispose(OBC,Done);
  321. BreakpointsCollection^.ShowAllBreakpoints;
  322. end
  323. else if assigned(OBC) then
  324. BreakpointsCollection:=OBC;
  325. end;
  326. if OK=false then
  327. ErrorBox(msg_errorloadingbreakpoints,nil);
  328. ReadBreakpoints:=OK;
  329. Dispose(S, Done);
  330. PopStatus;
  331. {$else NODEBUG}
  332. ReadBreakpoints:=true;
  333. {$endif NODEBUG}
  334. end;
  335. function WriteBreakpoints(F: PResourceFile): boolean;
  336. var
  337. S : PMemoryStream;
  338. OK : boolean;
  339. begin
  340. {$ifndef NODEBUG}
  341. if not assigned(BreakpointsCollection) then
  342. {$endif NODEBUG}
  343. WriteBreakPoints:=true
  344. {$ifndef NODEBUG}
  345. else
  346. begin
  347. PushStatus(msg_storingbreakpoints);
  348. New(S, Init(30*1024,4096));
  349. S^.Put(BreakpointsCollection);
  350. S^.Seek(0);
  351. F^.CreateResource(resBreakpoints,rcBinary,0);
  352. OK:=F^.AddResourceEntryFromStream(resBreakpoints,langDefault,0,S^,S^.GetSize);
  353. Dispose(S, Done);
  354. if OK=false then
  355. ErrorBox(msg_errorstoringbreakpoints,nil);
  356. WriteBreakPoints:=OK;
  357. PopStatus;
  358. end;
  359. {$endif NODEBUG}
  360. end;
  361. function DeskUseSyntaxHighlight(Editor: PFileEditor): boolean;
  362. var b : boolean;
  363. begin
  364. b:= (*(Editor^.IsFlagSet(efSyntaxHighlight)) and *) ((Editor^.FileName='') or
  365. MatchesMaskList(NameAndExtOf(Editor^.FileName),HighlightExts));
  366. DeskUseSyntaxHighlight:=b;
  367. end;
  368. function ReadOpenWindows(F: PResourceFile; const VM : TVideoMode): boolean;
  369. var S: PMemoryStream;
  370. OK: boolean;
  371. DV: word;
  372. WI: TWindowInfo;
  373. Title: string;
  374. XDataOfs: word;
  375. XData: array[0..1024] of byte;
  376. procedure GetData(var B; Size: word);
  377. begin
  378. if Size>0 Then
  379. Begin
  380. Move(XData[XDataOfs],B,Size);
  381. Inc(XDataOfs,Size);
  382. End;
  383. end;
  384. procedure ProcessWindowInfo;
  385. var W: PWindow;
  386. SW: PSourceWindow absolute W;
  387. St: string;
  388. Ch: AnsiChar;
  389. TP,TP2: TPoint;
  390. L: longint;
  391. R: TRect;
  392. ZZ: byte;
  393. Z: TRect;
  394. Len : Byte;
  395. BM: TEditorBookMark;
  396. begin
  397. XDataOfs:=0;
  398. Desktop^.Lock;
  399. W:=SearchWindow(Title);
  400. case WI.HelpCtx of
  401. hcSourceWindow :
  402. begin
  403. GetData(len,1);
  404. SetLength(St,Len);
  405. GetData(St[1],Len);
  406. W:=ITryToOpenFile(@WI.Bounds,St,0,0,false,false,true);
  407. if Assigned(W)=false then
  408. begin
  409. ClearFormatParams;
  410. AddFormatParamStr(St);
  411. Desktop^.Unlock;
  412. ErrorBox(msg_cantopenfile,@FormatParams);
  413. Desktop^.Lock;
  414. end
  415. else
  416. begin
  417. GetData(L,sizeof(L));
  418. If DeskUseSyntaxHighlight(SW^.Editor) Then
  419. L:=L or efSyntaxHighlight
  420. else
  421. L:=L and not efSyntaxHighlight;
  422. SW^.Editor^.SetFlags(L);
  423. GetData(TP,sizeof(TP)); GetData(TP2,sizeof(TP2));
  424. SW^.Editor^.SetSelection(TP,TP2);
  425. GetData(TP,sizeof(TP)); SW^.Editor^.SetCurPtr(TP.X,TP.Y);
  426. GetData(TP,sizeof(TP)); SW^.Editor^.ScrollTo(TP.X,TP.Y);
  427. for L:=0 to 9 do begin
  428. GetData(BM,Sizeof(BM));
  429. SW^.Editor^.SetBookmark(L,BM); {restore bookmarks}
  430. end;
  431. end;
  432. end;
  433. hcClipboardWindow:
  434. W:=ClipboardWindow;
  435. hcCalcWindow:
  436. W:=CalcWindow;
  437. hcMessagesWindow:
  438. begin
  439. if MessagesWindow=nil then
  440. Desktop^.Insert(New(PMessagesWindow, Init));
  441. W:=MessagesWindow;
  442. end;
  443. hcCompilerMessagesWindow:
  444. W:=CompilerMessageWindow;
  445. {$ifndef NODEBUG}
  446. hcGDBWindow:
  447. begin
  448. InitGDBWindow;
  449. W:=GDBWindow;
  450. end;
  451. hcDisassemblyWindow:
  452. begin
  453. InitDisassemblyWindow;
  454. W:=DisassemblyWindow;
  455. end;
  456. hcWatchesWindow:
  457. begin
  458. if WatchesWindow=nil then
  459. begin
  460. New(WatchesWindow,Init);
  461. Desktop^.Insert(WatchesWindow);
  462. end;
  463. W:=WatchesWindow;
  464. end;
  465. hcStackWindow:
  466. begin
  467. if StackWindow=nil then
  468. begin
  469. New(StackWindow,Init);
  470. Desktop^.Insert(StackWindow);
  471. end;
  472. W:=StackWindow;
  473. end;
  474. hcFPURegisters:
  475. begin
  476. if FPUWindow=nil then
  477. begin
  478. New(FPUWindow,Init);
  479. Desktop^.Insert(FPUWindow);
  480. end;
  481. W:=FPUWindow;
  482. end;
  483. hcVectorRegisters:
  484. begin
  485. if VectorWindow=nil then
  486. begin
  487. New(VectorWindow,Init);
  488. Desktop^.Insert(VectorWindow);
  489. end;
  490. W:=VectorWindow;
  491. end;
  492. hcRegistersWindow:
  493. begin
  494. if RegistersWindow=nil then
  495. begin
  496. New(RegistersWindow,Init);
  497. Desktop^.Insert(RegistersWindow);
  498. end;
  499. W:=RegistersWindow;
  500. end;
  501. hcBreakpointListWindow:
  502. begin
  503. if BreakpointsWindow=nil then
  504. begin
  505. New(BreakpointsWindow,Init);
  506. Desktop^.Insert(BreakpointsWindow);
  507. end;
  508. W:=BreakpointsWindow;
  509. end;
  510. {$endif NODEBUG}
  511. hcASCIITableWindow:
  512. begin
  513. if ASCIIChart=nil then
  514. begin
  515. New(ASCIIChart, Init);
  516. Desktop^.Insert(ASCIIChart);
  517. end;
  518. W:=ASCIIChart;
  519. if DV>=$A then
  520. begin
  521. GetData(ch,sizeof(AnsiChar));
  522. AsciiChart^.Report^.AsciiChar:=ord(ch);
  523. AsciiChart^.Table^.SetCursor(
  524. ord(ch) mod AsciiChart^.Table^.Size.X,
  525. ord(ch) div AsciiChart^.Table^.Size.X);
  526. end;
  527. end;
  528. end;
  529. if W=nil then
  530. begin
  531. Desktop^.Unlock;
  532. Exit;
  533. end;
  534. {calculate new location and size of window}
  535. if (VM.col > 0) and (ScreenWidth<>VM.col) then
  536. begin
  537. WI.Bounds.A.X:=round(WI.Bounds.A.X*ScreenWidth/VM.col);
  538. if (W^.Flags and wfGrow)<>0 then
  539. WI.Bounds.B.X:=Max(16,round(WI.Bounds.B.X*ScreenWidth/VM.col));
  540. end;
  541. if (VM.row > 2) and (ScreenHeight<>VM.row) then
  542. begin
  543. WI.Bounds.A.Y:=round(WI.Bounds.A.Y*(ScreenHeight-2)/(VM.row-2));
  544. if (W^.Flags and wfGrow)<>0 then
  545. WI.Bounds.B.Y:=Max(6,round(WI.Bounds.B.Y*(ScreenHeight-2)/(VM.row-2)));
  546. end;
  547. {relocate and resize window as needed}
  548. W^.GetBounds(R);
  549. if (R.A.X<>WI.Bounds.A.X) or (R.A.Y<>WI.Bounds.A.Y) then
  550. R.Move(WI.Bounds.A.X-R.A.X,WI.Bounds.A.Y-R.A.Y);
  551. if (W^.Flags and wfGrow)<>0 then
  552. begin
  553. R.B.X:=R.A.X+(WI.Bounds.B.X-WI.Bounds.A.X);
  554. R.B.Y:=R.A.Y+(WI.Bounds.B.Y-WI.Bounds.A.Y);
  555. end;
  556. W^.Locate(R);
  557. if W^.GetState(sfVisible)<>WI.Visible then
  558. if WI.Visible then
  559. begin
  560. W^.Show;
  561. W^.MakeFirst;
  562. end
  563. else
  564. W^.Hide;
  565. {check if window is out screen bounds and bring it back if so}
  566. ZZ:=0;
  567. Desktop^.GetExtent(Z);
  568. if R.A.Y>Z.B.Y-7 then
  569. begin
  570. R.A.Y:=Z.B.Y-7;
  571. ZZ:=1;
  572. end;
  573. if R.A.X>Z.B.X-4 then
  574. begin
  575. R.A.X:=Z.B.X-4;
  576. ZZ:=1;
  577. end;
  578. if R.A.Y<0 then
  579. begin
  580. R.A.Y:=0;
  581. ZZ:=1;
  582. end;
  583. if R.A.X<0 then
  584. begin
  585. R.A.X:=0;
  586. ZZ:=1;
  587. end;
  588. if ZZ<>0 then W^.MoveTo(R.A.X,R.A.Y);
  589. W^.Number:=WI.WinNb;
  590. Desktop^.Unlock;
  591. end;
  592. begin
  593. PushStatus(msg_readingdesktopcontents);
  594. New(S, Init(32*1024,4096));
  595. OK:=F^.ReadResourceEntryToStream(resDesktop,langDefault,S^);
  596. S^.Seek(0);
  597. if OK then
  598. begin
  599. S^.Read(DV,SizeOf(DV));
  600. OK:=(DV=DesktopVersion) or (DV>=MinDesktopVersion);
  601. if OK=false then
  602. ErrorBox(msg_invaliddesktopversionlayoutlost,nil);
  603. end;
  604. if OK then
  605. begin
  606. XDataOfs:=0;
  607. repeat
  608. S^.Read(WI,sizeof(WI));
  609. if S^.Status=stOK then
  610. begin
  611. SetLength(Title,WI.TitleLen);
  612. S^.Read(Title[1],WI.TitleLen);
  613. FillChar(XData,SizeOf(XData),0);
  614. if WI.ExtraDataSize>0 then
  615. S^.Read(XData,WI.ExtraDataSize);
  616. ProcessWindowInfo;
  617. end;
  618. until (S^.Status<>stOK) or (S^.GetPos=S^.GetSize);
  619. (* TempDesk:=PFPDesktop(S^.Get);
  620. OK:=Assigned(TempDesk);
  621. if OK then
  622. begin
  623. Dispose(Desktop, Done);
  624. Desktop:=TempDesk;
  625. with Desktop^ do
  626. begin
  627. GetSubViewPtr(S^,CompilerMessageWindow);
  628. GetSubViewPtr(S^,CompilerStatusDialog);
  629. GetSubViewPtr(S^,ClipboardWindow);
  630. if Assigned(ClipboardWindow) then Clipboard:=ClipboardWindow^.Editor;
  631. GetSubViewPtr(S^,CalcWindow);
  632. GetSubViewPtr(S^,GDBWindow);
  633. GetSubViewPtr(S^,BreakpointsWindow);
  634. GetSubViewPtr(S^,WatchesWindow);
  635. GetSubViewPtr(S^,UserScreenWindow);
  636. GetSubViewPtr(S^,ASCIIChart);
  637. GetSubViewPtr(S^,MessagesWindow); LastToolMessageFocused:=nil;
  638. end;
  639. Application^.GetExtent(R);
  640. Inc(R.A.Y);Dec(R.B.Y);
  641. DeskTop^.Locate(R);
  642. Application^.Insert(Desktop);
  643. Desktop^.ReDraw;
  644. Message(Application,evBroadcast,cmUpdate,nil);
  645. end;*)
  646. if OK=false then
  647. ErrorBox(msg_errorloadingdesktop,nil);
  648. end;
  649. Dispose(S, Done);
  650. PopStatus;
  651. ReadOpenWindows:=OK;
  652. end;
  653. function WriteOpenWindows(F: PResourceFile): boolean;
  654. var S: PMemoryStream;
  655. procedure CollectInfo(P: PView);
  656. var W: PWindow;
  657. SW: PSourceWindow absolute W;
  658. WI: TWindowInfo;
  659. Title: string;
  660. XDataOfs: word;
  661. XData: array[0..1024] of byte;
  662. St: string;
  663. Ch: AnsiChar;
  664. TP: TPoint;
  665. BM: TEditorBookMark;
  666. L: longint;
  667. procedure AddData(const B; Size: word);
  668. begin
  669. Move(B,XData[XDataOfs],Size);
  670. Inc(XDataOfs,Size);
  671. end;
  672. begin
  673. XDataOfs:=0;
  674. W:=nil;
  675. if (P^.HelpCtx=hcSourceWindow) or
  676. (P^.HelpCtx=hcHelpWindow) or
  677. (P^.HelpCtx=hcClipboardWindow) or
  678. (P^.HelpCtx=hcCalcWindow) or
  679. (P^.HelpCtx=hcInfoWindow) or
  680. (P^.HelpCtx=hcBrowserWindow) or
  681. (P^.HelpCtx=hcMessagesWindow) or
  682. (P^.HelpCtx=hcCompilerMessagesWindow) or
  683. (P^.HelpCtx=hcGDBWindow) or
  684. (P^.HelpCtx=hcDisassemblyWindow) or
  685. (P^.HelpCtx=hcStackWindow) or
  686. (P^.HelpCtx=hcRegistersWindow) or
  687. (P^.HelpCtx=hcFPURegisters) or
  688. (P^.HelpCtx=hcVectorRegisters) or
  689. (P^.HelpCtx=hcWatchesWindow) or
  690. (P^.HelpCtx=hcBreakpointListWindow) or
  691. (P^.HelpCtx=hcASCIITableWindow)
  692. then
  693. W:=PWindow(P);
  694. if Assigned(W) and (P^.HelpCtx=hcSourceWindow) then
  695. if SW^.Editor^.FileName='' then
  696. W:=nil;
  697. if W=nil then Exit;
  698. FillChar(WI,sizeof(WI),0);
  699. Title:=W^.GetTitle(255);
  700. WI.HelpCtx:=W^.HelpCtx;
  701. W^.GetBounds(WI.Bounds);
  702. WI.Visible:=W^.GetState(sfVisible);
  703. WI.WinNb:=W^.Number;
  704. case WI.HelpCtx of
  705. hcSourceWindow :
  706. begin
  707. St:=SW^.Editor^.FileName; AddData(St,length(St)+1);
  708. L:=SW^.Editor^.GetFlags; AddData(L,sizeof(L));
  709. TP:=SW^.Editor^.SelStart; AddData(TP,sizeof(TP));
  710. TP:=SW^.Editor^.SelEnd; AddData(TP,sizeof(TP));
  711. TP:=SW^.Editor^.CurPos; AddData(TP,sizeof(TP));
  712. TP:=SW^.Editor^.Delta; AddData(TP,sizeof(TP));
  713. for L:=0 to 9 do begin
  714. BM:=SW^.Editor^.GetBookmark(L); AddData(BM,Sizeof(BM)); {save bookmarks}
  715. end;
  716. end;
  717. hcAsciiTableWindow :
  718. begin
  719. ch:=chr(PFPAsciiChart(P)^.Report^.AsciiChar);
  720. AddData(ch,sizeof(AnsiChar));
  721. end;
  722. end;
  723. WI.TitleLen:=length(Title);
  724. WI.ExtraDataSize:=XDataOfs;
  725. S^.Write(WI,sizeof(WI));
  726. S^.Write(Title[1],WI.TitleLen);
  727. if WI.ExtraDataSize>0 then
  728. S^.Write(XData,WI.ExtraDataSize);
  729. end;
  730. var W: word;
  731. OK: boolean;
  732. PV: PView;
  733. begin
  734. PushStatus(msg_storingdesktopcontents);
  735. New(S, Init(30*1024,4096));
  736. OK:=Assigned(S);
  737. if OK then
  738. begin
  739. W:=DesktopVersion;
  740. S^.Write(W,SizeOf(W));
  741. { S^.Put(Desktop);
  742. with Desktop^ do
  743. begin
  744. PutSubViewPtr(S^,CompilerMessageWindow);
  745. PutSubViewPtr(S^,CompilerStatusDialog);
  746. PutSubViewPtr(S^,ClipboardWindow);
  747. PutSubViewPtr(S^,CalcWindow);
  748. PutSubViewPtr(S^,GDBWindow);
  749. PutSubViewPtr(S^,BreakpointsWindow);
  750. PutSubViewPtr(S^,WatchesWindow);
  751. PutSubViewPtr(S^,UserScreenWindow);
  752. PutSubViewPtr(S^,ASCIIChart);
  753. PutSubViewPtr(S^,MessagesWindow);
  754. end;}
  755. { PV:=Application^.Last;
  756. while PV<>nil do
  757. begin
  758. CollectInfo(PV);
  759. PV:=PV^.PrevView;
  760. end;}
  761. PV:=Desktop^.Last;
  762. while PV<>nil do
  763. begin
  764. CollectInfo(PV);
  765. PV:=PV^.PrevView;
  766. end;
  767. OK:=(S^.Status=stOK);
  768. if OK then
  769. begin
  770. S^.Seek(0);
  771. OK:=F^.CreateResource(resDesktop,rcBinary,0);
  772. OK:=OK and F^.AddResourceEntryFromStream(resDesktop,langDefault,0,S^,S^.GetSize);
  773. end;
  774. Dispose(S, Done);
  775. end;
  776. if OK=false then
  777. ErrorBox(msg_errorstoringdesktop,nil);
  778. PopStatus;
  779. WriteOpenWindows:=OK;
  780. end;
  781. function WriteFlags(F: PResourceFile): boolean;
  782. var
  783. OK: boolean;
  784. begin
  785. F^.CreateResource(resDesktopFlags,rcBinary,0);
  786. OK:=F^.AddResourceEntry(resDesktopFlags,langDefault,0,DesktopFileFlags,
  787. SizeOf(DesktopFileFlags));
  788. if OK=false then
  789. ErrorBox(msg_errorwritingflags,nil);
  790. WriteFlags:=OK;
  791. end;
  792. function ReadCodeComplete(F: PResourceFile): boolean;
  793. var S: PMemoryStream;
  794. OK: boolean;
  795. begin
  796. PushStatus(msg_readingcodecompletewordlist);
  797. New(S, Init(1024,1024));
  798. OK:=F^.ReadResourceEntryToStream(resCodeComplete,langDefault,S^);
  799. S^.Seek(0);
  800. if OK then
  801. OK:=LoadCodeComplete(S^);
  802. Dispose(S, Done);
  803. if OK=false then
  804. ErrorBox(msg_errorloadingcodecompletewordlist,nil);
  805. PopStatus;
  806. ReadCodeComplete:=OK;
  807. end;
  808. function WriteCodeComplete(F: PResourceFile): boolean;
  809. var OK: boolean;
  810. S: PMemoryStream;
  811. begin
  812. PushStatus(msg_storingcodecompletewordlist);
  813. New(S, Init(1024,1024));
  814. OK:=StoreCodeComplete(S^);
  815. if OK then
  816. begin
  817. S^.Seek(0);
  818. F^.CreateResource(resCodeComplete,rcBinary,0);
  819. OK:=F^.AddResourceEntryFromStream(resCodeComplete,langDefault,0,S^,S^.GetSize);
  820. end;
  821. Dispose(S, Done);
  822. if OK=false then
  823. ErrorBox(msg_errorstoringcodecompletewordlist,nil);
  824. PopStatus;
  825. WriteCodeComplete:=OK;
  826. end;
  827. function ReadCodeTemplates(F: PResourceFile): boolean;
  828. var S: PMemoryStream;
  829. OK: boolean;
  830. begin
  831. PushStatus(msg_readingcodetemplates);
  832. New(S, Init(1024,4096));
  833. OK:=F^.ReadResourceEntryToStream(resCodeTemplates,langDefault,S^);
  834. S^.Seek(0);
  835. if OK then
  836. OK:=LoadCodeTemplates(S^);
  837. Dispose(S, Done);
  838. if OK=false then
  839. ErrorBox(msg_errorloadingcodetemplates,nil);
  840. PopStatus;
  841. ReadCodeTemplates:=OK;
  842. end;
  843. function WriteCodeTemplates(F: PResourceFile): boolean;
  844. var OK: boolean;
  845. S: PMemoryStream;
  846. begin
  847. PushStatus(msg_storingcodetemplates);
  848. New(S, Init(1024,4096));
  849. OK:=StoreCodeTemplates(S^);
  850. if OK then
  851. begin
  852. S^.Seek(0);
  853. F^.CreateResource(resCodeTemplates,rcBinary,0);
  854. OK:=F^.AddResourceEntryFromStream(resCodeTemplates,langDefault,0,S^,S^.GetSize);
  855. end;
  856. Dispose(S, Done);
  857. if OK=false then
  858. ErrorBox(msg_errorstoringcodetemplates,nil);
  859. PopStatus;
  860. WriteCodeTemplates:=OK;
  861. end;
  862. function ReadReturnToLastDir(F: PResourceFile): boolean;
  863. var S: PMemoryStream;
  864. OK: boolean;
  865. Dir:AnsiString;
  866. Size:sw_integer;
  867. begin
  868. PushStatus(msg_readingreturntolastdir);
  869. New(S, Init(1024,4096));
  870. OK:=F^.ReadResourceEntryToStream(ResLastDirectory,langDefault,S^);
  871. S^.Seek(0);
  872. if OK then
  873. begin
  874. S^.Read(Size, sizeof(Size)); { Read directory size }
  875. if Size>0 then
  876. begin
  877. Setlength(Dir,Size);
  878. S^.Read(Dir[1], Size); { Read the directory }
  879. {$i-}ChDir(Dir);{$i+}
  880. IOResult; {eat io result so it does not affect later operations}
  881. GetDir(0,StartUpDir);
  882. end;
  883. end;
  884. Dispose(S, Done);
  885. if OK=false then
  886. ErrorBox(msg_errorloadingreturntolastdir,nil);
  887. PopStatus;
  888. ReadReturnToLastDir:=OK;
  889. end;
  890. function WriteReturnToLastDir(F: PResourceFile): boolean;
  891. var OK: boolean;
  892. S: PMemoryStream;
  893. Dir:AnsiString;
  894. Size:sw_integer;
  895. begin
  896. PushStatus(msg_storingreturntolastdir);
  897. New(S, Init(1024,4096));
  898. OK:=true;
  899. {$i-}GetDir(0,Dir);{$i+}
  900. if IOResult=0 then
  901. begin
  902. Size:=length(Dir);
  903. S^.Write(Size, sizeof(Size));
  904. if Size>0 then S^.Write(Dir[1],Size);
  905. S^.Seek(0);
  906. F^.CreateResource(ResLastDirectory,rcBinary,0);
  907. OK:=F^.AddResourceEntryFromStream(ResLastDirectory,langDefault,0,S^,S^.GetSize);
  908. end;
  909. Dispose(S, Done);
  910. if OK=false then
  911. ErrorBox(msg_errorstoringreturntolastdir,nil);
  912. PopStatus;
  913. WriteReturnToLastDir:=OK;
  914. end;
  915. function ReadFlags(F: PResourceFile): boolean;
  916. var
  917. OK: boolean;
  918. begin
  919. OK:=F^.ReadResourceEntry(resDesktopFlags,langDefault,DesktopFileFlags,
  920. sizeof(DesktopFileFlags));
  921. if OK=false then
  922. ErrorBox(msg_errorreadingflags,nil);
  923. ReadFlags:=OK;
  924. end;
  925. function WriteVideoMode(F: PResourceFile): boolean;
  926. var
  927. OK: boolean;
  928. begin
  929. F^.CreateResource(resVideo,rcBinary,0);
  930. OK:=F^.AddResourceEntry(resVideo,langDefault,0,ScreenMode,
  931. SizeOf(TVideoMode));
  932. if OK=false then
  933. ErrorBox(msg_errorstoringvideomode,nil);
  934. WriteVideoMode:=OK;
  935. end;
  936. function ReadVideoMode(F: PResourceFile;var NewScreenMode : TVideoMode): boolean;
  937. var
  938. OK,test : boolean;
  939. begin
  940. test:=F^.ReadResourceEntry(resVideo,langDefault,NewScreenMode,
  941. sizeof(NewScreenMode));
  942. if not test then
  943. NewScreenMode:=ScreenMode;
  944. OK:=test;
  945. if OK=false then
  946. ErrorBox(msg_errorreadingvideomode,nil);
  947. ReadVideoMode:=OK;
  948. end;
  949. function ReadSymbols(F: PResourceFile): boolean;
  950. var S: PMemoryStream;
  951. OK: boolean;
  952. R: PResource;
  953. begin
  954. ReadSymbols:=false; { if no symbols stored ... no problems }
  955. R:=F^.FindResource(resSymbols);
  956. if not Assigned(R) then
  957. exit;
  958. PushStatus(msg_readingsymbolinformation);
  959. New(S, Init(32*1024,4096));
  960. OK:=F^.ReadResourceEntryToStream(resSymbols,langDefault,S^);
  961. S^.Seek(0);
  962. if OK then
  963. OK:=LoadBrowserCol(S);
  964. Dispose(S, Done);
  965. if OK=false then
  966. ErrorBox(msg_errorloadingsymbolinformation,nil);
  967. PopStatus;
  968. ReadSymbols:=OK;
  969. end;
  970. function WriteSymbols(F: PResourceFile): boolean;
  971. var S: PMemoryStream;
  972. OK: boolean;
  973. begin
  974. OK:=Assigned(Modules);
  975. if OK then
  976. begin
  977. PushStatus(msg_storingsymbolinformation);
  978. New(S, Init(200*1024,4096));
  979. OK:=Assigned(S);
  980. if OK then
  981. OK:=StoreBrowserCol(S);
  982. if OK then
  983. begin
  984. S^.Seek(0);
  985. F^.CreateResource(resSymbols,rcBinary,0);
  986. OK:=F^.AddResourceEntryFromStream(resSymbols,langDefault,0,S^,S^.GetSize);
  987. end;
  988. Dispose(S, Done);
  989. if OK=false then
  990. ErrorBox(msg_errorstoringsymbolinformation,nil);
  991. PopStatus;
  992. end;
  993. WriteSymbols:=OK;
  994. end;
  995. function LoadDesktop: boolean;
  996. var OK,VOK: boolean;
  997. F: PResourceFile;
  998. VM : TVideoMode;
  999. DesktopFileVersion: Longword; { Version desktop file was saved with }
  1000. begin
  1001. PushStatus(msg_readingdesktopfile);
  1002. New(F, LoadFile(DesktopPath));
  1003. OK:=false;
  1004. if Assigned(F) then
  1005. begin
  1006. OK:=ReadVersion(F,DesktopFileVersion);
  1007. OK:=ReadFlags(F);
  1008. VOK:=ReadVideoMode(F,VM);
  1009. if VOK and ((VM.Col<>ScreenMode.Col) or
  1010. (VM.Row<>ScreenMode.Row) or (VM.Color<>ScreenMode.Color)) then
  1011. begin
  1012. if Assigned(Application) then
  1013. Application^.SetScreenVideoMode(VM);
  1014. end;
  1015. if not VOK then
  1016. begin
  1017. VM.row:=0; VM.col:=0; {safety measure}
  1018. end;
  1019. if ((DesktopFileFlags and dfHistoryLists)<>0) then
  1020. OK:=ReadHistory(F) and OK;
  1021. if ((DesktopFileFlags and dfWatches)<>0) then
  1022. OK:=ReadWatches(F) and OK;
  1023. if ((DesktopFileFlags and dfBreakpoints)<>0) then
  1024. OK:=ReadBreakpoints(F) and OK;
  1025. if ((DesktopFileFlags and dfOpenWindows)<>0) then
  1026. OK:=ReadOpenWindows(F,VM) and OK;
  1027. { no errors if no browser info available PM }
  1028. if ((DesktopFileFlags and dfSymbolInformation)<>0) then
  1029. OK:=ReadSymbols(F) and OK;
  1030. if ((DesktopFileFlags and dfCodeCompleteWords)<>0) then
  1031. OK:=ReadCodeComplete(F) and OK;
  1032. if ((DesktopFileFlags and dfCodeTemplates)<>0) then
  1033. OK:=ReadCodeTemplates(F) and OK;
  1034. if not OverrideLastDirOption then
  1035. if ((DesktopFileFlags and dfReturnToLastDir)<>0) then
  1036. StartupOptions:=StartupOptions or soReturnToLastDir
  1037. else
  1038. StartupOptions:=StartupOptions and( not soReturnToLastDir);
  1039. if ((StartupOptions and soReturnToLastDir)<>0) then
  1040. OK:=ReadReturnToLastDir(F) and OK;
  1041. {$ifdef Unix}
  1042. OK:=ReadKeys(F) and OK;
  1043. {$endif Unix}
  1044. Dispose(F, Done);
  1045. end;
  1046. PopStatus;
  1047. LoadDesktop:=OK;
  1048. end;
  1049. function SaveDesktop: boolean;
  1050. var OK: boolean;
  1051. F: PResourceFile;
  1052. TempPath: string;
  1053. begin
  1054. TempPath:=DirOf(DesktopPath)+DesktopTempName;
  1055. PushStatus(msg_writingdesktopfile);
  1056. New(F, CreateFile(TempPath));
  1057. if Assigned(Clipboard) then
  1058. if (DesktopFileFlags and dfClipboardContent)<>0 then
  1059. Clipboard^.SetFlags(Clipboard^.GetFlags or efStoreContent)
  1060. else
  1061. Clipboard^.SetFlags(Clipboard^.GetFlags and not efStoreContent);
  1062. OK:=false;
  1063. if Assigned(F) then
  1064. begin
  1065. OK:=WriteVersion(F);
  1066. OK:=OK and WriteFlags(F);
  1067. OK:=OK and WriteVideoMode(F);
  1068. if ((DesktopFileFlags and dfHistoryLists)<>0) then
  1069. OK:=OK and WriteHistory(F);
  1070. if ((DesktopFileFlags and dfWatches)<>0) then
  1071. OK:=OK and WriteWatches(F);
  1072. if ((DesktopFileFlags and dfBreakpoints)<>0) then
  1073. OK:=OK and WriteBreakpoints(F);
  1074. if ((DesktopFileFlags and dfOpenWindows)<>0) then
  1075. OK:=OK and WriteOpenWindows(F);
  1076. { no errors if no browser info available PM }
  1077. if ((DesktopFileFlags and dfSymbolInformation)<>0) then
  1078. OK:=OK and (WriteSymbols(F) or not Assigned(Modules));
  1079. if ((DesktopFileFlags and dfCodeCompleteWords)<>0) then
  1080. OK:=OK and WriteCodeComplete(F);
  1081. if ((DesktopFileFlags and dfCodeTemplates)<>0) then
  1082. OK:=OK and WriteCodeTemplates(F);
  1083. {if ((DesktopFileFlags and dfReturnToLastDir)<>0) then
  1084. always write last dir }
  1085. OK:=WriteReturnToLastDir(F) and OK;
  1086. {$ifdef Unix}
  1087. OK:=OK and WriteKeys(F);
  1088. {$endif Unix}
  1089. Dispose(F, Done);
  1090. end;
  1091. if OK then
  1092. begin
  1093. if ExistsFile(DesktopPath) then
  1094. OK:=EraseFile(DesktopPath);
  1095. OK:=OK and RenameFile(TempPath,DesktopPath);
  1096. if OK=false then
  1097. ErrorBox(msg_failedtoreplacedesktopfile,nil);
  1098. end;
  1099. PopStatus;
  1100. SaveDesktop:=OK;
  1101. end;
  1102. function WriteSymbolsFile(const filename : string): boolean;
  1103. var OK: boolean;
  1104. F: PResourceFile;
  1105. begin
  1106. WriteSymbolsFile:=false;
  1107. If not assigned(Modules) then
  1108. exit;
  1109. New(F, CreateFile(FileName));
  1110. OK:=Assigned(F);
  1111. if OK and ((DesktopFileFlags and dfSymbolInformation)<>0) then
  1112. OK:=OK and WriteSymbols(F);
  1113. if assigned(F) then
  1114. Dispose(F,Done);
  1115. WriteSymbolsFile:=OK;
  1116. end;
  1117. function ReadSymbolsFile(const FileName : string): boolean;
  1118. var OK: boolean;
  1119. F: PResourceFile;
  1120. begin
  1121. ReadSymbolsFile:=false;
  1122. { Don't read again !! }
  1123. If assigned(Modules) then
  1124. exit;
  1125. New(F, LoadFile(FileName));
  1126. OK:=Assigned(F);
  1127. if OK and ((DesktopFileFlags and dfSymbolInformation)<>0) then
  1128. OK:=OK and ReadSymbols(F);
  1129. if assigned(F) then
  1130. Dispose(F,Done);
  1131. ReadSymbolsFile:=OK;
  1132. end;
  1133. END.