diff options
| author | Mariano Javier Suligoy | 2015-08-30 02:48:45 -0300 |
|---|---|---|
| committer | Mariano Javier Suligoy | 2015-08-30 02:48:45 -0300 |
| commit | c688b55019e485ddf66cd119173016ec6c8bd4e5 (patch) | |
| tree | 8f1d9eac70d8689545a66a378b4937530b42e8a7 /core/ustring.cpp | |
| parent | a19a653e2cae50f43b8de5d4ba69170c7d2fa800 (diff) | |
| parent | 7bc9846f169a0a65970c64ca3fc2e799eaa8b990 (diff) | |
| download | godot-c688b55019e485ddf66cd119173016ec6c8bd4e5.tar.gz godot-c688b55019e485ddf66cd119173016ec6c8bd4e5.tar.zst godot-c688b55019e485ddf66cd119173016ec6c8bd4e5.zip | |
Merge branch 'master' of https://github.com/okamstudio/godot
# Solved Conflicts:
# tools/editor/property_editor.cpp
# tools/editor/property_editor.h
Diffstat (limited to 'core/ustring.cpp')
| -rw-r--r-- | core/ustring.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/core/ustring.cpp b/core/ustring.cpp index 3cfc1e4a3..ff7c8984f 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -3048,6 +3048,37 @@ bool String::is_valid_identifier() const { //kind of poor should be rewritten properly +String String::world_wrap(int p_chars_per_line) const { + + int from=0; + int last_space=0; + String ret; + for(int i=0;i<length();i++) { + if (i-from>=p_chars_per_line) { + if (last_space==-1) { + ret+=substr(from,i-from+1)+"\n"; + } else { + ret+=substr(from,last_space-from)+"\n"; + i=last_space; //rewind + } + from=i+1; + last_space=-1; + } else if (operator[](i)==' ' || operator[](i)=='\t') { + last_space=i; + } else if (operator[](i)=='\n') { + ret+=substr(from,i-from); + from=i+1; + last_space=-1; + } + } + + if (from<length()) { + ret+=substr(from,length()); + } + + return ret; +} + String String::c_unescape() const { String escaped=*this; |
