Home

Add

Edit

Without Linenumbers

Code in Textfield

Download

  1. '##############################################################################################################################
    
  2. Function TGS_Refresh(V_Client As TGS_Client_Type Ptr) As String
    
  3. 'Print #G_STDOutFN, "==REFRESH=="
    
  4. Dim D As String
    
  5. 
    
  6. Dim TPtr As Uinteger
    
  7. Dim TPtrOption2 As Ubyte Ptr = Cast(Ubyte Ptr, @TPtr) + 3
    
  8. Dim TPtrOption1 As Ubyte Ptr = Cast(Ubyte Ptr, @TPtr) + 2
    
  9. Dim TPtrOption As Ushort Ptr = Cast(Ushort Ptr, @TPtr) + 1
    
  10. Dim TPtrColor As Ubyte Ptr = Cast(Ubyte Ptr, @TPtr) + 1
    
  11. Dim TPtrText As Ubyte Ptr = Cast(Ubyte Ptr, @TPtr) + 0
    
  12. 
    
  13. Dim TTemp As Uinteger
    
  14. Dim TTempOption2 As Ubyte Ptr = Cast(Ubyte Ptr, @TTemp) + 3
    
  15. Dim TTempOption1 As Ubyte Ptr = Cast(Ubyte Ptr, @TTemp) + 2
    
  16. Dim TTempOption As Ushort Ptr = Cast(Ushort Ptr, @TTemp) + 1
    
  17. Dim TTempColor As Ubyte Ptr = Cast(Ubyte Ptr, @TTemp) + 1
    
  18. Dim TTempText As Ubyte Ptr = Cast(Ubyte Ptr, @TTemp) + 0
    
  19. 
    
  20. Dim TLast As Uinteger
    
  21. Dim TLastOption2 As Ubyte Ptr = Cast(Ubyte Ptr, @TLast) + 3
    
  22. Dim TLastOption1 As Ubyte Ptr = Cast(Ubyte Ptr, @TLast) + 2
    
  23. Dim TLastOption As Ushort Ptr = Cast(Ushort Ptr, @TLast) + 1
    
  24. Dim TLastColor As Ubyte Ptr = Cast(Ubyte Ptr, @TLast) + 1
    
  25. Dim TLastText As Ubyte Ptr = Cast(Ubyte Ptr, @TLast) + 0
    
  26. 
    
  27. Dim TMax As Uinteger
    
  28. Dim TLastPos As Uinteger
    
  29. Dim TLastX As Uinteger
    
  30. Dim TLastY As Uinteger
    
  31. Dim TCurX As Uinteger
    
  32. Dim TCurY As Uinteger
    
  33. Dim TSendChr As Ubyte
    
  34. 
    
  35. Dim TPrintMore As Ubyte
    
  36. Dim THead As String
    
  37. 
    
  38. With *V_Client
    
  39.     TMax = .V_ValWindow_Width * .V_ValWindow_Height
    
  40.     If .V_FullUpdate = 1 Then
    
  41.         For X As Uinteger = 0 To TMax - 1
    
  42.             .V_ScreenBufferView[X] = &B00000000000000000000011100100000
    
  43.         Next
    
  44.         THead += Chr(27) & "[2J"
    
  45.     End If
    
  46.     THead += Chr(27) & "[H" & Chr(27) & "[0m" & Chr(27) & "[?25h"
    
  47.     For X As Uinteger = 0 To TMax - 1
    
  48.         If (.V_ScreenBufferBS[X] <> .V_ScreenBufferView[X]) Or (.V_FullUpdate = 1) Then
    
  49.             TPtr = .V_ScreenBufferBS[X]
    
  50.             TTemp = .V_ScreenBufferView[X]
    
  51.             If X > (TLastPos + 1) Then
    
  52.                 TCurX = X Mod .V_ValWindow_Width
    
  53.                 TCurY = Fix(X \ .V_ValWindow_Width)
    
  54.                 TLastX = TLastPos Mod .V_ValWindow_Width
    
  55.                 TLastY = Fix(TLastPos \ .V_ValWindow_Width)
    
  56.                 If (TLastX = TCurX) And (TLastY + 1 = TCurY) Then
    
  57.                     D += Chr(27) & "[1B"
    
  58.                     TLast = 0
    
  59.                 Else
    
  60.                     D += Chr(27) & "[" & Str(TCurY + 1) & ";" & Str(TCurX + 1) & "H"
    
  61.                     If (TCurY = TLastY) And (TCurX > TLastX) Then
    
  62.                         For XX As Uinteger = TLastX To TCurX - 1
    
  63.                             If (TCurY * .V_ValWindow_Width * XX) >= TMax Then TLast = 0: Exit For
    
  64.                             If .V_ScreenBufferBS[TCurY * .V_ValWindow_Width * XX] <> TLast Then TLast = 0: Exit For
    
  65.                         Next
    
  66.                     End If
    
  67.                 End If
    
  68.             End If
    
  69.             TLastPos = X
    
  70.             If (TLast = 0) Or (*TLastColor <> *TPtrColor) Or (*TLastOption <> *TPtrOption) Or (.V_FullUpdate = 1) Then
    
  71.                 If (TLast = 0) Or (*TLastColor <> *TPtrColor) Or (.V_FullUpdate = 1) Then
    
  72.                     D += Chr(27) & "[" & Str(30 + (*TPtrColor And &B00000111)) & "m"
    
  73.                     D += Chr(27) & "[" & Str(40 + (*TPtrColor And &B00111000) Shr 3) & "m"
    
  74.                 End If
    
  75.                 If (TLast = 0) Or ((*TLastOption1 And TGS_Bold) <> (*TPtrOption1 And TGS_Bold)) Or (.V_FullUpdate = 1) Then
    
  76.                     If (*TPtrOption1 And TGS_Bold) <> 0 Then
    
  77.                         D += Chr(27) & "[1m"
    
  78.                     Else: D += Chr(27) & "[21m"
    
  79.                     End If
    
  80.                 End If
    
  81.                 If (TLast = 0) Or ((*TLastOption1 And TGS_Underline) <> (*TPtrOption1 And TGS_Underline)) Or (.V_FullUpdate = 1) Then
    
  82.                     If (*TPtrOption1 And TGS_Underline) <> 0 Then
    
  83.                         D += Chr(27) & "[4m"
    
  84.                     Else: D += Chr(27) & "[24m"
    
  85.                     End If
    
  86.                 End If
    
  87.                 If (TLast = 0) Or ((*TLastOption1 And (TGS_BlinkSlow Or TGS_BlinkFast)) <> (*TPtrOption1 And (TGS_BlinkSlow Or TGS_BlinkFast))) Or (.V_FullUpdate = 1) Then
    
  88.                     Select Case (*TPtrOption1 And (TGS_BlinkSlow Or TGS_BlinkFast))
    
  89.                         Case TGS_BlinkSlow: D += Chr(27) & "[5m"
    
  90.                         Case TGS_BlinkFast: D += Chr(27) & "[6m"
    
  91.                         Case Else: D += Chr(27) & "[25m"
    
  92.                     End Select
    
  93.                 End If
    
  94.             End If
    
  95.             D += Chr(*TPtrText)
    
  96. '           If .V_Scroll1 > 0 Then Print #G_STDOutFN, "REFRESH: Chr:>"; Chr(*TPtrText); "<"
    
  97.             .V_ScreenBufferView[X] = .V_ScreenBufferBS[X]
    
  98.             TLast = .V_ScreenBufferView[X]
    
  99.         End If
    
  100.     Next
    
  101. '   Print #G_STDOutFN, "============ DatLen:"; Len(D)
    
  102. '   Kill "temp."dat
    
  103. '   dim tfn as integer = freefile
    
  104. '   Open "temp."dat for output as #tfn
    
  105. '   print #tfn, D;
    
  106. '   close #tfn
    
  107.     .V_FullUpdate = 0
    
  108. End With
    
  109. 'Print #G_STDOutFN, "--REFRESH--"
    
  110. If D = "" Then Return ""
    
  111. D = THead & D & Chr(27) & "[H"
    
  112. 'Print #G_STDOutFN, "DatLen:"; Len(D)
    
  113. Return D
    
  114. End Function