2021-07-08 15:33:46 +02:00
|
|
|
extends "res://addons/godot_xterm/nodes/terminal/terminal.gd"
|
2021-07-02 19:27:34 +02:00
|
|
|
|
|
|
|
onready var pty = $PTY
|
|
|
|
|
2021-07-03 16:57:19 +02:00
|
|
|
var _next_bell := true
|
|
|
|
|
2021-07-02 19:27:34 +02:00
|
|
|
|
|
|
|
func _ready():
|
|
|
|
pty.fork(OS.get_environment("SHELL"))
|
2021-07-03 16:57:19 +02:00
|
|
|
|
|
|
|
|
|
|
|
func _on_Terminal_bell():
|
|
|
|
# Limit the rate at which bells can be rung in case the user does something crazy such as
|
|
|
|
# `while true; do echo -e "\a"; done`
|
|
|
|
# which causes a real mess if we keep adding AudioStreamPlayers.
|
|
|
|
if not _next_bell:
|
|
|
|
return
|
|
|
|
|
|
|
|
var player := AudioStreamPlayer.new()
|
2021-07-12 17:55:00 +02:00
|
|
|
player.stream = preload("res://addons/godot_xterm/themes/audio/bell.wav")
|
2021-07-03 16:57:19 +02:00
|
|
|
player.autoplay = true
|
|
|
|
player.connect("finished", self, "_on_player_finished", [player])
|
|
|
|
add_child(player)
|
|
|
|
_next_bell = false
|
|
|
|
|
|
|
|
|
|
|
|
func _on_player_finished(player: AudioStreamPlayer):
|
|
|
|
player.queue_free()
|
|
|
|
|
|
|
|
|
|
|
|
func _on_Timer_timeout():
|
|
|
|
_next_bell = true
|