fpmansi.inc 2.1 KB

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