mirror of
https://github.com/lihop/godot-xterm.git
synced 2025-05-03 12:04:24 +02:00
Move bell to main terminal
This commit is contained in:
parent
e8c27f2796
commit
6afaa55914
3 changed files with 29 additions and 31 deletions
|
@ -2,31 +2,6 @@ extends "res://addons/godot_xterm/nodes/terminal/terminal.gd"
|
|||
|
||||
onready var pty = $PTY
|
||||
|
||||
var _next_bell := true
|
||||
|
||||
|
||||
func _ready():
|
||||
pty.fork(OS.get_environment("SHELL"))
|
||||
|
||||
|
||||
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()
|
||||
player.stream = preload("res://addons/godot_xterm/themes/audio/bell.wav")
|
||||
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
|
||||
|
|
|
@ -21,9 +21,4 @@ env = {
|
|||
"TERM": "xterm-256color"
|
||||
}
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
||||
wait_time = 0.1
|
||||
autostart = true
|
||||
|
||||
[connection signal="bell" from="." to="." method="_on_Terminal_bell"]
|
||||
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue