1# -*- coding: utf-8 -*- 2 3# Copyright (c) 2014 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> 4# 5 6""" 7Module implementing a Gettext lexer with some additional methods. 8""" 9 10from PyQt5.Qsci import QsciLexerPO 11 12from .Lexer import Lexer 13import Preferences 14 15 16class LexerPO(Lexer, QsciLexerPO): 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 QsciLexerPO.__init__(self, parent) 27 Lexer.__init__(self) 28 29 self.commentString = "#" 30 31 self.keywordSetDescriptions = [] 32 33 def initProperties(self): 34 """ 35 Public slot to initialize the properties. 36 """ 37 self.setFoldComments(Preferences.getEditor("PoFoldComment")) 38 self.setFoldCompact(Preferences.getEditor("AllFoldCompact")) 39 40 def isCommentStyle(self, style): 41 """ 42 Public method to check, if a style is a comment style. 43 44 @param style style to check (integer) 45 @return flag indicating a comment style (boolean) 46 """ 47 return style in [QsciLexerPO.Comment, QsciLexerPO.ProgrammerComment] 48 49 def isStringStyle(self, style): 50 """ 51 Public method to check, if a style is a string style. 52 53 @param style style to check (integer) 54 @return flag indicating a string style (boolean) 55 """ 56 return style in [QsciLexerPO.MessageIdText, 57 QsciLexerPO.MessageStringText, 58 QsciLexerPO.MessageContextText] 59 60 def defaultKeywords(self, kwSet): 61 """ 62 Public method to get the default keywords. 63 64 @param kwSet number of the keyword set (integer) 65 @return string giving the keywords (string) or None 66 """ 67 return QsciLexerPO.keywords(self, kwSet) 68