diff options
| author | Eugene Sandulenko | 2017-08-03 22:50:01 +0200 | 
|---|---|---|
| committer | Eugene Sandulenko | 2017-08-04 21:54:20 +0200 | 
| commit | 23649e8d87bf2c1d8c93fa0c4a6502285b258429 (patch) | |
| tree | bb1e573839ee5fbee1db80ae21b61c7136ce50ce /graphics/macgui/mactext.cpp | |
| parent | 66f59aa893449596298a2cee1d8f761bcf8cc9bd (diff) | |
| download | scummvm-rg350-23649e8d87bf2c1d8c93fa0c4a6502285b258429.tar.gz scummvm-rg350-23649e8d87bf2c1d8c93fa0c4a6502285b258429.tar.bz2 scummvm-rg350-23649e8d87bf2c1d8c93fa0c4a6502285b258429.zip | |
GRAPHICS: MACGUI: Initial code for copying selection to clipboard
Diffstat (limited to 'graphics/macgui/mactext.cpp')
| -rw-r--r-- | graphics/macgui/mactext.cpp | 76 | 
1 files changed, 76 insertions, 0 deletions
| diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp index b3942f0d38..f2366790ef 100644 --- a/graphics/macgui/mactext.cpp +++ b/graphics/macgui/mactext.cpp @@ -492,4 +492,80 @@ void MacText::getRowCol(int x, int y, int *sx, int *sy, int *row, int *col) {  	}  } +Common::String MacText::getTextChunk(int startRow, int startCol, int endRow, int endCol, bool formatted) { +	Common::String res; + +	CLIP(startRow, 0, (int)_textLines.size() - 1); +	CLIP(endRow, 0, (int)_textLines.size() - 1); + +	for (int i = startRow; i <= endRow; i++) { +		if (i == startRow && i == endRow) { +			for (uint chunk = 0; chunk < _textLines[i].chunks.size() - 1; chunk++) { +				if (startCol <= 0) { +					if (formatted) +						res += _textLines[i].chunks[chunk].toString(); + +					if (endCol <= _textLines[i].chunks[chunk].text.size()) +						res += _textLines[i].chunks[chunk].text; +					else +						res += Common::String(_textLines[i].chunks[chunk].text.c_str(), endCol); +				} else if (_textLines[i].chunks[chunk].text.size() > startCol) { +					if (formatted) +						res += _textLines[i].chunks[chunk].toString(); + +					res += Common::String(_textLines[i].chunks[chunk].text.c_str() + startCol); +				} + +				startCol -= _textLines[i].chunks[chunk].text.size(); +				endCol -= _textLines[i].chunks[chunk].text.size(); + +				if (endCol <= 0) +					break; +			} +		} else if (i == startRow && startCol != 0) { +			for (uint chunk = 0; chunk < _textLines[i].chunks.size() - 1; chunk++) { +				if (startCol <= 0) { +					if (formatted) +						res += _textLines[i].chunks[chunk].toString(); + +					res += _textLines[i].chunks[chunk].text; +				} else if (_textLines[i].chunks[chunk].text.size() > startCol) { +					if (formatted) +						res += _textLines[i].chunks[chunk].toString(); + +					res += Common::String(_textLines[i].chunks[chunk].text.c_str() + startCol); +				} + +				startCol -= _textLines[i].chunks[chunk].text.size(); +			} +		} else if (i == endRow) { +			for (uint chunk = 0; chunk < _textLines[i].chunks.size() - 1; chunk++) { +				if (formatted) +					res += _textLines[i].chunks[chunk].toString(); + +				if (endCol <= _textLines[i].chunks[chunk].text.size()) +					res += _textLines[i].chunks[chunk].text; +				else +					res += Common::String(_textLines[i].chunks[chunk].text.c_str(), endCol); + +				endCol -= _textLines[i].chunks[chunk].text.size(); + +				if (endCol <= 0) +					break; +			} +		} else { +			for (uint chunk = 0; chunk < _textLines[i].chunks.size() - 1; chunk++) { +				if (formatted) +					res += _textLines[i].chunks[chunk].toString(); + +				res += _textLines[i].chunks[chunk].text; +			} + +			res += '\n'; +		} +	} + +	return res; +} +  } // End of namespace Graphics | 
