QScintilla/MarkupProviders/MarkdownProvider.py

changeset 5407
f833f89571b8
parent 5404
6b19ad5470a3
child 5411
a163fbbf2bea
--- a/QScintilla/MarkupProviders/MarkdownProvider.py	Sun Jan 08 18:51:55 2017 +0100
+++ b/QScintilla/MarkupProviders/MarkdownProvider.py	Sun Jan 08 18:52:16 2017 +0100
@@ -205,10 +205,13 @@
         @param editor reference to the editor to work on
         @type Editor
         """
+        if editor is None:
+            return
+        
         from .HyperlinkMarkupDialog import HyperlinkMarkupDialog
         dlg = HyperlinkMarkupDialog(False, True)
         if dlg.exec_() == QDialog.Accepted:
-            text,  target, title = dlg.getData()
+            text, target, title = dlg.getData()
             
             link = "[{0}]".format(text)
             if target and title:
@@ -250,3 +253,65 @@
         cline, cindex = editor.getCursorPosition()
         editor.setCursorPosition(cline + 3, 0)
         editor.endUndoAction()
+    
+    def hasQuote(self):
+        """
+        Public method to indicate the availability of block quote markup.
+        
+        @return flag indicating the availability of block quote markup
+        @rtype bool
+        """
+        return True
+    
+    def quote(self, editor):
+        """
+        Public method to generate block quote text.
+        
+        @param editor reference to the editor to work on
+        @type Editor
+        """
+        if editor is None:
+            return
+        
+        editor.beginUndoAction()
+        markup = "> "
+        sline, sindex, eline, eindex = editor.getSelection()
+        for line in range(sline, eline + 1 if eindex > 0 else eline):
+            editor.insertAt(markup, line, 0)
+        editor.endUndoAction()
+    
+    def hasImage(self):
+        """
+        Public method to indicate the availability of image markup.
+        
+        @return flag indicating the availability of image markup
+        @rtype bool
+        """
+        return True
+    
+    def image(self, editor):
+        """
+        Public method to generate image text.
+        
+        @param editor reference to the editor to work on
+        @type Editor
+        """
+        if editor is None:
+            return
+        
+        from .ImageMarkupDialog import ImageMarkupDialog
+        dlg = ImageMarkupDialog(ImageMarkupDialog.MarkDownMode)
+        if dlg.exec_() == QDialog.Accepted:
+            address, altText, title, originalSize, width, height = \
+                dlg.getData()
+            
+            if title:
+                markup = '![{0}]({1} "{2}")'.format(altText, address, title)
+            else:
+                markup = '![{0}]({1})'.format(altText, address)
+            
+            editor.beginUndoAction()
+            editor.insert(markup)
+            cline, cindex = editor.getCursorPosition()
+            editor.setCursorPosition(cline, cindex + len(markup))
+            editor.endUndoAction()

eric ide

mercurial