mirror of
https://github.com/lihop/godot-xterm.git
synced 2025-05-04 12:14:24 +02:00
parent
115521f645
commit
09dc080a2e
8 changed files with 98 additions and 0 deletions
BIN
examples/bell.wav
Normal file
BIN
examples/bell.wav
Normal file
Binary file not shown.
21
examples/bell.wav.import
Normal file
21
examples/bell.wav.import
Normal file
|
@ -0,0 +1,21 @@
|
|||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamSample"
|
||||
path="res://.import/bell.wav-90c86fbe33880ba47c154bebbc865497.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://examples/bell.wav"
|
||||
dest_files=[ "res://.import/bell.wav-90c86fbe33880ba47c154bebbc865497.sample" ]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop=false
|
||||
compress/mode=0
|
|
@ -2,6 +2,31 @@ extends GDXterm.Terminal
|
|||
|
||||
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("../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
|
||||
|
|
|
@ -19,3 +19,10 @@ env = {
|
|||
"COLORTERM": "truecolor",
|
||||
"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