src/eric7/QScintilla/Lexers/LexerPygments.py

branch
eric7
changeset 9293
7d9d916a9a9f
parent 9221
bf71ee032bb4
child 9295
d14096c04126
equal deleted inserted replaced
9292:a5c8a0213fe3 9293:7d9d916a9a9f
301 PYGMENTS_MULTILINECOMMENT: True, 301 PYGMENTS_MULTILINECOMMENT: True,
302 PYGMENTS_HEREDOC: True, 302 PYGMENTS_HEREDOC: True,
303 PYGMENTS_BACKTICKSTRING: True, 303 PYGMENTS_BACKTICKSTRING: True,
304 } 304 }
305 305
306 self.__commentString = {
307 "Bash": "#",
308 "Batchfile": "REM ",
309 "C": "//",
310 "C++": "//",
311 "C#": "//",
312 "CMake": "#",
313 "CoffeScript": "#",
314 "CSS": "#",
315 "D": "//",
316 "Fortran": "c ",
317 "Gettext Catalog": "#",
318 "IDL": "//",
319 "INI": "#",
320 "Java": "//",
321 "JavaScript": "//",
322 "JSON": "//",
323 "Lua": "--",
324 "Makefile": "#",
325 "Matlab": "%~",
326 "Octave": "#",
327 "Perl": "#",
328 "PostScript": "%",
329 "POVRay": "//",
330 "Properties": "#",
331 "Python": "#",
332 "RPMSpec": "#",
333 "Ruby": "#",
334 "SQL": "--",
335 "Tcl": "#",
336 "TeX": "%",
337 "TOML": "#",
338 "YAML": "#",
339 }
340
341 self.__streamCommentString = {
342 "CoffeScript": {"start": "###\n", "end": "\n###"},
343 "C": {"start": "/* ", "end": " */"},
344 "C++": {"start": "/* ", "end": " */"},
345 "C#": {"start": "/* ", "end": " */"},
346 "CSS": {"start": "/* ", "end": " */"},
347 "D": {"start": "/+ ", "end": " +/"},
348 "HTML": {"start": "<!-- ", "end": " -->"},
349 "IDL": {"start": "/* ", "end": " */"},
350 "Java": {"start": "/* ", "end": " */"},
351 "JavaScript": {"start": "/* ", "end": " */"},
352 "JSON": {"start": "/* ", "end": " */"},
353 "Lua": {"start": "--[[ ", "end": " ]]--"},
354 "POVRay": {"start": "/* ", "end": " */"},
355 "XML": {"start": "<!-- ", "end": " -->"},
356 }
357
358 self.__boxCommentString = {
359 "C": {"start": "/* ", "middle": " * ", "end": " */"},
360 "C++": {"start": "/* ", "middle": " * ", "end": " */"},
361 "C#": {"start": "/* ", "middle": " * ", "end": " */"},
362 "D": {"start": "/* ", "middle": " * ", "end": " */"},
363 "IDL": {"start": "/* ", "middle": " * ", "end": " */"},
364 "Java": {"start": "/* ", "middle": " * ", "end": " */"},
365 "JavaScript": {"start": "/* ", "middle": " * ", "end": " */"},
366 "POVRay": {"start": "/* ", "middle": " * ", "end": " */"},
367 }
368
306 def readSettings(self, qs, prefix="/Scintilla"): 369 def readSettings(self, qs, prefix="/Scintilla"):
307 """ 370 """
308 Public method to read the lexer settings. 371 Public method to read the lexer settings.
309 372
310 Note: Overridden to treat the Pygments lexer specially. 373 Note: Overridden to treat the Pygments lexer specially.
562 625
563 @param kwSet number of the keyword set (integer) 626 @param kwSet number of the keyword set (integer)
564 @return string giving the keywords (string) or None 627 @return string giving the keywords (string) or None
565 """ 628 """
566 return None # __IGNORE_WARNING_M831__ 629 return None # __IGNORE_WARNING_M831__
630
631 def commentStr(self):
632 """
633 Public method to return the comment string.
634
635 @return comment string
636 @rtype str
637 """
638 try:
639 return self.__commentString[self.name()]
640 except KeyError:
641 return ""
642
643 def canBlockComment(self):
644 """
645 Public method to determine, whether the lexer language supports a
646 block comment.
647
648 @return flag indicating block comment is available
649 @rtype bool
650 """
651 return self.name() in self.__commentString
652
653 def streamCommentStr(self):
654 """
655 Public method to return the stream comment strings.
656
657 @return dictionary containing the start and end stream comment strings
658 @type dict of {"start": str, "end": str}
659 """
660 try:
661 return self.__streamCommentString
662 except KeyError:
663 return {"start": "", "end": ""}
664
665 def canStreamComment(self):
666 """
667 Public method to determine, whether the lexer language supports a
668 stream comment.
669
670 @return flag indicating stream comment is available
671 @type bool
672 """
673 return self.name() in self.__streamCommentString
674
675 def boxCommentStr(self):
676 """
677 Public method to return the box comment strings.
678
679 @return dictionary containing the start, middle and end box comment strings
680 @type dict of {"start": str, "middle": str, "end": str}
681 """
682 try:
683 return self.__boxCommentString
684 except KeyError:
685 return {"start": "", "middle": "", "end": ""}
686
687 def canBoxComment(self):
688 """
689 Public method to determine, whether the lexer language supports a
690 box comment.
691
692 @return flag box comment is available
693 @type bool
694 """
695 return self.name() in self.__boxCommentString

eric ide

mercurial