mirror of
https://github.com/lihop/godot-xterm.git
synced 2025-05-07 13:15:30 +02:00
Add/update more files
This commit is contained in:
parent
3307231b65
commit
0769592a1b
44 changed files with 4188 additions and 362 deletions
|
@ -5,15 +5,20 @@ extends Control
|
|||
|
||||
signal data_received(data)
|
||||
|
||||
|
||||
# The user must have these programs installed for this to work.
|
||||
const dependencies = PoolStringArray(['which', 'socat', 'bash'])
|
||||
const host = '127.0.0.1'
|
||||
const port = 17154
|
||||
const port = 7154
|
||||
|
||||
# Enable recording of all data send to the psuedoterminal master.
|
||||
# This is useful if you want to record a session if you are trying
|
||||
# to make a showcase of the terminal ;-)
|
||||
export var record: bool = false
|
||||
export(String) var record_file_path = '/tmp/godot-xterm-record.json'
|
||||
|
||||
var socat_pid = -1
|
||||
var stream_peer = StreamPeerTCP.new()
|
||||
var record_file
|
||||
|
||||
|
||||
func _ready():
|
||||
|
@ -22,11 +27,11 @@ func _ready():
|
|||
if exit_code != 0:
|
||||
OS.alert("Make sure the following programs are installed and in your $PATH: " + \
|
||||
dependencies.join(", ") + ".", "Misssing Dependencies!")
|
||||
|
||||
# Start socat.
|
||||
socat_pid = OS.execute("socat",
|
||||
["-d", "-d", "tcp-l:%d,bind=%s,reuseaddr,fork" % [port, host],
|
||||
"exec:bash,pty,setsid,stderr,login,ctty"], false)
|
||||
else:
|
||||
# Start socat.
|
||||
socat_pid = OS.execute("socat",
|
||||
["-d", "-d", "tcp-l:%d,bind=%s,reuseaddr,fork" % [port, host],
|
||||
"exec:bash,pty,setsid,stderr,login,ctty"], false)
|
||||
|
||||
# Create a StreamPeerTCP to connect to socat.
|
||||
var err = stream_peer.connect_to_host(host, port)
|
||||
|
@ -37,12 +42,21 @@ func _ready():
|
|||
var status = stream_peer.get_status()
|
||||
var connected = stream_peer.is_connected_to_host()
|
||||
|
||||
# Set the TERM environment variable, so that the correct escape sequences
|
||||
# are sent to Terminal. By default this is set to dumb, which lacks support
|
||||
# for even simple commands such as clear and reset.
|
||||
stream_peer.put_data("export TERM=xterm\n".to_ascii())
|
||||
stream_peer.put_data("clear\n".to_ascii())
|
||||
|
||||
# Connect the Terminal and StreamPeer.
|
||||
$Terminal.connect('data_sent', self, 'send_data')
|
||||
connect("data_received", $Terminal, "receive_data")
|
||||
$Terminal.connect('output', self, 'send_data')
|
||||
connect("data_received", $Terminal, "write")
|
||||
|
||||
|
||||
func send_data(data: PoolByteArray):
|
||||
if record:
|
||||
# Save the data and timestamp to a file
|
||||
record_file.write()
|
||||
stream_peer.put_data(data)
|
||||
|
||||
|
||||
|
@ -59,5 +73,7 @@ func _process(delta):
|
|||
|
||||
|
||||
func _exit_tree():
|
||||
if record:
|
||||
record_file.close()
|
||||
if socat_pid != -1:
|
||||
OS.execute("kill", ["-9", socat_pid], false)
|
||||
|
|
|
@ -1,24 +1,40 @@
|
|||
[gd_scene load_steps=3 format=2]
|
||||
[gd_scene load_steps=7 format=2]
|
||||
|
||||
[ext_resource path="res://scenes/demo.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/godot_xterm/terminal.gd" type="Script" id=2]
|
||||
[ext_resource path="res://addons/godot_xterm/fonts/source_code_pro/source_code_pro_regular.tres" type="DynamicFont" id=3]
|
||||
[ext_resource path="res://addons/godot_xterm/fonts/source_code_pro/source_code_pro_italic.tres" type="DynamicFont" id=4]
|
||||
[ext_resource path="res://addons/godot_xterm/fonts/source_code_pro/source_code_pro_bold_italic.tres" type="DynamicFont" id=5]
|
||||
[ext_resource path="res://addons/godot_xterm/fonts/source_code_pro/source_code_pro_bold.tres" type="DynamicFont" id=6]
|
||||
|
||||
[node name="Demo" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 120.0
|
||||
margin_top = 80.0
|
||||
margin_right = 120.0
|
||||
margin_bottom = 80.0
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Terminal" type="Control" parent="."]
|
||||
margin_right = 631.0
|
||||
margin_bottom = 401.0
|
||||
margin_left = 95.937
|
||||
margin_top = 44.6138
|
||||
margin_right = 695.937
|
||||
margin_bottom = 444.614
|
||||
rect_min_size = Vector2( 600, 400 )
|
||||
script = ExtResource( 2 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
font_family = {
|
||||
"bold": ExtResource( 6 ),
|
||||
"bold_italic": ExtResource( 5 ),
|
||||
"italic": ExtResource( 4 ),
|
||||
"regular": ExtResource( 3 )
|
||||
}
|
||||
font_size = 16
|
||||
colors = {
|
||||
"black": Color( 0.121569, 0.00784314, 0.00784314, 1 )
|
||||
}
|
||||
window_options = {
|
||||
|
||||
}
|
||||
|
|
39
scenes/showcase.tscn
Normal file
39
scenes/showcase.tscn
Normal file
|
@ -0,0 +1,39 @@
|
|||
[gd_scene load_steps=7 format=2]
|
||||
|
||||
[ext_resource path="res://scenes/demo.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/godot_xterm/terminal.gd" type="Script" id=2]
|
||||
[ext_resource path="res://addons/godot_xterm/fonts/source_code_pro/source_code_pro_regular.tres" type="DynamicFont" id=3]
|
||||
[ext_resource path="res://addons/godot_xterm/fonts/source_code_pro/source_code_pro_italic.tres" type="DynamicFont" id=4]
|
||||
[ext_resource path="res://addons/godot_xterm/fonts/source_code_pro/source_code_pro_bold_italic.tres" type="DynamicFont" id=5]
|
||||
[ext_resource path="res://addons/godot_xterm/fonts/source_code_pro/source_code_pro_bold.tres" type="DynamicFont" id=6]
|
||||
|
||||
[node name="Demo" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Terminal" type="Control" parent="."]
|
||||
margin_left = 163.651
|
||||
margin_top = 68.7974
|
||||
margin_right = 763.651
|
||||
margin_bottom = 468.797
|
||||
rect_min_size = Vector2( 600, 400 )
|
||||
script = ExtResource( 2 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
font_family = {
|
||||
"bold": ExtResource( 6 ),
|
||||
"bold_italic": ExtResource( 5 ),
|
||||
"italic": ExtResource( 4 ),
|
||||
"regular": ExtResource( 3 )
|
||||
}
|
||||
colors = {
|
||||
"black": Color( 0.121569, 0.00784314, 0.00784314, 1 )
|
||||
}
|
||||
window_options = {
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue