Format files using GDScript Toolkit

https://github.com/Scony/godot-gdscript-toolkit
This commit is contained in:
Leroy Hopson 2021-05-26 10:39:48 +07:00 committed by Leroy Hopson
parent a0237bb5d5
commit f43149f204
10 changed files with 64 additions and 64 deletions

4
.gitignore vendored
View file

@ -1,4 +1,3 @@
# Godot-specific ignores
.import/
export.cfg
@ -7,3 +6,6 @@ export_presets.cfg
# Mono-specific ignores
.mono/
data_*/
# Python-specific ignores
.venv

View file

@ -45,13 +45,7 @@ func import(source_file, save_path, options, r_platform_variant, r_gen_files):
asciicast.add_track(Animation.TYPE_METHOD, 0)
asciicast.track_set_path(0, ".")
var frame = {
"time": 0.0,
"data": {
"method": "write",
"args": [PoolByteArray()]
}
}
var frame = {"time": 0.0, "data": {"method": "write", "args": [PoolByteArray()]}}
while not file.eof_reached():
var line = file.get_line()

View file

@ -1,7 +1,6 @@
tool
extends EditorPlugin
var asciicast_import_plugin

View file

@ -1,6 +1,5 @@
extends Animation
signal data_written(data)
signal data_read(data)

View file

@ -11,7 +11,6 @@ const CURSOR_LEFT = "\u001b[D"
const DEFAULT_FOREGROUND_COLOR = "\u001b[0m"
var terminal
@ -30,6 +29,7 @@ func write_string(string: String, color: Color = Color.white) -> void:
# Reset color back to default.
terminal.write("\u001b[0m".to_utf8())
# tput_* functions based on the tput command.
# See: https://man7.org/linux/man-pages/man1/tput.1.html for more info.

View file

@ -13,6 +13,7 @@ const BACKSPACE_ALT = 127
onready var viewport = get_viewport()
func _ready():
viewport.connect("size_changed", self, "_resize")
_resize()
@ -26,7 +27,7 @@ func _input(event):
accept_event()
# TODO: Handle more of these.
if (event.control and event.scancode == KEY_C):
if event.control and event.scancode == KEY_C:
data.append(3)
elif event.unicode:
data.append(event.unicode)

View file

@ -62,8 +62,7 @@ func draw_title():
var err = config.load("res://addons/godot_xterm/plugin.cfg")
if err == OK:
$Terminal.write("\n")
$Terminal.write("Version: %s" % config.get_value("plugin", "version",
"unknown"))
$Terminal.write("Version: %s" % config.get_value("plugin", "version", "unknown"))
row += 2
@ -95,7 +94,7 @@ func draw_menu():
func _on_Terminal_key_pressed(data: String, event: InputEventKey) -> void:
match(data):
match data:
TPut.CURSOR_UP: # Up arrow key
selected_index = int(clamp(selected_index - 1, 0, menu_items.size() - 1))
draw_menu()
@ -120,8 +119,7 @@ func _on_Terminal_key_pressed(data: String, event: InputEventKey) -> void:
"Asciicast":
var scene = item.scene.instance()
var animation_player: AnimationPlayer = scene.get_node("AnimationPlayer")
scene.connect("key_pressed", self, "_on_Asciicast_key_pressed",
[animation_player])
scene.connect("key_pressed", self, "_on_Asciicast_key_pressed", [animation_player])
get_tree().get_root().add_child(scene)
visible = false
scene.grab_focus()
@ -132,9 +130,15 @@ func _on_Terminal_key_pressed(data: String, event: InputEventKey) -> void:
scene.queue_free()
"Terminal":
if OS.get_name() == "Windows":
return OS.call_deferred("alert", "Psuedoterminal node currently"
return OS.call_deferred(
"alert",
(
"Psuedoterminal node currently"
+ " uses pty.h but needs to use either winpty or conpty"
+ " to work on Windows.", "Terminal not Supported on Windows")
+ " to work on Windows."
),
"Terminal not Supported on Windows"
)
var scene = item.scene.instance()
var pty = scene.get_node("Pseudoterminal")
get_tree().get_root().add_child(scene)
@ -148,7 +152,8 @@ func _on_Terminal_key_pressed(data: String, event: InputEventKey) -> void:
get_tree().quit()
func _on_Asciicast_key_pressed(data: String, _event: InputEventKey,
animation_player: AnimationPlayer) -> void:
func _on_Asciicast_key_pressed(
data: String, _event: InputEventKey, animation_player: AnimationPlayer
) -> void:
if data == "\u001b":
animation_player.emit_signal("animation_finished")

View file

@ -25,4 +25,5 @@ __meta__ = {
}
rows = 31
cols = 102
[connection signal="key_pressed" from="Terminal" to="." method="_on_Terminal_key_pressed"]

View file

@ -1,7 +1,6 @@
extends Node
func _on_Terminal_key_pressed(event: InputEventKey, data: PoolByteArray):
print(data as Array)
print(event.scancode)