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.
This commit is contained in:
gambas 2021-03-02 18:59:47 +01:00 committed by Christof Thalhofer
parent e8531901da
commit 85c8320fe4
3 changed files with 41 additions and 1 deletions

View file

@ -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

View file

@ -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

View file

@ -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