[Scummvm-git-logs] scummvm master -> 4c996feb5d504eae715608c3587303d5c1464fae
npjg
nathanael.gentrydb8 at gmail.com
Fri Jul 31 05:09:05 UTC 2020
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
1ef07ff5dd GRAPHICS: MACGUI: MacText: Fix selection offsets
4c996feb5d GRAPHICS: MACGUI: MacText: Fix selection condition
Commit: 1ef07ff5dd6e4a574e736cf14a3763cc6eedb3b5
https://github.com/scummvm/scummvm/commit/1ef07ff5dd6e4a574e736cf14a3763cc6eedb3b5
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2020-07-31T01:08:45-04:00
Commit Message:
GRAPHICS: MACGUI: MacText: Fix selection offsets
There is an additional "character" at the end of each line that we weren't
counting, which is what caused selection setting to get off.
Changed paths:
graphics/macgui/mactext.cpp
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 681a9eb5ed..71f7cb967c 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -1042,18 +1042,18 @@ void MacText::setSelection(int pos, bool start) {
for (uint i = 0; i < _textLines[row].chunks.size(); i++) {
if ((uint)pos < _textLines[row].chunks[i].text.size()) {
colX += _textLines[row].chunks[i].getFont()->getStringWidth(Common::U32String(_textLines[row].chunks[i].text.c_str(), pos));
- col += pos;
+ col += pos + 1;
pos = 0;
break;
} else {
colX += _textLines[row].chunks[i].getFont()->getStringWidth(Common::U32String(_textLines[row].chunks[i].text));
pos -= _textLines[row].chunks[i].text.size();
- col += _textLines[row].chunks[i].text.size();
+ col += _textLines[row].chunks[i].text.size() + 1;
}
}
break;
} else {
- pos -= getLineCharWidth(row);
+ pos -= getLineCharWidth(row) + (row ? 1 : 0);
}
row++;
Commit: 4c996feb5d504eae715608c3587303d5c1464fae
https://github.com/scummvm/scummvm/commit/4c996feb5d504eae715608c3587303d5c1464fae
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2020-07-31T01:08:56-04:00
Commit Message:
GRAPHICS: MACGUI: MacText: Fix selection condition
Outside the while loop we only check pos > 0 once.
Changed paths:
graphics/macgui/mactext.cpp
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 71f7cb967c..2560339c66 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -1037,35 +1037,35 @@ void MacText::setSelection(int pos, bool start) {
int row = 0, col = 0;
int colX = 0;
- while (pos > 0) {
- if (pos < getLineCharWidth(row)) {
- for (uint i = 0; i < _textLines[row].chunks.size(); i++) {
- if ((uint)pos < _textLines[row].chunks[i].text.size()) {
- colX += _textLines[row].chunks[i].getFont()->getStringWidth(Common::U32String(_textLines[row].chunks[i].text.c_str(), pos));
- col += pos + 1;
- pos = 0;
- break;
- } else {
- colX += _textLines[row].chunks[i].getFont()->getStringWidth(Common::U32String(_textLines[row].chunks[i].text));
- pos -= _textLines[row].chunks[i].text.size();
- col += _textLines[row].chunks[i].text.size() + 1;
+ if (pos > 0) {
+ while (pos > 0) {
+ if (pos < getLineCharWidth(row)) {
+ for (uint i = 0; i < _textLines[row].chunks.size(); i++) {
+ if ((uint)pos < _textLines[row].chunks[i].text.size()) {
+ colX += _textLines[row].chunks[i].getFont()->getStringWidth(Common::U32String(_textLines[row].chunks[i].text.c_str(), pos));
+ col += pos + 1;
+ pos = 0;
+ break;
+ } else {
+ colX += _textLines[row].chunks[i].getFont()->getStringWidth(Common::U32String(_textLines[row].chunks[i].text));
+ pos -= _textLines[row].chunks[i].text.size();
+ col += _textLines[row].chunks[i].text.size() + 1;
+ }
}
+ break;
+ } else {
+ pos -= getLineCharWidth(row) + 1; // (row ? 1 : 0);
}
- break;
- } else {
- pos -= getLineCharWidth(row) + (row ? 1 : 0);
- }
- row++;
- if ((uint)row >= _textLines.size()) {
- colX = _surface->w;
- col = getLineCharWidth(row);
+ row++;
+ if ((uint)row >= _textLines.size()) {
+ colX = _surface->w;
+ col = getLineCharWidth(row);
- break;
+ break;
+ }
}
- }
-
- if (pos == -1) {
+ } else {
row = _textLines.size() - 1;
colX = _surface->w;
col = getLineCharWidth(row);
More information about the Scummvm-git-logs
mailing list