unixsmsg.inc 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. {
  2. $Id$
  3. System dependent system messages for unix
  4. Copyright (c) 2002 by Pierre Muller
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Library General Public
  7. License as published by the Free Software Foundation; either
  8. version 2 of the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Library General Public License for more details.
  13. You should have received a copy of the GNU Library General Public
  14. License along with this library; if not, write to the Free
  15. Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. }
  17. { This file is still a dummy,
  18. it should use ioctl to get information about resizing of windows }
  19. uses
  20. {$ifdef VER1_0}
  21. linux;
  22. {$else}
  23. unix;
  24. {$endif}
  25. Const
  26. SystemEventActive : Boolean = false;
  27. type
  28. TWinSize = record
  29. ws_row, ws_col, ws_xpixel, ws_ypixel : smallint;
  30. end;
  31. var
  32. lastxsize,lastysize : longint;
  33. procedure InitSystemMsg;
  34. var
  35. WinSize : TWinSize;
  36. begin
  37. If SystemEventActive then
  38. exit;
  39. { Code to enable size tracking should go here }
  40. PendingSystemHead:=@PendingSystemEvent;
  41. PendingSystemTail:=@PendingSystemEvent;
  42. PendingSystemEvents:=0;
  43. FillChar(LastSystemEvent,sizeof(TSystemEvent),0);
  44. FillChar(WinSize,sizeof(WinSize),0);
  45. ioctl(stdinputhandle,TIOCGWINSZ,@winsize);
  46. LastXSize:=WinSize.ws_row;
  47. LastYSize:=WinSize.ws_col;
  48. If LastXSize=0 then
  49. LastXSize:=80;
  50. If LastYSize=0 then
  51. LastYSize:=25;
  52. SystemEventActive:=true;
  53. end;
  54. procedure DoneSystemMsg;
  55. begin
  56. if not SystemEventActive then
  57. exit;
  58. { Code to disable size tracking should go here }
  59. SystemEventActive:=false;
  60. end;
  61. procedure GetSystemEvent(var SystemEvent: TSystemEvent);
  62. begin
  63. if PendingSystemEvents=0 then
  64. PollSystemEvent(SystemEvent);
  65. if PendingSystemEvents=0 then
  66. exit;
  67. SystemEvent:=PendingSystemHead^;
  68. inc(PendingSystemHead);
  69. if longint(PendingSystemHead)=longint(@PendingSystemEvent)+sizeof(PendingSystemEvent) then
  70. PendingSystemHead:=@PendingSystemEvent;
  71. dec(PendingSystemEvents);
  72. LastSystemEvent:=SystemEvent;
  73. end;
  74. function PollSystemEvent(var SystemEvent: TSystemEvent):boolean;
  75. var
  76. CloseState : word;
  77. WinSize : TWinSize;
  78. begin
  79. SystemEvent.typ:=SysNothing;
  80. if not SystemEventActive then
  81. exit(false);
  82. if PendingSystemEvents>0 then
  83. begin
  84. SystemEvent:=PendingSystemHead^;
  85. PollSystemEvent:=true;
  86. end
  87. else
  88. begin
  89. FillChar(WinSize,sizeof(WinSize),0);
  90. ioctl(stdinputhandle,TIOCGWINSZ,@winsize);
  91. if (winsize.ws_col<>0) and (winsize.ws_row<>0) and
  92. ((winsize.ws_row<>lastxsize) or (winsize.ws_col<>lastysize)) then
  93. begin
  94. SystemEvent.typ:=SysResize;
  95. SystemEvent.x:=WinSize.ws_row;
  96. SystemEvent.y:=WinSize.ws_col;
  97. PutSystemEvent(SystemEvent);
  98. LastXSize:=WinSize.ws_row;
  99. LastYSize:=WinSize.ws_col;
  100. PollSystemEvent:=true;
  101. end
  102. else
  103. PollSystemEvent:=false;
  104. end;
  105. end;
  106. {
  107. $Log$
  108. Revision 1.2 2002-06-07 14:15:10 pierre
  109. * add window resizing support for unix
  110. Revision 1.1 2002/05/21 11:59:57 pierre
  111. + system messages unit added
  112. }