fb:porticula NoPaste
multikey and inkey
Uploader: | Eternal_Pain |
Datum/Zeit: | 20.09.2007 13:00:20 |
Sub EInput (Byval NULL as any ptr)
' Dim IMessage as Message_Dat_Interface
' IMessage.NickName = InterfaceName
' IMessage.MsgCol = 15 'weiss
Static inputmaxlen As Integer=450
Static StartX As Integer= 1
Static StartY As Integer=25
Static FeedLen As Integer=79
Static FontColor As Integer= 0
Static BackColor As Integer=15
Dim key As String*2
Dim cursor As Integer=1
Dim inputstring As String
Dim FRefresh As Byte=1
Dim ViewString As String
Dim VCursor As Integer
Dim SS As Integer
Dim SE As Integer
Color FontColor,BackColor
Locate StartY,StartX,0:?Space(FeedLen);
Color 0,7
Locate StartY,StartX,0:?Chr(32);
Color 0,14
Do
key=inkey
If Multikey(&h0E) Then 'BackSpace
If Len(inputstring) And (Cursor > 1) Then
inputstring = Left(inputstring, Cursor - 2) + Right(inputstring, Len(inputstring) - Cursor + 1)
If Cursor>1 Then Cursor -= 1
sleep (66),1
FRefresh = 1
End If
ElseIf Multikey(&h53) Then 'Del
If (Cursor <= Len(inputstring)) Then
inputstring = Left(inputstring, Cursor - 1) + Right(inputstring, Len(inputstring) - Cursor)
sleep (55),1
FRefresh = 1
End If
ElseIf Multikey(&h1C) Then 'Enter
If len(inputstring) Then
' Interface_Messages_Refresh_Flag = 1
' IMessage.Message = inputstring
inputstring = ""
' Interface_Send (IMessage)
Cursor=1
sleep (5),1
FRefresh = 1
End If
ElseIf MultiKey(&h01) Then 'ESC
inputstring=""
Cursor = 1
sleep (55),1
FRefresh = 1
ElseIf MultiKey(&h4B) Then 'Left
If Cursor > 1 Then
Cursor -= 1
sleep (55),1
FRefresh = 1
End If
ElseIf MultiKey(&h4D) Then 'Right
If Cursor And (Cursor <= Len(inputstring)) Then
Cursor += 1
sleep (55),1
FRefresh = 1
End If
ElseIf MultiKey(&h47) Then 'Home/Pos1
Cursor = 1
sleep (55),1
FRefresh = 1
ElseIf MultiKey(&h4F) Then 'End
If Cursor Then
Cursor = Len(inputstring)+1
sleep (55),1
FRefresh = 1
End If
End If
If key[0]>31 and key[0]<256 Then
If key[0]=255 Then
If key[1]=107 then
' Interface_Close (0)
end
End If
Else
If ( Len(inputstring) < inputmaxlen ) Then
inputstring = Left(inputstring, Cursor - 1) + Key + Right(inputstring, Len(inputstring) - (Cursor-1) )
Cursor += 1
FRefresh = 1
End If
End If
End If
If FRefresh Then
SS=Cursor-(FeedLen)
SS=Iif(SS<1,1,SS)
SE=SS+(FeedLen)
SE=Iif(SE>Len(inputstring),Len(inputstring),SE)
ViewString=Mid(inputstring,SS,1+(SE-SS))
VCursor=Iif(SS>1,Cursor-(SS-1),Cursor)
' MutexLock (ThreadHandle)
Color FontColor,BackColor
Locate StartY,StartX,0
?ViewString+Space((FeedLen+1)-Len(ViewString));
color 7
If SS>1 And VCursor>4 Then
Locate StartY,StartX,0
?"...<<";
End If
If SE<Len(inputstring) And VCursor<(FeedLen-4) Then
Locate StartY,(StartX+FeedLen)-5,0
?">>...";
End If
Color 15,7
Locate StartY,(StartX-1)+VCursor,0
?Chr(Screen (StartY, (StartX-1)+VCursor, 0));
' MutexUnlock (ThreadHandle)
FRefresh = 0
End If
Sleep (1)
Loop
End Sub
'-----------------------------------------------------------------------------'
EInput(0)