[Scummvm-git-logs] scummvm master -> 73916d9aca54dac3e030d3a8d7f0eb69dd22f22d

sev- sev at scummvm.org
Thu Jun 10 11:58:56 UTC 2021


This automated email contains information about 20 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
0467fa91cc GRAPHICS: MACGUI: clear the selection and cursor after we de-activated the mactext. refresh mactext every time we change
dea9455a96 GRAPHICS: MACGUI: introduce two variable to lingo, _selEnd and _selStart, which has default value -1. selEnd and selStar
0f7e7bd462 GRAPHICS: MACGUI: disable the ability of setting active in setEditable. currently, director will only set the first edit
88541a8303 GRAPHICS: MACGUI: fix the behaviour when the selEnd and selStart has the same value, currently, we will move the cursor 
3c7844e5a2 GRAPHICS: MACGUI: fix the behaviour when we set the editable text member active
bdf81ad565 GRAPHICS: MACGUI: fix the copy/paste operations when we have multi-paragraph selection in mactext
12232c992a GRAPHICS: MACGUI: fix calculating the pure text size in mactext
51698610d2 GRAPHICS: MACGUI: inherit paragraphEnd when we adding new line in mactext
777a8c1d17 GRAPHICS: MACGUI: modify the logic when we are calculating PureTextSize in mactext
5e734b0ca0 GRAPHICS: MACGUI: fix cursor drawing when we scroll the mactext
d02ec882de GRAPHICS: MACGUI: fix selection drawing when we have text alignments in mactext
68f0483458 GRAPHICS: MACGUI: enhance getRowCol in mactext by using bsearch
8caf7abf4a GRAPHICS: MACGUI: fix getRowCol when we have text alignment, modify the behaviour when we drawing selection in mactext
24821716db GRAPHICS: MACGUI: fix drawing selection when we have a not complete line in mactext
9b262360ed GRAPHICS: MACGUI: complete setMaxWidth in mactext
4c3630f648 GRAPHICS: MACGUI: undraw the cursor when we are selecting in mactext
34972626d4 GRAPHICS: MACGUI: remove the selection after we set maxWidth in mactext
3332517243 DIRECTOR: move selStart and selEnd from Lingo to Movie
86e21663d5 GRAPHICS: MACGUI: fix setSelection offset in mactext
73916d9aca GRAPHICS: MACGUI: remove a case which has already been checked before in macWM


Commit: 0467fa91ccda4219185fc8b71999dc4ad74789d8
    https://github.com/scummvm/scummvm/commit/0467fa91ccda4219185fc8b71999dc4ad74789d8
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-10T13:58:41+02:00

Commit Message:
GRAPHICS: MACGUI: clear the selection and cursor after we de-activated the mactext. refresh mactext every time we change the active status

Changed paths:
    graphics/macgui/mactext.cpp


diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 26fcec52c3..38c0c2568b 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -845,8 +845,15 @@ void MacText::setActive(bool active) {
 	g_system->getTimerManager()->removeTimerProc(&cursorTimerHandler);
 	if (_active) {
 		g_system->getTimerManager()->installTimerProc(&cursorTimerHandler, 200000, this, "macEditableText");
+	} else {
+		// clear the selection and cursor
+		_selectedText.endY = -1;
+		_cursorState = false;
 	}
 
+	// after we change the status of active, we need to do a refresh to clear the stuff we don't need
+	_contentIsDirty = true;
+
 	if (!_cursorOff && _cursorState == true)
 		undrawCursor();
 }


Commit: dea9455a9652fc0ea0b3d394b3c68d338865f069
    https://github.com/scummvm/scummvm/commit/dea9455a9652fc0ea0b3d394b3c68d338865f069
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-10T13:58:41+02:00

Commit Message:
GRAPHICS: MACGUI: introduce two variable to lingo, _selEnd and _selStart, which has default value -1. selEnd and selStart specify the selection area every time you activated the mactext

Changed paths:
    engines/director/channel.cpp
    engines/director/lingo/lingo-the.cpp
    engines/director/lingo/lingo.cpp
    engines/director/lingo/lingo.h
    graphics/macgui/mactext.cpp
    graphics/macgui/mactext.h


diff --git a/engines/director/channel.cpp b/engines/director/channel.cpp
index 062d04f4d4..f2ad06a7f0 100644
--- a/engines/director/channel.cpp
+++ b/engines/director/channel.cpp
@@ -314,6 +314,9 @@ void Channel::setClean(Sprite *nextSprite, int spriteId, bool partial) {
 
 void Channel::setEditable(bool editable) {
 	if (_sprite->_cast && _sprite->_cast->_type == kCastText) {
+		// if the sprite is editable, then we refresh the selEnd and setStart
+		if (editable && _widget)
+			((Graphics::MacText *)_widget)->setSelRange(g_lingo->_selStart, g_lingo->_selEnd);
 		if (_sprite->_cast->isEditable() == editable)
 			return;
 		_sprite->_cast->setEditable(editable);
diff --git a/engines/director/lingo/lingo-the.cpp b/engines/director/lingo/lingo-the.cpp
index a05e115270..8cb746519d 100644
--- a/engines/director/lingo/lingo-the.cpp
+++ b/engines/director/lingo/lingo-the.cpp
@@ -969,6 +969,7 @@ void Lingo::setTheEntity(int entity, Datum &id, int field, Datum &d) {
 		_vm->setVersion(d.asInt());
 		break;
 	case kTheSelEnd:
+		_selEnd = d.asInt();
 		if (movie->_currentEditableTextChannel != 0) {
 			Channel *channel = score->getChannelById(movie->_currentEditableTextChannel);
 
@@ -977,6 +978,7 @@ void Lingo::setTheEntity(int entity, Datum &id, int field, Datum &d) {
 		}
 		break;
 	case kTheSelStart:
+		_selStart = d.asInt();
 		if (movie->_currentEditableTextChannel != 0) {
 			Channel *channel = score->getChannelById(movie->_currentEditableTextChannel);
 
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index e23d638788..25b19280b5 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -170,6 +170,9 @@ Lingo::Lingo(DirectorEngine *vm) : _vm(vm) {
 	_floatPrecision = 4;
 	_floatPrecisionFormat = "%.4f";
 
+	_selStart = -1;
+	_selEnd = -1;
+
 	_localvars = NULL;
 
 	//kTheEntities
diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h
index a8f8edd6ed..a2589111b7 100644
--- a/engines/director/lingo/lingo.h
+++ b/engines/director/lingo/lingo.h
@@ -443,6 +443,9 @@ public:
 
 	Common::String _floatPrecisionFormat;
 
+	int _selStart;
+	int _selEnd;
+
 	bool _hadError;
 
 	bool _inCond;
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 38c0c2568b..85f876e966 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -214,6 +214,9 @@ void MacText::init() {
 	_textMaxHeight = 0;
 	_surface = nullptr;
 
+	_selEnd = -1;
+	_selStart = -1;
+
 	_defaultFormatting.wm = _wm;
 	// try to set fgcolor as default color in chunks
 	if (_wm->_mode & kWMModeWin95) {
@@ -845,6 +848,9 @@ void MacText::setActive(bool active) {
 	g_system->getTimerManager()->removeTimerProc(&cursorTimerHandler);
 	if (_active) {
 		g_system->getTimerManager()->installTimerProc(&cursorTimerHandler, 200000, this, "macEditableText");
+		// inactive -> active, we reset the selection
+		setSelection(_selStart, true);
+		setSelection(_selEnd, false);
 	} else {
 		// clear the selection and cursor
 		_selectedText.endY = -1;
@@ -868,11 +874,6 @@ void MacText::setEditable(bool editable) {
 	setActive(editable);
 	_active = editable;
 	if (editable) {
-		// TODO: Select whole region. This is done every time the text is set from
-		// uneditable to editable.
-		setSelection(0, true);
-		setSelection(-1, false);
-
 		_wm->setActiveWidget(this);
 	} else {
 		undrawCursor();
@@ -1229,6 +1230,9 @@ uint MacText::getSelectionIndex(bool start) {
 }
 
 void MacText::setSelection(int pos, bool start) {
+	// -1 for start represent the begining of text, i.e. 0
+	if (pos == -1 && start)
+		pos = 0;
 	int row = 0, col = 0;
 	int colX = 0;
 
@@ -1260,6 +1264,8 @@ void MacText::setSelection(int pos, bool start) {
 				break;
 			}
 		}
+	} else if (pos == 0) {
+		colX = col = row = 0;
 	} else {
 		row = _textLines.size() - 1;
 		colX = _surface->w;
@@ -1470,9 +1476,12 @@ bool MacText::processEvent(Common::Event &event) {
 		return false;
 
 	if (event.type == Common::EVENT_LBUTTONDOWN) {
+		bool active = _active;
 		_wm->setActiveWidget(this);
-
-		startMarking(event.mouse.x, event.mouse.y);
+		if (active == true) {
+			// inactive -> active switching, we don't start marking the selection, because we have initial selection
+			startMarking(event.mouse.x, event.mouse.y);
+		}
 
 		return true;
 	} else if (event.type == Common::EVENT_LBUTTONUP) {
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index ae112b3a9a..11c48d35d1 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -219,11 +219,18 @@ public:
 	Common::U32String cutSelection();
 	const SelectedText *getSelectedText() { return &_selectedText; }
 
+	/**
+	 * set the selection of mactext
+	 * @param pos pos of selection, 0 represent first, -1 represent the end of text
+	 * @param start selection start or selection end
+	 */
 	void setSelection(int pos, bool start);
 
 	Common::U32String getEditedString();
 	Common::U32String getText() { return _str; }
 
+	void setSelRange(int selStart, int selEnd) { _selStart = selStart, _selEnd = selEnd; }
+
 private:
 	void init();
 	bool isCutAllowed();
@@ -285,6 +292,9 @@ protected:
 	int _interLinear;
 	int _textShadow;
 
+	int _selEnd;
+	int _selStart;
+
 	int _textMaxWidth;
 	int _textMaxHeight;
 


Commit: 0f7e7bd4623c16254501225c6b21bc121b5637ae
    https://github.com/scummvm/scummvm/commit/0f7e7bd4623c16254501225c6b21bc121b5637ae
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-10T13:58:41+02:00

Commit Message:
GRAPHICS: MACGUI: disable the ability of setting active in setEditable. currently, director will only set the first editable text widget to active

Changed paths:
    engines/director/castmember.cpp
    engines/director/channel.cpp
    graphics/macgui/mactext.cpp


diff --git a/engines/director/castmember.cpp b/engines/director/castmember.cpp
index cc0c6f663f..d2edc162a6 100644
--- a/engines/director/castmember.cpp
+++ b/engines/director/castmember.cpp
@@ -693,6 +693,12 @@ Graphics::MacWidget *TextCastMember::createWidget(Common::Rect &bbox, Channel *c
 		((Graphics::MacText *)widget)->_focusable = _editable;
 		((Graphics::MacText *)widget)->setEditable(_editable);
 		((Graphics::MacText *)widget)->_selectable = _editable;
+
+		// since we disable the ability of setActive in setEdtiable, then we need to set active widget manually
+		Graphics::MacWidget *activeWidget;
+		activeWidget = g_director->_wm->getActiveWidget();
+		if (activeWidget == nullptr || !activeWidget->isEditable())
+			g_director->_wm->setActiveWidget(widget);
 		break;
 
 	case kCastButton:
diff --git a/engines/director/channel.cpp b/engines/director/channel.cpp
index f2ad06a7f0..9a8dd34597 100644
--- a/engines/director/channel.cpp
+++ b/engines/director/channel.cpp
@@ -327,7 +327,10 @@ void Channel::setEditable(bool editable) {
 			((Graphics::MacText *)_widget)->_focusable = editable;
 			((Graphics::MacText *)_widget)->setEditable(editable);
 			((Graphics::MacText *)_widget)->_selectable = editable;
-			g_director->_wm->setActiveWidget(_widget);
+			// we only set the first editable text member in score active
+			Graphics::MacWidget *activewidget = g_director->_wm->getActiveWidget();
+			if (activewidget == nullptr || !activewidget->isEditable())
+				g_director->_wm->setActiveWidget(_widget);
 		}
 	}
 }
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 85f876e966..41765b77b7 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -871,11 +871,7 @@ void MacText::setEditable(bool editable) {
 	_editable = editable;
 	_cursorOff = !editable;
 
-	setActive(editable);
-	_active = editable;
-	if (editable) {
-		_wm->setActiveWidget(this);
-	} else {
+	if (!editable) {
 		undrawCursor();
 	}
 }


Commit: 88541a8303edc3b70ecaa0b4fe8fb2ae1e14dd4e
    https://github.com/scummvm/scummvm/commit/88541a8303edc3b70ecaa0b4fe8fb2ae1e14dd4e
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-10T13:58:41+02:00

Commit Message:
GRAPHICS: MACGUI: fix the behaviour when the selEnd and selStart has the same value, currently, we will move the cursor here, just as director does

Changed paths:
    graphics/macgui/mactext.cpp


diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 41765b77b7..20f4cde70c 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -1122,9 +1122,12 @@ void MacText::drawSelection(int xoff, int yoff) {
 	if (_selectedText.endY == -1)
 		return;
 
-	// we check if the selection size is 0, then we don't draw it anymore
+	// we check if the selection size is 0, then we don't draw it anymore, and we set the cursor here
 	// it's a small optimize, but can bring us correct behavior
 	if (!_inTextSelection && _selectedText.startX == _selectedText.endX && _selectedText.startY == _selectedText.endY) {
+		_cursorRow = _selectedText.startRow;
+		_cursorCol = _selectedText.startCol;
+		updateCursorPos();
 		_selectedText.startY = _selectedText.endY = -1;
 		return;
 	}


Commit: 3c7844e5a2c622c17617e7cd220920ab2e777dcb
    https://github.com/scummvm/scummvm/commit/3c7844e5a2c622c17617e7cd220920ab2e777dcb
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-10T13:58:41+02:00

Commit Message:
GRAPHICS: MACGUI: fix the behaviour when we set the editable text member active

Changed paths:
    engines/director/castmember.cpp
    engines/director/channel.cpp


diff --git a/engines/director/castmember.cpp b/engines/director/castmember.cpp
index d2edc162a6..1c5322330e 100644
--- a/engines/director/castmember.cpp
+++ b/engines/director/castmember.cpp
@@ -695,10 +695,11 @@ Graphics::MacWidget *TextCastMember::createWidget(Common::Rect &bbox, Channel *c
 		((Graphics::MacText *)widget)->_selectable = _editable;
 
 		// since we disable the ability of setActive in setEdtiable, then we need to set active widget manually
-		Graphics::MacWidget *activeWidget;
-		activeWidget = g_director->_wm->getActiveWidget();
-		if (activeWidget == nullptr || !activeWidget->isEditable())
-			g_director->_wm->setActiveWidget(widget);
+		if (_editable) {
+			Graphics::MacWidget *activeWidget = g_director->_wm->getActiveWidget();
+			if (activeWidget == nullptr || !activeWidget->isEditable())
+				g_director->_wm->setActiveWidget(widget);
+		}
 		break;
 
 	case kCastButton:
diff --git a/engines/director/channel.cpp b/engines/director/channel.cpp
index 9a8dd34597..92d81ed219 100644
--- a/engines/director/channel.cpp
+++ b/engines/director/channel.cpp
@@ -328,9 +328,11 @@ void Channel::setEditable(bool editable) {
 			((Graphics::MacText *)_widget)->setEditable(editable);
 			((Graphics::MacText *)_widget)->_selectable = editable;
 			// we only set the first editable text member in score active
-			Graphics::MacWidget *activewidget = g_director->_wm->getActiveWidget();
-			if (activewidget == nullptr || !activewidget->isEditable())
-				g_director->_wm->setActiveWidget(_widget);
+			if (editable) {
+				Graphics::MacWidget *activewidget = g_director->_wm->getActiveWidget();
+				if (activewidget == nullptr || !activewidget->isEditable())
+					g_director->_wm->setActiveWidget(_widget);
+			}
 		}
 	}
 }


Commit: bdf81ad565631fb6e9197e978582fad5aa3d43c4
    https://github.com/scummvm/scummvm/commit/bdf81ad565631fb6e9197e978582fad5aa3d43c4
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-10T13:58:41+02:00

Commit Message:
GRAPHICS: MACGUI: fix the copy/paste operations when we have multi-paragraph selection in mactext

Changed paths:
    graphics/macgui/mactext.cpp
    graphics/macgui/macwindowmanager.cpp


diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 20f4cde70c..42a8504983 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -1311,7 +1311,7 @@ Common::U32String MacText::cutSelection() {
 		SWAP(s.startCol, s.endCol);
 	}
 
-	Common::U32String selection = MacText::getTextChunk(s.startRow, s.startCol, s.endRow, s.endCol, true, false);
+	Common::U32String selection = MacText::getTextChunk(s.startRow, s.startCol, s.endRow, s.endCol, true, true);
 
 	deleteSelection();
 	clearSelection();
@@ -1332,7 +1332,7 @@ bool MacText::processEvent(Common::Event &event) {
 				_wm->setTextInClipboard(cutSelection());
 				return true;
 			case Common::KEYCODE_c:
-				_wm->setTextInClipboard(getSelection(true, false));
+				_wm->setTextInClipboard(getSelection(true, true));
 				return true;
 			case Common::KEYCODE_v:
 				if (g_system->hasTextInClipboard()) {
@@ -1702,7 +1702,7 @@ Common::U32String MacText::getTextChunk(int startRow, int startCol, int endRow,
 
 				startCol -= _textLines[i].chunks[chunk].text.size();
 			}
-			if (newlines)
+			if (newlines && _textLines[i].paragraphEnd)
 				res += '\n';
 		// We are at the end row, and it could be not completely requested
 		} else if (i == endRow) {
@@ -1732,7 +1732,7 @@ Common::U32String MacText::getTextChunk(int startRow, int startCol, int endRow,
 				res += _textLines[i].chunks[chunk].text;
 			}
 
-			if (newlines)
+			if (newlines && _textLines[i].paragraphEnd)
 				res += '\n';
 		}
 	}
@@ -1760,8 +1760,8 @@ void MacText::insertTextFromClipboard() {
 			ppos += getLineCharWidth(i);
 		ppos += _cursorCol;
 
-		Common::U32String pre_str = getTextChunk(start, 0, _cursorRow, _cursorCol, true, false);
-		Common::U32String sub_str = getTextChunk(_cursorRow, _cursorCol, end, getLineCharWidth(end, true), true, false);
+		Common::U32String pre_str = getTextChunk(start, 0, _cursorRow, _cursorCol, true, true);
+		Common::U32String sub_str = getTextChunk(_cursorRow, _cursorCol, end, getLineCharWidth(end, true), true, true);
 
 		// Remove it from the text
 		for (int i = start; i <= end; i++) {
diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index 37331e585a..893732bd33 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -398,29 +398,47 @@ void MacWindowManager::disableScreenCopy() {
 // this is refer to how we deal U32String in splitString in mactext
 // maybe we can optimize this specifically
 Common::U32String stripFormat(const Common::U32String &str) {
-	Common::U32String res;
+	Common::U32String res, paragraph, tmp;
 	// calc the size of str
 	const Common::U32String::value_type *l = str.c_str();
 	while (*l) {
-		if (*l == '\r') {
-			l++;
-		} else if (*l == '\n') {
-			l++;
-		} else if (*l == '\001') {
-			l++;
-			// if there are two \001, then we regard it as one character
-			if (*l == '\001') {
-				res += *l++;
+		// split paragraph first
+		paragraph.clear();
+		while (*l) {
+			if (*l == '\r') {
+				l++;
+				if (*l == '\n')
+					l++;
+				break;
+			}
+			if (*l == '\n') {
+				l++;
+				break;
+			}
+			paragraph += *l++;
+		}
+		const Common::U32String::value_type *s = paragraph.c_str();
+		tmp.clear();
+		while (*s) {
+			if (*s == '\001') {
+				s++;
+				// if there are two \001, then we regard it as one character
+				if (*s == '\001') {
+					tmp += *s++;
+				}
+			} else if (*s == '\015') {	// binary format
+				// we are skipping the formatting stuffs
+				// this number 12, and the number 23, is the size of our format
+				s += 12;
+			} else if (*s == '\016') {	// human-readable format
+				s += 23;
+			} else {
+				tmp += *s++;
 			}
-		} else if (*l == '\015') {	// binary format
-			// we are skipping the formatting stuffs
-			// this number 12, and the number 23, is the size of our format
-			l += 12;
-		} else if (*l == '\016') {	// human-readable format
-			l += 23;
-		} else {
-			res += *l++;
 		}
+		res += tmp;
+		if (*l)
+			res += '\n';
 	}
 	return res;
 }


Commit: 12232c992ad7334051514f5b19f59b5d3d3be7b5
    https://github.com/scummvm/scummvm/commit/12232c992ad7334051514f5b19f59b5d3d3be7b5
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-10T13:58:41+02:00

Commit Message:
GRAPHICS: MACGUI: fix calculating the pure text size in mactext

Changed paths:
    graphics/macgui/macwindowmanager.cpp


diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index 893732bd33..c506d770b7 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -448,6 +448,18 @@ void MacWindowManager::setTextInClipboard(const Common::U32String &str) {
 	g_system->setTextInClipboard(stripFormat(str));
 }
 
+// get the text size ignoring \n
+int getPureTextSize(const Common::U32String &str) {
+	const Common::U32String::value_type *l = str.c_str();
+	int res = 0;
+	while (*l) {
+		if (*l != '\n')
+			res++;
+		l++;
+	}
+	return res;
+}
+
 Common::U32String MacWindowManager::getTextFromClipboard(const Common::U32String &format, int *size) {
 	Common::U32String global_str = g_system->getTextFromClipboard();
 	// str is what we need
@@ -456,19 +468,19 @@ Common::U32String MacWindowManager::getTextFromClipboard(const Common::U32String
 		// if wm clipboard is empty, then we use the global clipboard, which won't contain the format
 		str = format + global_str;
 		if (size)
-			*size = str.size();
+			*size = getPureTextSize(global_str);
 	} else {
 		Common::U32String tmp = stripFormat(_clipboard);
 		if (tmp == global_str) {
 			// if the text is equal, then we use wm one which contains the format
 			str = _clipboard;
 			if (size)
-				*size = tmp.size();
+				*size = getPureTextSize(tmp);
 		} else {
 			// otherwise, we prefer the global one
 			str = format + global_str;
 			if (size)
-				*size = str.size();
+				*size = getPureTextSize(global_str);
 		}
 	}
 	return str;


Commit: 51698610d22cd8515c417ba70f18d4c75f44610f
    https://github.com/scummvm/scummvm/commit/51698610d22cd8515c417ba70f18d4c75f44610f
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-10T13:58:41+02:00

Commit Message:
GRAPHICS: MACGUI: inherit paragraphEnd when we adding new line in mactext

Changed paths:
    graphics/macgui/mactext.cpp


diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 42a8504983..339b19579a 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -1933,6 +1933,9 @@ void MacText::addNewLine(int *row, int *col) {
 	MacFontRun newchunk = line->chunks[ch];
 	MacTextLine newline;
 
+	// we have to inherit paragraphEnd from the origin line
+	newline.paragraphEnd = line->paragraphEnd;
+
 	newchunk.text = line->chunks[ch].text.substr(pos);
 	line->chunks[ch].text = line->chunks[ch].text.substr(0, pos);
 	line->paragraphEnd = true;


Commit: 777a8c1d174adf42261bc3d69fa55eacf633b081
    https://github.com/scummvm/scummvm/commit/777a8c1d174adf42261bc3d69fa55eacf633b081
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-10T13:58:41+02:00

Commit Message:
GRAPHICS: MACGUI: modify the logic when we are calculating PureTextSize in mactext

Changed paths:
    graphics/macgui/macwindowmanager.cpp


diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index c506d770b7..4ecfcf72cd 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -449,13 +449,25 @@ void MacWindowManager::setTextInClipboard(const Common::U32String &str) {
 }
 
 // get the text size ignoring \n
-int getPureTextSize(const Common::U32String &str) {
+int getPureTextSize(const Common::U32String &str, bool global) {
 	const Common::U32String::value_type *l = str.c_str();
 	int res = 0;
-	while (*l) {
-		if (*l != '\n')
-			res++;
-		l++;
+	if (global) {
+		// if we are in global, then we have no format in str. thus, we ignore all \r \n
+		while (*l) {
+			if (*l != '\n' && *l != '\r')
+				res++;
+			l++;
+		}
+	} else {
+		// if we are not in global, then we are using the wm clipboard, which use \n for new line
+		// i think that if statement can be optimized to, like if (*l != '\n' && (!global || *l != '\r'))
+		// but for the sake of readability, we keep codes here
+		while (*l) {
+			if (*l != '\n')
+				res++;
+			l++;
+		}
 	}
 	return res;
 }
@@ -468,19 +480,19 @@ Common::U32String MacWindowManager::getTextFromClipboard(const Common::U32String
 		// if wm clipboard is empty, then we use the global clipboard, which won't contain the format
 		str = format + global_str;
 		if (size)
-			*size = getPureTextSize(global_str);
+			*size = getPureTextSize(global_str, true);
 	} else {
 		Common::U32String tmp = stripFormat(_clipboard);
 		if (tmp == global_str) {
 			// if the text is equal, then we use wm one which contains the format
 			str = _clipboard;
 			if (size)
-				*size = getPureTextSize(tmp);
+				*size = getPureTextSize(tmp, false);
 		} else {
 			// otherwise, we prefer the global one
 			str = format + global_str;
 			if (size)
-				*size = getPureTextSize(global_str);
+				*size = getPureTextSize(global_str, true);
 		}
 	}
 	return str;


Commit: 5e734b0ca01da69ab65d1106ee0554484ebaaeae
    https://github.com/scummvm/scummvm/commit/5e734b0ca01da69ab65d1106ee0554484ebaaeae
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-10T13:58:41+02:00

Commit Message:
GRAPHICS: MACGUI: fix cursor drawing when we scroll the mactext

Changed paths:
    graphics/macgui/mactext.cpp


diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 339b19579a..07be3696a3 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -2038,7 +2038,7 @@ void MacText::updateCursorPos() {
 		else if (_textAlignment == kTextAlignCenter)
 			alignOffset = (_textMaxWidth / 2) - (getLineWidth(_cursorRow) / 2);
 
-		_cursorY = _textLines[_cursorRow].y + offset.y - 2;
+		_cursorY = _textLines[_cursorRow].y + offset.y - 2 - _scrollPos;
 		_cursorX = getLineWidth(_cursorRow, false, _cursorCol) + alignOffset + offset.x - 1;
 	}
 


Commit: d02ec882de91b76eeec9389ea0f5f69de6d27b2e
    https://github.com/scummvm/scummvm/commit/d02ec882de91b76eeec9389ea0f5f69de6d27b2e
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-10T13:58:41+02:00

Commit Message:
GRAPHICS: MACGUI: fix selection drawing when we have text alignments in mactext

Changed paths:
    graphics/macgui/mactext.cpp


diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 07be3696a3..db1a79a4ae 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -1159,22 +1159,28 @@ void MacText::drawSelection(int xoff, int yoff) {
 
 	int numLines = 0;
 	int x1 = 0, x2 = 0;
+	int row = s.startRow;
+	int alignOffset = 0;
 
 	for (int y = start; y < end; y++) {
 		if (!numLines) {
 			x1 = 0;
 			x2 = getDimensions().width() - 1;
 
-			if (y + _scrollPos == s.startY && s.startX > 0) {
-				numLines = getLineHeight(s.startRow);
+			if (_textAlignment == kTextAlignRight)
+				alignOffset = _textMaxWidth - getLineWidth(row);
+			else if (_textAlignment == kTextAlignCenter)
+				alignOffset = (_textMaxWidth / 2) - (getLineWidth(row) / 2);
+
+			numLines = getLineHeight(row);
+			if (y + _scrollPos == s.startY && s.startX > 0)
 				x1 = s.startX;
-			}
-			if (y + _scrollPos >= lastLineStart) {
-				numLines = getLineHeight(s.endRow);
+			if (y + _scrollPos >= lastLineStart)
 				x2 = s.endX;
-			}
+
 			x1 = MIN<int>(x1 + xoff, getDimensions().width() - 1);
-			x2 = MIN<int>(x2 + xoff, getDimensions().width() - 1);
+			x2 = MIN<int>(x2 + xoff + alignOffset, getDimensions().width() - 1);
+			row++;
 		} else {
 			numLines--;
 		}


Commit: 68f0483458ee78372788e931624d79ac9c0c5748
    https://github.com/scummvm/scummvm/commit/68f0483458ee78372788e931624d79ac9c0c5748
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-10T13:58:41+02:00

Commit Message:
GRAPHICS: MACGUI: enhance getRowCol in mactext by using bsearch

Changed paths:
    graphics/macgui/mactext.cpp


diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index db1a79a4ae..545fbe6dca 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -1585,11 +1585,18 @@ void MacText::getRowCol(int x, int y, int *sx, int *sy, int *row, int *col) {
 
 	y = CLIP(y, 0, _textMaxHeight);
 
-	// FIXME: We should use bsearch() here
-	nrow = _textLines.size() - 1;
-
-	while (nrow && _textLines[nrow].y > y)
-		(nrow)--;
+	nrow = _textLines.size();
+	// use [lb, ub) bsearch here, final anser would we lb
+	int lb = 0, ub = nrow;
+	while (ub - lb > 1) {
+		int mid = (ub + lb) / 2;
+		if (_textLines[mid].y <= y) {
+			lb = mid;
+		} else {
+			ub = mid;
+		}
+	}
+	nrow = lb;
 
 	nsy = _textLines[nrow].y;
 


Commit: 8caf7abf4ad10a9d8c8e8c2faacb2e8cf8e74e87
    https://github.com/scummvm/scummvm/commit/8caf7abf4ad10a9d8c8e8c2faacb2e8cf8e74e87
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-10T13:58:41+02:00

Commit Message:
GRAPHICS: MACGUI: fix getRowCol when we have text alignment, modify the behaviour when we drawing selection in mactext

Changed paths:
    graphics/macgui/mactext.cpp


diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 545fbe6dca..af0ee23ec6 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -1134,7 +1134,9 @@ void MacText::drawSelection(int xoff, int yoff) {
 
 	SelectedText s = _selectedText;
 
+	bool swaped = false;
 	if (s.startY > s.endY || (s.startY == s.endY && s.startX > s.endX)) {
+		swaped = true;
 		SWAP(s.startX, s.endX);
 		SWAP(s.startY, s.endY);
 		SWAP(s.startRow, s.endRow);
@@ -1178,12 +1180,19 @@ void MacText::drawSelection(int xoff, int yoff) {
 			if (y + _scrollPos >= lastLineStart)
 				x2 = s.endX;
 
-			x1 = MIN<int>(x1 + xoff, getDimensions().width() - 1);
-			x2 = MIN<int>(x2 + xoff + alignOffset, getDimensions().width() - 1);
+			// if we are selecting text reversely, and we are at the first line but not the select from begining, then we add offset to x1
+			// the reason here is if we are not drawing the single line, then we draw selection from x1 to x2 + offset. i.e. we draw from begin
+			// otherwise, we draw selection from x1 + offset to x2 + offset
+			if (swaped && row == s.startRow && s.startCol != 0) {
+				x1 = MIN<int>(x1 + xoff + alignOffset, getDimensions().width() - 1);
+				x2 = MIN<int>(x2 + xoff + alignOffset, getDimensions().width() - 1);
+			} else {
+				x1 = MIN<int>(x1 + xoff, getDimensions().width() - 1);
+				x2 = MIN<int>(x2 + xoff + alignOffset, getDimensions().width() - 1);
+			}
 			row++;
-		} else {
-			numLines--;
 		}
+		numLines--;
 
 		byte *ptr = (byte *)_composeSurface->getBasePtr(x1, MIN<int>(y + yoff, getDimensions().height() - 1));
 
@@ -1602,6 +1611,12 @@ void MacText::getRowCol(int x, int y, int *sx, int *sy, int *row, int *col) {
 
 	ncol = 0;
 
+	int alignOffset = 0;
+	if (_textAlignment == kTextAlignRight)
+		alignOffset = _textMaxWidth - getLineWidth(nrow);
+	else if (_textAlignment == kTextAlignCenter)
+		alignOffset = (_textMaxWidth / 2) - (getLineWidth(nrow) / 2);
+
 	int width = 0, pwidth = 0;
 	int mcol = 0, pmcol = 0;
 	uint chunk;
@@ -1613,7 +1628,7 @@ void MacText::getRowCol(int x, int y, int *sx, int *sy, int *row, int *col) {
 			mcol += _textLines[nrow].chunks[chunk].text.size();
 		}
 
-		if (width > x)
+		if (width + alignOffset > x)
 			break;
 	}
 
@@ -1627,7 +1642,7 @@ void MacText::getRowCol(int x, int y, int *sx, int *sy, int *row, int *col) {
 
 	for (int i = str.size(); i >= 0; i--) {
 		int strw = _textLines[nrow].chunks[chunk].getFont()->getStringWidth(str);
-		if (strw + pwidth < x) {
+		if (strw + pwidth + alignOffset < x) {
 			ncol = pmcol + i;
 			nsx = strw + pwidth;
 			break;


Commit: 24821716dbed6e4dbbb66db44ffcf86fd2c4add2
    https://github.com/scummvm/scummvm/commit/24821716dbed6e4dbbb66db44ffcf86fd2c4add2
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-10T13:58:41+02:00

Commit Message:
GRAPHICS: MACGUI: fix drawing selection when we have a not complete line in mactext

Changed paths:
    graphics/macgui/mactext.cpp


diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index af0ee23ec6..be72d21da2 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -1160,10 +1160,38 @@ void MacText::drawSelection(int xoff, int yoff) {
 	end = MIN((int)getDimensions().height(), end);
 
 	int numLines = 0;
-	int x1 = 0, x2 = 0;
+	int x1 = 0, x2 = getDimensions().width() - 1;
 	int row = s.startRow;
 	int alignOffset = 0;
 
+	// we may draw part of the selection, so we need to calc the height of first line
+	if (s.startY < _scrollPos) {
+		int start_row = 0;
+		getRowCol(s.startX, _scrollPos, nullptr, &numLines, &start_row, nullptr);
+		numLines = getLineHeight(start_row) - (_scrollPos - numLines);
+		if (start_row == s.startRow)
+			x1 = s.startX;
+		if (start_row == s.endRow)
+			x2 = s.endX;
+		// deal with the first line, which is not a complete line
+		if (numLines) {
+			if (_textAlignment == kTextAlignRight)
+				alignOffset = _textMaxWidth - getLineWidth(start_row);
+			else if (_textAlignment == kTextAlignCenter)
+				alignOffset = (_textMaxWidth / 2) - (getLineWidth(start_row) / 2);
+
+			if (swaped && start_row == s.startRow && s.startCol != 0) {
+				x1 = MIN<int>(x1 + xoff + alignOffset, getDimensions().width() - 1);
+				x2 = MIN<int>(x2 + xoff + alignOffset, getDimensions().width() - 1);
+			} else {
+				x1 = MIN<int>(x1 + xoff, getDimensions().width() - 1);
+				x2 = MIN<int>(x2 + xoff + alignOffset, getDimensions().width() - 1);
+			}
+
+			row = start_row + 1;
+		}
+	}
+
 	for (int y = start; y < end; y++) {
 		if (!numLines) {
 			x1 = 0;


Commit: 9b262360ed370f9724176e0decdaa6042939da52
    https://github.com/scummvm/scummvm/commit/9b262360ed370f9724176e0decdaa6042939da52
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-10T13:58:41+02:00

Commit Message:
GRAPHICS: MACGUI: complete setMaxWidth in mactext

Changed paths:
    graphics/macgui/mactext.cpp


diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index be72d21da2..8f7a886c15 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -273,21 +273,37 @@ void MacText::setMaxWidth(int maxWidth) {
 	if (maxWidth == _maxWidth)
 		return;
 
-	if (!_str.empty())
-		warning("TODO: MacText::setMaxWidth() is incorrect.");
+	if (maxWidth < 0) {
+		warning("trying to set maxWidth to %d", maxWidth);
+		return;
+	}
 
-	// It does not take into account the edited string
-	// Actually, it should reshuffle all paragraphs
+	Common::U32String str = getTextChunk(0, 0, -1, -1, true, true);
 
-	_maxWidth = maxWidth;
+	// keep the cursor pos
+	int ppos = 0;
+	for (int i = 0; i < _cursorRow; i++)
+		ppos += getLineCharWidth(i);
+	ppos += _cursorCol;
 
+	_maxWidth = maxWidth;
 	_textLines.clear();
 
-	splitString(_str);
+	splitString(str);
+
+	// restore the cursor pos
+	_cursorRow = 0;
+	while (ppos > getLineCharWidth(_cursorRow, true)) {
+		ppos -= getLineCharWidth(_cursorRow, true);
+		_cursorRow++;
+	}
+	_cursorCol = ppos;
 
 	recalcDims();
+	updateCursorPos();
 
 	_fullRefresh = true;
+	_contentIsDirty = true;
 }
 
 void MacText::setDefaultFormatting(uint16 fontId, byte textSlant, uint16 fontSize,


Commit: 4c3630f6482ed50eb32081cb1690031f33290bd3
    https://github.com/scummvm/scummvm/commit/4c3630f6482ed50eb32081cb1690031f33290bd3
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-10T13:58:41+02:00

Commit Message:
GRAPHICS: MACGUI: undraw the cursor when we are selecting in mactext

Changed paths:
    graphics/macgui/mactext.cpp


diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 8f7a886c15..f6ed6ceb34 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -1080,8 +1080,8 @@ bool MacText::draw(bool forceRedraw) {
 		_composeSurface->frameRect(borderRect, 0);
 	}
 
-	// if we are drawing the selection text, then we don't draw the cursor
-	if (_cursorState && !(_selectedText.endY != -1 && _active))
+	// if we are drawing the selection text or we are selecting, then we don't draw the cursor
+	if (_cursorState && !((_inTextSelection || _selectedText.endY != -1) && _active))
 		_composeSurface->blitFrom(*_cursorSurface, *_cursorRect, Common::Point(_cursorX, _cursorY + offset.y + 1));
 
 	if (_selectedText.endY != -1 && _active)


Commit: 34972626d495a16ad680c848b5c72598acca58b6
    https://github.com/scummvm/scummvm/commit/34972626d495a16ad680c848b5c72598acca58b6
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-10T13:58:41+02:00

Commit Message:
GRAPHICS: MACGUI: remove the selection after we set maxWidth in mactext

Changed paths:
    graphics/macgui/mactext.cpp


diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index f6ed6ceb34..7b1ba3758b 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -299,6 +299,9 @@ void MacText::setMaxWidth(int maxWidth) {
 	}
 	_cursorCol = ppos;
 
+	// after we set maxWidth, we reset the selection
+	_selectedText.endY = -1;
+
 	recalcDims();
 	updateCursorPos();
 


Commit: 3332517243f1a2cdc0effb98a3c5d6547d0c3702
    https://github.com/scummvm/scummvm/commit/3332517243f1a2cdc0effb98a3c5d6547d0c3702
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-10T13:58:41+02:00

Commit Message:
DIRECTOR: move selStart and selEnd from Lingo to Movie

Changed paths:
    engines/director/channel.cpp
    engines/director/lingo/lingo-the.cpp
    engines/director/lingo/lingo.cpp
    engines/director/lingo/lingo.h
    engines/director/movie.cpp
    engines/director/movie.h


diff --git a/engines/director/channel.cpp b/engines/director/channel.cpp
index 92d81ed219..f0ec1e4036 100644
--- a/engines/director/channel.cpp
+++ b/engines/director/channel.cpp
@@ -316,7 +316,7 @@ void Channel::setEditable(bool editable) {
 	if (_sprite->_cast && _sprite->_cast->_type == kCastText) {
 		// if the sprite is editable, then we refresh the selEnd and setStart
 		if (editable && _widget)
-			((Graphics::MacText *)_widget)->setSelRange(g_lingo->_selStart, g_lingo->_selEnd);
+			((Graphics::MacText *)_widget)->setSelRange(g_director->getCurrentMovie()->_selStart, g_director->getCurrentMovie()->_selEnd);
 		if (_sprite->_cast->isEditable() == editable)
 			return;
 		_sprite->_cast->setEditable(editable);
diff --git a/engines/director/lingo/lingo-the.cpp b/engines/director/lingo/lingo-the.cpp
index 8cb746519d..59e78da08a 100644
--- a/engines/director/lingo/lingo-the.cpp
+++ b/engines/director/lingo/lingo-the.cpp
@@ -969,7 +969,7 @@ void Lingo::setTheEntity(int entity, Datum &id, int field, Datum &d) {
 		_vm->setVersion(d.asInt());
 		break;
 	case kTheSelEnd:
-		_selEnd = d.asInt();
+		g_director->getCurrentMovie()->_selEnd = d.asInt();
 		if (movie->_currentEditableTextChannel != 0) {
 			Channel *channel = score->getChannelById(movie->_currentEditableTextChannel);
 
@@ -978,7 +978,7 @@ void Lingo::setTheEntity(int entity, Datum &id, int field, Datum &d) {
 		}
 		break;
 	case kTheSelStart:
-		_selStart = d.asInt();
+		g_director->getCurrentMovie()->_selStart = d.asInt();
 		if (movie->_currentEditableTextChannel != 0) {
 			Channel *channel = score->getChannelById(movie->_currentEditableTextChannel);
 
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index 25b19280b5..e23d638788 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -170,9 +170,6 @@ Lingo::Lingo(DirectorEngine *vm) : _vm(vm) {
 	_floatPrecision = 4;
 	_floatPrecisionFormat = "%.4f";
 
-	_selStart = -1;
-	_selEnd = -1;
-
 	_localvars = NULL;
 
 	//kTheEntities
diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h
index a2589111b7..a8f8edd6ed 100644
--- a/engines/director/lingo/lingo.h
+++ b/engines/director/lingo/lingo.h
@@ -443,9 +443,6 @@ public:
 
 	Common::String _floatPrecisionFormat;
 
-	int _selStart;
-	int _selEnd;
-
 	bool _hadError;
 
 	bool _inCond;
diff --git a/engines/director/movie.cpp b/engines/director/movie.cpp
index 8ca481463a..821921262a 100644
--- a/engines/director/movie.cpp
+++ b/engines/director/movie.cpp
@@ -70,6 +70,9 @@ Movie::Movie(Window *window) {
 	_cast = new Cast(this);
 	_sharedCast = nullptr;
 	_score = new Score(this);
+
+	_selEnd = -1;
+	_selStart = -1;
 }
 
 Movie::~Movie() {
diff --git a/engines/director/movie.h b/engines/director/movie.h
index de5393338b..fd9fd97f6c 100644
--- a/engines/director/movie.h
+++ b/engines/director/movie.h
@@ -169,6 +169,9 @@ public:
 	int _keyCode;
 	byte _keyFlags;
 
+	int _selStart;
+	int _selEnd;
+
 private:
 	Window *_window;
 	DirectorEngine *_vm;


Commit: 86e21663d57203caf12c0784e959b57d20ca22c1
    https://github.com/scummvm/scummvm/commit/86e21663d57203caf12c0784e959b57d20ca22c1
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-10T13:58:41+02:00

Commit Message:
GRAPHICS: MACGUI: fix setSelection offset in mactext

Changed paths:
    graphics/macgui/mactext.cpp


diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 7b1ba3758b..dd18cb6c83 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -1303,18 +1303,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(_textLines[row].chunks[i].text.substr(0, pos));
-						col += pos + 1;
+						col += pos;
 						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;
+						col += _textLines[row].chunks[i].text.size();
 					}
 				}
 				break;
 			} else {
-				pos -= getLineCharWidth(row) + 1; // (row ? 1 : 0);
+				pos -= getLineCharWidth(row); // (row ? 1 : 0);
 			}
 
 			row++;


Commit: 73916d9aca54dac3e030d3a8d7f0eb69dd22f22d
    https://github.com/scummvm/scummvm/commit/73916d9aca54dac3e030d3a8d7f0eb69dd22f22d
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-10T13:58:41+02:00

Commit Message:
GRAPHICS: MACGUI: remove a case which has already been checked before in macWM

Changed paths:
    graphics/macgui/macwindowmanager.cpp


diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index 4ecfcf72cd..fa31ae4b3d 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -840,8 +840,7 @@ bool MacWindowManager::processEvent(Common::Event &event) {
 		BaseMacWindow *w = *it;
 
 		if (w->hasAllFocus() || (w->isEditable() && event.type == Common::EVENT_KEYDOWN) ||
-				w->getDimensions().contains(event.mouse.x, event.mouse.y)
-				|| (_activeWidget && _activeWidget->isEditable())) {
+				w->getDimensions().contains(event.mouse.x, event.mouse.y)) {
 			if (event.type == Common::EVENT_LBUTTONDOWN || event.type == Common::EVENT_LBUTTONUP)
 				setActiveWindow(w->getId());
 




More information about the Scummvm-git-logs mailing list