Implement very stupid history

This commit is contained in:
Sebastian Morr 2020-09-01 19:59:07 +02:00
parent 8ee7abbc82
commit 590408e54c
3 changed files with 22 additions and 2 deletions

View file

@ -1,6 +1,6 @@
echo "Hi" > file1 echo "Hi" > file1
echo "Ho" > file1 echo "Ho" > file2
echo "Hu" > file1 echo "Hu" > file3
git hash-object -w file1 git hash-object -w file1
git hash-object -w file2 git hash-object -w file2
git hash-object -w file3 git hash-object -w file3

View file

@ -18,6 +18,7 @@ func _ready():
# Load first level. # Load first level.
load_level(0) load_level(0)
$Terminal/Input.grab_focus()
func list_levels(): func list_levels():
var levels = [] var levels = []
@ -96,6 +97,7 @@ func read_commit_message():
$CommitMessage.show() $CommitMessage.show()
$Terminal/Input.editable = false $Terminal/Input.editable = false
$CommitMessage.text = game.read_file($ActiveRepository.path+"/.git/COMMIT_EDITMSG") $CommitMessage.text = game.read_file($ActiveRepository.path+"/.git/COMMIT_EDITMSG")
$CommitMessage.grab_focus()
func save_commit_message(): func save_commit_message():
game.write_file($ActiveRepository.path+"/.git/COMMIT_EDITMSG", $CommitMessage.text) game.write_file($ActiveRepository.path+"/.git/COMMIT_EDITMSG", $CommitMessage.text)
@ -104,3 +106,4 @@ func save_commit_message():
$Terminal/Input.editable = true $Terminal/Input.editable = true
$CommitMessage.text = "" $CommitMessage.text = ""
$CommitMessage.hide() $CommitMessage.hide()
$Terminal/Input.grab_focus()

View file

@ -2,7 +2,24 @@ extends Node2D
var thread var thread
var history = []
var history_position = 0
func _input(event):
if history.size() > 0:
if event.is_action_pressed("ui_up"):
history_position -= 1
history_position %= history.size()
$Input.text = history[history_position]
if event.is_action_pressed("ui_down"):
history_position += 1
history_position %= history.size()
$Input.text = history[history_position]
func send_command(command): func send_command(command):
history.push_back(command)
history_position += 1
thread = Thread.new() thread = Thread.new()
thread.start(self, "run_command_in_a_thread", command) thread.start(self, "run_command_in_a_thread", command)