Adding and removing an entire line of text in a string #12841
MincerafterJack
started this conversation in
Engine Core
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm not aware of similar methods in the String class, so how about adding methods in String class like new_line(text: String), insert_line(text: String, at: int), remove_line(at: int, keep_empty_line :bool = false), and get_line_count()?
The main benefit of this would be implementing a single-node solution for chat/info text that uses a Label node instead of an RichTextLabel as rich text is unnecessary sometimes.
new_line(text: String) is basically string + "\n" + text
insert_line(text: String, at: int) makes an empty line at the line number specified, and put the text there. Negative line numbers count from the end like arrays. (whether line number starts from 0 or 1 is up for discussion)
remove_line(at: int, keep_empty_line :bool = false) removes an entire line at the line number specified. Negative line numbers count from the end like arrays.
get_line_count() gets the amount of lines in the given string. Empty strings will have a line count of 0.
Beta Was this translation helpful? Give feedback.
All reactions