Beispiel #1
0
    def __init__(self, parent=None):

        QsciLexer.__init__(self, parent)
        Lexer.__init__(self)

        self.editor = parent
        return
Beispiel #2
0
    def __init__( self, parent = None ):

        QsciLexer.__init__( self, parent )
        Lexer.__init__( self )

        self.editor = parent
        return
 def __init__(self, parent = None):
     """
     Constructor
     
     @param parent parent widget of this lexer
     """
     QsciLexer.__init__(self, parent)
     Lexer.__init__(self)
     
     self.editor = parent
 def __init__(self, language, parent=None):
     """
     Constructor
     
     @param language The lexer language. (string or QString)
     @param parent The parent widget of this lexer. (QextScintilla)
     """
     QsciLexer.__init__(self, parent)
     
     # These default font families are taken from QScintilla
     if Globals.isWindowsPlatform():
         self.__defaultFontFamily = "Courier New"
     elif Globals.isMacPlatform():
         self.__defaultFontFamily = "Courier"
     else:
         self.__defaultFontFamily = "Bitstream Vera Sans Mono"
     
     # instantiate a lexer object for the given language
     language = unicode(language)
     lex = QScintilla.Lexers.getLexer(language)
     if lex is None:
         raise PreferencesLexerLanguageError(language)
     
     # define the local store
     self.colours = {}
     self.defaultColours = {}
     self.papers = {}
     self.defaultPapers = {}
     self.eolFills = {}
     self.defaultEolFills = {}
     self.fonts = {}
     self.defaultFonts = {}
     self.descriptions = {}
     self.ind2style = {}
     self.styles = QStringList()
     
     # fill local store with default values from lexer
     # and built up styles list and conversion table from index to style
     self.__language = lex.language()
     
     index = 0
     for i in range(128):
         desc = lex.description(i)
         if not desc.isEmpty():
             self.descriptions[i] = desc
             self.styles.append(desc)
             
             self.colours[i] = lex.defaultColor(i)
             self.papers[i] = lex.defaultPaper(i)
             self.eolFills[i] = lex.defaultEolFill(i)
             self.fonts[i] = lex.defaultFont(i)
             # Override QScintilla's default font family to
             # always use a monospaced font
             self.fonts[i].setFamily(self.__defaultFontFamily)
             
             self.defaultColours[i] = lex.defaultColor(i)
             self.defaultPapers[i] = lex.defaultPaper(i)
             self.defaultEolFills[i] = lex.defaultEolFill(i)
             self.defaultFonts[i] = lex.defaultFont(i)
             self.defaultFonts[i].setFamily(self.__defaultFontFamily)
             
             self.ind2style[index] = i
             index += 1
     
     self.connect(self, SIGNAL("colorChanged (const QColor&, int)"), 
                  self.setColor)
     self.connect(self, SIGNAL("eolFillChanged (bool, int)"), 
                  self.setEolFill)
     self.connect(self, SIGNAL("fontChanged (const QFont&, int)"), 
                  self.setFont)
     self.connect(self, SIGNAL("paperChanged (const QColor&, int )"), 
                  self.setPaper)
     
     # read the last stored values from preferences file
     self.readSettings(Preferences.Prefs.settings, "Scintilla")