refactor terminal usage to scene

This commit is contained in:
Matt Parker
2026-01-19 18:55:47 +10:00
parent 26ce5b981e
commit ddc9286029
9 changed files with 79 additions and 38 deletions

View File

@@ -0,0 +1,33 @@
using GDExtensionBindgen;
using Godot;
namespace SharpIDE.Godot.Features.TerminalBase;
public partial class SharpIdeTerminal : Control
{
private Terminal _terminal = null!;
public override void _Ready()
{
var terminalControl = GetNode<Control>("Terminal");
_terminal = new Terminal(terminalControl);
}
[RequiresGodotUiThread]
public void Write(string text)
{
_terminal.Write(text);
}
public async Task WriteAsync(byte[] text)
{
await this.InvokeAsync(() => _terminal.Write(text));
}
[RequiresGodotUiThread]
public void ClearTerminal()
{
// .Clear removes all text except for the bottom row, so lets make sure we have a blank line, and cursor at start
_terminal.Write("\r\n");
_terminal.Clear();
}
}

View File

@@ -0,0 +1 @@
uid://7j2hyf2tvcdi

View File

@@ -0,0 +1,25 @@
[gd_scene load_steps=3 format=3 uid="uid://beo6fg8r0ogxc"]
[ext_resource type="Script" uid="uid://7j2hyf2tvcdi" path="res://Features/TerminalBase/SharpIdeTerminal.cs" id="1_kpqy5"]
[ext_resource type="Theme" uid="uid://bswaamju2blyt" path="res://Features/TerminalBase/TerminalTheme.tres" id="2_76y22"]
[node name="SharpIdeTerminal" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
size_flags_vertical = 3
script = ExtResource("1_kpqy5")
[node name="Terminal" type="Terminal" parent="."]
copy_on_selection = true
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("2_76y22")