Skip to content

Commit

Permalink
Bug fix in print_message() function in utilities.hpp
Browse files Browse the repository at this point in the history
  • Loading branch information
ProjectPhysX committed Jun 25, 2023
1 parent 009f40d commit deb0a35
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/utilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,21 +597,21 @@ inline void print_message(const string& message, const string& keyword="", const
const string word = v.at(i);
const uint wordlength = length(word);
l += wordlength+1u; // word + space
if(l<=w) { // word fits -> append word and space
if(l<=w+1u) { // word fits -> append word and space
p += word+" ";
} else if(wordlength>w) { // word overflows -> split word into next line
p += substring(word, 0, w-(l-wordlength-1u))+" |\n| "+f;
v[i] = substring(v[i], w-(l-wordlength-1u)); i--; // reuse same vector element for overflowing part, decrement i to start next line with this overflowing part
l = 0u; // reset line length
} else { // word does not fit -> fill remaining line with spaces
l = l-length(v.at(i--))-1u; // remove word from line, decrement i to start next line with this word
for(uint j=l; j<w; j++) p += " ";
p += " |\n| "+f;
for(uint j=l; j<=w; j++) p += " ";
p += "|\n| "+f;
l = 0u; // reset line length
}
}
for(uint j=l; j<w; j++) p += " ";
println("\r| "+keyword+p+" |");
for(uint j=l; j<=w; j++) p += " ";
println("\r| "+keyword+p+"|");
}
inline void print_error(const string& s) { // print formatted error message
print_message(s, "Error");
Expand Down

0 comments on commit deb0a35

Please sign in to comment.