Esempio n. 1
0
    def __createHighlightBySetting(self, setting):
        if setting is None:
            return

        for language in setting.getChildren():
            if language is None or language.getName() is None or "" == language.getName():
                continue

            languageName = language.getName().lower().strip()
            if not languages.LANGUAGE_MAP.has_key(languageName):
                continue
            lexer = languages.LANGUAGE_MAP[languageName]

            """ gets path of style file """
            if language.getAttrs().has_key("style"):
                styleFilePath = language.getAttrs()["style"].strip()
                if "" == styleFilePath:
                    continue
                styleFilePath = "%s%s..%s..%s..%s%s" % (
                    os.path.dirname(__file__),
                    os.path.sep,
                    os.path.sep,
                    os.path.sep,
                    os.path.sep,
                    styleFilePath,
                )
                if not os.path.exists(styleFilePath):
                    continue

                styleSettings = XmlLoader().load(styleFilePath)
                if styleSettings is None:
                    continue

                highlightStyle = Highlight()
                for setting in styleSettings.getChildren():
                    if setting is None or "" == setting.getName():
                        continue
                    if "keywords" == setting.getName():
                        keywords = setting.getCharData().strip()
                        if "" != keywords:
                            highlightStyle.setKeywords(keywords)
                    elif "styles" == setting.getName():
                        for mode in setting.getChildren():
                            if mode is None or mode.getName() is None or "" == mode.getName():
                                continue
                            font = self.__createFontBySetting(mode)
                            highlightStyle.getHighlightStyles()[mode.getName().lower().strip()] = font

                self.getEditorStyle().getHighlightStyles()[lexer] = highlightStyle