mirror of
https://github.com/lihop/godot-xterm.git
synced 2025-05-03 12:04:24 +02:00
parent
36974e6794
commit
db6486e6f3
11 changed files with 199 additions and 77 deletions
53
examples/asciicast/asciicast.gd
Normal file
53
examples/asciicast/asciicast.gd
Normal file
|
@ -0,0 +1,53 @@
|
|||
extends Container
|
||||
# This Container ensures that the terminal always fills
|
||||
# the window and/or screen. It also connects the terminal
|
||||
# to the input/output of the Psuedoterminal.
|
||||
|
||||
const ESCAPE = 27
|
||||
const BACKSPACE = 8
|
||||
const BEEP = 7
|
||||
const SPACE = 32
|
||||
const LEFT_BRACKET = 91
|
||||
const ENTER = 10
|
||||
const BACKSPACE_ALT = 127
|
||||
|
||||
onready var viewport = get_viewport()
|
||||
|
||||
func _ready():
|
||||
viewport.connect("size_changed", self, "_resize")
|
||||
_resize()
|
||||
$Terminal/AnimationPlayer.play("a")
|
||||
|
||||
|
||||
func _input(event):
|
||||
#return
|
||||
if event is InputEventKey and event.pressed:
|
||||
var data = PoolByteArray([])
|
||||
accept_event()
|
||||
|
||||
# TODO: Handle more of these.
|
||||
if (event.control and event.scancode == KEY_C):
|
||||
data.append(3)
|
||||
elif event.unicode:
|
||||
data.append(event.unicode)
|
||||
elif event.scancode == KEY_ENTER:
|
||||
data.append(ENTER)
|
||||
elif event.scancode == KEY_BACKSPACE:
|
||||
data.append(BACKSPACE_ALT)
|
||||
elif event.scancode == KEY_ESCAPE:
|
||||
data.append(27)
|
||||
elif event.scancode == KEY_TAB:
|
||||
data.append(9)
|
||||
elif OS.get_scancode_string(event.scancode) == "Shift":
|
||||
pass
|
||||
elif OS.get_scancode_string(event.scancode) == "Control":
|
||||
pass
|
||||
else:
|
||||
pass
|
||||
#push_warning('Unhandled input. scancode: ' + str(OS.get_scancode_string(event.scancode)))
|
||||
#emit_signal("output", data)
|
||||
|
||||
|
||||
func _resize():
|
||||
rect_size = viewport.size
|
||||
$Terminal.rect_size = rect_size
|
24
examples/asciicast/asciicast.tscn
Normal file
24
examples/asciicast/asciicast.tscn
Normal file
|
@ -0,0 +1,24 @@
|
|||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://examples/asciicast/asciicast.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/godot_xterm/themes/default.theme" type="Theme" id=2]
|
||||
[ext_resource path="res://addons/godot_xterm/nodes/terminal/terminal.gdns" type="Script" id=4]
|
||||
[ext_resource path="res://examples/asciicast/example.cast" type="Animation" id=6]
|
||||
|
||||
[node name="Container" type="Container"]
|
||||
margin_right = 40.0
|
||||
margin_bottom = 40.0
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Terminal" type="Control" parent="."]
|
||||
margin_right = 40.0
|
||||
margin_bottom = 40.0
|
||||
theme = ExtResource( 2 )
|
||||
script = ExtResource( 4 )
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="Terminal"]
|
||||
method_call_mode = 1
|
||||
anims/a = ExtResource( 6 )
|
13
examples/asciicast/example.cast.import
Normal file
13
examples/asciicast/example.cast.import
Normal file
|
@ -0,0 +1,13 @@
|
|||
[remap]
|
||||
|
||||
importer="godot_xterm"
|
||||
type="Animation"
|
||||
path="res://.import/example.cast-9299cc6d12357f676344c3d48e3179e0.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://examples/asciicast/example.cast"
|
||||
dest_files=[ "res://.import/example.cast-9299cc6d12357f676344c3d48e3179e0.res" ]
|
||||
|
||||
[params]
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue