*Implement a new clipboardText property on the base TextInfo class, which returns the text property, processed by convertCrlf.
*TextInfo.copyToClipboard: pass the clipboardText property to api.copyToClip rather than convertCrlf(self.text).
*Base virtualBuffer: rather than implementing a copyToClipboard method, instead implement a clipboardText property. It still inserts linefeeds in between block fields etc, but just returns the text, rather than copying it to the clipboard now of course.
*DisplayModelTextInfo: implement a clipboardText property, which fetches its super clipboardText property, but converts NULLs to spaces before returning.
offset=self._getClosestOffsetFromPoint(x,y)\r
return offset,offset\r
\r
+ def _get_clipboardText(self):\r
+ return super(DisplayModelTextInfo,self).clipboardText.replace('\0',' ')\r
\r
class EditableTextDisplayModelTextInfo(DisplayModelTextInfo):\r
\r
"""Retrieves x and y coordinates corresponding with the textInfo start. It should return Point"""\r
raise NotImplementedError\r
\r
+ def _get_clipboardText(self):\r
+ """Text suitably formatted for copying to the clipboard. E.g. crlf characters inserted between lines."""\r
+ return convertToCrlf(self.text)\r
+\r
def copyToClipboard(self):\r
"""Copy the content of this instance to the clipboard.\r
@return: C{True} if successful, C{False} otherwise.\r
@rtype: bool\r
"""\r
import api\r
- return api.copyToClip(convertToCrlf(self.text))\r
+ return api.copyToClip(self.clipboardText)\r
\r
def getTextInChunks(self, unit):\r
"""Retrieve the text of this instance in chunks of a given unit.\r
return startOffset.value,endOffset.value\r
return super(VirtualBufferTextInfo, self)._getUnitOffsets(unit, offset)\r
\r
- def copyToClipboard(self):\r
+ def _get_clipboardText(self):\r
# Blocks should start on a new line, but they don't necessarily have an end of line indicator.\r
# Therefore, get the text in block (paragraph) chunks and join the chunks with \r\n.\r
blocks = (block.strip("\r\n") for block in self.getTextInChunks(textInfos.UNIT_PARAGRAPH))\r
- return api.copyToClip("\r\n".join(blocks))\r
+ return "\r\n".join(blocks)\r
\r
def getControlFieldSpeech(self, attrs, ancestorAttrs, fieldType, formatConfig=None, extraDetail=False, reason=None):\r
textList = []\r