mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-22 16:20:19 +01:00
Dropdown menu for premade commands
This commit is contained in:
parent
6d0fff27ad
commit
0b4c4f9449
2 changed files with 40 additions and 13 deletions
15
terminal.gd
15
terminal.gd
|
@ -8,11 +8,22 @@ var history_position = 0
|
||||||
onready var input = $Control/Input
|
onready var input = $Control/Input
|
||||||
onready var output = $Control/Output
|
onready var output = $Control/Output
|
||||||
onready var repo = $"../Repositories/ActiveRepository"
|
onready var repo = $"../Repositories/ActiveRepository"
|
||||||
|
onready var command_dropdown = $Control/CommandDropdown
|
||||||
onready var main = get_parent()
|
onready var main = get_parent()
|
||||||
|
|
||||||
|
var premade_commands = [
|
||||||
|
'git commit --allow-empty -m "empty"',
|
||||||
|
'echo $RANDOM | git hash-object -w --stdin',
|
||||||
|
'git switch -c $RANDOM',
|
||||||
|
]
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
repo.shell.connect("output", self, "receive_output")
|
repo.shell.connect("output", self, "receive_output")
|
||||||
|
|
||||||
|
for command in premade_commands:
|
||||||
|
command_dropdown.get_popup().add_item(command)
|
||||||
|
command_dropdown.get_popup().connect("id_pressed", self, "load_command")
|
||||||
|
|
||||||
func _input(event):
|
func _input(event):
|
||||||
if event is InputEventKey:
|
if event is InputEventKey:
|
||||||
input.grab_focus()
|
input.grab_focus()
|
||||||
|
@ -31,6 +42,10 @@ func _input(event):
|
||||||
input.caret_position = input.text.length()
|
input.caret_position = input.text.length()
|
||||||
get_tree().set_input_as_handled()
|
get_tree().set_input_as_handled()
|
||||||
|
|
||||||
|
func load_command(id):
|
||||||
|
input.text = premade_commands[id]
|
||||||
|
input.caret_position = input.text.length()
|
||||||
|
|
||||||
func send_command(command):
|
func send_command(command):
|
||||||
history.push_back(command)
|
history.push_back(command)
|
||||||
history_position = history.size()
|
history_position = history.size()
|
||||||
|
|
|
@ -43,7 +43,7 @@ __meta__ = {
|
||||||
|
|
||||||
[node name="Output" type="RichTextLabel" parent="Control"]
|
[node name="Output" type="RichTextLabel" parent="Control"]
|
||||||
margin_right = 1920.0
|
margin_right = 1920.0
|
||||||
margin_bottom = 979.0
|
margin_bottom = 1007.0
|
||||||
focus_mode = 2
|
focus_mode = 2
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
custom_styles/normal = SubResource( 1 )
|
custom_styles/normal = SubResource( 1 )
|
||||||
|
@ -53,54 +53,66 @@ scroll_following = true
|
||||||
selection_enabled = true
|
selection_enabled = true
|
||||||
|
|
||||||
[node name="Button" parent="Control" instance=ExtResource( 4 )]
|
[node name="Button" parent="Control" instance=ExtResource( 4 )]
|
||||||
|
visible = false
|
||||||
margin_left = 0.0
|
margin_left = 0.0
|
||||||
margin_top = 979.0
|
margin_top = 887.0
|
||||||
margin_right = 1920.0
|
margin_right = 1920.0
|
||||||
margin_bottom = 999.0
|
margin_bottom = 907.0
|
||||||
text = "git commit --allow-empty"
|
text = "git commit --allow-empty"
|
||||||
align = 0
|
align = 0
|
||||||
|
|
||||||
[node name="Button5" parent="Control" instance=ExtResource( 4 )]
|
[node name="Button5" parent="Control" instance=ExtResource( 4 )]
|
||||||
|
visible = false
|
||||||
margin_left = 0.0
|
margin_left = 0.0
|
||||||
margin_top = 999.0
|
margin_top = 907.0
|
||||||
margin_right = 1920.0
|
margin_right = 1920.0
|
||||||
margin_bottom = 1019.0
|
margin_bottom = 927.0
|
||||||
text = "echo $RANDOM | git hash-object -w --stdin"
|
text = "echo $RANDOM | git hash-object -w --stdin"
|
||||||
align = 0
|
align = 0
|
||||||
|
|
||||||
[node name="Button6" parent="Control" instance=ExtResource( 4 )]
|
[node name="Button6" parent="Control" instance=ExtResource( 4 )]
|
||||||
visible = false
|
visible = false
|
||||||
margin_left = 0.0
|
margin_left = 0.0
|
||||||
margin_top = 1019.0
|
margin_top = 927.0
|
||||||
margin_right = 1920.0
|
margin_right = 1920.0
|
||||||
margin_bottom = 1039.0
|
margin_bottom = 947.0
|
||||||
text = "git update-index --add noises; git write-tree"
|
text = "git update-index --add noises; git write-tree"
|
||||||
align = 0
|
align = 0
|
||||||
|
|
||||||
[node name="Button2" parent="Control" instance=ExtResource( 4 )]
|
[node name="Button2" parent="Control" instance=ExtResource( 4 )]
|
||||||
|
visible = false
|
||||||
margin_left = 0.0
|
margin_left = 0.0
|
||||||
margin_top = 1019.0
|
margin_top = 947.0
|
||||||
margin_right = 1920.0
|
margin_right = 1920.0
|
||||||
margin_bottom = 1039.0
|
margin_bottom = 967.0
|
||||||
text = "git switch -c $RANDOM"
|
text = "git switch -c $RANDOM"
|
||||||
align = 0
|
align = 0
|
||||||
|
|
||||||
[node name="Button3" parent="Control" instance=ExtResource( 4 )]
|
[node name="Button3" parent="Control" instance=ExtResource( 4 )]
|
||||||
visible = false
|
visible = false
|
||||||
margin_left = 0.0
|
margin_left = 0.0
|
||||||
margin_top = 999.0
|
margin_top = 967.0
|
||||||
margin_right = 1920.0
|
margin_right = 1920.0
|
||||||
margin_bottom = 1019.0
|
margin_bottom = 987.0
|
||||||
text = "git checkout HEAD^"
|
text = "git checkout HEAD^"
|
||||||
align = 0
|
align = 0
|
||||||
|
|
||||||
[node name="Button4" parent="Control" instance=ExtResource( 4 )]
|
[node name="Button4" parent="Control" instance=ExtResource( 4 )]
|
||||||
visible = false
|
visible = false
|
||||||
margin_left = 0.0
|
margin_left = 0.0
|
||||||
margin_top = 1019.0
|
margin_top = 987.0
|
||||||
|
margin_right = 1920.0
|
||||||
|
margin_bottom = 1007.0
|
||||||
|
text = "sleep 1;echo hey"
|
||||||
|
align = 0
|
||||||
|
|
||||||
|
[node name="CommandDropdown" type="MenuButton" parent="Control"]
|
||||||
|
margin_top = 1007.0
|
||||||
margin_right = 1920.0
|
margin_right = 1920.0
|
||||||
margin_bottom = 1039.0
|
margin_bottom = 1039.0
|
||||||
text = "sleep 1;echo hey"
|
custom_fonts/font = ExtResource( 1 )
|
||||||
|
text = "Pick a command..."
|
||||||
|
flat = false
|
||||||
align = 0
|
align = 0
|
||||||
|
|
||||||
[node name="Input" type="LineEdit" parent="Control"]
|
[node name="Input" type="LineEdit" parent="Control"]
|
||||||
|
|
Loading…
Reference in a new issue