MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / indent

Method indent

core/string/ustring.cpp:4267–4286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4265}
4266
4267String String::indent(const String &p_prefix) const {
4268 String new_string;
4269 int line_start = 0;
4270
4271 for (int i = 0; i < length(); i++) {
4272 const char32_t c = operator[](i);
4273 if (c == '\n') {
4274 if (i == line_start) {
4275 new_string += c; // Leave empty lines empty.
4276 } else {
4277 new_string += p_prefix + substr(line_start, i - line_start + 1);
4278 }
4279 line_start = i + 1;
4280 }
4281 }
4282 if (line_start != length()) {
4283 new_string += p_prefix + substr(line_start);
4284 }
4285 return new_string;
4286}
4287
4288String String::dedent() const {
4289 String new_string;

Callers 3

_cell_button_pressedMethod · 0.80
_translate_doc_stringFunction · 0.80
test_string.hFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected