mirror of
https://github.com/lihop/godot-xterm.git
synced 2025-05-05 04:34:23 +02:00
Format files using GDScript Toolkit
https://github.com/Scony/godot-gdscript-toolkit
This commit is contained in:
parent
a0237bb5d5
commit
f43149f204
10 changed files with 64 additions and 64 deletions
|
@ -37,40 +37,34 @@ func import(source_file, save_path, options, r_platform_variant, r_gen_files):
|
|||
var err = file.open(source_file, File.READ)
|
||||
if err != OK:
|
||||
return err
|
||||
|
||||
|
||||
var header = file.get_line()
|
||||
|
||||
|
||||
var asciicast = Asciicast.new()
|
||||
|
||||
|
||||
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()
|
||||
if line == "":
|
||||
continue
|
||||
|
||||
|
||||
var p = JSON.parse(line)
|
||||
if typeof(p.result) != TYPE_ARRAY:
|
||||
continue
|
||||
|
||||
|
||||
var event_type: String = p.result[1]
|
||||
var event_data: PoolByteArray = p.result[2].to_utf8()
|
||||
|
||||
|
||||
# Asciicast recordings have a resolution of 0.000001, however animation
|
||||
# track keys only have a resolution of 0.01, therefore we must combine
|
||||
# events that would occur in the same keyframe, otherwise only the last
|
||||
# event is inserted and the previous events are overwritten.
|
||||
var time = stepify(p.result[0], 0.01)
|
||||
|
||||
|
||||
if event_type == "o":
|
||||
if time == frame.time:
|
||||
asciicast.track_remove_key_at_position(0, time)
|
||||
|
@ -78,9 +72,9 @@ func import(source_file, save_path, options, r_platform_variant, r_gen_files):
|
|||
else:
|
||||
frame.time = time
|
||||
frame.data.args = [event_data]
|
||||
|
||||
|
||||
asciicast.track_insert_key(0, frame.time, frame.data)
|
||||
|
||||
|
||||
asciicast.length = frame.time
|
||||
|
||||
|
||||
return ResourceSaver.save("%s.%s" % [save_path, get_save_extension()], asciicast)
|
||||
|
|
|
@ -1,21 +1,20 @@
|
|||
tool
|
||||
extends EditorPlugin
|
||||
|
||||
|
||||
var asciicast_import_plugin
|
||||
|
||||
|
||||
func _enter_tree():
|
||||
asciicast_import_plugin = preload("res://addons/godot_xterm/import_plugins/asciicast_import_plugin.gd").new()
|
||||
add_import_plugin(asciicast_import_plugin)
|
||||
|
||||
|
||||
var asciicast_script = preload("res://addons/godot_xterm/resources/asciicast.gd")
|
||||
add_custom_type("Asciicast", "Animation", asciicast_script, null)
|
||||
|
||||
|
||||
var terminal_script = preload("res://addons/godot_xterm/nodes/terminal/terminal.gdns")
|
||||
var terminal_icon = preload("res://addons/godot_xterm/nodes/terminal/terminal_icon.svg")
|
||||
add_custom_type("Terminal", "Control", terminal_script, terminal_icon)
|
||||
|
||||
|
||||
var pseudoterminal_script = preload("res://addons/godot_xterm/nodes/pseudoterminal/pseudoterminal.gdns")
|
||||
var pseudoterminal_icon = preload("res://addons/godot_xterm/nodes/pseudoterminal/pseudoterminal_icon.svg")
|
||||
add_custom_type("Pseudoterminal", "Node", pseudoterminal_script, pseudoterminal_icon)
|
||||
|
@ -24,7 +23,7 @@ func _enter_tree():
|
|||
func _exit_tree():
|
||||
remove_import_plugin(asciicast_import_plugin)
|
||||
asciicast_import_plugin = null
|
||||
|
||||
|
||||
remove_custom_type("Asciicast")
|
||||
remove_custom_type("Terminal")
|
||||
remove_custom_type("Psuedoterminal")
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
extends Animation
|
||||
|
||||
|
||||
signal data_written(data)
|
||||
signal data_read(data)
|
||||
|
||||
export(int) var version: int = 2
|
||||
export (int) var version: int = 2
|
||||
# Initial terminal width (number of columns).
|
||||
export(int) var width: int
|
||||
export (int) var width: int
|
||||
# Initial terminal height (number of rows).
|
||||
export(int) var height: int
|
||||
export (int) var height: int
|
||||
|
||||
|
||||
func get_class() -> String:
|
||||
|
@ -20,4 +19,4 @@ func is_class(name) -> bool:
|
|||
|
||||
|
||||
func _init():
|
||||
step = 0.01 # Parent override.
|
||||
step = 0.01 # Parent override.
|
||||
|
|
Binary file not shown.
|
@ -11,7 +11,6 @@ const CURSOR_LEFT = "\u001b[D"
|
|||
|
||||
const DEFAULT_FOREGROUND_COLOR = "\u001b[0m"
|
||||
|
||||
|
||||
var terminal
|
||||
|
||||
|
||||
|
@ -24,12 +23,13 @@ func write_string(string: String, color: Color = Color.white) -> void:
|
|||
if color:
|
||||
var fg = "\u001b[38;2;%d;%d;%dm" % [color.r8, color.g8, color.b8]
|
||||
terminal.write(fg.to_utf8())
|
||||
|
||||
|
||||
terminal.write(string.to_utf8())
|
||||
|
||||
|
||||
# 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.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue