fpmansi.inc 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. {
  2. $Id$
  3. This file is part of the Free Pascal Integrated Development Environment
  4. Copyright (c) 2000 by Pierre Muller
  5. Ansi dump capability
  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. procedure TIDEApp.CreateAnsiFile;
  13. var
  14. f : text;
  15. Buf : PVideoBuf;
  16. re : word;
  17. UL,LR : TPoint;
  18. Name, DefExt : string;
  19. function GetPoint(var P :TPoint) : boolean;
  20. var
  21. E : TEvent;
  22. begin
  23. repeat
  24. GetEvent(E);
  25. until (E.What=evMouseDown) or
  26. ((E.What=evKeyDown) and ((E.KeyCode=kbEsc) or (E.KeyCode=kbEnter)));
  27. if (E.What=evMouseDown) then
  28. begin
  29. GetPoint:=true;
  30. P:=E.Where;
  31. end
  32. else if (E.KeyCode=kbEnter) then
  33. GetPoint:=true
  34. else
  35. GetPoint:=false;
  36. end;
  37. begin
  38. { First copy the whole screen untouched }
  39. GetMem(Buf,VideoBufSize * SizeOf(TVideoCell));
  40. Move(VideoBuf^,Buf^,VideoBufSize * SizeOf(TVideoCell));
  41. { partial screen save ? }
  42. PushStatus(msg_click_upper_left);
  43. UL.X:=0;UL.Y:=0;
  44. if not GetPoint(UL) then
  45. begin
  46. PopStatus;
  47. exit;
  48. end;
  49. PopStatus;
  50. PushStatus(msg_click_lower_right);
  51. LR.X:=Size.X-1;LR.Y:=Size.Y-1;
  52. if not GetPoint(LR) then
  53. begin
  54. PopStatus;
  55. exit;
  56. end;
  57. PopStatus;
  58. { How should we do this ?? }
  59. { after ask for a file name to save }
  60. DefExt:='*.ans';
  61. Name:='screen.ans';
  62. PushStatus(msg_saveansifile);
  63. Re:=Application^.ExecuteDialog(New(PFileDialog, Init(DefExt,
  64. dialog_savefileas, label_name, fdOkButton, FileId)), @Name);
  65. if Re<>cmCancel then
  66. begin
  67. Assign(f,Name);
  68. Rewrite(f);
  69. ExportBufferToAnsiFile(Buf^,UL.X,LR.X,UL.Y,LR.Y,
  70. Size.X,f);
  71. Close(f);
  72. end;
  73. PopStatus;
  74. end;
  75. {
  76. $Log$
  77. Revision 1.1 2001-08-04 11:30:23 peter
  78. * ide works now with both compiler versions
  79. Revision 1.1.2.2 2000/11/22 11:03:32 pierre
  80. + window selection for Ansi Dump
  81. Revision 1.1.2.1 2000/11/21 17:43:24 pierre
  82. + first version of dump ansi file
  83. }