mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-01 03:03:40 +00:00
UI: Handle newlines after ellipsis.
This commit is contained in:
parent
2f570481b7
commit
7dc3287617
@ -153,9 +153,9 @@ void WordWrapper::AppendWord(int endIndex, int lastChar, bool addNewline) {
|
||||
x_ = 0.0f;
|
||||
} else {
|
||||
// We may have appended a newline - check.
|
||||
size_t pos = out_.substr(lastLineStart_).find_last_of("\n");
|
||||
size_t pos = out_.find_last_of("\n");
|
||||
if (pos != out_.npos) {
|
||||
lastLineStart_ += pos;
|
||||
lastLineStart_ = pos + 1;
|
||||
}
|
||||
|
||||
if (lastChar == -1 && !out_.empty()) {
|
||||
@ -202,12 +202,15 @@ void WordWrapper::Wrap() {
|
||||
|
||||
// Is this a newline character, hard wrapping?
|
||||
if (c == '\n') {
|
||||
if (skipNextWord_) {
|
||||
lastIndex_ = beforeIndex;
|
||||
skipNextWord_ = false;
|
||||
}
|
||||
// This will include the newline character.
|
||||
AppendWord(afterIndex, c, false);
|
||||
// We wrapped once, so stop forcing.
|
||||
forceEarlyWrap_ = false;
|
||||
scanForNewline_ = false;
|
||||
skipNextWord_ = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -731,6 +731,12 @@ static bool TestWrapText() {
|
||||
EXPECT_WORDWRAP_EQ_STR(shyTestString.c_str(), 10, FLAG_ELLIPSIZE_TEXT, "Very...");
|
||||
EXPECT_WORDWRAP_EQ_STR(shyTestString.c_str(), 10, FLAG_WRAP_TEXT | FLAG_ELLIPSIZE_TEXT, "Very-\nlong");
|
||||
|
||||
// Newlines should not be removed and should influence wrapping.
|
||||
EXPECT_WORDWRAP_EQ_STR("Hello\ngoodbye yes\nno", 14, 0, "Hello\ngoodbye ");
|
||||
EXPECT_WORDWRAP_EQ_STR("Hello\ngoodbye yes\nno", 14, FLAG_WRAP_TEXT, "Hello\ngoodbye \nyes\nno");
|
||||
EXPECT_WORDWRAP_EQ_STR("Hello\ngoodbye yes\nno", 14, FLAG_ELLIPSIZE_TEXT, "Hello\ngoodb...\nno");
|
||||
EXPECT_WORDWRAP_EQ_STR("Hello\ngoodbye yes\nno", 14, FLAG_WRAP_TEXT | FLAG_ELLIPSIZE_TEXT, "Hello\ngoodbye \nyes\nno");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user