- fixed mouse to compile with $i386_att

+ linux crt supports redirecting (not Esc-codes anymore)
This commit is contained in:
peter 1998-04-05 13:56:54 +00:00
parent b3d30402ce
commit d4b538a297
2 changed files with 75 additions and 27 deletions

View File

@ -41,7 +41,7 @@ Interface
{returns which button was pressed after last call to function} {returns which button was pressed after last call to function}
Function mouse_press(var x,y:Longint;button:Longint):Longint; Function mouse_press(var x,y:Longint;button:Longint):Longint;
{returns which button was realeased after last call to function} {returns which button was realeased after last call to function}
Function mouse_release (var row,col:Longint;button : Longint):integer; Function mouse_release (var x,y:Longint;button:Longint):integer;
{set's mouse y range} {set's mouse y range}
Procedure mouse_yrange (min,max:Longint); Procedure mouse_yrange (min,max:Longint);
{set's mouse y range} {set's mouse y range}
@ -54,6 +54,8 @@ Interface
Function IsRPressed:Boolean; Function IsRPressed:Boolean;
{return if left button pressed} {return if left button pressed}
Function IsLPressed:Boolean; Function IsLPressed:Boolean;
{return if middle button pressed}
Function IsMPressed:Boolean;
{return mouse X coordinate in textmode} {return mouse X coordinate in textmode}
Function MouseX:longint; Function MouseX:longint;
{return mouse Y coordinate in textmode} {return mouse Y coordinate in textmode}
@ -68,6 +70,8 @@ Var
Implementation Implementation
{$I386_ATT}
Function Check_Mouse:Boolean; Function Check_Mouse:Boolean;
begin begin
asm asm
@ -151,7 +155,7 @@ begin
end; end;
end; end;
function mouse_release (var row,col:Longint;button : Longint):integer; function mouse_release (var x,y:Longint;button : Longint):integer;
begin begin
{$IFDEF MOUSECHECK} {$IFDEF MOUSECHECK}
If (Not MouseFound) Then Exit; If (Not MouseFound) Then Exit;
@ -226,7 +230,7 @@ Begin
{$ENDIF} {$ENDIF}
asm asm
xorl %ebx,%ebx xorl %ebx,%ebx
movl $0xa,%ax movl $0xa,%eax
movl $0xff,%ecx movl $0xff,%ecx
xorl %edx,%edx xorl %edx,%edx
movb 8(%ebp),%dh movb 8(%ebp),%dh
@ -297,6 +301,7 @@ Begin
pushl %ebp pushl %ebp
int $0x33 int $0x33
popl %ebp popl %ebp
movl %ebx,%eax
shrl $1,%eax shrl $1,%eax
andl $1,%eax andl $1,%eax
movb %al,__RESULT movb %al,__RESULT
@ -313,6 +318,24 @@ Begin
pushl %ebp pushl %ebp
int $0x33 int $0x33
popl %ebp popl %ebp
movl %ebx,%eax
andl $1,%eax
movb %al,__RESULT
end;
end;
Function IsMPressed:Boolean;
Begin
{$IFDEF MOUSECHECK}
If (Not MouseFound) Then Exit;
{$ENDIF}
asm
movl $3,%eax
pushl %ebp
int $0x33
popl %ebp
movl %ebx,%eax
shrl $2,%eax
andl $1,%eax andl $1,%eax
movb %al,__RESULT movb %al,__RESULT
end; end;
@ -382,7 +405,11 @@ Begin
End. End.
{ {
$Log$ $Log$
Revision 1.2 1998-03-26 12:25:22 peter Revision 1.3 1998-04-05 13:56:54 peter
- fixed mouse to compile with $i386_att
+ linux crt supports redirecting (not Esc-codes anymore)
Revision 1.2 1998/03/26 12:25:22 peter
* integrated both mouse units * integrated both mouse units
Revision 1.1.1.1 1998/03/25 11:18:41 root Revision 1.1.1.1 1998/03/25 11:18:41 root

View File

@ -112,6 +112,8 @@ Var
ScrnCol : TScreenColors; ScrnCol : TScreenColors;
CurrX,CurrY : Byte; CurrX,CurrY : Byte;
ExitSave : Pointer; ExitSave : Pointer;
Redir : boolean; { is the output being redirected (not a TTY) }
{***************************************************************************** {*****************************************************************************
Some Handy Functions Not in the System.PP Some Handy Functions Not in the System.PP
@ -432,7 +434,15 @@ begin
y:=CurrY; y:=CurrY;
CurrY:=$ff; CurrY:=$ff;
end; end;
ttySendStr(XY2Ansi(x,y,CurrX,CurrY)); if Redir then
begin
if longint(y)-longint(CurrY)=1 then
ttySendStr(#10);
end
else
ttySendStr(XY2Ansi(x,y,CurrX,CurrY));
CurrX:=x; CurrX:=x;
CurrY:=y; CurrY:=y;
end; end;
@ -446,7 +456,9 @@ procedure ttyColor(a:byte);
begin begin
if a<>TextAttr then if a<>TextAttr then
begin begin
ttySendStr(Attr2Ansi(a,TextAttr)); if not Redir then
ttySendStr(Attr2Ansi(a,TextAttr));
TextAttr:=a; TextAttr:=a;
OldTextAttr:=a; OldTextAttr:=a;
end; end;
@ -678,7 +690,8 @@ Begin
oldflush:=ttySetFlush(Flushing); oldflush:=ttySetFlush(Flushing);
if FullWin then if FullWin then
begin begin
ttySendStr(#27'[H'#27'[2J'); if not Redir then
ttySendStr(#27'[H'#27'[2J');
CurrX:=1; CurrX:=1;
CurrY:=1; CurrY:=1;
FillChar(Scrn,sizeof(Scrn),' '); FillChar(Scrn,sizeof(Scrn),' ');
@ -701,15 +714,15 @@ Procedure ClrEol;
} }
Begin Begin
if FullWin then if FullWin then
ttySendStr(#27'[K')
else
begin begin
if not Redir then
ttySendStr(#27'[K');
end
else
begin
ttySendStr(Space(WinMaxX-CurrX)); ttySendStr(Space(WinMaxX-CurrX));
ttyGotoXY(0,CurrY); ttyGotoXY(0,CurrY);
end; end;
End; End;
@ -995,7 +1008,6 @@ Begin
end; end;
if State=1 then if State=1 then
PushKey(ch); PushKey(ch);
end end
else else
Begin Begin
@ -1187,12 +1199,11 @@ end;
Function CrtWrite(Var F: TextRec): Integer; Function CrtWrite(Var F: TextRec): Integer;
{ {
Top level write function for CRT Top level write function for CRT
} }
Var Var
Temp : String; Temp : String;
Begin Begin
Move(F.BufPTR^[0],Temp[1],F.BufPos); Move(F.BufPTR^[0],Temp[1],F.BufPos);
temp[0]:=chr(F.BufPos); temp[0]:=chr(F.BufPos);
@ -1235,7 +1246,7 @@ Function CrtRead(Var F: TextRec): Integer;
Read from CRT associated file. Read from CRT associated file.
} }
Begin Begin
F.BufEnd:=fdRead(LongInt(F.Handle), F.BufPtr^, F.BufSize); F.BufEnd:=fdRead(F.Handle, F.BufPtr^, F.BufSize);
F.BufPos:=F.BufEnd; F.BufPos:=F.BufEnd;
CrtWrite(F); CrtWrite(F);
CrtRead:=0; CrtRead:=0;
@ -1409,26 +1420,36 @@ Begin
AssignCrt(Input); AssignCrt(Input);
TextRec(Output).Mode:=fmOutput; TextRec(Output).Mode:=fmOutput;
TextRec(Input).Mode:=fmInput; TextRec(Input).Mode:=fmInput;
Redir:=not IsAtty(TextRec(Output).Handle);
{Set default Terminal Settings} {Set default Terminal Settings}
SetRawMode(True); SetRawMode(True);
{Get Current X&Y or Reset to Home} {Get Current X&Y or Reset to Home}
if Redir then
GetXY(CurrX,CurrY);
if (CurrX=0) then
begin begin
CurrX:=1; CurrX:=1;
CurrY:=1; CurrY:=1;
ttySendStr(#27'[H'); end
end; else
begin
{Reset Attribute (TextAttr=7 at startup)} GetXY(CurrX,CurrY);
if (CurrX=0) then
ttySendStr(#27'[m'); begin
CurrX:=1;
CurrY:=1;
ttySendStr(#27'[H');
end;
{Reset Attribute (TextAttr=7 at startup)}
ttySendStr(#27'[m');
end;
End. End.
{ {
$Log$ $Log$
Revision 1.1 1998-03-25 11:18:43 root Revision 1.2 1998-04-05 13:56:54 peter
Initial revision - fixed mouse to compile with $i386_att
+ linux crt supports redirecting (not Esc-codes anymore)
Revision 1.1.1.1 1998/03/25 11:18:43 root
* Restored version
Revision 1.10 1998/03/16 23:38:52 peter Revision 1.10 1998/03/16 23:38:52 peter
+ support for textattr:= setting between writes + support for textattr:= setting between writes