fixed caret issue so it properly tracks
This commit is contained in:
@@ -248,20 +248,14 @@ func GetBottomScroll():
|
||||
func UpdateCaretPos():
|
||||
|
||||
await get_tree().create_timer(.01).timeout
|
||||
var font = terminalLine.get_theme_font("normal_font")
|
||||
var font_size = terminalLine.get_theme_font_size("normal_font_size")
|
||||
var visible_text = terminalLine.get_parsed_text()
|
||||
var lines = visible_text.split("\n")
|
||||
var last_line = lines[-1]
|
||||
var char_rectY = terminalLine.get_content_height()
|
||||
var text_line = TextLine.new()
|
||||
var ruler: Label = $"caret-ruler"
|
||||
|
||||
text_line.width = terminalLine.size.x
|
||||
text_line.flags = TextServer.JUSTIFICATION_NONE
|
||||
text_line.alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
text_line.add_string(last_line, font, font_size)
|
||||
ruler.autowrap_mode =TextServer.AUTOWRAP_WORD_SMART
|
||||
ruler.text = visible_text
|
||||
|
||||
caret.position.x = text_line.get_line_width()
|
||||
caret.position.y = char_rectY - 50
|
||||
var last_char_index = ruler.text.length() - 1
|
||||
var char_rect = ruler.get_character_bounds(max(0, last_char_index))
|
||||
caret.position.x = char_rect.end.x + 1
|
||||
caret.position.y = terminalLine.get_content_height() - 50
|
||||
|
||||
pass
|
||||
|
||||
@@ -86,6 +86,7 @@ viewport_path = NodePath("Interactables/PC/Sprite3D/SubViewport")
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_nmbs0"]
|
||||
font_size = 42
|
||||
font_color = Color(0, 0, 0, 1)
|
||||
|
||||
[sub_resource type="Theme" id="Theme_nmbs0"]
|
||||
default_font_size = 42
|
||||
@@ -230,6 +231,15 @@ size = Vector2i(1830, 1400)
|
||||
script = ExtResource("10_gba58")
|
||||
terminalLine = NodePath("MarginContainer/ScrollContainer/VBoxContainer/Label")
|
||||
|
||||
[node name="caret-ruler" type="Label" parent="Interactables/PC/Sprite3D/SubViewport"]
|
||||
clip_contents = true
|
||||
custom_minimum_size = Vector2(1800, 0)
|
||||
offset_right = 1800.0
|
||||
offset_bottom = 58.0
|
||||
text = "a0ifjaojkfna"
|
||||
label_settings = SubResource("LabelSettings_nmbs0")
|
||||
autowrap_mode = 3
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="Interactables/PC/Sprite3D/SubViewport"]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
@@ -243,16 +253,8 @@ scroll_horizontal_custom_step = 0.001
|
||||
scroll_vertical_custom_step = 0.001
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Interactables/PC/Sprite3D/SubViewport/MarginContainer/ScrollContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label3" type="Label" parent="Interactables/PC/Sprite3D/SubViewport/MarginContainer/ScrollContainer/VBoxContainer"]
|
||||
visible = false
|
||||
clip_contents = true
|
||||
custom_minimum_size = Vector2(1800, 0)
|
||||
layout_mode = 2
|
||||
text = "a0ifjaojkfna"
|
||||
label_settings = SubResource("LabelSettings_nmbs0")
|
||||
autowrap_mode = 3
|
||||
|
||||
[node name="Label" type="RichTextLabel" parent="Interactables/PC/Sprite3D/SubViewport/MarginContainer/ScrollContainer/VBoxContainer"]
|
||||
clip_contents = false
|
||||
|
||||
Reference in New Issue
Block a user