Skip to content

Commit aa4f6fb

Browse files
committed
Bug fix in print_message() function in utilities.hpp
1 parent 5e082cf commit aa4f6fb

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

src/utilities.hpp

+5-11
Original file line numberDiff line numberDiff line change
@@ -3766,12 +3766,6 @@ inline void print(const string& s, const int textcolor) {
37663766
inline void print(const string& s, const int textcolor, const int backgroundcolor) {
37673767
std::cout << s;
37683768
}
3769-
inline void print_no_reset(const string& s, const int textcolor) { // print with color, but don't reset color afterwards (faster)
3770-
std::cout << s;
3771-
}
3772-
inline void print_no_reset(const string& s, const int textcolor, const int backgroundcolor) { // print with color, but don't reset color afterwards (faster)
3773-
std::cout << s;
3774-
}
37753769
#endif // UTILITIES_CONSOLE_COLOR
37763770

37773771
#ifdef UTILITIES_REGEX
@@ -3813,27 +3807,27 @@ inline void print_message(const string& message, const string& keyword="", const
38133807
const string word = v.at(i);
38143808
const uint wordlength = length(word);
38153809
l += wordlength+1u; // word + space
3816-
if(l<=w) { // word fits -> append word and space
3810+
if(l<=w+1u) { // word fits -> append word and space
38173811
p += word+" ";
38183812
} else if(wordlength>w) { // word overflows -> split word into next line
38193813
p += substring(word, 0, w-(l-wordlength-1u))+" |\n| "+f;
38203814
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
38213815
l = 0u; // reset line length
38223816
} else { // word does not fit -> fill remaining line with spaces
38233817
l = l-length(v.at(i--))-1u; // remove word from line, decrement i to start next line with this word
3824-
for(uint j=l; j<w; j++) p += " ";
3825-
p += " |\n| "+f;
3818+
for(uint j=l; j<=w; j++) p += " ";
3819+
p += "|\n| "+f;
38263820
l = 0u; // reset line length
38273821
}
38283822
}
3829-
for(uint j=l; j<w; j++) p += " ";
3823+
for(uint j=l; j<=w; j++) p += " ";
38303824
if(keyword_color<0||keyword_color>15) {
38313825
print("\r| "+keyword);
38323826
} else {
38333827
print("\r| ");
38343828
print(keyword, keyword_color);
38353829
}
3836-
println(p+" |");
3830+
println(p+"|");
38373831
}
38383832
inline void print_error(const string& s) { // print formatted error message
38393833
print_message(s, "Error", color_red);

0 commit comments

Comments
 (0)