From 4b988717e635bd3278e875303f5b181699284a71 Mon Sep 17 00:00:00 2001 From: Sebastian Morr Date: Tue, 29 Sep 2020 17:05:04 +0200 Subject: [PATCH] Use simple pager for long output --- arrow.tscn | 1 - main.tscn | 5 ++++- node.tscn | 12 ++++++------ terminal.gd | 7 ++++++- terminal.tscn | 19 +++++++++++++++++++ 5 files changed, 35 insertions(+), 9 deletions(-) diff --git a/arrow.tscn b/arrow.tscn index 2550926..07cfdb5 100644 --- a/arrow.tscn +++ b/arrow.tscn @@ -5,7 +5,6 @@ [node name="Arrow" type="Node2D"] show_behind_parent = true -z_as_relative = false script = ExtResource( 1 ) [node name="Line" type="Line2D" parent="."] diff --git a/main.tscn b/main.tscn index 2c0beef..6a4af7b 100644 --- a/main.tscn +++ b/main.tscn @@ -30,7 +30,10 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="Background" type="ColorRect" parent="."] +[node name="CanvasLayer" type="CanvasLayer" parent="."] +layer = -1 + +[node name="Background" type="ColorRect" parent="CanvasLayer"] anchor_right = 1.0 anchor_bottom = 1.0 mouse_filter = 2 diff --git a/node.tscn b/node.tscn index 4773043..7fc1ab2 100644 --- a/node.tscn +++ b/node.tscn @@ -17,9 +17,11 @@ corner_radius_bottom_right = 5 corner_radius_bottom_left = 5 [node name="Node" type="Node2D"] -z_index = 1 script = ExtResource( 1 ) +[node name="Arrows" type="Node2D" parent="."] +z_index = -1 + [node name="Rect" type="ColorRect" parent="."] margin_left = -29.0 margin_top = -28.0 @@ -48,6 +50,9 @@ __meta__ = { "_edit_use_anchors_": false } +[node name="Pop" type="AudioStreamPlayer2D" parent="."] +stream = ExtResource( 4 ) + [node name="Content" type="Label" parent="."] visible = false margin_left = -22.2898 @@ -60,10 +65,5 @@ custom_colors/font_color = Color( 1, 1, 1, 1 ) __meta__ = { "_edit_use_anchors_": false } - -[node name="Arrows" type="Node2D" parent="."] - -[node name="Pop" type="AudioStreamPlayer2D" parent="."] -stream = ExtResource( 4 ) [connection signal="mouse_entered" from="Rect" to="." method="_on_hover"] [connection signal="mouse_exited" from="Rect" to="." method="_on_unhover"] diff --git a/terminal.gd b/terminal.gd index 0259775..71359b6 100644 --- a/terminal.gd +++ b/terminal.gd @@ -98,7 +98,12 @@ func run_command_in_a_thread(command): input.text = "" input.editable = true - output.text = output.text + "$ " + command + "\n" + o + + if o.length() <= 200: + output.text = output.text + "$ " + command + "\n" + o + else: + $Pager/Text.text = o + $Pager.popup() repository.update_everything() func receive_output(text): diff --git a/terminal.tscn b/terminal.tscn index a578cb4..5b585f3 100644 --- a/terminal.tscn +++ b/terminal.tscn @@ -42,6 +42,8 @@ size_flags_vertical = 3 [node name="Output" type="RichTextLabel" parent="Rows/TopHalf"] anchor_right = 1.0 anchor_bottom = 1.0 +margin_top = -1.92206 +margin_bottom = -1.92212 size_flags_vertical = 3 custom_styles/normal = SubResource( 1 ) custom_fonts/normal_font = ExtResource( 4 ) @@ -106,6 +108,23 @@ mouse_filter = 1 syntax_highlighting = false [node name="TCPServer" parent="." instance=ExtResource( 3 )] + +[node name="Pager" type="WindowDialog" parent="."] +visible = true +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = 18.0 +margin_top = 39.0 +margin_right = -687.0 +margin_bottom = -48.0 + +[node name="Text" type="RichTextLabel" parent="Pager"] +anchor_right = 1.0 +anchor_bottom = 1.0 +custom_fonts/normal_font = ExtResource( 4 ) +__meta__ = { +"_edit_use_anchors_": false +} [connection signal="item_selected" from="Rows/TopHalf/Completions" to="." method="_completion_selected"] [connection signal="text_changed" from="Rows/InputLine/Input" to="." method="_input_changed"] [connection signal="text_entered" from="Rows/InputLine/Input" to="." method="send_command"]