1# -*- coding: utf-8 -*- 2 3# Copyright (c) 2008 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> 4# 5 6""" 7Module implementing a Fortran lexer with some additional methods. 8""" 9 10from PyQt5.Qsci import QsciLexerFortran 11 12from .Lexer import Lexer 13import Preferences 14 15 16class LexerFortran(Lexer, QsciLexerFortran): 17 """ 18 Subclass to implement some additional lexer dependant methods. 19 """ 20 def __init__(self, parent=None): 21 """ 22 Constructor 23 24 @param parent parent widget of this lexer 25 """ 26 QsciLexerFortran.__init__(self, parent) 27 Lexer.__init__(self) 28 29 self.commentString = "c " 30 31 self.keywordSetDescriptions = [ 32 self.tr("Primary keywords and identifiers"), 33 self.tr("Intrinsic functions"), 34 self.tr("Extended and user defined functions"), 35 ] 36 37 def initProperties(self): 38 """ 39 Public slot to initialize the properties. 40 """ 41 self.setFoldCompact(Preferences.getEditor("AllFoldCompact")) 42 43 def autoCompletionWordSeparators(self): 44 """ 45 Public method to return the list of separators for autocompletion. 46 47 @return list of separators (list of strings) 48 """ 49 return ['.'] 50 51 def isCommentStyle(self, style): 52 """ 53 Public method to check, if a style is a comment style. 54 55 @param style style to check (integer) 56 @return flag indicating a comment style (boolean) 57 """ 58 return style in [QsciLexerFortran.Comment] 59 60 def isStringStyle(self, style): 61 """ 62 Public method to check, if a style is a string style. 63 64 @param style style to check (integer) 65 @return flag indicating a string style (boolean) 66 """ 67 return style in [QsciLexerFortran.DoubleQuotedString, 68 QsciLexerFortran.SingleQuotedString, 69 QsciLexerFortran.UnclosedString] 70 71 def defaultKeywords(self, kwSet): 72 """ 73 Public method to get the default keywords. 74 75 @param kwSet number of the keyword set (integer) 76 @return string giving the keywords (string) or None 77 """ 78 return QsciLexerFortran.keywords(self, kwSet) 79