QScintilla/MarkupProviders/MarkdownProvider.py

changeset 5398
1f4509cf8f35
parent 5397
fee5485e67f4
child 5402
ce21a78a5fcf
--- a/QScintilla/MarkupProviders/MarkdownProvider.py	Mon Jan 02 12:49:28 2017 +0100
+++ b/QScintilla/MarkupProviders/MarkdownProvider.py	Mon Jan 02 20:13:40 2017 +0100
@@ -22,6 +22,15 @@
         """
         super(MarkdownProvider, self).__init__()
     
+    def kind(self):
+        """
+        Public method to get the markup kind.
+        
+        @return string with markup kind
+        @rtype str
+        """
+        return "markdown"
+    
     def hasBold(self):
         """
         Public method to indicate the availability of bold markup.
@@ -49,6 +58,15 @@
         """
         return True
     
+    def headerLevels(self):
+        """
+        Public method to determine the available header levels.
+        
+        @return supported header levels
+        @rtype int
+        """
+        return 6
+    
     def bold(self, editor):
         """
         Public method to generate bold text.
@@ -76,6 +94,24 @@
         """
         self.__insertMarkup("~~", editor)
     
+    def header(self, editor, level):
+        """
+        Public method to generate a header.
+        
+        @param editor reference to the editor to work on
+        @type Editor
+        @param level header level
+        @type int
+        """
+        if editor is None or level > self.headerLevels():
+            return
+        
+        editor.beginUndoAction()
+        cline, cindex = editor.getCursorPosition()
+        editor.insertAt(level * "#" + " ", cline, 0)
+        editor.setCursorPosition(cline, level + 1)
+        editor.endUndoAction()
+    
     def __insertMarkup(self, markup, editor):
         """
         Private method to insert the specified markup.

eric ide

mercurial