fpdesk.pas 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  1. {
  2. $Id$
  3. This file is part of the Free Pascal Integrated Development Environment
  4. Copyright (c) 1998 by Berczi Gabor
  5. Desktop loading/saving routines
  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 FPDesk;
  13. interface
  14. const
  15. DesktopVersion = $0006; { <- if you change any Load&Store methods,
  16. default object properties (Options,State)
  17. then you should also change this }
  18. ResDesktopFlags = 'FLAGS';
  19. ResVideo = 'VIDEOMODE';
  20. ResHistory = 'HISTORY';
  21. ResClipboard = 'CLIPBOARD';
  22. ResWatches = 'WATCHES';
  23. ResBreakpoints = 'BREAKPOINTS';
  24. ResDesktop = 'DESKTOP';
  25. ResSymbols = 'SYMBOLS';
  26. ResCodeComplete = 'CODECOMPLETE';
  27. ResCodeTemplates = 'CODETEMPLATES';
  28. procedure InitDesktopFile;
  29. function LoadDesktop: boolean;
  30. function SaveDesktop: boolean;
  31. procedure DoneDesktopFile;
  32. function WriteSymbolsFile(const filename : string): boolean;
  33. function ReadSymbolsFile(const filename : string): boolean;
  34. implementation
  35. uses Dos,
  36. Objects,Drivers,Video,
  37. Views,App,HistList,BrowCol,
  38. WResource,WViews,WEditor,
  39. WUtils,
  40. {$ifndef NODEBUG}
  41. fpdebug,
  42. {$endif ndef NODEBUG}
  43. FPConst,FPVars,FPUtils,FPViews,FPCompile,FPTools,FPHelp,
  44. FPCodCmp,FPCodTmp;
  45. procedure InitDesktopFile;
  46. begin
  47. if DesktopLocation=dlCurrentDir then
  48. DesktopPath:=FExpand(DesktopName)
  49. else
  50. DesktopPath:=FExpand(DirOf(INIPath)+DesktopName);
  51. end;
  52. procedure DoneDesktopFile;
  53. begin
  54. end;
  55. function ReadHistory(F: PResourceFile): boolean;
  56. var S: PMemoryStream;
  57. OK: boolean;
  58. begin
  59. PushStatus('Reading history...');
  60. New(S, Init(32*1024,4096));
  61. OK:=F^.ReadResourceEntryToStream(resHistory,langDefault,S^);
  62. S^.Seek(0);
  63. if OK then
  64. LoadHistory(S^);
  65. Dispose(S, Done);
  66. if OK=false then
  67. ErrorBox('Error loading history',nil);
  68. PopStatus;
  69. ReadHistory:=OK;
  70. end;
  71. function WriteHistory(F: PResourceFile): boolean;
  72. var S: PMemoryStream;
  73. OK: boolean;
  74. begin
  75. PushStatus('Storing history...');
  76. New(S, Init(10*1024,4096));
  77. StoreHistory(S^);
  78. S^.Seek(0);
  79. F^.CreateResource(resHistory,rcBinary,0);
  80. OK:=F^.AddResourceEntryFromStream(resHistory,langDefault,0,S^,S^.GetSize);
  81. Dispose(S, Done);
  82. if OK=false then
  83. ErrorBox('Error storing history',nil);
  84. PopStatus;
  85. WriteHistory:=OK;
  86. end;
  87. (*function ReadClipboard(F: PResourceFile): boolean;
  88. begin
  89. ReadClipboard:=true;
  90. end;
  91. function WriteClipboard(F: PResourceFile): boolean;
  92. var S: PMemoryStream;
  93. begin
  94. if Assigned(Clipboard) then
  95. begin
  96. PushStatus('Storing clipboard content...');
  97. New(S, Init(10*1024,4096));
  98. Clipboard^.SaveToStream(S^);
  99. S^.Seek(0);
  100. F^.CreateResource(resClipboard,rcBinary,0);
  101. F^.AddResourceEntryFromStream(resClipboard,langDefault,0,S^,S^.GetSize);
  102. Dispose(S, Done);
  103. PopStatus;
  104. end;
  105. WriteClipboard:=true;
  106. end;*)
  107. function ReadWatches(F: PResourceFile): boolean;
  108. {$ifndef NODEBUG}
  109. var S: PMemoryStream;
  110. OK: boolean;
  111. OWC : PWatchesCollection;
  112. {$endif}
  113. begin
  114. {$ifndef NODEBUG}
  115. PushStatus('Reading watches...');
  116. New(S, Init(32*1024,4096));
  117. OK:=F^.ReadResourceEntryToStream(resWatches,langDefault,S^);
  118. S^.Seek(0);
  119. if OK then
  120. begin
  121. OWC:=WatchesCollection;
  122. WatchesCollection:=PWatchesCollection(S^.Get);
  123. OK:=(S^.Status=stOK);
  124. if OK and assigned(OWC) and assigned(WatchesCollection) then
  125. Dispose(OWC,Done)
  126. else if assigned(OWC) then
  127. WatchesCollection:=OWC;
  128. end;
  129. if OK=false then
  130. ErrorBox('Error loading watches',nil);
  131. ReadWatches:=OK;
  132. Dispose(S, Done);
  133. PopStatus;
  134. {$else NODEBUG}
  135. ReadWatches:=true;
  136. {$endif NODEBUG}
  137. end;
  138. function WriteWatches(F: PResourceFile): boolean;
  139. var
  140. S : PMemoryStream;
  141. OK : boolean;
  142. begin
  143. {$ifndef NODEBUG}
  144. if not assigned(WatchesCollection) then
  145. {$endif NODEBUG}
  146. WriteWatches:=true
  147. {$ifndef NODEBUG}
  148. else
  149. begin
  150. PushStatus('Storing watches...');
  151. New(S, Init(30*1024,4096));
  152. S^.Put(WatchesCollection);
  153. S^.Seek(0);
  154. F^.CreateResource(resWatches,rcBinary,0);
  155. OK:=F^.AddResourceEntryFromStream(resWatches,langDefault,0,S^,S^.GetSize);
  156. Dispose(S, Done);
  157. if OK=false then
  158. ErrorBox('Error storing watches',nil);
  159. PopStatus;
  160. WriteWatches:=OK;
  161. end;
  162. {$endif NODEBUG}
  163. end;
  164. function ReadBreakpoints(F: PResourceFile): boolean;
  165. {$ifndef NODEBUG}
  166. var S: PMemoryStream;
  167. OK: boolean;
  168. OBC : PBreakpointCollection;
  169. {$endif}
  170. begin
  171. {$ifndef NODEBUG}
  172. PushStatus('Reading breakpoints...');
  173. New(S, Init(32*1024,4096));
  174. OK:=F^.ReadResourceEntryToStream(resBreakpoints,langDefault,S^);
  175. S^.Seek(0);
  176. if OK then
  177. begin
  178. OBC:=BreakpointsCollection;
  179. BreakpointsCollection:=PBreakpointCollection(S^.get);
  180. OK:=(S^.Status=stOK);
  181. If OK and assigned(OBC) and assigned(BreakpointsCollection) then
  182. Begin
  183. Dispose(OBC,Done);
  184. BreakpointsCollection^.ShowAllBreakpoints;
  185. end
  186. else if assigned(OBC) then
  187. BreakpointsCollection:=OBC;
  188. end;
  189. if OK=false then
  190. ErrorBox('Error loading breakpoints',nil);
  191. ReadBreakpoints:=OK;
  192. Dispose(S, Done);
  193. PopStatus;
  194. {$else NODEBUG}
  195. ReadBreakpoints:=true;
  196. {$endif NODEBUG}
  197. end;
  198. function WriteBreakpoints(F: PResourceFile): boolean;
  199. var
  200. S : PMemoryStream;
  201. OK : boolean;
  202. begin
  203. {$ifndef NODEBUG}
  204. if not assigned(BreakpointsCollection) then
  205. {$endif NODEBUG}
  206. WriteBreakPoints:=true
  207. {$ifndef NODEBUG}
  208. else
  209. begin
  210. PushStatus('Storing breakpoints...');
  211. New(S, Init(30*1024,4096));
  212. BreakpointsCollection^.Store(S^);
  213. S^.Seek(0);
  214. F^.CreateResource(resBreakpoints,rcBinary,0);
  215. OK:=F^.AddResourceEntryFromStream(resBreakpoints,langDefault,0,S^,S^.GetSize);
  216. Dispose(S, Done);
  217. if OK=false then
  218. ErrorBox('Error storing breakpoints',nil);
  219. WriteBreakPoints:=OK;
  220. PopStatus;
  221. end;
  222. {$endif NODEBUG}
  223. end;
  224. function ReadOpenWindows(F: PResourceFile): boolean;
  225. var S: PMemoryStream;
  226. TempDesk: PFPDesktop;
  227. OK: boolean;
  228. R : TRect;
  229. W: word;
  230. begin
  231. PushStatus('Reading desktop contents...');
  232. New(S, Init(32*1024,4096));
  233. OK:=F^.ReadResourceEntryToStream(resDesktop,langDefault,S^);
  234. S^.Seek(0);
  235. if OK then
  236. begin
  237. S^.Read(W,SizeOf(W));
  238. OK:=(W=DesktopVersion);
  239. if OK=false then
  240. ErrorBox('Invalid desktop version. Desktop layout lost.',nil);
  241. end;
  242. if OK then
  243. begin
  244. TempDesk:=PFPDesktop(S^.Get);
  245. OK:=Assigned(TempDesk);
  246. if OK then
  247. begin
  248. Dispose(Desktop, Done);
  249. Desktop:=TempDesk;
  250. with Desktop^ do
  251. begin
  252. GetSubViewPtr(S^,CompilerMessageWindow);
  253. GetSubViewPtr(S^,CompilerStatusDialog);
  254. GetSubViewPtr(S^,ClipboardWindow);
  255. if Assigned(ClipboardWindow) then Clipboard:=ClipboardWindow^.Editor;
  256. GetSubViewPtr(S^,CalcWindow);
  257. GetSubViewPtr(S^,ProgramInfoWindow);
  258. GetSubViewPtr(S^,GDBWindow);
  259. GetSubViewPtr(S^,BreakpointsWindow);
  260. GetSubViewPtr(S^,WatchesWindow);
  261. GetSubViewPtr(S^,UserScreenWindow);
  262. GetSubViewPtr(S^,ASCIIChart);
  263. GetSubViewPtr(S^,MessagesWindow); LastToolMessageFocused:=nil;
  264. end;
  265. Application^.GetExtent(R);
  266. Inc(R.A.Y);Dec(R.B.Y);
  267. DeskTop^.Locate(R);
  268. Application^.Insert(Desktop);
  269. Desktop^.ReDraw;
  270. Message(Application,evBroadcast,cmUpdate,nil);
  271. end;
  272. if OK=false then
  273. ErrorBox('Error loading desktop',nil);
  274. end;
  275. Dispose(S, Done);
  276. PopStatus;
  277. ReadOpenWindows:=OK;
  278. end;
  279. function WriteOpenWindows(F: PResourceFile): boolean;
  280. var S: PMemoryStream;
  281. W: word;
  282. OK: boolean;
  283. begin
  284. PushStatus('Storing desktop contents...');
  285. New(S, Init(30*1024,4096));
  286. OK:=Assigned(S);
  287. if OK then
  288. begin
  289. W:=DesktopVersion;
  290. S^.Write(W,SizeOf(W));
  291. S^.Put(Desktop);
  292. with Desktop^ do
  293. begin
  294. PutSubViewPtr(S^,CompilerMessageWindow);
  295. PutSubViewPtr(S^,CompilerStatusDialog);
  296. PutSubViewPtr(S^,ClipboardWindow);
  297. PutSubViewPtr(S^,CalcWindow);
  298. PutSubViewPtr(S^,ProgramInfoWindow);
  299. PutSubViewPtr(S^,GDBWindow);
  300. PutSubViewPtr(S^,BreakpointsWindow);
  301. PutSubViewPtr(S^,WatchesWindow);
  302. PutSubViewPtr(S^,UserScreenWindow);
  303. PutSubViewPtr(S^,ASCIIChart);
  304. PutSubViewPtr(S^,MessagesWindow);
  305. end;
  306. OK:=(S^.Status=stOK);
  307. if OK then
  308. begin
  309. S^.Seek(0);
  310. OK:=F^.CreateResource(resDesktop,rcBinary,0);
  311. OK:=OK and F^.AddResourceEntryFromStream(resDesktop,langDefault,0,S^,S^.GetSize);
  312. end;
  313. Dispose(S, Done);
  314. end;
  315. if OK=false then
  316. ErrorBox('Error storing desktop',nil);
  317. PopStatus;
  318. WriteOpenWindows:=OK;
  319. end;
  320. function WriteFlags(F: PResourceFile): boolean;
  321. var
  322. OK: boolean;
  323. begin
  324. F^.CreateResource(resDesktopFlags,rcBinary,0);
  325. OK:=F^.AddResourceEntry(resDesktopFlags,langDefault,0,DesktopFileFlags,
  326. SizeOf(DesktopFileFlags));
  327. if OK=false then
  328. ErrorBox('Error writing flags',nil);
  329. WriteFlags:=OK;
  330. end;
  331. function ReadCodeComplete(F: PResourceFile): boolean;
  332. var S: PMemoryStream;
  333. OK: boolean;
  334. R: PResource;
  335. begin
  336. PushStatus('Reading CodeComplete wordlist...');
  337. New(S, Init(1024,1024));
  338. OK:=F^.ReadResourceEntryToStream(resCodeComplete,langDefault,S^);
  339. S^.Seek(0);
  340. if OK then
  341. OK:=LoadCodeComplete(S^);
  342. Dispose(S, Done);
  343. if OK=false then
  344. ErrorBox('Error loading CodeComplete wordlist',nil);
  345. PopStatus;
  346. ReadCodeComplete:=OK;
  347. end;
  348. function WriteCodeComplete(F: PResourceFile): boolean;
  349. var OK: boolean;
  350. S: PMemoryStream;
  351. begin
  352. PushStatus('Writing CodeComplete wordlist...');
  353. New(S, Init(1024,1024));
  354. OK:=StoreCodeComplete(S^);
  355. if OK then
  356. begin
  357. S^.Seek(0);
  358. F^.CreateResource(resCodeComplete,rcBinary,0);
  359. OK:=F^.AddResourceEntryFromStream(resCodeComplete,langDefault,0,S^,S^.GetSize);
  360. end;
  361. Dispose(S, Done);
  362. if OK=false then
  363. ErrorBox('Error writing CodeComplete wordlist',nil);
  364. PopStatus;
  365. WriteCodeComplete:=OK;
  366. end;
  367. function ReadCodeTemplates(F: PResourceFile): boolean;
  368. var S: PMemoryStream;
  369. OK: boolean;
  370. R: PResource;
  371. begin
  372. PushStatus('Reading CodeTemplates...');
  373. New(S, Init(1024,4096));
  374. OK:=F^.ReadResourceEntryToStream(resCodeTemplates,langDefault,S^);
  375. S^.Seek(0);
  376. if OK then
  377. OK:=LoadCodeTemplates(S^);
  378. Dispose(S, Done);
  379. if OK=false then
  380. ErrorBox('Error loading CodeTemplates wordlist',nil);
  381. PopStatus;
  382. ReadCodeTemplates:=OK;
  383. end;
  384. function WriteCodeTemplates(F: PResourceFile): boolean;
  385. var OK: boolean;
  386. S: PMemoryStream;
  387. begin
  388. PushStatus('Writing CodeTemplates...');
  389. New(S, Init(1024,4096));
  390. OK:=StoreCodeTemplates(S^);
  391. if OK then
  392. begin
  393. S^.Seek(0);
  394. F^.CreateResource(resCodeTemplates,rcBinary,0);
  395. OK:=F^.AddResourceEntryFromStream(resCodeTemplates,langDefault,0,S^,S^.GetSize);
  396. end;
  397. Dispose(S, Done);
  398. if OK=false then
  399. ErrorBox('Error writing CodeTemplates',nil);
  400. PopStatus;
  401. WriteCodeTemplates:=OK;
  402. end;
  403. function ReadFlags(F: PResourceFile): boolean;
  404. var
  405. size : sw_word;
  406. OK: boolean;
  407. begin
  408. OK:=F^.ReadResourceEntry(resDesktopFlags,langDefault,DesktopFileFlags,
  409. size);
  410. if OK=false then
  411. ErrorBox('Error loading flags',nil);
  412. ReadFlags:=OK;
  413. end;
  414. function WriteVideoMode(F: PResourceFile): boolean;
  415. var
  416. OK: boolean;
  417. begin
  418. F^.CreateResource(resVideo,rcBinary,0);
  419. OK:=F^.AddResourceEntry(resVideo,langDefault,0,ScreenMode,
  420. SizeOf(TVideoMode));
  421. if OK=false then
  422. ErrorBox('Error storing video mode',nil);
  423. WriteVideoMode:=OK;
  424. end;
  425. function ReadVideoMode(F: PResourceFile;var NewScreenMode : TVideoMode): boolean;
  426. var
  427. size : sw_word;
  428. OK,test : boolean;
  429. begin
  430. size:=SizeOf(TVideoMode);
  431. test:=F^.ReadResourceEntry(resVideo,langDefault,NewScreenMode,
  432. size);
  433. if not test then
  434. NewScreenMode:=ScreenMode;
  435. OK:=test and (size = SizeOf(TVideoMode));
  436. if OK=false then
  437. ErrorBox('Error loading video mode',nil);
  438. ReadVideoMode:=OK;
  439. end;
  440. function ReadSymbols(F: PResourceFile): boolean;
  441. var S: PMemoryStream;
  442. OK: boolean;
  443. R: PResource;
  444. begin
  445. { if no symbols stored ... no problems }
  446. R:=F^.FindResource(resSymbols);
  447. if not Assigned(R) then
  448. exit;
  449. PushStatus('Reading symbol information...');
  450. New(S, Init(32*1024,4096));
  451. OK:=F^.ReadResourceEntryToStream(resSymbols,langDefault,S^);
  452. S^.Seek(0);
  453. if OK then
  454. OK:=LoadBrowserCol(S);
  455. Dispose(S, Done);
  456. if OK=false then
  457. ErrorBox('Error loading symbol information',nil);
  458. PopStatus;
  459. ReadSymbols:=OK;
  460. end;
  461. function WriteSymbols(F: PResourceFile): boolean;
  462. var S: PMemoryStream;
  463. OK: boolean;
  464. begin
  465. OK:=Assigned(Modules);
  466. if OK then
  467. begin
  468. PushStatus('Storing symbol information...');
  469. New(S, Init(200*1024,4096));
  470. OK:=Assigned(S);
  471. if OK then
  472. OK:=StoreBrowserCol(S);
  473. if OK then
  474. begin
  475. S^.Seek(0);
  476. F^.CreateResource(resSymbols,rcBinary,0);
  477. OK:=F^.AddResourceEntryFromStream(resSymbols,langDefault,0,S^,S^.GetSize);
  478. end;
  479. Dispose(S, Done);
  480. if OK=false then
  481. ErrorBox('Error storing symbol information',nil);
  482. PopStatus;
  483. end;
  484. WriteSymbols:=OK;
  485. end;
  486. function LoadDesktop: boolean;
  487. var OK,VOK: boolean;
  488. F: PResourceFile;
  489. VM : TVideoMode;
  490. begin
  491. PushStatus('Reading desktop file...');
  492. New(F, LoadFile(GetShortName(DesktopPath)));
  493. OK:=false;
  494. if Assigned(F) then
  495. begin
  496. OK:=ReadFlags(F);
  497. VOK:=ReadVideoMode(F,VM);
  498. if VOK and ((VM.Col<>ScreenMode.Col) or
  499. (VM.Row<>ScreenMode.Row) or (VM.Color<>ScreenMode.Color)) then
  500. Application^.SetScreenVideoMode(VM);
  501. if ((DesktopFileFlags and dfHistoryLists)<>0) then
  502. OK:=OK and ReadHistory(F);
  503. if ((DesktopFileFlags and dfWatches)<>0) then
  504. OK:=OK and ReadWatches(F);
  505. if ((DesktopFileFlags and dfOpenWindows)<>0) then
  506. OK:=OK and ReadOpenWindows(F);
  507. if ((DesktopFileFlags and dfBreakpoints)<>0) then
  508. OK:=OK and ReadBreakpoints(F);
  509. { no errors if no browser info available PM }
  510. if ((DesktopFileFlags and dfSymbolInformation)<>0) then
  511. OK:=OK and ReadSymbols(F);
  512. if ((DesktopFileFlags and dfCodeCompleteWords)<>0) then
  513. OK:=OK and ReadCodeComplete(F);
  514. if ((DesktopFileFlags and dfCodeTemplates)<>0) then
  515. OK:=OK and ReadCodeTemplates(F);
  516. Dispose(F, Done);
  517. end;
  518. PopStatus;
  519. LoadDesktop:=OK;
  520. end;
  521. function SaveDesktop: boolean;
  522. var OK: boolean;
  523. F: PResourceFile;
  524. TempPath: string;
  525. begin
  526. TempPath:=DirOf(DesktopPath)+DesktopTempName;
  527. PushStatus('Writing desktop file...');
  528. New(F, CreateFile(GetShortName(TempPath)));
  529. if Assigned(Clipboard) then
  530. if (DesktopFileFlags and dfClipboardContent)<>0 then
  531. Clipboard^.Flags:=Clipboard^.Flags or efStoreContent
  532. else
  533. Clipboard^.Flags:=Clipboard^.Flags and not efStoreContent;
  534. OK:=false;
  535. if Assigned(F) then
  536. begin
  537. OK:=WriteFlags(F);
  538. OK:=OK and WriteVideoMode(F);
  539. if ((DesktopFileFlags and dfHistoryLists)<>0) then
  540. OK:=OK and WriteHistory(F);
  541. if ((DesktopFileFlags and dfWatches)<>0) then
  542. OK:=OK and WriteWatches(F);
  543. if ((DesktopFileFlags and dfOpenWindows)<>0) then
  544. OK:=OK and WriteOpenWindows(F);
  545. if ((DesktopFileFlags and dfBreakpoints)<>0) then
  546. OK:=OK and WriteBreakpoints(F);
  547. { no errors if no browser info available PM }
  548. if ((DesktopFileFlags and dfSymbolInformation)<>0) then
  549. OK:=OK and (WriteSymbols(F) or not Assigned(Modules));
  550. if ((DesktopFileFlags and dfCodeCompleteWords)<>0) then
  551. OK:=OK and WriteCodeComplete(F);
  552. if ((DesktopFileFlags and dfCodeTemplates)<>0) then
  553. OK:=OK and WriteCodeTemplates(F);
  554. Dispose(F, Done);
  555. end;
  556. if OK then
  557. begin
  558. if ExistsFile(DesktopPath) then
  559. OK:=EraseFile(DesktopPath);
  560. OK:=OK and RenameFile(TempPath,DesktopPath);
  561. if OK=false then
  562. ErrorBox('Failed to replace desktop file.',nil);
  563. end;
  564. PopStatus;
  565. SaveDesktop:=OK;
  566. end;
  567. function WriteSymbolsFile(const filename : string): boolean;
  568. var OK: boolean;
  569. F: PResourceFile;
  570. begin
  571. WriteSymbolsFile:=false;
  572. If not assigned(Modules) then
  573. exit;
  574. New(F, CreateFile(GetShortName(FileName)));
  575. OK:=Assigned(F);
  576. if OK and ((DesktopFileFlags and dfSymbolInformation)<>0) then
  577. OK:=OK and WriteSymbols(F);
  578. if assigned(F) then
  579. Dispose(F,Done);
  580. WriteSymbolsFile:=OK;
  581. end;
  582. function ReadSymbolsFile(const FileName : string): boolean;
  583. var OK: boolean;
  584. F: PResourceFile;
  585. begin
  586. ReadSymbolsFile:=false;
  587. { Don't read again !! }
  588. If assigned(Modules) then
  589. exit;
  590. New(F, LoadFile(GetShortName(FileName)));
  591. OK:=Assigned(F);
  592. if OK and ((DesktopFileFlags and dfSymbolInformation)<>0) then
  593. OK:=OK and ReadSymbols(F);
  594. if assigned(F) then
  595. Dispose(F,Done);
  596. ReadSymbolsFile:=OK;
  597. end;
  598. END.
  599. {
  600. $Log$
  601. Revision 1.22 2000-02-07 12:03:48 pierre
  602. Last commit is from Gabor's changes!
  603. Revision 1.21 2000/02/07 11:55:27 pierre
  604. + Code Complete and Template saving from Gabor
  605. Revision 1.20 2000/02/04 00:12:57 pierre
  606. * Breakpoint are marked in source at desktop loading
  607. Revision 1.19 2000/01/25 00:26:36 pierre
  608. + Browser info saving
  609. Revision 1.18 2000/01/03 11:38:33 michael
  610. Changes from Gabor
  611. Revision 1.17 1999/12/20 00:30:56 pierre
  612. * problem with VideoMode storing solved
  613. Revision 1.16 1999/12/10 13:02:05 pierre
  614. + VideoMode save/restore
  615. Revision 1.15 1999/11/26 17:09:51 pierre
  616. * Force Desktop into Screen
  617. Revision 1.14 1999/11/25 00:25:43 pierre
  618. * add Status when loading/saving files
  619. Revision 1.13 1999/09/20 15:37:59 pierre
  620. * ReadOpenWindows and ReadSymobls was missing, still does not work correctly :(
  621. Revision 1.12 1999/09/17 16:41:10 pierre
  622. * other stream error for Watches/Breakpoints corrected
  623. Revision 1.11 1999/09/17 16:28:58 pierre
  624. * ResWatches in WriteBreakpoints typo !
  625. Revision 1.10 1999/09/16 14:34:58 pierre
  626. + TBreakpoint and TWatch registering
  627. + WatchesCollection and BreakpointsCollection stored in desk file
  628. * Syntax highlighting was broken
  629. Revision 1.9 1999/09/07 09:23:00 pierre
  630. * no errors if no browser info available
  631. Revision 1.8 1999/08/16 18:25:16 peter
  632. * Adjusting the selection when the editor didn't contain any line.
  633. * Reserved word recognition redesigned, but this didn't affect the overall
  634. syntax highlight speed remarkably (at least not on my Amd-K6/350).
  635. The syntax scanner loop is a bit slow but the main problem is the
  636. recognition of special symbols. Switching off symbol processing boosts
  637. the performance up to ca. 200%...
  638. * The editor didn't allow copying (for ex to clipboard) of a single character
  639. * 'File|Save as' caused permanently run-time error 3. Not any more now...
  640. * Compiler Messages window (actually the whole desktop) did not act on any
  641. keypress when compilation failed and thus the window remained visible
  642. + Message windows are now closed upon pressing Esc
  643. + At 'Run' the IDE checks whether any sources are modified, and recompiles
  644. only when neccessary
  645. + BlockRead and BlockWrite (Ctrl+K+R/W) implemented in TCodeEditor
  646. + LineSelect (Ctrl+K+L) implemented
  647. * The IDE had problems closing help windows before saving the desktop
  648. Revision 1.7 1999/08/03 20:22:30 peter
  649. + TTab acts now on Ctrl+Tab and Ctrl+Shift+Tab...
  650. + Desktop saving should work now
  651. - History saved
  652. - Clipboard content saved
  653. - Desktop saved
  654. - Symbol info saved
  655. * syntax-highlight bug fixed, which compared special keywords case sensitive
  656. (for ex. 'asm' caused asm-highlighting, while 'ASM' didn't)
  657. * with 'whole words only' set, the editor didn't found occourences of the
  658. searched text, if the text appeared previously in the same line, but didn't
  659. satisfied the 'whole-word' condition
  660. * ^QB jumped to (SelStart.X,SelEnd.X) instead of (SelStart.X,SelStart.Y)
  661. (ie. the beginning of the selection)
  662. * when started typing in a new line, but not at the start (X=0) of it,
  663. the editor inserted the text one character more to left as it should...
  664. * TCodeEditor.HideSelection (Ctrl-K+H) didn't update the screen
  665. * Shift shouldn't cause so much trouble in TCodeEditor now...
  666. * Syntax highlight had problems recognizing a special symbol if it was
  667. prefixed by another symbol character in the source text
  668. * Auto-save also occours at Dos shell, Tool execution, etc. now...
  669. Revision 1.5 1999/06/30 23:58:13 pierre
  670. + BreakpointsList Window implemented
  671. with Edit/New/Delete functions
  672. + Individual breakpoint dialog with support for all types
  673. ignorecount and conditions
  674. (commands are not yet implemented, don't know if this wolud be useful)
  675. awatch and rwatch have problems because GDB does not annotate them
  676. I fixed v4.16 for this
  677. Revision 1.4 1999/04/15 08:58:05 peter
  678. * syntax highlight fixes
  679. * browser updates
  680. Revision 1.3 1999/04/07 21:55:45 peter
  681. + object support for browser
  682. * html help fixes
  683. * more desktop saving things
  684. * NODEBUG directive to exclude debugger
  685. Revision 1.2 1999/03/23 16:16:39 peter
  686. * linux fixes
  687. Revision 1.1 1999/03/23 15:11:28 peter
  688. * desktop saving things
  689. * vesa mode
  690. * preferences dialog
  691. }