def _onAnchorClicked(self, link): """Overwritten URL click handler""" if link == 'javascript:history.back()' or link == 'history.back()': if self.__parentWidget.viewerHistory.backAvailable(): self.__parentWidget.onBack() else: logging.warning('No step back avaialable') return if link == 'javascript:history.forward()' or link == 'history.forward()': if self.__parentWidget.viewerHistory.forwardAvailable(): self.__parentWidget.onForward() else: logging.warning('No step forward available') return fileName, anchorOrLine = self._resolveLink(link) if fileName: mime, _, _ = getFileProperties(fileName) if isMarkdownMime(mime): self.__parentWidget.updateCurrentHistoryPosition() self.__parentWidget.setFileName(fileName) else: # It is a resolved link to some kind of non-markdown file GlobalData().mainWindow.openFile(fileName, anchorOrLine)
def __onFileTypeChanged(self, fileName, uuid, newFileType): """Triggered when a buffer content type has changed""" if self.__parentWidget.getUUID() != uuid: return if not isMarkdownMime(newFileType): self.__disconnectEditorSignals() self.__updateTimer.stop() self.setVisible(False) self.__topBar.updateInfoIcon(self.__topBar.STATE_UNKNOWN) return # Update the bar and show it self.setVisible(True) self.process() # The buffer type change event comes when the content is loaded first # time. So this is a good point to restore the position _, _, _, hPos, vPos = getFilePosition(fileName) self.setScrollbarPositions(hPos, vPos)
def isMarkdownBuffer(self): """True if it is a markdown buffer""" return isMarkdownMime(self.mime)