unixsmsg.inc 3.4 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. BaseUnix,unix;
  24. {$endif}
  25. Const
  26. SystemEventActive : Boolean = false;
  27. var
  28. lastxsize,lastysize : longint;
  29. procedure InitSystemMsg;
  30. var
  31. WinSize : TWinSize;
  32. begin
  33. If SystemEventActive then
  34. exit;
  35. { Code to enable size tracking should go here }
  36. PendingSystemHead:=@PendingSystemEvent;
  37. PendingSystemTail:=@PendingSystemEvent;
  38. PendingSystemEvents:=0;
  39. FillChar(LastSystemEvent,sizeof(TSystemEvent),0);
  40. FillChar(WinSize,sizeof(WinSize),0);
  41. fpioctl(stdinputhandle,TIOCGWINSZ,@winsize);
  42. LastXSize:=WinSize.ws_row;
  43. LastYSize:=WinSize.ws_col;
  44. If LastXSize=0 then
  45. LastXSize:=80;
  46. If LastYSize=0 then
  47. LastYSize:=25;
  48. SystemEventActive:=true;
  49. end;
  50. procedure DoneSystemMsg;
  51. begin
  52. if not SystemEventActive then
  53. exit;
  54. { Code to disable size tracking should go here }
  55. SystemEventActive:=false;
  56. end;
  57. procedure GetSystemEvent(var SystemEvent: TSystemEvent);
  58. begin
  59. if PendingSystemEvents=0 then
  60. PollSystemEvent(SystemEvent);
  61. if PendingSystemEvents=0 then
  62. exit;
  63. SystemEvent:=PendingSystemHead^;
  64. inc(PendingSystemHead);
  65. if longint(PendingSystemHead)=longint(@PendingSystemEvent)+sizeof(PendingSystemEvent) then
  66. PendingSystemHead:=@PendingSystemEvent;
  67. dec(PendingSystemEvents);
  68. LastSystemEvent:=SystemEvent;
  69. end;
  70. function PollSystemEvent(var SystemEvent: TSystemEvent):boolean;
  71. var
  72. CloseState : word;
  73. WinSize : TWinSize;
  74. begin
  75. SystemEvent.typ:=SysNothing;
  76. if not SystemEventActive then
  77. exit(false);
  78. if PendingSystemEvents>0 then
  79. begin
  80. SystemEvent:=PendingSystemHead^;
  81. PollSystemEvent:=true;
  82. end
  83. else
  84. begin
  85. FillChar(WinSize,sizeof(WinSize),0);
  86. fpioctl(stdinputhandle,TIOCGWINSZ,@winsize);
  87. if (winsize.ws_col<>0) and (winsize.ws_row<>0) and
  88. ((winsize.ws_row<>lastxsize) or (winsize.ws_col<>lastysize)) then
  89. begin
  90. SystemEvent.typ:=SysResize;
  91. SystemEvent.x:=WinSize.ws_row;
  92. SystemEvent.y:=WinSize.ws_col;
  93. PutSystemEvent(SystemEvent);
  94. LastXSize:=WinSize.ws_row;
  95. LastYSize:=WinSize.ws_col;
  96. PollSystemEvent:=true;
  97. end
  98. else
  99. PollSystemEvent:=false;
  100. end;
  101. end;
  102. {
  103. $Log$
  104. Revision 1.4 2003-10-01 16:20:27 marco
  105. * baseunix fixes for 1.1
  106. Revision 1.3 2003/06/18 09:54:13 pierre
  107. * use termios.inc TwinSize definition
  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. }