Commits

Henning Schröder committed 4e2b52c

mode for i18n-po-files

Comments (0)

Files changed (1)

codeaide/modes/po.py

+# -*- coding: utf-8 -*-
+from codeaide.base import *
+from codeaide.modes.language import *
+from codeaide.modes.language.highlighter import HighlighterBase
+from codeaide.modes.language.phighlighter import SyntaxHighlighter, load_syntax
+
+
+po_syntax = {
+  "partitions": [
+      ("string", "'", "'"),
+      ("string", '"', '"'),
+      ("comment", "#", "\n", True),            
+  ],
+  "scanner": {
+      None: [
+         ("number", "(0x)?\d+(\.\d*)?"),
+         ("name", "[A-Za-z_][A-Za-z_0-9]*"),
+         ("colon", ":")
+      ]
+  },
+  "formats": {
+     "name": "%(syntax_keyword)s",
+     "comment": "%(syntax_comment)s",
+     "string":  "%(syntax_string)s",
+  }
+}
+
+
+
+class PoHighlighter(SyntaxHighlighter):
+
+    
+    def __init__(self, textedit):
+        partition_scanner, scanners, formats = load_syntax(po_syntax, textedit.settings.scheme)
+        SyntaxHighlighter.__init__(self, textedit.document(),
+                                   partition_scanner, scanners, formats, textedit.font())
+
+
+                                   
+
+
+
+
+class PoHighlighting(HighlighterBase):
+
+
+    def init_highlighter(self):
+        self.highlighter = PoHighlighter(self.textedit)
+
+        
+        
+class Po(LanguageModeBase):
+
+    #require_modules = [
+    #    ]
+    requires = [
+        "PoHighlighting", 
+      ]
+
+    mimetype = "text/x-python"
+    pattern = "^.*\.po$"