From 85c8320fe4aa134d6131040fdd9c63021ea88575 Mon Sep 17 00:00:00 2001 From: gambas Date: Tue, 2 Mar 2021 18:59:47 +0100 Subject: [PATCH] TerminalView: Support for terminal bell. [GB.FORM.TERMINAL] * NEW: TerminalView: Handle terminal bell with a screen flash. * NEW: TerminalView: 'Bell' is new event that is raised when the terminal bells, and that overrides the default behaviour if handled. --- .../.src/TerminalView/TerminalLink.class | 2 +- .../.src/TerminalView/TerminalScreen.class | 7 ++++ .../.src/TerminalView/TerminalView.class | 33 +++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/comp/src/gb.form.terminal/.src/TerminalView/TerminalLink.class b/comp/src/gb.form.terminal/.src/TerminalView/TerminalLink.class index 13af63988..d525eeeb9 100644 --- a/comp/src/gb.form.terminal/.src/TerminalView/TerminalLink.class +++ b/comp/src/gb.form.terminal/.src/TerminalView/TerminalLink.class @@ -30,7 +30,7 @@ End Public Sub Select(Start As Integer, Length As Integer, Optional (Type) As String) - GetView()._SelectLink(Start, Length, Type) + If _Pos >= Start And If _Pos < (Start + Length) Then GetView()._SelectLink(Start, Length, Type) End diff --git a/comp/src/gb.form.terminal/.src/TerminalView/TerminalScreen.class b/comp/src/gb.form.terminal/.src/TerminalView/TerminalScreen.class index 6cc323052..dc334b236 100644 --- a/comp/src/gb.form.terminal/.src/TerminalView/TerminalScreen.class +++ b/comp/src/gb.form.terminal/.src/TerminalView/TerminalScreen.class @@ -433,6 +433,7 @@ Public Sub Print(sText As String) Select Case iCode Case 7 + Bell Case 8 CursorLeft Case 9 @@ -2447,3 +2448,9 @@ Public Sub SetLink(Optional X1 As Integer, Y1 As Integer, X2 As Integer, Y2 As I $LY2 = Y2 End + +Private Sub Bell() + + GetView()._Bell() + +End diff --git a/comp/src/gb.form.terminal/.src/TerminalView/TerminalView.class b/comp/src/gb.form.terminal/.src/TerminalView/TerminalView.class index 1cae77fcd..1a54758df 100644 --- a/comp/src/gb.form.terminal/.src/TerminalView/TerminalView.class +++ b/comp/src/gb.form.terminal/.src/TerminalView/TerminalView.class @@ -23,6 +23,8 @@ Event Link '' '' The [./link] property will return an object that gives you the text of the link. Event Click +'' This event is raised when the terminal wants to emit a bell +Event Bell '' Return or set if the terminal view has a border. Property Border As Boolean @@ -157,6 +159,9 @@ Private $bSetLink As Boolean Private $iLinkY As Integer Private $iLinkLength As Integer +Private $bBell As Boolean +Private $hTimerBell As Timer + 'Private $bDoubleFont As Boolean = True '' Create a new TerminalView control @@ -508,6 +513,7 @@ Public Sub View_Draw() Endif If $bSuspend Then Paint.FillRect(0, 0, Paint.W, Paint.H, Color.SetAlpha($hView.Background, 128)) + If $bBell Then Paint.FillRect(0, 0, Paint.W, Paint.H, Color.SetAlpha($hView.Foreground, 128)) End @@ -1814,3 +1820,30 @@ Public Sub View_Drop() Endif End + +Public Sub TimerBell_Timer() + + $bBell = False + $hView.Refresh + Stop Event + +End + +Public Sub _Bell() + + If Object.CanRaise(Me, "Bell") Then + Raise Bell + Stop Event + Return + Endif + + $bBell = True + $hView.Refresh + + If Not $hTimerBell Then + $hTimerBell = New Timer As "TimerBell" + $hTimerBell.Delay = 100 + Endif + $hTimerBell.Start + +End