From 62fefce8f7ee1a7e9471778530447e8179b3d9a1 Mon Sep 17 00:00:00 2001 From: gambas Date: Mon, 10 Sep 2018 20:49:46 +0200 Subject: [PATCH] TerminalView: Animate scrolling when Application.Animations property is TRUE. [GB.FORM.TERMINAL] * NEW: TerminalView: Animate scrolling when Application.Animations property is TRUE. --- comp/src/gb.form.terminal/.project | 1 + .../.src/TerminalView/FTestTerminalView.class | 1 + .../TerminalView/TerminalFilter_VT100.class | 32 ++++++++--------- .../.src/TerminalView/TerminalView.class | 35 +++++++++++++++++-- 4 files changed, 50 insertions(+), 19 deletions(-) diff --git a/comp/src/gb.form.terminal/.project b/comp/src/gb.form.terminal/.project index 4451773c7..aaa5a0043 100644 --- a/comp/src/gb.form.terminal/.project +++ b/comp/src/gb.form.terminal/.project @@ -11,6 +11,7 @@ Component=gb.form Component=gb.term Component=gb.net Authors="BenoƮt Minisini\nFabien Bodard" +Environment="GB_JIT_DEBUG=0" TabSize=2 Language=fr Type=Component diff --git a/comp/src/gb.form.terminal/.src/TerminalView/FTestTerminalView.class b/comp/src/gb.form.terminal/.src/TerminalView/FTestTerminalView.class index a2044ec00..18c953788 100644 --- a/comp/src/gb.form.terminal/.src/TerminalView/FTestTerminalView.class +++ b/comp/src/gb.form.terminal/.src/TerminalView/FTestTerminalView.class @@ -27,6 +27,7 @@ End Public Sub Form_Open() 'Exec ["stty", "onlcr"] Wait + Application.Animations = True TerminalView1.Exec(["bash"]) 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 4df358143..0b9f95bb0 100644 --- a/comp/src/gb.form.terminal/.src/TerminalView/TerminalFilter_VT100.class +++ b/comp/src/gb.form.terminal/.src/TerminalView/TerminalFilter_VT100.class @@ -9,7 +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 +'Private $iCpt As Integer Public Sub Reset() @@ -176,21 +176,21 @@ Private Sub Escape(hView As TerminalView, hScreen As TerminalScreen, hOutput As sStr = Mid$(sData, iPos, iLen) - If hScreen.DEBUG_FILTER Then - Inc $iCpt - Error Format($iCpt, "######0"); " | "; - Error "ESC"; - For I = 1 To Len(sStr) - Error " "; Mid$(sStr, I, 1); - Next - Error - If $iCpt > 5120 Then - hScreen.DebugRefresh - hView.Suspended = True - Stop - hView.Suspended = False - Endif - Endif + ' If hScreen.DEBUG_FILTER Then + ' Inc $iCpt + ' Error Format($iCpt, "######0"); " | "; + ' Error "ESC"; + ' For I = 1 To Len(sStr) + ' Error " "; Mid$(sStr, I, 1); + ' Next + ' Error + ' If $iCpt > 5120 Then + ' hScreen.DebugRefresh + ' hView.Suspended = True + ' Stop + ' hView.Suspended = False + ' Endif + ' Endif Select Case Left(sStr) diff --git a/comp/src/gb.form.terminal/.src/TerminalView/TerminalView.class b/comp/src/gb.form.terminal/.src/TerminalView/TerminalView.class index 8dff5b1ea..727da24e9 100644 --- a/comp/src/gb.form.terminal/.src/TerminalView/TerminalView.class +++ b/comp/src/gb.form.terminal/.src/TerminalView/TerminalView.class @@ -90,6 +90,11 @@ Private $fLastMouseDownY As Integer Private mnuPopup As Menu +Private $iScrollY As Integer +Private $iTargetY As Integer +Private $hTimerScroll As Timer +Private $bIgnoreNextAnimation As Boolean + 'Private $bDoubleFont As Boolean = True Public Sub _new() @@ -369,7 +374,7 @@ End Private Sub GetScrollY() As Integer - Return $hScroll.Value + Return $iScrollY '$hScroll.Value End @@ -384,7 +389,7 @@ Public Sub View_Draw() ApplyLimit - $hScreen.Paint(GetScrollY() * $LH, $LH, $CW, $iAscent, $bHideCursor, $hCacheFont) + $hScreen.Paint(GetScrollY(), $LH, $CW, $iAscent, $bHideCursor, $hCacheFont) If $bTermUseMouse Then Paint.FillRect($iMouseX * $CW, $iMouseY * $LH, $CW, $LH, Color.SetAlpha(Color.SelectedBackground, 64)) @@ -998,10 +1003,33 @@ End Public Sub ScrollBar_Change() - Refresh + $iTargetY = $hScroll.Value * $LH + If $iTargetY <> $iScrollY Then + If Application.Animations And If Not $bIgnoreNextAnimation Then + If Not $hTimerScroll Then + $hTimerScroll = New Timer As "TimerScroll" + $hTimerScroll.Delay = 20 + Endif + $hTimerScroll.Start + Else + $bIgnoreNextAnimation = False + $iScrollY = $iTargetY + $hView.Refresh + Endif + Endif End +Public Sub TimerScroll_Timer() + + $iScrollY += ($iTargetY - $iScrollY + Sgn($iTargetY - $iScrollY)) \ 2 + $hView.Refresh + + If $iScrollY = $iTargetY Then $hTimerScroll.Stop + +End + + Public Sub Kill() If $hProcess Then @@ -1078,6 +1106,7 @@ End Public Sub _ShowScreen() + $bIgnoreNextAnimation = True $hScroll.Value = $hScreen.ScreenTop() Refresh