Godot 4 automatic changes

This commit is contained in:
Daniel Inkpen 2022-11-09 20:57:46 +00:00
parent 8b5caafbc7
commit cdbf3f2adc
75 changed files with 1034 additions and 952 deletions

View file

@ -1,11 +1,11 @@
tool
@tool
extends "../../terminal.gd"
signal exited(exit_code, signum)
var editor_settings: EditorSettings
onready var pty = $PTY
@onready var pty = $PTY
# Sets terminal colors according to a dictionary that maps terminal color names
@ -25,7 +25,7 @@ func _ready():
# Get colors from TextEdit theme. Created using the default (Adaptive) theme
# for reference, but will probably cause strange results if using another theme
# better to use a dedicated terminal theme, rather than relying on this.
# better to use a dedicated terminal theme, rather than relying checked this.
_set_terminal_colors(
{
"black": "caret_background_color",

View file

@ -1,4 +1,4 @@
[gd_resource type="ShortCut" load_steps=2 format=2]
[gd_resource type="Shortcut" load_steps=2 format=2]
[sub_resource type="InputEventKey" id=1]
shift = true

View file

@ -1,4 +1,4 @@
[gd_resource type="ShortCut" load_steps=2 format=2]
[gd_resource type="Shortcut" load_steps=2 format=2]
[sub_resource type="InputEventKey" id=1]
shift = true

View file

@ -1,4 +1,4 @@
[gd_resource type="ShortCut" load_steps=2 format=2]
[gd_resource type="Shortcut" load_steps=2 format=2]
[sub_resource type="InputEventKey" id=1]
shift = true

View file

@ -1,4 +1,4 @@
[gd_resource type="ShortCut" load_steps=2 format=2]
[gd_resource type="Shortcut" load_steps=2 format=2]
[sub_resource type="InputEventKey" id=1]
shift = true

View file

@ -1,4 +1,4 @@
[gd_resource type="ShortCut" load_steps=2 format=2]
[gd_resource type="Shortcut" load_steps=2 format=2]
[sub_resource type="InputEventKey" id=1]
control = true

View file

@ -1,4 +1,4 @@
[gd_resource type="ShortCut" load_steps=2 format=2]
[gd_resource type="Shortcut" load_steps=2 format=2]
[sub_resource type="InputEventKey" id=1]
control = true

View file

@ -12,48 +12,48 @@ enum CWDType {
### Shortcuts ###
export(ShortCut) var new_terminal_shortcut = preload("./default_new_terminal_shortcut.tres")
export(ShortCut) var kill_terminal_shortcut = preload("./default_kill_terminal_shortcut.tres")
export(ShortCut) var copy_shortcut = preload("./default_copy_shortcut.tres")
export(ShortCut) var paste_shortcut = preload("./default_paste_shortcut.tres")
@export var new_terminal_shortcut: Shortcut = preload("./default_new_terminal_shortcut.tres")
@export var kill_terminal_shortcut: Shortcut = preload("./default_kill_terminal_shortcut.tres")
@export var copy_shortcut: Shortcut = preload("./default_copy_shortcut.tres")
@export var paste_shortcut: Shortcut = preload("./default_paste_shortcut.tres")
export(ShortCut) var next_tab_shortcut = preload("./default_tab_right_shortcut.tres")
export(ShortCut) var previous_tab_shortcut = preload("./default_tab_left_shortcut.tres")
@export var next_tab_shortcut: Shortcut = preload("./default_tab_right_shortcut.tres")
@export var previous_tab_shortcut: Shortcut = preload("./default_tab_left_shortcut.tres")
### Scroll settings ###
# The maximum amount of lines the terminal keeps in its buffer.
export var scrollback_buffer_lines := 1000
@export var scrollback_buffer_lines := 1000
# If true, mouse wheel up and down can be used to scroll the terminal.
export var mouse_wheel_scroll := true
@export var mouse_wheel_scroll := true
# Whether or not to display scroll bar.
export var show_scroll_bar := true
@export var show_scroll_bar := true
# Copy/paste settings.
export var copy_on_selection := false
@export var copy_on_selection := false
# Font settings.
export var font_size: int = 14
export var letter_spacing: int = 0
export var line_height: float = 1.2
export var ctrl_scroll_to_resize_font := true
@export var font_size: int = 14
@export var letter_spacing: int = 0
@export var line_height: float = 1.2
@export var ctrl_scroll_to_resize_font := true
# Bell settings.
export var visual_bell := true
export var audio_bell := true
export var bell_sound: AudioStream
@export var visual_bell := true
@export var audio_bell := true
@export var bell_sound: AudioStream
# Exec args.
export(FileType) var file_type := FileType.USE_SHELL_ENV
export var custom_file := "/bin/sh"
@export var file_type: FileType := FileType.USE_SHELL_ENV
@export var custom_file := "/bin/sh"
export(CWDType) var cwd_type := CWDType.USE_PROJECT_DIRECTORY
export var custom_cwd := ""
@export var cwd_type: CWDType := CWDType.USE_PROJECT_DIRECTORY
@export var custom_cwd := ""
export var args := PoolStringArray()
@export var args := PackedStringArray()
export var use_os_env := true
export var extra_env := {
@export var use_os_env := true
@export var extra_env := {
TERM = "xterm-256color",
COLORTERM = "truecolor",
}

View file

@ -4,7 +4,7 @@
# These snippets are copyright of their authors and released under the MIT license:
# - Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur (MIT License).
# - Copyright (c) 2014-2021 Godot Engine contributors (MIT License).
tool
@tool
extends Control
const EditorTerminal := preload("./editor_terminal.tscn")
@ -23,23 +23,23 @@ enum TerminalPopupMenuOptions {
}
# Has access to the EditorSettings singleton so it can dynamically generate the
# terminal color scheme based on editor theme settings.
# terminal color scheme based checked editor theme settings.
var editor_plugin: EditorPlugin
var editor_interface: EditorInterface
onready var editor_settings: EditorSettings = editor_interface.get_editor_settings()
onready var tabs: Tabs = $VBoxContainer/TabbarContainer/Tabs
onready var tabbar_container: HBoxContainer = $VBoxContainer/TabbarContainer
onready var add_button: ToolButton = $VBoxContainer/TabbarContainer/Tabs/AddButton
onready var tab_container: TabContainer = $VBoxContainer/TabContainer
onready var terminal_popup_menu: PopupMenu = $VBoxContainer/TerminalPopupMenu
@onready var editor_settings: EditorSettings = editor_interface.get_editor_settings()
@onready var tabs: TabBar = $VBoxContainer/TabbarContainer/TabBar
@onready var tabbar_container: HBoxContainer = $VBoxContainer/TabbarContainer
@onready var add_button: Button = $VBoxContainer/TabbarContainer/TabBar/AddButton
@onready var tab_container: TabContainer = $VBoxContainer/TabContainer
@onready var terminal_popup_menu: PopupMenu = $VBoxContainer/TerminalPopupMenu
# Size label.
# Used to show the size of the terminal (rows/cols) and panel (pixels) when resized.
onready var size_label: Label = $SizeLabel
onready var size_label_timer: Timer = $SizeLabel/SizeLabelTimer
@onready var size_label: Label = $SizeLabel
@onready var size_label_timer: Timer = $SizeLabel/SizeLabelTimer
onready var ready := true
@onready var ready := true
var _theme := Theme.new()
var _settings: TerminalSettings
@ -47,7 +47,7 @@ var _tab_container_min_size
func _ready():
tab_container.add_stylebox_override("panel", get_stylebox("background", "EditorStyles"))
tab_container.add_theme_stylebox_override("panel", get_stylebox("background", "EditorStyles"))
_update_settings()
@ -76,10 +76,10 @@ func _update_settings() -> void:
if editor_interface.has_method("get_editor_scale"):
editor_scale = editor_interface.get_editor_scale()
rect_min_size = Vector2(0, tabbar_container.rect_size.y + 182) * editor_scale
rect_size.y = 415
minimum_size = Vector2(0, tabbar_container.size.y + 182) * editor_scale
size.y = 415
tabs.tab_close_display_policy = Tabs.CLOSE_BUTTON_SHOW_ALWAYS
tabs.tab_close_display_policy = TabBar.CLOSE_BUTTON_SHOW_ALWAYS
# Update shortcuts.
if _settings.new_terminal_shortcut:
@ -104,13 +104,13 @@ func _update_settings() -> void:
func _update_terminal_tabs():
# Wait a couple of frames to allow everything to resize before updating.
yield(get_tree(), "idle_frame")
yield(get_tree(), "idle_frame")
await get_tree().idle_frame
await get_tree().idle_frame
if tabs.get_offset_buttons_visible():
# Move add button to fixed position on the tabbar.
# Move add button to fixed position checked the tabbar.
if add_button.get_parent() == tabs:
add_button.rect_position = Vector2.ZERO
add_button.position = Vector2.ZERO
tabs.remove_child(add_button)
tabbar_container.add_child(add_button)
tabbar_container.move_child(add_button, 0)
@ -122,7 +122,7 @@ func _update_terminal_tabs():
var last_tab := Rect2()
if tabs.get_tab_count() > 0:
last_tab = tabs.get_tab_rect(tabs.get_tab_count() - 1)
add_button.rect_position = Vector2(
add_button.position = Vector2(
last_tab.position.x + last_tab.size.x + 3, last_tab.position.y
)
@ -132,12 +132,12 @@ func _update_terminal_tabs():
func _on_AddButton_pressed():
var shell = OS.get_environment("SHELL") if OS.has_environment("SHELL") else "sh"
var terminal := EditorTerminal.instance()
var terminal := EditorTerminal.instantiate()
tabs.add_tab(shell.get_file())
terminal.editor_settings = editor_settings
terminal.set_anchors_preset(PRESET_WIDE)
terminal.connect("gui_input", self, "_on_TabContainer_gui_input")
terminal.connect("exited", self, "_on_Terminal_exited", [terminal])
terminal.connect("gui_input",Callable(self,"_on_TabContainer_gui_input"))
terminal.connect("exited",Callable(self,"_on_Terminal_exited").bind(terminal))
tab_container.add_child(terminal)
terminal.pty.fork(shell)
terminal.grab_focus()
@ -172,7 +172,7 @@ func _notification(what):
_update_terminal_tabs()
NOTIFICATION_RESIZED:
_update_terminal_tabs()
NOTIFICATION_WM_FOCUS_IN:
NOTIFICATION_APPLICATION_FOCUS_IN:
_update_terminal_tabs()
@ -182,7 +182,7 @@ func _input(event: InputEvent) -> void:
# Global shortcut to open new terminal and make terminal panel visible.
if _settings.new_terminal_shortcut and _settings.new_terminal_shortcut.shortcut:
if event.shortcut_match(_settings.new_terminal_shortcut.shortcut):
if event.is_match(_settings.new_terminal_shortcut.shortcut):
get_tree().set_input_as_handled()
editor_plugin.make_bottom_panel_item_visible(self)
_on_AddButton_pressed()
@ -194,38 +194,38 @@ func _input(event: InputEvent) -> void:
):
# Kill terminal.
if _settings.kill_terminal_shortcut and _settings.kill_terminal_shortcut.shortcut:
if event.shortcut_match(_settings.kill_terminal_shortcut.shortcut):
if event.is_match(_settings.kill_terminal_shortcut.shortcut):
get_tree().set_input_as_handled()
_on_TerminalPopupMenu_id_pressed(TerminalPopupMenuOptions.KILL_TERMINAL)
# Copy.
if _settings.copy_shortcut and _settings.copy_shortcut.shortcut:
if event.shortcut_match(_settings.copy_shortcut.shortcut):
if event.is_match(_settings.copy_shortcut.shortcut):
get_tree().set_input_as_handled()
_on_TerminalPopupMenu_id_pressed(TerminalPopupMenuOptions.COPY)
# Paste.
if _settings.paste_shortcut and _settings.paste_shortcut.shortcut:
if event.shortcut_match(_settings.paste_shortcut.shortcut):
if event.is_match(_settings.paste_shortcut.shortcut):
get_tree().set_input_as_handled()
_on_TerminalPopupMenu_id_pressed(TerminalPopupMenuOptions.PASTE)
# Next tab.
if _settings.next_tab_shortcut and _settings.next_tab_shortcut.shortcut:
if event.shortcut_match(_settings.next_tab_shortcut.shortcut):
if event.is_match(_settings.next_tab_shortcut.shortcut):
get_tree().set_input_as_handled()
tabs.current_tab = min(tabs.current_tab + 1, tabs.get_tab_count() - 1)
# Previous tab.
if _settings.previous_tab_shortcut and _settings.previous_tab_shortcut.shortcut:
if event.shortcut_match(_settings.previous_tab_shortcut.shortcut):
if event.is_match(_settings.previous_tab_shortcut.shortcut):
get_tree().set_input_as_handled()
tabs.current_tab = max(tabs.current_tab - 1, 0)
func _on_TabContainer_gui_input(event):
if event is InputEventMouseButton and event.button_index == BUTTON_RIGHT:
terminal_popup_menu.rect_position = event.global_position
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_RIGHT:
terminal_popup_menu.position = event.global_position
terminal_popup_menu.popup()
@ -243,7 +243,7 @@ func _on_TerminalPopupMenu_id_pressed(id):
for i in OS.clipboard.length():
var event = InputEventKey.new()
event.unicode = ord(OS.clipboard[i])
event.pressed = true
event.button_pressed = true
terminal._gui_input(event)
TerminalPopupMenuOptions.COPY_ALL:
OS.clipboard = terminal.copy_all()
@ -262,7 +262,7 @@ func _on_Panel_resized():
if not size_label:
return
var size = tab_container.rect_size
var size = tab_container.size
if tabs.get_tab_count() > 0:
var terminal = tab_container.get_child(tabs.current_tab)
var cols = terminal.get_cols()

View file

@ -4,7 +4,7 @@
[sub_resource type="Image" id=6]
data = {
"data": PoolByteArray( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ),
"data": PackedByteArray( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ),
"format": "LumAlpha8",
"height": 16,
"mipmaps": false,
@ -20,14 +20,14 @@ size = Vector2( 16, 16 )
[sub_resource type="StyleBoxTexture" id=3]
texture = SubResource( 2 )
region_rect = Rect2( 0, 0, 16, 16 )
margin_left = 2.0
margin_right = 2.0
margin_top = 2.0
margin_bottom = 2.0
offset_left = 2.0
offset_right = 2.0
offset_top = 2.0
offset_bottom = 2.0
[sub_resource type="Image" id=7]
data = {
"data": PoolByteArray( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 224, 224, 0, 224, 224, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 224, 224, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 224, 224, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 224, 224, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 224, 224, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 224, 224, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 0, 0, 0, 0, 224, 224, 224, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 0, 0, 0, 0, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 224, 224, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 224, 224, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 224, 224, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 224, 224, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 224, 224, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 224, 224, 0, 224, 224, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ),
"data": PackedByteArray( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 224, 224, 0, 224, 224, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 224, 224, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 224, 224, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 224, 224, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 224, 224, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 224, 224, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 0, 0, 0, 0, 224, 224, 224, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 0, 0, 0, 0, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 224, 224, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 224, 224, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 224, 224, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 224, 224, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 224, 224, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 224, 224, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 224, 224, 0, 224, 224, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ),
"format": "RGBA8",
"height": 16,
"mipmaps": false,
@ -43,8 +43,8 @@ size = Vector2( 16, 16 )
[node name="Panel" type="Panel"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_top = -3.0
rect_min_size = Vector2( 0, 34 )
offset_top = -3.0
minimum_size = Vector2( 0, 34 )
custom_styles/panel = SubResource( 3 )
script = ExtResource( 1 )
__meta__ = {
@ -54,48 +54,48 @@ __meta__ = {
[node name="VBoxContainer" type="VBoxContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
rect_min_size = Vector2( 0, 24 )
minimum_size = Vector2( 0, 24 )
custom_constants/separation = 0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="TabbarContainer" type="HBoxContainer" parent="VBoxContainer"]
margin_right = 1024.0
margin_bottom = 24.0
offset_right = 1024.0
offset_bottom = 24.0
[node name="Tabs" type="Tabs" parent="VBoxContainer/TabbarContainer"]
margin_right = 1024.0
margin_bottom = 24.0
[node name="TabBar" type="TabBar" parent="VBoxContainer/TabbarContainer"]
offset_right = 1024.0
offset_bottom = 24.0
size_flags_horizontal = 3
tab_align = 0
tab_alignment = 0
tab_close_display_policy = 1
drag_to_rearrange_enabled = true
__meta__ = {
"_edit_use_anchors_": false
}
[node name="AddButton" type="ToolButton" parent="VBoxContainer/TabbarContainer/Tabs"]
margin_left = 3.0
margin_right = 31.0
margin_bottom = 24.0
hint_tooltip = "Add a new scene."
[node name="AddButton" type="Button" parent="VBoxContainer/TabbarContainer/TabBar"]
offset_left = 3.0
offset_right = 31.0
offset_bottom = 24.0
tooltip_text = "Add a new scene."
icon = SubResource( 5 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="PopupMenu" type="PopupMenu" parent="VBoxContainer/TabbarContainer"]
margin_left = 906.0
margin_right = 1024.0
margin_bottom = 88.0
offset_left = 906.0
offset_right = 1024.0
offset_bottom = 88.0
items = [ "Kill", null, 0, false, false, 0, 0, null, "", false, "Kill Others", null, 0, false, false, 1, 0, null, "", false, "Kill to the Right", null, 0, false, false, 2, 0, null, "", false, "Kill All", null, 0, false, false, 3, 0, null, "", false ]
[node name="TabContainer" type="TabContainer" parent="VBoxContainer"]
margin_top = 24.0
margin_right = 1024.0
margin_bottom = 603.0
rect_clip_content = true
offset_top = 24.0
offset_right = 1024.0
offset_bottom = 603.0
clip_contents = true
size_flags_vertical = 3
custom_constants/top_margin = 0
custom_constants/side_margin = 0
@ -103,8 +103,8 @@ custom_styles/panel = SubResource( 3 )
tabs_visible = false
[node name="TerminalPopupMenu" type="PopupMenu" parent="VBoxContainer"]
margin_right = 193.0
margin_bottom = 160.0
offset_right = 193.0
offset_bottom = 160.0
size_flags_horizontal = 0
size_flags_vertical = 0
items = [ "New Terminal", null, 0, false, false, 0, 0, null, "", false, "", null, 0, false, true, 1, 0, null, "", true, "Copy", null, 0, false, false, 2, 0, null, "", false, "Paste", null, 0, false, false, 3, 0, null, "", false, "Copy All", null, 0, false, false, 4, 0, null, "", false, "", null, 0, false, false, 5, 0, null, "", true, "Clear", null, 0, false, false, 6, 0, null, "", false, "Kill Terminal", null, 0, false, false, 7, 0, null, "", false ]
@ -118,10 +118,10 @@ anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -52.0
margin_top = -15.5
margin_right = 52.0
margin_bottom = 15.5
offset_left = -52.0
offset_top = -15.5
offset_right = 52.0
offset_bottom = 15.5
text = "Size: %d rows; %d cols
(%d x %d)"
align = 1
@ -133,10 +133,10 @@ __meta__ = {
show_behind_parent = true
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -5.0
margin_top = -5.0
margin_right = 5.0
margin_bottom = 5.0
offset_left = -5.0
offset_top = -5.0
offset_right = 5.0
offset_bottom = 5.0
grow_horizontal = 2
grow_vertical = 2
__meta__ = {
@ -146,10 +146,10 @@ __meta__ = {
[node name="SizeLabelTimer" type="Timer" parent="SizeLabel"]
[connection signal="resized" from="." to="." method="_on_Panel_resized"]
[connection signal="reposition_active_tab_request" from="VBoxContainer/TabbarContainer/Tabs" to="." method="_on_Tabs_reposition_active_tab_request"]
[connection signal="tab_changed" from="VBoxContainer/TabbarContainer/Tabs" to="." method="_on_Tabs_tab_changed"]
[connection signal="tab_close" from="VBoxContainer/TabbarContainer/Tabs" to="." method="_on_Tabs_tab_close"]
[connection signal="pressed" from="VBoxContainer/TabbarContainer/Tabs/AddButton" to="." method="_on_AddButton_pressed"]
[connection signal="reposition_active_tab_request" from="VBoxContainer/TabbarContainer/TabBar" to="." method="_on_Tabs_reposition_active_tab_request"]
[connection signal="tab_changed" from="VBoxContainer/TabbarContainer/TabBar" to="." method="_on_Tabs_tab_changed"]
[connection signal="tab_closed" from="VBoxContainer/TabbarContainer/TabBar" to="." method="_on_Tabs_tab_close"]
[connection signal="pressed" from="VBoxContainer/TabbarContainer/TabBar/AddButton" to="." method="_on_AddButton_pressed"]
[connection signal="gui_input" from="VBoxContainer/TabContainer" to="." method="_on_TabContainer_gui_input"]
[connection signal="id_pressed" from="VBoxContainer/TerminalPopupMenu" to="." method="_on_TerminalPopupMenu_id_pressed"]
[connection signal="timeout" from="SizeLabel/SizeLabelTimer" to="." method="_on_SizeLabelTimer_timeout"]

View file

@ -1,34 +1,34 @@
tool
@tool
extends EditorImportPlugin
const Asciicast = preload("../resources/asciicast.gd")
func get_importer_name():
func _get_importer_name():
return "godot_xterm"
func get_visible_name():
func _get_visible_name():
return "asciicast"
func get_recognized_extensions():
func _get_recognized_extensions():
return ["cast"]
func get_save_extension():
func _get_save_extension():
return "res"
func get_resource_type():
func _get_resource_type():
return "Animation"
func get_import_options(preset):
func _get_import_options(preset):
return []
func get_preset_count():
func _get_preset_count():
return 0
@ -45,29 +45,31 @@ 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": [PackedByteArray()]}}
while not file.eof_reached():
var line = file.get_line()
if line == "":
continue
var p = JSON.parse(line)
var test_json_conv = JSON.new()
test_json_conv.parse(line)
var p = test_json_conv.get_data()
if typeof(p.result) != TYPE_ARRAY:
continue
var event_type: String = p.result[1]
var event_data: PoolByteArray = p.result[2].to_utf8()
var event_data: PackedByteArray = p.result[2].to_utf8_buffer()
# 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)
var time = snapped(p.result[0], 0.01)
if event_type == "o":
if time == frame.time:
asciicast.track_remove_key_at_position(0, time)
asciicast.track_remove_key_at_time(0, time)
frame.data.args[0] = frame.data.args[0] + event_data
else:
frame.time = time
@ -77,4 +79,4 @@ func import(source_file, save_path, options, r_platform_variant, r_gen_files):
asciicast.length = frame.time
return ResourceSaver.save("%s.%s" % [save_path, get_save_extension()], asciicast)
return ResourceSaver.save("%s.%s" % [save_path, _get_save_extension()], asciicast)

View file

@ -1,34 +1,34 @@
tool
@tool
extends EditorImportPlugin
const XrdbTheme := preload("../resources/xrdb_theme.gd")
func get_importer_name():
func _get_importer_name():
return "godot_xterm_xrdb_importer"
func get_visible_name():
func _get_visible_name():
return "xrdb_theme"
func get_recognized_extensions():
func _get_recognized_extensions():
return ["xrdb", "Xresources", "xresources"]
func get_save_extension():
func _get_save_extension():
return "res"
func get_resource_type():
func _get_resource_type():
return "Theme"
func get_import_options(preset):
func _get_import_options(preset):
return []
func get_preset_count():
func _get_preset_count():
return 0
@ -121,4 +121,4 @@ func import(source_file, save_path, options, r_platform_variant, r_gen_files):
"cursor_text_color":
theme.set_color("cursor_text", "Terminal", color)
return ResourceSaver.save("%s.%s" % [save_path, get_save_extension()], theme)
return ResourceSaver.save("%s.%s" % [save_path, _get_save_extension()], theme)

View file

@ -1,6 +1,6 @@
# Copyright (c) 2021, Leroy Hopson (MIT License)
tool
@tool
extends Object
# Wrapper around libuv utility functions.
# GDNative does not currently support registering static functions so we fake it.
@ -23,9 +23,9 @@ static func get_cwd() -> String:
static func get_windows_build_number() -> int:
assert(OS.get_name() == "Windows", "This function is only supported on Windows.")
assert(OS.get_name() == "Windows") #,"This function is only supported checked Windows.")
var release: String = LibuvUtils.new().get_os_release()
assert(false, "Not implemented.")
assert(false) #,"Not implemented.")
return 0
@ -35,4 +35,4 @@ static func kill(pid: int, signum: int):
static func new():
assert(false, "Abstract sealed (i.e. static) class should not be instantiated.")
assert(false) #,"Abstract sealed (i.e. static) class should not be instantiated.")

View file

@ -1,4 +1,4 @@
tool
@tool
extends Node
signal data_received(data)
@ -20,5 +20,5 @@ func _not_implemented() -> int:
if stack.size() >= 2 and "function" in stack[1]:
method = "%s()" % stack[1].function
push_error("Method %s not implemented on the current platform (%s)." % [method, OS.get_name()])
push_error("Method %s not implemented checked the current platform (%s)." % [method, OS.get_name()])
return ERR_METHOD_NOT_FOUND

View file

@ -3,7 +3,7 @@
# Copyright (c) 2016, Daniel Imms (MIT License).
# Copyright (c) 2018, Microsoft Corporation (MIT License).
# Copyright (c) 2021-2022, Leroy Hopson (MIT License).
tool
@tool
extends "../pty_native.gd"
const LibuvUtils := preload("../libuv_utils.gd")
@ -18,7 +18,7 @@ const DEFAULT_ENV := {TERM = DEFAULT_NAME, COLORTERM = "truecolor"}
const FALLBACK_FILE = "sh"
## Default messages to indicate PAUSE/RESUME for automatic flow control.
## To avoid conflicts with rebound XON/XOFF control codes (such as on-my-zsh),
## To avoid conflicts with rebound XON/XOFF control codes (such as checked-my-zsh),
## the sequences can be customized in IPtyForkOptions.
#const FLOW_CONTROL_PAUSE = char(0x13) # defaults to XOFF
#const FLOW_CONTROL_RESUME = char(0x11) # defaults to XON
@ -35,7 +35,7 @@ enum Signal {
SIGFPE = 8, # Erroneous arithmetic operation
SIGKILL = 9, # Kill (cannot be caught or ignored)
SIGSEGV = 11, # Invalid memory reference
SIGPIPE = 13, # Write on a pipe with no one to read it
SIGPIPE = 13, # Write checked a pipe with no one to read it
SIGALRM = 14, # Alarm clock
SIGTERM = 15, # Termination signal
}
@ -62,18 +62,18 @@ var uid: int
var gid: int
var _fd: int = -1
var _exit_cb: FuncRef
var _exit_cb: Callable
# Writes data to the socket.
# data: The data to write.
func write(data) -> void:
assert(
data is PoolByteArray or data is String,
"Invalid type for argument 'data'. Should be of type PoolByteArray or String"
data is PackedByteArray or data is String,
"Invalid type for argument 'data'. Should be of type PackedByteArray or String"
)
if _pipe:
_pipe.write(data if data is PoolByteArray else data.to_utf8())
_pipe.write(data if data is PackedByteArray else data.to_utf8_buffer())
func resize(cols: int, rows: int) -> void:
@ -88,14 +88,14 @@ func kill(signum: int = Signal.SIGHUP) -> void:
LibuvUtils.kill(_pid, signum)
func _parse_env(env: Dictionary = {}) -> PoolStringArray:
func _parse_env(env: Dictionary = {}) -> PackedStringArray:
var keys := env.keys()
var pairs := PoolStringArray()
var pairs := PackedStringArray()
for key in keys:
var value = env[key]
var valid = key is String and value is String
assert(valid, "Env key/value pairs must be of type String/String.")
assert(valid) #,"Env key/value pairs must be of type String/String.")
if not valid:
push_warning("Skipping invalid env key/value pair.")
@ -113,7 +113,7 @@ func _process(_delta):
func fork(
file: String = OS.get_environment("SHELL"),
args: PoolStringArray = PoolStringArray(),
args: PackedStringArray = PackedStringArray(),
cwd = LibuvUtils.get_cwd(),
cols: int = DEFAULT_COLS,
rows: int = DEFAULT_ROWS,
@ -122,18 +122,18 @@ func fork(
utf8 = true
) -> int:
# File.
if file.empty():
if file.is_empty():
file = FALLBACK_FILE
# Environment variables.
# If we are using OS env vars, sanitize them to remove variables that might confuse our terminal.
# If we are using OS env vars, sanitize them to remove_at variables that might confuse our terminal.
var final_env := _sanitize_env(LibuvUtils.get_os_environ()) if use_os_env else {}
for key in env.keys():
final_env[key] = env[key]
var parsed_env: PoolStringArray = _parse_env(final_env)
var parsed_env: PackedStringArray = _parse_env(final_env)
# Exit callback.
_exit_cb = FuncRef.new()
_exit_cb = Callable.new()
_exit_cb.set_instance(self)
_exit_cb.set_function("_on_exit")
@ -157,7 +157,7 @@ func fork(
_pipe.open(_fd)
# Must connect to signal AFTER opening, otherwise we will get error ENOTSOCK.
_pipe.connect("data_received", self, "_on_pipe_data_received")
_pipe.connect("data_received",Callable(self,"_on_pipe_data_received"))
return OK

View file

@ -1,2 +1,2 @@
tool
extends Viewport
@tool
extends SubViewport

View file

@ -4,10 +4,10 @@
[sub_resource type="GDScript" id=1]
script/source = "tool
extends Viewport
extends SubViewport
"
[node name="Viewport" type="Viewport"]
[node name="SubViewport" type="SubViewport"]
size = Vector2( 2, 2 )
own_world = true
transparent_bg = true
@ -22,8 +22,8 @@ script = SubResource( 1 )
[node name="Terminal" type="Control" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
margin_right = -2.0
margin_bottom = -2.0
offset_right = -2.0
offset_bottom = -2.0
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false

View file

@ -1,4 +1,4 @@
tool
@tool
extends EditorPlugin
var pty_supported := OS.get_name() in ["X11", "Server", "OSX"]
@ -31,7 +31,7 @@ func _enter_tree():
"X11", "Server", "OSX":
pty_script = load("%s/pty.gd" % base_dir)
add_custom_type("PTY", "Node", pty_script, pty_icon)
terminal_panel = preload("./editor_plugins/terminal/terminal_panel.tscn").instance()
terminal_panel = preload("./editor_plugins/terminal/terminal_panel.tscn").instantiate()
terminal_panel.editor_plugin = self
terminal_panel.editor_interface = get_editor_interface()
add_control_to_bottom_panel(terminal_panel, "Terminal")

View file

@ -3,7 +3,7 @@
# Copyright (c) 2016, Daniel Imms (MIT License).
# Copyright (c) 2018, Microsoft Corporation (MIT License).
# Copyright (c) 2021-2022, Leroy Hopson (MIT License).
tool
@tool
extends Node
const _LibuvUtils := preload("./nodes/pty/libuv_utils.gd")
@ -23,23 +23,39 @@ const Signal = _PTYUnix.Signal
signal data_received(data)
signal exited(exit_code, signum)
export(NodePath) var terminal_path := NodePath() setget set_terminal_path
@export var terminal_path: NodePath := NodePath() :
get:
return terminal_path # TODOConverter40 Non existent get function
set(mod_value):
mod_value # TODOConverter40 Copy here content of set_terminal_path
var _terminal: _Terminal = null setget _set_terminal
var _terminal: _Terminal = null :
get:
return _terminal # TODOConverter40 Non existent get function
set(mod_value):
mod_value # TODOConverter40 Copy here content of _set_terminal
# The column size in characters.
export(int) var cols: int = DEFAULT_COLS setget set_cols, get_cols
@export var cols: int: int = DEFAULT_COLS :
get:
return cols # TODOConverter40 Copy here content of get_cols
set(mod_value):
mod_value # TODOConverter40 Copy here content of set_cols
# The row size in characters.
export(int) var rows: int = DEFAULT_ROWS setget set_rows, get_rows
@export var rows: int: int = DEFAULT_ROWS :
get:
return rows # TODOConverter40 Copy here content of get_rows
set(mod_value):
mod_value # TODOConverter40 Copy here content of set_rows
# Environment to be set for the child program.
export(Dictionary) var env := DEFAULT_ENV
@export var env: Dictionary := DEFAULT_ENV
# If true the environment variables in the env Dictionary will be merged with
# the environment variables of the operating system (e.g. printenv), with the
# former taking precedence in the case of conflicts.
export(bool) var use_os_env := true
@export var use_os_env: bool := true
var _cols := DEFAULT_COLS
var _rows := DEFAULT_ROWS
@ -52,10 +68,10 @@ func _init():
"X11", "Server", "OSX":
_pty_native = _PTYUnix.new()
_:
push_error("PTY is not support on current platform (%s)." % os_name)
push_error("PTY is not support checked current platform (%s)." % os_name)
_pty_native.connect("data_received", self, "_on_pty_native_data_received")
_pty_native.connect("exited", self, "_on_pty_native_exited")
_pty_native.connect("data_received",Callable(self,"_on_pty_native_data_received"))
_pty_native.connect("exited",Callable(self,"_on_pty_native_exited"))
add_child(_pty_native)
@ -92,9 +108,9 @@ func _set_terminal(value: _Terminal):
# Disconect the current terminal, if any.
if _terminal:
disconnect("data_received", _terminal, "write")
_terminal.disconnect("data_sent", self, "write")
_terminal.disconnect("size_changed", self, "resizev")
disconnect("data_received",Callable(_terminal,"write"))
_terminal.disconnect("data_sent",Callable(self,"write"))
_terminal.disconnect("size_changed",Callable(self,"resizev"))
_terminal = value
@ -103,12 +119,12 @@ func _set_terminal(value: _Terminal):
# Connect the new terminal.
resize(_terminal.get_cols(), _terminal.get_rows())
if not _terminal.is_connected("size_changed", self, "resizev"):
_terminal.connect("size_changed", self, "resizev")
if not _terminal.is_connected("data_sent", self, "write"):
_terminal.connect("data_sent", self, "write")
if not is_connected("data_received", _terminal, "write"):
connect("data_received", _terminal, "write")
if not _terminal.is_connected("size_changed",Callable(self,"resizev")):
_terminal.connect("size_changed",Callable(self,"resizev"))
if not _terminal.is_connected("data_sent",Callable(self,"write")):
_terminal.connect("data_sent",Callable(self,"write"))
if not is_connected("data_received",Callable(_terminal,"write")):
connect("data_received",Callable(_terminal,"write"))
# Writes data to the socket.
@ -138,7 +154,7 @@ func resizev(size: Vector2) -> void:
# Kill the pty.
# sigint: The signal to send. By default this is SIGHUP.
# This is not supported on Windows.
# This is not supported checked Windows.
func kill(signum: int = Signal.SIGHUP) -> void:
_pty_native.kill(signum)
@ -153,7 +169,7 @@ func _notification(what: int):
func fork(
file: String = OS.get_environment("SHELL"),
args: PoolStringArray = PoolStringArray(),
args: PackedStringArray = PackedStringArray(),
cwd = _LibuvUtils.get_cwd(),
cols: int = _cols,
rows: int = _rows,

View file

@ -3,11 +3,11 @@ extends Animation
signal data_written(data)
signal data_read(data)
export(int) var version: int = 2
@export var version: int: int = 2
# Initial terminal width (number of columns).
export(int) var width: int
@export var width: int: int
# Initial terminal height (number of rows).
export(int) var height: int
@export var height: int: int
func get_class() -> String:
@ -15,7 +15,7 @@ func get_class() -> String:
func is_class(name) -> bool:
return name == get_class() or .is_class(name)
return name == get_class() or super.is_class(name)
func _init():

View file

@ -6,4 +6,4 @@ func get_class() -> String:
func is_class(name) -> bool:
return name == get_class() or .is_class(name)
return name == get_class() or super.is_class(name)

View file

@ -4,7 +4,7 @@
# These snippets are copyright of their authors and released under the MIT license:
# - Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur (MIT License).
# - Copyright (c) 2014-2021 Godot Engine contributors (MIT License).
tool
@tool
extends Control
signal data_sent(data)
@ -24,28 +24,32 @@ enum SelectionMode {
POINTER,
}
export(UpdateMode) var update_mode = UpdateMode.AUTO setget set_update_mode
@export var update_mode: UpdateMode = UpdateMode.AUTO :
get:
return update_mode # TODOConverter40 Non existent get function
set(mod_value):
mod_value # TODOConverter40 Copy here content of set_update_mode
# If true, text in the terminal will be copied to the clipboard when selected.
export(bool) var copy_on_selection
@export var copy_on_selection: bool
# Bell
# If muted, the "bell" signal will not be emitted when the bell "\u0007" character
# is written to the terminal.
export var bell_muted := false
@export var bell_muted := false
# Amount of time in seconds that must pass before emitting a new "bell" signal.
# This can be useful in cases where the bell character is being written too
# frequently such as `while true; do echo -e "\a"; done`.
export var bell_cooldown: float = 0.1
@export var bell_cooldown: float = 0.1
export var blink_on_time: float = 0.6
export var blink_off_time: float = 0.3
@export var blink_on_time: float = 0.6
@export var blink_off_time: float = 0.3
var _cols := 2
var _rows := 2
var _default_theme: Theme = preload("./themes/default.tres")
var _viewport: Viewport = preload("./nodes/terminal/viewport.tscn").instance()
var _viewport: SubViewport = preload("./nodes/terminal/viewport.tscn").instantiate()
var _native_terminal: Control = _viewport.get_node("Terminal")
var _screen := TextureRect.new()
@ -73,11 +77,11 @@ func get_rows() -> int:
func write(data) -> void:
assert(
data is PoolByteArray or data is String,
"Invalid type for argument 'data'. Should be of type PoolByteArray or String."
data is PackedByteArray or data is String,
"Invalid type for argument 'data'. Should be of type PackedByteArray or String."
)
# Will be cleared when _flush() is called after VisualServer emits the "frame_pre_draw" signal.
# Will be cleared when _flush() is called after RenderingServer emits the "frame_pre_draw" signal.
_buffer.push_back(data)
# Ensure redraw is requested if terminal is visible.
@ -87,16 +91,16 @@ func write(data) -> void:
func _flush():
for data in _buffer:
_native_terminal.write(data if data is PoolByteArray else data.to_utf8())
_native_terminal.write(data if data is PackedByteArray else data.to_utf8_buffer())
_native_terminal.update()
_buffer.clear()
func clear() -> void:
var initial_size = _native_terminal.rect_size
_native_terminal.rect_size.y = _native_terminal.cell_size.y
var initial_size = _native_terminal.size
_native_terminal.size.y = _native_terminal.cell_size.y
_native_terminal.clear_sb()
_native_terminal.rect_size = initial_size
_native_terminal.size = initial_size
func copy_selection() -> String:
@ -111,22 +115,22 @@ func _ready():
_update_theme()
_native_terminal.update_mode = update_mode
_native_terminal.connect("data_sent", self, "_on_data_sent")
_native_terminal.connect("key_pressed", self, "_on_key_pressed")
_native_terminal.connect("size_changed", self, "_on_size_changed")
_native_terminal.connect("data_sent",Callable(self,"_on_data_sent"))
_native_terminal.connect("key_pressed",Callable(self,"_on_key_pressed"))
_native_terminal.connect("size_changed",Callable(self,"_on_size_changed"))
_viewport.size = rect_size
_viewport.render_target_update_mode = Viewport.UPDATE_ALWAYS
_viewport.size = size
_viewport.render_target_update_mode = SubViewport.UPDATE_ALWAYS
_screen.set_anchors_preset(PRESET_WIDE)
_screen.texture = _viewport.get_texture()
_native_terminal.connect("bell", self, "_on_bell")
_native_terminal.connect("bell",Callable(self,"_on_bell"))
_bell_timer.one_shot = true
add_child(_bell_timer)
_selection_timer.wait_time = 0.05
_selection_timer.connect("timeout", self, "_on_selection_held")
_selection_timer.connect("timeout",Callable(self,"_on_selection_held"))
add_child(_viewport)
add_child(_screen)
@ -138,31 +142,31 @@ func _ready():
# we make all the draw_* calls caused by writing. We need to use signals
# here rather than yield otherwise we will sometimes get a "Resumed
# function after yield but class instance is gone" error.
VisualServer.connect("frame_pre_draw", self, "_flush")
RenderingServer.connect("frame_pre_draw",Callable(self,"_flush"))
func _update_theme():
# Themes are not propagated through the Viewport, so in order for theme
# Themes are not propagated through the SubViewport, so in order for theme
# inheritance to work we can pass through the theme variables manually.
for color in _default_theme.get_color_list("Terminal"):
var c: Color
if has_color(color, "Terminal"):
if has_theme_color(color, "Terminal"):
c = get_color(color, "Terminal")
else:
c = _default_theme.get_color(color, "Terminal")
_native_terminal.add_color_override(color, c)
_native_terminal.add_theme_color_override(color, c)
for font in _default_theme.get_font_list("Terminal"):
var f: Font
if has_font(font, "Terminal"):
if has_theme_font(font, "Terminal"):
f = get_font(font, "Terminal")
elif has_font("regular", "Terminal"):
elif has_theme_font("regular", "Terminal"):
f = get_font("regular", "Terminal")
else:
if _default_theme.has_font(font, "Terminal"):
if _default_theme.has_theme_font(font, "Terminal"):
f = _default_theme.get_font(font, "Terminal")
else:
f = _default_theme.get_font(font, "regular")
_native_terminal.add_font_override(font, f)
_native_terminal.add_theme_font_override(font, f)
_native_terminal._update_theme()
_native_terminal._update_size()
@ -180,7 +184,7 @@ func _gui_input(event):
# Return to bottom of scrollback buffer if we scrolled up. Ignore modifier
# keys pressed in isolation or if Ctrl+Shift modifier keys are pressed.
if (
not event.scancode in [KEY_ALT, KEY_SHIFT, KEY_CONTROL, KEY_META, KEY_MASK_CMD]
not event.scancode in [KEY_ALT, KEY_SHIFT, KEY_CTRL, KEY_META, KEY_MASK_CMD]
and not (event.control and event.shift)
):
_native_terminal.sb_reset()
@ -197,7 +201,7 @@ func _handle_mouse_wheel(event: InputEventMouseButton):
if not event or not event.is_pressed():
return
if event.button_index == BUTTON_WHEEL_UP:
if event.button_index == MOUSE_BUTTON_WHEEL_UP:
if event.alt:
# Scroll 5 times as fast as normal (like TextEdit).
_native_terminal.sb_up(15 * event.factor)
@ -205,7 +209,7 @@ func _handle_mouse_wheel(event: InputEventMouseButton):
# Scroll 3 lines.
_native_terminal.sb_up(3 * event.factor)
if event.button_index == BUTTON_WHEEL_DOWN:
if event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
if event.alt:
# Scroll 5 times as fast as normal (like TextEdit).
_native_terminal.sb_down(15 * event.factor)
@ -216,7 +220,7 @@ func _handle_mouse_wheel(event: InputEventMouseButton):
func _handle_selection(event: InputEventMouse):
if event is InputEventMouseButton:
if not event or not event.is_pressed() or not event.button_index == BUTTON_LEFT:
if not event or not event.is_pressed() or not event.button_index == MOUSE_BUTTON_LEFT:
return
if _selecting:
@ -230,7 +234,7 @@ func _handle_selection(event: InputEventMouse):
elif event is InputEventMouseMotion:
if (
event.button_mask & BUTTON_MASK_LEFT
event.button_mask & MOUSE_BUTTON_MASK_LEFT
and _selecting_mode != SelectionMode.NONE
and not _selecting
):
@ -240,7 +244,7 @@ func _handle_selection(event: InputEventMouse):
func _on_selection_held() -> void:
if not Input.is_mouse_button_pressed(BUTTON_LEFT) or _selecting_mode == SelectionMode.NONE:
if not Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT) or _selecting_mode == SelectionMode.NONE:
if copy_on_selection:
var selection = _native_terminal.copy_selection()
OS.set_clipboard(selection)
@ -255,18 +259,18 @@ func _on_selection_held() -> void:
func _notification(what: int) -> void:
match what:
NOTIFICATION_RESIZED:
_viewport.size = rect_size
_viewport.size = size
_refresh()
NOTIFICATION_THEME_CHANGED:
_update_theme()
_refresh()
func _on_data_sent(data: PoolByteArray):
func _on_data_sent(data: PackedByteArray):
emit_signal("data_sent", data)
func _on_key_pressed(data: PoolByteArray, event: InputEventKey):
func _on_key_pressed(data: PackedByteArray, event: InputEventKey):
emit_signal("key_pressed", data.get_string_from_utf8(), event)

View file

@ -1,6 +1,6 @@
[gd_resource type="Theme" load_steps=2 format=2]
[ext_resource path="res://addons/godot_xterm/themes/fonts/regular.tres" type="DynamicFont" id=1]
[ext_resource path="res://addons/godot_xterm/themes/fonts/regular.tres" type="FontFile" id=1]
[resource]
default_font = ExtResource( 1 )

View file

@ -1,6 +1,6 @@
[gd_resource type="Theme" load_steps=2 format=2]
[ext_resource path="res://addons/godot_xterm/themes/fonts/regular.tres" type="DynamicFont" id=4]
[ext_resource path="res://addons/godot_xterm/themes/fonts/regular.tres" type="FontFile" id=4]
[resource]
default_font = ExtResource( 4 )

View file

@ -1,6 +1,6 @@
[gd_resource type="Theme" load_steps=2 format=2]
[sub_resource type="DynamicFont" id=1]
[sub_resource type="FontFile" id=1]
size = 14
extra_spacing_bottom = 1

View file

@ -1,6 +1,6 @@
[gd_resource type="DynamicFont" load_steps=2 format=2]
[gd_resource type="FontFile" load_steps=2 format=2]
[ext_resource path="res://addons/godot_xterm/themes/fonts/hack/hack_regular-3.003.ttf" type="DynamicFontData" id=4]
[ext_resource path="res://addons/godot_xterm/themes/fonts/hack/hack_regular-3.003.ttf" type="FontFile" id=4]
[resource]
size = 14

View file

@ -1,4 +1,4 @@
extends Reference
extends RefCounted
# Control Sequence Introducer
const CSI = "\u001b["
@ -17,24 +17,24 @@ class ANSIColor:
# colors of the selected terminal theme. Whereas Color will set
# the exact color specified regardless of theme.
const black = {fg = 30, bg = 40}
const red = {fg = 31, bg = 41}
const green = {fg = 32, bg = 42}
const yellow = {fg = 33, bg = 43}
const blue = {fg = 34, bg = 44}
const magenta = {fg = 35, bg = 45}
const cyan = {fg = 36, bg = 46}
const white = {fg = 37, bg = 47}
const bright_black = {fg = 90, bg = 100}
const black = {fg = 30, panel = 40}
const red = {fg = 31, panel = 41}
const green = {fg = 32, panel = 42}
const yellow = {fg = 33, panel = 43}
const blue = {fg = 34, panel = 44}
const magenta = {fg = 35, panel = 45}
const cyan = {fg = 36, panel = 46}
const white = {fg = 37, panel = 47}
const bright_black = {fg = 90, panel = 100}
const gray = bright_black
const grey = bright_black
const bright_red = {fg = 91, bg = 101}
const bright_green = {fg = 92, bg = 102}
const bright_yellow = {fg = 93, bg = 103}
const bright_blue = {fg = 94, bg = 104}
const bright_magenta = {fg = 95, bg = 105}
const bright_cyan = {fg = 96, bg = 106}
const bright_white = {fg = 97, bg = 107}
const bright_red = {fg = 91, panel = 101}
const bright_green = {fg = 92, panel = 102}
const bright_yellow = {fg = 93, panel = 103}
const bright_blue = {fg = 94, panel = 104}
const bright_magenta = {fg = 95, panel = 105}
const bright_cyan = {fg = 96, panel = 106}
const bright_white = {fg = 97, panel = 107}
func _init():
assert(
@ -46,23 +46,23 @@ class ANSIColor:
var terminal
func _init(p_terminal: Control) -> void:
func _init(p_terminal: Control):
if p_terminal:
terminal = p_terminal
func write_string(string: String, color: Color = Color.white) -> void:
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(fg.to_utf8_buffer())
terminal.write(string.to_utf8())
terminal.write(string.to_utf8_buffer())
# Reset color back to default.
terminal.write("\u001b[0m".to_utf8())
terminal.write("\u001b[0m".to_utf8_buffer())
# tput_* functions based on the tput command.
# tput_* functions based checked the tput command.
# See: https://man7.org/linux/man-pages/man1/tput.1.html for more info.
@ -88,8 +88,8 @@ func setaf(color) -> void:
func setab(color) -> void:
if color is Color:
terminal.write("\u001b[48;2;%d;%d;%dm" % [color.r8, color.g8, color.b8])
elif "bg" in color and color.bg is int:
terminal.write("\u001b[%dm" % color.bg)
elif "panel" in color and color.panel is int:
terminal.write("\u001b[%dm" % color.panel)
else:
push_error("Invalid color: %s" % color)