mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 20:29:14 +02:00
* add window resizing support for unix
This commit is contained in:
parent
463d53271c
commit
d51ea019eb
@ -196,18 +196,21 @@ FOR FPC THESE ARE THE TRANSLATIONS
|
|||||||
{$UNDEF OS_DOS}
|
{$UNDEF OS_DOS}
|
||||||
{$DEFINE OS_LINUX}
|
{$DEFINE OS_LINUX}
|
||||||
{$DEFINE OS_UNIX}
|
{$DEFINE OS_UNIX}
|
||||||
|
{$DEFINE HasSysMsgUnit}
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
{$IFDEF FreeBSD}
|
{$IFDEF FreeBSD}
|
||||||
{$UNDEF OS_DOS}
|
{$UNDEF OS_DOS}
|
||||||
{$DEFINE OS_FREEBSD}
|
{$DEFINE OS_FREEBSD}
|
||||||
{$DEFINE OS_UNIX}
|
{$DEFINE OS_UNIX}
|
||||||
|
{$DEFINE HasSysMsgUnit}
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
{$IFDEF NETBSD}
|
{$IFDEF NETBSD}
|
||||||
{$UNDEF OS_DOS}
|
{$UNDEF OS_DOS}
|
||||||
{$DEFINE OS_NETBSD}
|
{$DEFINE OS_NETBSD}
|
||||||
{$DEFINE OS_UNIX}
|
{$DEFINE OS_UNIX}
|
||||||
|
{$DEFINE HasSysMsgUnit}
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
|
|
||||||
@ -400,7 +403,10 @@ FOR FPC THESE ARE THE TRANSLATIONS
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.8 2002-06-02 08:32:51 marco
|
Revision 1.9 2002-06-07 14:15:10 pierre
|
||||||
|
* add window resizing support for unix
|
||||||
|
|
||||||
|
Revision 1.8 2002/06/02 08:32:51 marco
|
||||||
* renamefest
|
* renamefest
|
||||||
|
|
||||||
Revision 1.7 2002/05/21 12:02:02 pierre
|
Revision 1.7 2002/05/21 12:02:02 pierre
|
||||||
|
@ -24,15 +24,45 @@
|
|||||||
{ This file is still a dummy,
|
{ This file is still a dummy,
|
||||||
it should use ioctl to get information about resizing of windows }
|
it should use ioctl to get information about resizing of windows }
|
||||||
|
|
||||||
|
uses
|
||||||
|
{$ifdef VER1_0}
|
||||||
|
linux;
|
||||||
|
{$else}
|
||||||
|
unix;
|
||||||
|
{$endif}
|
||||||
|
|
||||||
Const
|
Const
|
||||||
SystemEventActive : Boolean = false;
|
SystemEventActive : Boolean = false;
|
||||||
|
|
||||||
|
type
|
||||||
|
TWinSize = record
|
||||||
|
ws_row, ws_col, ws_xpixel, ws_ypixel : smallint;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
var
|
||||||
|
lastxsize,lastysize : longint;
|
||||||
|
|
||||||
procedure InitSystemMsg;
|
procedure InitSystemMsg;
|
||||||
|
var
|
||||||
|
WinSize : TWinSize;
|
||||||
begin
|
begin
|
||||||
If SystemEventActive then
|
If SystemEventActive then
|
||||||
exit;
|
exit;
|
||||||
{ Code to enable size tracking should go here }
|
{ Code to enable size tracking should go here }
|
||||||
|
PendingSystemHead:=@PendingSystemEvent;
|
||||||
|
PendingSystemTail:=@PendingSystemEvent;
|
||||||
|
PendingSystemEvents:=0;
|
||||||
|
FillChar(LastSystemEvent,sizeof(TSystemEvent),0);
|
||||||
|
FillChar(WinSize,sizeof(WinSize),0);
|
||||||
|
ioctl(stdinputhandle,TIOCGWINSZ,@winsize);
|
||||||
|
LastXSize:=WinSize.ws_row;
|
||||||
|
LastYSize:=WinSize.ws_col;
|
||||||
|
If LastXSize=0 then
|
||||||
|
LastXSize:=80;
|
||||||
|
If LastYSize=0 then
|
||||||
|
LastYSize:=25;
|
||||||
|
|
||||||
SystemEventActive:=true;
|
SystemEventActive:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -47,22 +77,58 @@ end;
|
|||||||
|
|
||||||
procedure GetSystemEvent(var SystemEvent: TSystemEvent);
|
procedure GetSystemEvent(var SystemEvent: TSystemEvent);
|
||||||
begin
|
begin
|
||||||
PollSystemEvent(SystemEvent);
|
if PendingSystemEvents=0 then
|
||||||
|
PollSystemEvent(SystemEvent);
|
||||||
|
if PendingSystemEvents=0 then
|
||||||
|
exit;
|
||||||
|
SystemEvent:=PendingSystemHead^;
|
||||||
|
inc(PendingSystemHead);
|
||||||
|
if longint(PendingSystemHead)=longint(@PendingSystemEvent)+sizeof(PendingSystemEvent) then
|
||||||
|
PendingSystemHead:=@PendingSystemEvent;
|
||||||
|
dec(PendingSystemEvents);
|
||||||
|
LastSystemEvent:=SystemEvent;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function PollSystemEvent(var SystemEvent: TSystemEvent):boolean;
|
function PollSystemEvent(var SystemEvent: TSystemEvent):boolean;
|
||||||
var
|
var
|
||||||
CloseState : word;
|
CloseState : word;
|
||||||
|
WinSize : TWinSize;
|
||||||
begin
|
begin
|
||||||
SystemEvent.typ:=SysNothing;
|
SystemEvent.typ:=SysNothing;
|
||||||
if not SystemEventActive then
|
if not SystemEventActive then
|
||||||
exit(false);
|
exit(false);
|
||||||
PollSystemEvent:=false;
|
if PendingSystemEvents>0 then
|
||||||
|
begin
|
||||||
|
SystemEvent:=PendingSystemHead^;
|
||||||
|
PollSystemEvent:=true;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
FillChar(WinSize,sizeof(WinSize),0);
|
||||||
|
ioctl(stdinputhandle,TIOCGWINSZ,@winsize);
|
||||||
|
if (winsize.ws_col<>0) and (winsize.ws_row<>0) and
|
||||||
|
((winsize.ws_row<>lastxsize) or (winsize.ws_col<>lastysize)) then
|
||||||
|
begin
|
||||||
|
SystemEvent.typ:=SysResize;
|
||||||
|
SystemEvent.x:=WinSize.ws_row;
|
||||||
|
SystemEvent.y:=WinSize.ws_col;
|
||||||
|
PutSystemEvent(SystemEvent);
|
||||||
|
LastXSize:=WinSize.ws_row;
|
||||||
|
LastYSize:=WinSize.ws_col;
|
||||||
|
PollSystemEvent:=true;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
PollSystemEvent:=false;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.1 2002-05-21 11:59:57 pierre
|
Revision 1.2 2002-06-07 14:15:10 pierre
|
||||||
|
* add window resizing support for unix
|
||||||
|
|
||||||
|
Revision 1.1 2002/05/21 11:59:57 pierre
|
||||||
+ system messages unit added
|
+ system messages unit added
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -196,18 +196,21 @@ FOR FPC THESE ARE THE TRANSLATIONS
|
|||||||
{$UNDEF OS_DOS}
|
{$UNDEF OS_DOS}
|
||||||
{$DEFINE OS_LINUX}
|
{$DEFINE OS_LINUX}
|
||||||
{$DEFINE OS_UNIX}
|
{$DEFINE OS_UNIX}
|
||||||
|
{$DEFINE HasSysMsgUnit}
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
{$IFDEF FreeBSD}
|
{$IFDEF FreeBSD}
|
||||||
{$UNDEF OS_DOS}
|
{$UNDEF OS_DOS}
|
||||||
{$DEFINE OS_FREEBSD}
|
{$DEFINE OS_FREEBSD}
|
||||||
{$DEFINE OS_UNIX}
|
{$DEFINE OS_UNIX}
|
||||||
|
{$DEFINE HasSysMsgUnit}
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
{$IFDEF NETBSD}
|
{$IFDEF NETBSD}
|
||||||
{$UNDEF OS_DOS}
|
{$UNDEF OS_DOS}
|
||||||
{$DEFINE OS_NETBSD}
|
{$DEFINE OS_NETBSD}
|
||||||
{$DEFINE OS_UNIX}
|
{$DEFINE OS_UNIX}
|
||||||
|
{$DEFINE HasSysMsgUnit}
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
|
|
||||||
@ -400,7 +403,10 @@ FOR FPC THESE ARE THE TRANSLATIONS
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.8 2002-06-02 08:32:51 marco
|
Revision 1.9 2002-06-07 14:15:10 pierre
|
||||||
|
* add window resizing support for unix
|
||||||
|
|
||||||
|
Revision 1.8 2002/06/02 08:32:51 marco
|
||||||
* renamefest
|
* renamefest
|
||||||
|
|
||||||
Revision 1.7 2002/05/21 12:02:02 pierre
|
Revision 1.7 2002/05/21 12:02:02 pierre
|
||||||
|
@ -24,15 +24,45 @@
|
|||||||
{ This file is still a dummy,
|
{ This file is still a dummy,
|
||||||
it should use ioctl to get information about resizing of windows }
|
it should use ioctl to get information about resizing of windows }
|
||||||
|
|
||||||
|
uses
|
||||||
|
{$ifdef VER1_0}
|
||||||
|
linux;
|
||||||
|
{$else}
|
||||||
|
unix;
|
||||||
|
{$endif}
|
||||||
|
|
||||||
Const
|
Const
|
||||||
SystemEventActive : Boolean = false;
|
SystemEventActive : Boolean = false;
|
||||||
|
|
||||||
|
type
|
||||||
|
TWinSize = record
|
||||||
|
ws_row, ws_col, ws_xpixel, ws_ypixel : smallint;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
var
|
||||||
|
lastxsize,lastysize : longint;
|
||||||
|
|
||||||
procedure InitSystemMsg;
|
procedure InitSystemMsg;
|
||||||
|
var
|
||||||
|
WinSize : TWinSize;
|
||||||
begin
|
begin
|
||||||
If SystemEventActive then
|
If SystemEventActive then
|
||||||
exit;
|
exit;
|
||||||
{ Code to enable size tracking should go here }
|
{ Code to enable size tracking should go here }
|
||||||
|
PendingSystemHead:=@PendingSystemEvent;
|
||||||
|
PendingSystemTail:=@PendingSystemEvent;
|
||||||
|
PendingSystemEvents:=0;
|
||||||
|
FillChar(LastSystemEvent,sizeof(TSystemEvent),0);
|
||||||
|
FillChar(WinSize,sizeof(WinSize),0);
|
||||||
|
ioctl(stdinputhandle,TIOCGWINSZ,@winsize);
|
||||||
|
LastXSize:=WinSize.ws_row;
|
||||||
|
LastYSize:=WinSize.ws_col;
|
||||||
|
If LastXSize=0 then
|
||||||
|
LastXSize:=80;
|
||||||
|
If LastYSize=0 then
|
||||||
|
LastYSize:=25;
|
||||||
|
|
||||||
SystemEventActive:=true;
|
SystemEventActive:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -47,22 +77,58 @@ end;
|
|||||||
|
|
||||||
procedure GetSystemEvent(var SystemEvent: TSystemEvent);
|
procedure GetSystemEvent(var SystemEvent: TSystemEvent);
|
||||||
begin
|
begin
|
||||||
PollSystemEvent(SystemEvent);
|
if PendingSystemEvents=0 then
|
||||||
|
PollSystemEvent(SystemEvent);
|
||||||
|
if PendingSystemEvents=0 then
|
||||||
|
exit;
|
||||||
|
SystemEvent:=PendingSystemHead^;
|
||||||
|
inc(PendingSystemHead);
|
||||||
|
if longint(PendingSystemHead)=longint(@PendingSystemEvent)+sizeof(PendingSystemEvent) then
|
||||||
|
PendingSystemHead:=@PendingSystemEvent;
|
||||||
|
dec(PendingSystemEvents);
|
||||||
|
LastSystemEvent:=SystemEvent;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function PollSystemEvent(var SystemEvent: TSystemEvent):boolean;
|
function PollSystemEvent(var SystemEvent: TSystemEvent):boolean;
|
||||||
var
|
var
|
||||||
CloseState : word;
|
CloseState : word;
|
||||||
|
WinSize : TWinSize;
|
||||||
begin
|
begin
|
||||||
SystemEvent.typ:=SysNothing;
|
SystemEvent.typ:=SysNothing;
|
||||||
if not SystemEventActive then
|
if not SystemEventActive then
|
||||||
exit(false);
|
exit(false);
|
||||||
PollSystemEvent:=false;
|
if PendingSystemEvents>0 then
|
||||||
|
begin
|
||||||
|
SystemEvent:=PendingSystemHead^;
|
||||||
|
PollSystemEvent:=true;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
FillChar(WinSize,sizeof(WinSize),0);
|
||||||
|
ioctl(stdinputhandle,TIOCGWINSZ,@winsize);
|
||||||
|
if (winsize.ws_col<>0) and (winsize.ws_row<>0) and
|
||||||
|
((winsize.ws_row<>lastxsize) or (winsize.ws_col<>lastysize)) then
|
||||||
|
begin
|
||||||
|
SystemEvent.typ:=SysResize;
|
||||||
|
SystemEvent.x:=WinSize.ws_row;
|
||||||
|
SystemEvent.y:=WinSize.ws_col;
|
||||||
|
PutSystemEvent(SystemEvent);
|
||||||
|
LastXSize:=WinSize.ws_row;
|
||||||
|
LastYSize:=WinSize.ws_col;
|
||||||
|
PollSystemEvent:=true;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
PollSystemEvent:=false;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.1 2002-05-21 11:59:57 pierre
|
Revision 1.2 2002-06-07 14:15:10 pierre
|
||||||
|
* add window resizing support for unix
|
||||||
|
|
||||||
|
Revision 1.1 2002/05/21 11:59:57 pierre
|
||||||
+ system messages unit added
|
+ system messages unit added
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user