aboutsummaryrefslogtreecommitdiff
path: root/graphics/macgui/mactext.cpp
diff options
context:
space:
mode:
authorEugene Sandulenko2017-08-04 07:34:13 +0200
committerEugene Sandulenko2017-08-04 21:54:20 +0200
commit55a241494e0045d6e9a6b573e4d2cae3f390244f (patch)
tree69b49f0cc52f929aec2bfda8a929717ab0755310 /graphics/macgui/mactext.cpp
parentb2848951007b0667a258aaaea7b4d84a06bdeb83 (diff)
downloadscummvm-rg350-55a241494e0045d6e9a6b573e4d2cae3f390244f.tar.gz
scummvm-rg350-55a241494e0045d6e9a6b573e4d2cae3f390244f.tar.bz2
scummvm-rg350-55a241494e0045d6e9a6b573e4d2cae3f390244f.zip
GRAPHICS: MACGUI: Improved text selection edge case behaviour
Diffstat (limited to 'graphics/macgui/mactext.cpp')
-rw-r--r--graphics/macgui/mactext.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 64a8ebfd17..ade339f2e5 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -451,11 +451,13 @@ void MacText::getRowCol(int x, int y, int *sx, int *sy, int *row, int *col) {
// FIXME: We should use bsearch() here
*row = 0;
- while (*row < _textLines.size() - 1 && _textLines[*row].y < y)
+ while (*row < _textLines.size() && _textLines[*row].y < y)
(*row)++;
- if (*row)
+ if (*row == _textLines.size()) {
(*row)--;
+ x = getLineWidth(*row);
+ }
*sy = _textLines[*row].y;
@@ -464,7 +466,7 @@ void MacText::getRowCol(int x, int y, int *sx, int *sy, int *row, int *col) {
int width = 0, pwidth = 0;
int mcol = 0, pmcol = 0;
uint chunk;
- for (chunk = 0; chunk < _textLines[*row].chunks.size() - 1; chunk++) {
+ for (chunk = 0; chunk < _textLines[*row].chunks.size(); chunk++) {
pwidth = width;
pmcol = mcol;
if (!_textLines[*row].chunks[chunk].text.empty()) {
@@ -476,6 +478,9 @@ void MacText::getRowCol(int x, int y, int *sx, int *sy, int *row, int *col) {
break;
}
+ if (chunk == _textLines[*row].chunks.size())
+ chunk--;
+
Common::String str = _textLines[*row].chunks[chunk].text;
*col = mcol;