Add namespace

Adds a globally unique namespace `GDXterm` that can be used to
conveniently access scripts.
This commit is contained in:
Leroy Hopson 2021-07-03 20:44:51 +07:00
parent 964af715d6
commit 39702646dc
No known key found for this signature in database
GPG key ID: D2747312A6DB51AA
4 changed files with 20 additions and 7 deletions

View file

@ -0,0 +1,5 @@
class_name GDXterm
const Terminal := preload("./nodes/terminal/terminal.gd")
const PTYUnix := preload("./nodes/pty/unix/pty_unix.gd")
const TPut := preload("./util/tput.gd")

View file

@ -8,8 +8,6 @@ extends Control
# - https://tldp.org/HOWTO/Bash-Prompt-HOWTO/x361.html
# - https://www.youtube.com/watch?v=jTSQlIK_92w
const TPut := preload("res://addons/godot_xterm/util/tput.gd")
# Title generated using command: toilet -f pagga GODOT XTERM
const TITLE = """
\r
@ -38,7 +36,7 @@ var row: int
var menu_start_row: int
var offset: int
onready var tput = TPut.new($Terminal)
onready var tput = GDXterm.TPut.new($Terminal)
func _ready():
@ -105,10 +103,10 @@ func draw_menu():
func _on_Terminal_key_pressed(data: String, event: InputEventKey) -> void:
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))
draw_menu()
TPut.CURSOR_DOWN: # Down arrow key
tput.CURSOR_DOWN: # Down arrow key
selected_index = int(clamp(selected_index + 1, 0, menu_items.size() - 1))
draw_menu()
"1":

View file

@ -1,4 +1,4 @@
extends "res://addons/godot_xterm/nodes/terminal/terminal.gd"
extends GDXterm.Terminal
onready var pty = $PTY

View file

@ -8,6 +8,16 @@
config_version=4
_global_script_classes=[ {
"base": "Reference",
"class": "GDXterm",
"language": "GDScript",
"path": "res://addons/godot_xterm/namespace.gd"
} ]
_global_script_class_icons={
"GDXterm": ""
}
[application]
config/name="Godot Xterm"
@ -20,7 +30,7 @@ window/vsync/use_vsync=false
[editor_plugins]
enabled=PoolStringArray( "res://addons/godot_xterm/plugin.cfg", "res://addons/gut/plugin.cfg" )
enabled=PoolStringArray( "res://addons/godot_xterm/plugin.cfg" )
[rendering]