From 2b3cbd921798dd616f6ba368141ba48d921aacc7 Mon Sep 17 00:00:00 2001 From: gambas Date: Sat, 21 Apr 2018 20:38:57 +0200 Subject: [PATCH] TerminalView: Fix "EraseStartOfLine" VT-100 command and remove "Erase screen" optimization. [GB.FORM.TERMINAL] * BUG: TerminalView: Remove "Erase screen" optimization. * BUG: TerminalView: Fix "EraseStartOfLine" VT-100 command. --- .../.src/TerminalView/FTestTerminalView.class | 10 ++++----- .../TerminalView/TerminalFilter_VT100.class | 22 ++++++++++++++----- .../.src/TerminalView/TerminalScreen.class | 8 +++---- .../.src/TerminalView/TerminalView.class | 21 ++++++++++++------ 4 files changed, 39 insertions(+), 22 deletions(-) diff --git a/comp/src/gb.form.terminal/.src/TerminalView/FTestTerminalView.class b/comp/src/gb.form.terminal/.src/TerminalView/FTestTerminalView.class index 6721b6775..a2044ec00 100644 --- a/comp/src/gb.form.terminal/.src/TerminalView/FTestTerminalView.class +++ b/comp/src/gb.form.terminal/.src/TerminalView/FTestTerminalView.class @@ -119,8 +119,8 @@ Public Sub Button6_Click() End -Public Sub TerminalView1_Resize(W As Integer, H As Integer) - - Debug W;; H - -End +' Public Sub TerminalView1_Resize(W As Integer, H As Integer) +' +' Debug W;; H +' +' End diff --git a/comp/src/gb.form.terminal/.src/TerminalView/TerminalFilter_VT100.class b/comp/src/gb.form.terminal/.src/TerminalView/TerminalFilter_VT100.class index 250ed44ca..7e968dfe0 100644 --- a/comp/src/gb.form.terminal/.src/TerminalView/TerminalFilter_VT100.class +++ b/comp/src/gb.form.terminal/.src/TerminalView/TerminalFilter_VT100.class @@ -9,6 +9,7 @@ Private Enum MODE_AppScreen, MODE_AppCuKeys, MODE_AppKeyPad, MODE_Mouse1000, MOD Private $aMode As New Boolean[13] 'Private $aSavedMode As New Boolean[13] Private $sLeft As String +Private $iCpt As Integer Public Sub Reset() @@ -43,8 +44,10 @@ Public Sub OutputTo(hView As TerminalView, hScreen As TerminalScreen, hOutput As For iPos = Len(sData) DownTo 1 If Asc(sData, iPos) >= 192 Then Break Next - 'Debug "not valid";; iPos; " / "; Len(sData) - 'Debug Quote(Right(sData, 256)) + If TerminalScreen.DEBUG_FILTER Then + Debug "not valid";; iPos; " / "; Len(sData) + Debug Quote(Right(sData, 256)) + Endif If iPos = 0 Then Return $sLeft = Mid$(sData, iPos) sData = Left(sData, iPos - 1) @@ -55,7 +58,7 @@ Public Sub OutputTo(hView As TerminalView, hScreen As TerminalScreen, hOutput As 'Debug If(hProcess.Term.GetAttr().ONLCR, "+", "-"); "ONLCR" 'If Len(sData) >= 4096 Then - iPosEraseScreen = RInStr(sData, "\e[2J") + 'iPosEraseScreen = RInStr(sData, "\e[2J") 'If iPosEraseScreen > 0 Then Debug "erase screen at "; iPosEraseScreen 'Endif @@ -174,12 +177,19 @@ Private Sub Escape(hView As TerminalView, hScreen As TerminalScreen, hOutput As sStr = Mid$(sData, iPos, iLen) If hScreen.DEBUG_FILTER Then - Debug "ESC"; + Inc $iCpt + Error Format($iCpt, "######0"); " | "; + Error "ESC"; For I = 1 To Len(sStr) Error " "; Mid$(sStr, I, 1); Next Error - hScreen.DebugRefresh + If $iCpt > 5120 Then + hScreen.DebugRefresh + hView.Suspended = True + Stop + hView.Suspended = False + Endif Endif Select Case Left(sStr) @@ -477,7 +487,7 @@ Private Sub Escape(hView As TerminalView, hScreen As TerminalScreen, hOutput As Case "12" 'Ignored Case "25" ' Hide cursor - hScreen.HideCursor = True + If Not hScreen.DEBUG_FILTER Then hScreen.HideCursor = True Case "47" $aMode[MODE_AppScreen] = False hView.AlternateScreen = False diff --git a/comp/src/gb.form.terminal/.src/TerminalView/TerminalScreen.class b/comp/src/gb.form.terminal/.src/TerminalView/TerminalScreen.class index aee60eb55..dc6ae835c 100644 --- a/comp/src/gb.form.terminal/.src/TerminalView/TerminalScreen.class +++ b/comp/src/gb.form.terminal/.src/TerminalView/TerminalScreen.class @@ -262,7 +262,7 @@ Public Sub Print(sText As String) If sElt Then If DEBUG_FILTER Then - Debug Quote(sElt) + Error Quote(sElt) DebugRefresh Endif @@ -276,7 +276,7 @@ Public Sub Print(sText As String) iCode = Asc(sText, iLen + 1) If DEBUG_FILTER Then - Debug "^" & Chr$(64 + iCode) + Error "^" & Chr$(64 + iCode) DebugRefresh Endif @@ -531,7 +531,7 @@ Public Sub EraseStartOfLine() If hLine.Length <= $X Then hLine.Clear() Else - hLine.Text = Space$($X + 1) & String.Mid$(hLine.Text, $X + 1) + hLine.Text = Space$($X + 1) & String.Mid$(hLine.Text, $X + 2) Endif GetView()._RefreshLine($Y) @@ -1168,7 +1168,7 @@ End Public Sub DebugRefresh() If DEBUG_FILTER Then - Return + If GetView()._DisableFilter Then Return GetView().Refresh Inc GetView()._DisableFilter Wait diff --git a/comp/src/gb.form.terminal/.src/TerminalView/TerminalView.class b/comp/src/gb.form.terminal/.src/TerminalView/TerminalView.class index b06a96215..8dff5b1ea 100644 --- a/comp/src/gb.form.terminal/.src/TerminalView/TerminalView.class +++ b/comp/src/gb.form.terminal/.src/TerminalView/TerminalView.class @@ -925,10 +925,14 @@ Public Sub Process_Read() $sBuffer &= sData Endif - If (Timer - $fStart) >= 0.05 Then - $hOutputTimer.Trigger + If TerminalScreen.DEBUG_FILTER Then + If _DisableFilter = 0 Then $hOutputTimer.Trigger Else - $hOutputTimer.Restart + If (Timer - $fStart) >= 0.05 Then + $hOutputTimer.Trigger + Else + $hOutputTimer.Restart + Endif Endif End @@ -944,14 +948,17 @@ End Public Sub OutputTimer_Timer() Dim hOutput As Stream + Dim sBuffer As String $fStart = Timer - hOutput = GetOutputStream() - If hOutput Then $hFilter.OutputTo(Me, $hScreen, hOutput, $sBuffer) - - $sBuffer = "" $hOutputTimer.Stop + + hOutput = GetOutputStream() + sBuffer = $sBuffer + $sBuffer = "" + If hOutput Then $hFilter.OutputTo(Me, $hScreen, hOutput, sBuffer) + EnsureVisible End