mirror of
https://github.com/lihop/godot-xterm.git
synced 2024-11-22 09:40:25 +01: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
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
# Godot-specific ignores
|
# Godot-specific ignores
|
||||||
.import/
|
.import/
|
||||||
export.cfg
|
export.cfg
|
||||||
|
@ -7,3 +6,6 @@ export_presets.cfg
|
||||||
# Mono-specific ignores
|
# Mono-specific ignores
|
||||||
.mono/
|
.mono/
|
||||||
data_*/
|
data_*/
|
||||||
|
|
||||||
|
# Python-specific ignores
|
||||||
|
.venv
|
||||||
|
|
|
@ -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.add_track(Animation.TYPE_METHOD, 0)
|
||||||
asciicast.track_set_path(0, ".")
|
asciicast.track_set_path(0, ".")
|
||||||
|
|
||||||
var frame = {
|
var frame = {"time": 0.0, "data": {"method": "write", "args": [PoolByteArray()]}}
|
||||||
"time": 0.0,
|
|
||||||
"data": {
|
|
||||||
"method": "write",
|
|
||||||
"args": [PoolByteArray()]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while not file.eof_reached():
|
while not file.eof_reached():
|
||||||
var line = file.get_line()
|
var line = file.get_line()
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
tool
|
tool
|
||||||
extends EditorPlugin
|
extends EditorPlugin
|
||||||
|
|
||||||
|
|
||||||
var asciicast_import_plugin
|
var asciicast_import_plugin
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
extends Animation
|
extends Animation
|
||||||
|
|
||||||
|
|
||||||
signal data_written(data)
|
signal data_written(data)
|
||||||
signal data_read(data)
|
signal data_read(data)
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -11,7 +11,6 @@ const CURSOR_LEFT = "\u001b[D"
|
||||||
|
|
||||||
const DEFAULT_FOREGROUND_COLOR = "\u001b[0m"
|
const DEFAULT_FOREGROUND_COLOR = "\u001b[0m"
|
||||||
|
|
||||||
|
|
||||||
var terminal
|
var terminal
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,6 +29,7 @@ func write_string(string: String, color: Color = Color.white) -> void:
|
||||||
# Reset color back to default.
|
# Reset color back to default.
|
||||||
terminal.write("\u001b[0m".to_utf8())
|
terminal.write("\u001b[0m".to_utf8())
|
||||||
|
|
||||||
|
|
||||||
# tput_* functions based on the tput command.
|
# tput_* functions based on the tput command.
|
||||||
# See: https://man7.org/linux/man-pages/man1/tput.1.html for more info.
|
# See: https://man7.org/linux/man-pages/man1/tput.1.html for more info.
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ const BACKSPACE_ALT = 127
|
||||||
|
|
||||||
onready var viewport = get_viewport()
|
onready var viewport = get_viewport()
|
||||||
|
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
viewport.connect("size_changed", self, "_resize")
|
viewport.connect("size_changed", self, "_resize")
|
||||||
_resize()
|
_resize()
|
||||||
|
@ -26,7 +27,7 @@ func _input(event):
|
||||||
accept_event()
|
accept_event()
|
||||||
|
|
||||||
# TODO: Handle more of these.
|
# TODO: Handle more of these.
|
||||||
if (event.control and event.scancode == KEY_C):
|
if event.control and event.scancode == KEY_C:
|
||||||
data.append(3)
|
data.append(3)
|
||||||
elif event.unicode:
|
elif event.unicode:
|
||||||
data.append(event.unicode)
|
data.append(event.unicode)
|
||||||
|
|
|
@ -62,8 +62,7 @@ func draw_title():
|
||||||
var err = config.load("res://addons/godot_xterm/plugin.cfg")
|
var err = config.load("res://addons/godot_xterm/plugin.cfg")
|
||||||
if err == OK:
|
if err == OK:
|
||||||
$Terminal.write("\n")
|
$Terminal.write("\n")
|
||||||
$Terminal.write("Version: %s" % config.get_value("plugin", "version",
|
$Terminal.write("Version: %s" % config.get_value("plugin", "version", "unknown"))
|
||||||
"unknown"))
|
|
||||||
row += 2
|
row += 2
|
||||||
|
|
||||||
|
|
||||||
|
@ -95,7 +94,7 @@ func draw_menu():
|
||||||
|
|
||||||
|
|
||||||
func _on_Terminal_key_pressed(data: String, event: InputEventKey) -> void:
|
func _on_Terminal_key_pressed(data: String, event: InputEventKey) -> void:
|
||||||
match(data):
|
match data:
|
||||||
TPut.CURSOR_UP: # Up arrow key
|
TPut.CURSOR_UP: # Up arrow key
|
||||||
selected_index = int(clamp(selected_index - 1, 0, menu_items.size() - 1))
|
selected_index = int(clamp(selected_index - 1, 0, menu_items.size() - 1))
|
||||||
draw_menu()
|
draw_menu()
|
||||||
|
@ -120,8 +119,7 @@ func _on_Terminal_key_pressed(data: String, event: InputEventKey) -> void:
|
||||||
"Asciicast":
|
"Asciicast":
|
||||||
var scene = item.scene.instance()
|
var scene = item.scene.instance()
|
||||||
var animation_player: AnimationPlayer = scene.get_node("AnimationPlayer")
|
var animation_player: AnimationPlayer = scene.get_node("AnimationPlayer")
|
||||||
scene.connect("key_pressed", self, "_on_Asciicast_key_pressed",
|
scene.connect("key_pressed", self, "_on_Asciicast_key_pressed", [animation_player])
|
||||||
[animation_player])
|
|
||||||
get_tree().get_root().add_child(scene)
|
get_tree().get_root().add_child(scene)
|
||||||
visible = false
|
visible = false
|
||||||
scene.grab_focus()
|
scene.grab_focus()
|
||||||
|
@ -132,9 +130,15 @@ func _on_Terminal_key_pressed(data: String, event: InputEventKey) -> void:
|
||||||
scene.queue_free()
|
scene.queue_free()
|
||||||
"Terminal":
|
"Terminal":
|
||||||
if OS.get_name() == "Windows":
|
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"
|
+ " 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 scene = item.scene.instance()
|
||||||
var pty = scene.get_node("Pseudoterminal")
|
var pty = scene.get_node("Pseudoterminal")
|
||||||
get_tree().get_root().add_child(scene)
|
get_tree().get_root().add_child(scene)
|
||||||
|
@ -148,7 +152,8 @@ func _on_Terminal_key_pressed(data: String, event: InputEventKey) -> void:
|
||||||
get_tree().quit()
|
get_tree().quit()
|
||||||
|
|
||||||
|
|
||||||
func _on_Asciicast_key_pressed(data: String, _event: InputEventKey,
|
func _on_Asciicast_key_pressed(
|
||||||
animation_player: AnimationPlayer) -> void:
|
data: String, _event: InputEventKey, animation_player: AnimationPlayer
|
||||||
|
) -> void:
|
||||||
if data == "\u001b":
|
if data == "\u001b":
|
||||||
animation_player.emit_signal("animation_finished")
|
animation_player.emit_signal("animation_finished")
|
||||||
|
|
|
@ -25,4 +25,5 @@ __meta__ = {
|
||||||
}
|
}
|
||||||
rows = 31
|
rows = 31
|
||||||
cols = 102
|
cols = 102
|
||||||
|
|
||||||
[connection signal="key_pressed" from="Terminal" to="." method="_on_Terminal_key_pressed"]
|
[connection signal="key_pressed" from="Terminal" to="." method="_on_Terminal_key_pressed"]
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func _on_Terminal_key_pressed(event: InputEventKey, data: PoolByteArray):
|
func _on_Terminal_key_pressed(event: InputEventKey, data: PoolByteArray):
|
||||||
print(data as Array)
|
print(data as Array)
|
||||||
print(event.scancode)
|
print(event.scancode)
|
||||||
|
|
Loading…
Reference in a new issue