diff -r a5c8a0213fe3 -r 7d9d916a9a9f src/eric7/QScintilla/Lexers/LexerPygments.py --- a/src/eric7/QScintilla/Lexers/LexerPygments.py Tue Aug 23 16:21:07 2022 +0200 +++ b/src/eric7/QScintilla/Lexers/LexerPygments.py Tue Aug 23 19:14:35 2022 +0200 @@ -303,6 +303,69 @@ PYGMENTS_BACKTICKSTRING: True, } + self.__commentString = { + "Bash": "#", + "Batchfile": "REM ", + "C": "//", + "C++": "//", + "C#": "//", + "CMake": "#", + "CoffeScript": "#", + "CSS": "#", + "D": "//", + "Fortran": "c ", + "Gettext Catalog": "#", + "IDL": "//", + "INI": "#", + "Java": "//", + "JavaScript": "//", + "JSON": "//", + "Lua": "--", + "Makefile": "#", + "Matlab": "%~", + "Octave": "#", + "Perl": "#", + "PostScript": "%", + "POVRay": "//", + "Properties": "#", + "Python": "#", + "RPMSpec": "#", + "Ruby": "#", + "SQL": "--", + "Tcl": "#", + "TeX": "%", + "TOML": "#", + "YAML": "#", + } + + self.__streamCommentString = { + "CoffeScript": {"start": "###\n", "end": "\n###"}, + "C": {"start": "/* ", "end": " */"}, + "C++": {"start": "/* ", "end": " */"}, + "C#": {"start": "/* ", "end": " */"}, + "CSS": {"start": "/* ", "end": " */"}, + "D": {"start": "/+ ", "end": " +/"}, + "HTML": {"start": "<!-- ", "end": " -->"}, + "IDL": {"start": "/* ", "end": " */"}, + "Java": {"start": "/* ", "end": " */"}, + "JavaScript": {"start": "/* ", "end": " */"}, + "JSON": {"start": "/* ", "end": " */"}, + "Lua": {"start": "--[[ ", "end": " ]]--"}, + "POVRay": {"start": "/* ", "end": " */"}, + "XML": {"start": "<!-- ", "end": " -->"}, + } + + self.__boxCommentString = { + "C": {"start": "/* ", "middle": " * ", "end": " */"}, + "C++": {"start": "/* ", "middle": " * ", "end": " */"}, + "C#": {"start": "/* ", "middle": " * ", "end": " */"}, + "D": {"start": "/* ", "middle": " * ", "end": " */"}, + "IDL": {"start": "/* ", "middle": " * ", "end": " */"}, + "Java": {"start": "/* ", "middle": " * ", "end": " */"}, + "JavaScript": {"start": "/* ", "middle": " * ", "end": " */"}, + "POVRay": {"start": "/* ", "middle": " * ", "end": " */"}, + } + def readSettings(self, qs, prefix="/Scintilla"): """ Public method to read the lexer settings. @@ -564,3 +627,69 @@ @return string giving the keywords (string) or None """ return None # __IGNORE_WARNING_M831__ + + def commentStr(self): + """ + Public method to return the comment string. + + @return comment string + @rtype str + """ + try: + return self.__commentString[self.name()] + except KeyError: + return "" + + def canBlockComment(self): + """ + Public method to determine, whether the lexer language supports a + block comment. + + @return flag indicating block comment is available + @rtype bool + """ + return self.name() in self.__commentString + + def streamCommentStr(self): + """ + Public method to return the stream comment strings. + + @return dictionary containing the start and end stream comment strings + @type dict of {"start": str, "end": str} + """ + try: + return self.__streamCommentString + except KeyError: + return {"start": "", "end": ""} + + def canStreamComment(self): + """ + Public method to determine, whether the lexer language supports a + stream comment. + + @return flag indicating stream comment is available + @type bool + """ + return self.name() in self.__streamCommentString + + def boxCommentStr(self): + """ + Public method to return the box comment strings. + + @return dictionary containing the start, middle and end box comment strings + @type dict of {"start": str, "middle": str, "end": str} + """ + try: + return self.__boxCommentString + except KeyError: + return {"start": "", "middle": "", "end": ""} + + def canBoxComment(self): + """ + Public method to determine, whether the lexer language supports a + box comment. + + @return flag box comment is available + @type bool + """ + return self.name() in self.__boxCommentString