2020-09-01 21:25:24 +02:00
|
|
|
extends Control
|
2020-06-10 18:25:41 +02:00
|
|
|
|
2020-09-01 15:14:01 +02:00
|
|
|
var thread
|
|
|
|
|
2020-09-01 19:59:07 +02:00
|
|
|
var history = []
|
|
|
|
var history_position = 0
|
|
|
|
|
2020-09-01 21:25:24 +02:00
|
|
|
onready var input = $Control/Input
|
|
|
|
onready var output = $Control/Output
|
|
|
|
|
2020-09-01 19:59:07 +02:00
|
|
|
func _input(event):
|
|
|
|
if history.size() > 0:
|
|
|
|
if event.is_action_pressed("ui_up"):
|
|
|
|
history_position -= 1
|
|
|
|
history_position %= history.size()
|
2020-09-01 21:25:24 +02:00
|
|
|
input.text = history[history_position]
|
2020-09-01 19:59:07 +02:00
|
|
|
if event.is_action_pressed("ui_down"):
|
|
|
|
history_position += 1
|
|
|
|
history_position %= history.size()
|
2020-09-01 21:25:24 +02:00
|
|
|
input.text = history[history_position]
|
2020-09-01 19:59:07 +02:00
|
|
|
|
2020-09-01 14:03:18 +02:00
|
|
|
func send_command(command):
|
2020-09-01 19:59:07 +02:00
|
|
|
history.push_back(command)
|
|
|
|
history_position += 1
|
|
|
|
|
2020-09-01 15:14:01 +02:00
|
|
|
thread = Thread.new()
|
|
|
|
thread.start(self, "run_command_in_a_thread", command)
|
|
|
|
|
|
|
|
func run_command_in_a_thread(command):
|
2020-09-01 21:25:24 +02:00
|
|
|
var o = game.sh(command, "/tmp/active")
|
2020-09-01 14:03:18 +02:00
|
|
|
|
2020-09-01 21:25:24 +02:00
|
|
|
input.text = ""
|
|
|
|
output.text = output.text + "$ " + command + "\n" + o
|
|
|
|
output.scroll_vertical = 999999
|
2020-09-03 17:50:03 +02:00
|
|
|
$"../Repositories/ActiveRepository".update_everything() # FIXME
|