mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-12-22 20:32:38 +01:00
Fix caret position when using history
This commit is contained in:
parent
75bf6ed86a
commit
806253660f
5 changed files with 31 additions and 9 deletions
10
main.tscn
10
main.tscn
|
@ -45,6 +45,7 @@ __meta__ = {
|
|||
[node name="Output" type="TextEdit" parent="Terminal/Control"]
|
||||
margin_right = 700.0
|
||||
margin_bottom = 1038.0
|
||||
focus_mode = 0
|
||||
size_flags_vertical = 3
|
||||
custom_styles/read_only = SubResource( 1 )
|
||||
custom_fonts/font = ExtResource( 5 )
|
||||
|
@ -123,9 +124,10 @@ __meta__ = {
|
|||
|
||||
[node name="Repositories" type="HBoxContainer" parent="."]
|
||||
margin_left = 5.0
|
||||
margin_top = 75.0
|
||||
margin_top = 5.0
|
||||
margin_right = 1203.0
|
||||
margin_bottom = 1079.0
|
||||
mouse_filter = 2
|
||||
custom_constants/separation = 0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
|
@ -137,9 +139,10 @@ anchor_bottom = 0.0
|
|||
margin_left = 0.0
|
||||
margin_top = 0.0
|
||||
margin_right = 599.0
|
||||
margin_bottom = 1004.0
|
||||
margin_bottom = 1074.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
label = "Goal"
|
||||
|
||||
[node name="ActiveRepository" parent="Repositories" instance=ExtResource( 3 )]
|
||||
anchor_right = 0.0
|
||||
|
@ -147,8 +150,9 @@ anchor_bottom = 0.0
|
|||
margin_left = 599.0
|
||||
margin_top = 0.0
|
||||
margin_right = 1198.0
|
||||
margin_bottom = 1004.0
|
||||
margin_bottom = 1074.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
label = "Yours!"
|
||||
[connection signal="text_entered" from="Terminal/Control/Input" to="Terminal" method="send_command"]
|
||||
[connection signal="pressed" from="CommitMessage/SaveButton" to="." method="save_commit_message"]
|
||||
|
|
|
@ -23,10 +23,10 @@ __meta__ = {
|
|||
|
||||
[node name="ID" type="Label" parent="."]
|
||||
visible = false
|
||||
margin_left = -14.6409
|
||||
margin_top = -12.4902
|
||||
margin_right = 134.359
|
||||
margin_bottom = 40.5098
|
||||
margin_left = -19.9265
|
||||
margin_top = -12.0097
|
||||
margin_right = 129.073
|
||||
margin_bottom = 40.9903
|
||||
custom_fonts/font = ExtResource( 2 )
|
||||
custom_colors/font_color = Color( 1, 1, 1, 1 )
|
||||
text = "object_id"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
extends Container
|
||||
|
||||
export var label: String setget set_label
|
||||
export var path: String setget set_path, get_path
|
||||
var objects = {}
|
||||
|
||||
|
@ -28,6 +29,10 @@ func set_path(new_path):
|
|||
func get_path():
|
||||
return path
|
||||
|
||||
func set_label(new_label):
|
||||
label = new_label
|
||||
$Label.text = new_label
|
||||
|
||||
func update_index():
|
||||
$Index.text = git("ls-files")
|
||||
|
||||
|
@ -100,7 +105,7 @@ func apply_forces():
|
|||
var center_of_gravity = rect_size/2
|
||||
var d = o.position.distance_to(center_of_gravity)
|
||||
var dir = (o.position - center_of_gravity).normalized()
|
||||
var f = (d+0.00001)*0.01
|
||||
var f = (d+0.00001)*Vector2(0.03, 0.01)
|
||||
o.position -= dir*f
|
||||
|
||||
func git(args, splitlines = false):
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://repository.gd" type="Script" id=1]
|
||||
[ext_resource path="res://fonts/default.tres" type="DynamicFont" id=2]
|
||||
|
||||
[node name="Repository" type="Container"]
|
||||
anchor_right = 1.0
|
||||
|
@ -9,6 +10,7 @@ margin_left = 2.0
|
|||
margin_top = 3.0
|
||||
margin_right = -6.0
|
||||
margin_bottom = -4.0
|
||||
mouse_filter = 2
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
|
@ -47,4 +49,10 @@ text = "Update"
|
|||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
margin_left = 20.0
|
||||
margin_top = 20.0
|
||||
custom_fonts/font = ExtResource( 2 )
|
||||
text = "Repo name"
|
||||
[connection signal="pressed" from="Button" to="." method="update_everything"]
|
||||
|
|
|
@ -14,10 +14,15 @@ func _input(event):
|
|||
history_position -= 1
|
||||
history_position %= history.size()
|
||||
input.text = history[history_position]
|
||||
input.caret_position = input.text.length()
|
||||
# This prevents the Input taking the arrow as a "skip to beginning" command.
|
||||
get_tree().set_input_as_handled()
|
||||
if event.is_action_pressed("ui_down"):
|
||||
history_position += 1
|
||||
history_position %= history.size()
|
||||
input.text = history[history_position]
|
||||
input.caret_position = input.text.length()
|
||||
get_tree().set_input_as_handled()
|
||||
|
||||
func send_command(command):
|
||||
history.push_back(command)
|
||||
|
|
Loading…
Reference in a new issue