1# -*- coding: utf-8 -*- 2 3# Copyright (c) 2011 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> 4# 5 6""" 7Module implementing a Octave lexer with some additional methods. 8""" 9 10from PyQt5.Qsci import QsciLexerOctave 11 12from .Lexer import Lexer 13 14 15class LexerOctave(Lexer, QsciLexerOctave): 16 """ 17 Subclass to implement some additional lexer dependent methods. 18 """ 19 def __init__(self, parent=None): 20 """ 21 Constructor 22 23 @param parent parent widget of this lexer 24 """ 25 QsciLexerOctave.__init__(self, parent) 26 Lexer.__init__(self) 27 28 self.commentString = "#" 29 30 self.keywordSetDescriptions = [ 31 self.tr("Keywords"), 32 ] 33 34 def isCommentStyle(self, style): 35 """ 36 Public method to check, if a style is a comment style. 37 38 @param style style to check (integer) 39 @return flag indicating a comment style (boolean) 40 """ 41 return style in [QsciLexerOctave.Comment] 42 43 def isStringStyle(self, style): 44 """ 45 Public method to check, if a style is a string style. 46 47 @param style style to check (integer) 48 @return flag indicating a string style (boolean) 49 """ 50 return style in [QsciLexerOctave.DoubleQuotedString, 51 QsciLexerOctave.SingleQuotedString] 52 53 def defaultKeywords(self, kwSet): 54 """ 55 Public method to get the default keywords. 56 57 @param kwSet number of the keyword set (integer) 58 @return string giving the keywords (string) or None 59 """ 60 return QsciLexerOctave.keywords(self, kwSet) 61