def _syncTextToPreview(self): """When the timer above expires, this is called to sync text to preview per item 3 above. """ # Stop the timer; the next cursor movement will restart it. self._cursorMovementTimer.stop() # Perform an approximate match. mf = self._widget.webView.page().mainFrame() qp = core.workspace().currentDocument().qutepart webIndex = findApproxTextInTarget(qp.text, qp.textCursor().position(), mf.toPlainText()) # Move the cursor to webIndex in the preview pane, assuming # corresponding text was found. if webIndex >= 0: self._movePreviewPaneToIndex(webIndex)
def syncTextToPreview(self): """When the timer above expires, this is called to sync text to preview per item 3 above. It can also be called when a sync is needed (when switching windows, for example). """ # Only run this if we TRE is installed. if not findApproxTextInTarget: return # Stop the timer; the next cursor movement will restart it. self._cursorMovementTimer.stop() # Perform an approximate match. mf = self.webView.page().mainFrame() qp = core.workspace().currentDocument().qutepart webIndex = findApproxTextInTarget(qp.text, qp.textCursor().position(), mf.toPlainText()) # Move the cursor to webIndex in the preview pane, assuming # corresponding text was found. if webIndex >= 0: self._movePreviewPaneToIndex(webIndex)
def _onWebviewClick(self, webIndex): """Per item 3 above, this is called when the user clicks in the web view. It finds the matching location in the text pane then moves the text pane cursor. Params: webIndex - The index of the clicked character in a text rendering of the web page. """ # Retrieve the web page text and the qutepart text. tc = self._webTextContent() qp = core.workspace().currentDocument().qutepart # Perform an approximate match between the clicked webpage text and the # qutepart text. textIndex = findApproxTextInTarget(tc, webIndex, qp.text) # Move the cursor to textIndex in qutepart, assuming corresponding text # was found. if textIndex >= 0: self._moveTextPaneToIndex(textIndex)
def _onWebviewClick(self, webIndex): """Per item 3 above, this is called when the user clicks in the web view. It finds the matching location in the text pane then moves the text pane cursor. Params: webIndex - The index of the clicked character in a text rendering of the web page. """ # Retrieve the web page text and the qutepart text. tc = self._webTextContent() qp = core.workspace().currentDocument().qutepart # Perform an approximate match between the clicked webpage text and the # qutepart text. textIndex = findApproxTextInTarget(tc, webIndex, qp.text) # Move the cursor to textIndex in qutepart, assuming corresponding text # was found. if textIndex >= 0: self._moveTextPaneToIndex(textIndex)