custom_st_parser.gd 488 B

123456789101112131415
  1. extends LineEdit
  2. func _structured_text_parser(args, p_text):
  3. var output = []
  4. var tags = p_text.split(":")
  5. var prev = 0
  6. var count = int(tags.size())
  7. output.clear()
  8. for i in range(count):
  9. var range1 = Vector3i(prev, prev + tags[i].length(), TextServer.DIRECTION_AUTO)
  10. var range2 = Vector3i(prev + tags[i].length(), prev + tags[i].length() + 1, TextServer.DIRECTION_AUTO)
  11. output.push_front(range1)
  12. output.push_front(range2)
  13. prev = prev + tags[i].length() + 1
  14. return output