Home

Add

Edit

With Linenumbers

Code in Textfield

Download

'##############################################################################################################################
Function TGS_Refresh(V_Client As TGS_Client_Type Ptr) As String
'Print #G_STDOutFN, "==REFRESH=="
Dim D As String

Dim TPtr As Uinteger
Dim TPtrOption2 As Ubyte Ptr = Cast(Ubyte Ptr, @TPtr) + 3
Dim TPtrOption1 As Ubyte Ptr = Cast(Ubyte Ptr, @TPtr) + 2
Dim TPtrOption As Ushort Ptr = Cast(Ushort Ptr, @TPtr) + 1
Dim TPtrColor As Ubyte Ptr = Cast(Ubyte Ptr, @TPtr) + 1
Dim TPtrText As Ubyte Ptr = Cast(Ubyte Ptr, @TPtr) + 0

Dim TTemp As Uinteger
Dim TTempOption2 As Ubyte Ptr = Cast(Ubyte Ptr, @TTemp) + 3
Dim TTempOption1 As Ubyte Ptr = Cast(Ubyte Ptr, @TTemp) + 2
Dim TTempOption As Ushort Ptr = Cast(Ushort Ptr, @TTemp) + 1
Dim TTempColor As Ubyte Ptr = Cast(Ubyte Ptr, @TTemp) + 1
Dim TTempText As Ubyte Ptr = Cast(Ubyte Ptr, @TTemp) + 0

Dim TLast As Uinteger
Dim TLastOption2 As Ubyte Ptr = Cast(Ubyte Ptr, @TLast) + 3
Dim TLastOption1 As Ubyte Ptr = Cast(Ubyte Ptr, @TLast) + 2
Dim TLastOption As Ushort Ptr = Cast(Ushort Ptr, @TLast) + 1
Dim TLastColor As Ubyte Ptr = Cast(Ubyte Ptr, @TLast) + 1
Dim TLastText As Ubyte Ptr = Cast(Ubyte Ptr, @TLast) + 0

Dim TMax As Uinteger
Dim TLastPos As Uinteger
Dim TLastX As Uinteger
Dim TLastY As Uinteger
Dim TCurX As Uinteger
Dim TCurY As Uinteger
Dim TSendChr As Ubyte

Dim TPrintMore As Ubyte
Dim THead As String

With *V_Client
    TMax = .V_ValWindow_Width * .V_ValWindow_Height
    If .V_FullUpdate = 1 Then
        For X As Uinteger = 0 To TMax - 1
            .V_ScreenBufferView[X] = &B00000000000000000000011100100000
        Next
        THead += Chr(27) & "[2J"
    End If
    THead += Chr(27) & "[H" & Chr(27) & "[0m" & Chr(27) & "[?25h"
    For X As Uinteger = 0 To TMax - 1
        If (.V_ScreenBufferBS[X] <> .V_ScreenBufferView[X]) Or (.V_FullUpdate = 1) Then
            TPtr = .V_ScreenBufferBS[X]
            TTemp = .V_ScreenBufferView[X]
            If X > (TLastPos + 1) Then
                TCurX = X Mod .V_ValWindow_Width
                TCurY = Fix(X \ .V_ValWindow_Width)
                TLastX = TLastPos Mod .V_ValWindow_Width
                TLastY = Fix(TLastPos \ .V_ValWindow_Width)
                If (TLastX = TCurX) And (TLastY + 1 = TCurY) Then
                    D += Chr(27) & "[1B"
                    TLast = 0
                Else
                    D += Chr(27) & "[" & Str(TCurY + 1) & ";" & Str(TCurX + 1) & "H"
                    If (TCurY = TLastY) And (TCurX > TLastX) Then
                        For XX As Uinteger = TLastX To TCurX - 1
                            If (TCurY * .V_ValWindow_Width * XX) >= TMax Then TLast = 0: Exit For
                            If .V_ScreenBufferBS[TCurY * .V_ValWindow_Width * XX] <> TLast Then TLast = 0: Exit For
                        Next
                    End If
                End If
            End If
            TLastPos = X
            If (TLast = 0) Or (*TLastColor <> *TPtrColor) Or (*TLastOption <> *TPtrOption) Or (.V_FullUpdate = 1) Then
                If (TLast = 0) Or (*TLastColor <> *TPtrColor) Or (.V_FullUpdate = 1) Then
                    D += Chr(27) & "[" & Str(30 + (*TPtrColor And &B00000111)) & "m"
                    D += Chr(27) & "[" & Str(40 + (*TPtrColor And &B00111000) Shr 3) & "m"
                End If
                If (TLast = 0) Or ((*TLastOption1 And TGS_Bold) <> (*TPtrOption1 And TGS_Bold)) Or (.V_FullUpdate = 1) Then
                    If (*TPtrOption1 And TGS_Bold) <> 0 Then
                        D += Chr(27) & "[1m"
                    Else: D += Chr(27) & "[21m"
                    End If
                End If
                If (TLast = 0) Or ((*TLastOption1 And TGS_Underline) <> (*TPtrOption1 And TGS_Underline)) Or (.V_FullUpdate = 1) Then
                    If (*TPtrOption1 And TGS_Underline) <> 0 Then
                        D += Chr(27) & "[4m"
                    Else: D += Chr(27) & "[24m"
                    End If
                End If
                If (TLast = 0) Or ((*TLastOption1 And (TGS_BlinkSlow Or TGS_BlinkFast)) <> (*TPtrOption1 And (TGS_BlinkSlow Or TGS_BlinkFast))) Or (.V_FullUpdate = 1) Then
                    Select Case (*TPtrOption1 And (TGS_BlinkSlow Or TGS_BlinkFast))
                        Case TGS_BlinkSlow: D += Chr(27) & "[5m"
                        Case TGS_BlinkFast: D += Chr(27) & "[6m"
                        Case Else: D += Chr(27) & "[25m"
                    End Select
                End If
            End If
            D += Chr(*TPtrText)
'           If .V_Scroll1 > 0 Then Print #G_STDOutFN, "REFRESH: Chr:>"; Chr(*TPtrText); "<"
            .V_ScreenBufferView[X] = .V_ScreenBufferBS[X]
            TLast = .V_ScreenBufferView[X]
        End If
    Next
'   Print #G_STDOutFN, "============ DatLen:"; Len(D)
'   Kill "temp."dat
'   dim tfn as integer = freefile
'   Open "temp."dat for output as #tfn
'   print #tfn, D;
'   close #tfn
    .V_FullUpdate = 0
End With
'Print #G_STDOutFN, "--REFRESH--"
If D = "" Then Return ""
D = THead & D & Chr(27) & "[H"
'Print #G_STDOutFN, "DatLen:"; Len(D)
Return D
End Function