Ejemplo n.º 1
0
Archivo: lexer.py Proyecto: Garjy/edis
    def load_highlighter(self):
        """ Método público: carga el resaltado de sintáxis """

        scheme = editor_scheme.get_scheme(
            settings.get_setting('editor/scheme'))
        self.setDefaultPaper(QColor(scheme['BackgroundEditor']))
        self.setPaper(self.defaultPaper(0))
        self.setColor(QColor(scheme['Color']))

        types = dir(self)
        for _type in types:
            if _type in scheme:
                atr = getattr(self, _type)
                self.setColor(QColor(scheme[_type]), atr)
Ejemplo n.º 2
0
    def load_highlighter(self):
        """ Método público: carga el resaltado de sintáxis """

        scheme = editor_scheme.get_scheme(
            settings.get_setting('editor/scheme'))
        self.setDefaultPaper(QColor(scheme['BackgroundEditor']))
        self.setPaper(self.defaultPaper(0))
        self.setColor(QColor(scheme['Color']))

        types = dir(self)
        for _type in types:
            if _type in scheme:
                atr = getattr(self, _type)
                self.setColor(QColor(scheme[_type]), atr)
Ejemplo n.º 3
0
Archivo: editor.py Proyecto: Garjy/edis
    def __init__(self, obj_file):
        super(Editor, self).__init__()
        self.obj_file = obj_file  # Asociación con el objeto EdisFile
        self._font = None
        # Configuración
        use_tabs = settings.get_setting('editor/usetabs')
        self.setIndentationsUseTabs(use_tabs)
        self.setAutoIndent(settings.get_setting('editor/indent'))
        self.setBackspaceUnindents(True)
        # Quita el scrollbar
        self.send("sci_sethscrollbar", 0)
        # Configuración de indicadores
        self.send("sci_indicsetstyle", Editor.WORD_INDICATOR, "indic_box")
        self.send("sci_indicsetfore", Editor.WORD_INDICATOR, QColor("#FF0000"))
        self.send("sci_indicsetstyle",
                  Editor.WARNING_INDICATOR, "indic_squiggle")
        self.send("sci_indicsetfore",
                  Editor.WARNING_INDICATOR, QColor("#0000FF"))
        # Scheme
        self.scheme = editor_scheme.get_scheme(
            settings.get_setting('editor/scheme'))
        # Folding
        self.setFolding(QsciScintilla.PlainFoldStyle)  # en márgen 2
        self.setMarginWidth(3, 5)  # 5px de espacios en márgen 3
        self.send("sci_markersetfore",
            QsciScintilla.SC_MARKNUM_FOLDER,
            QColor(self.scheme['FoldMarkerFore']))
        self.send("sci_markersetback",
            QsciScintilla.SC_MARKNUM_FOLDER,
            QColor(self.scheme['FoldMarkerBack']))
        self.setFoldMarginColors(QColor(self.scheme['FoldMarginBack']),
                                 QColor(self.scheme['FoldMarginFore']))
        # Marcadores
        self.markerDefine(QsciScintilla.SC_MARK_LEFTRECT,
                          Editor.MARKER_MODIFIED)
        self.setMarkerBackgroundColor(
            QColor(226, 255, 141), Editor.MARKER_MODIFIED)
        self.markerDefine(QsciScintilla.SC_MARK_LEFTRECT, Editor.MARKER_SAVED)
        self.setMarkerBackgroundColor(QColor(55, 142, 103),
                                      Editor.MARKER_SAVED)

        # Actualiza flags (espacios en blanco, cursor, sidebar, etc)
        self.update_options()
        # Lexer
        self._lexer = lexer.Lexer()
        self.setLexer(self._lexer)
        # Autocompletado
        self.api = None
        if settings.get_setting('editor/completion'):
            self.active_code_completion()
        # Indentación
        self._indentation = settings.get_setting('editor/width-indent')
        self.send("sci_settabwidth", self._indentation)
        # Minimapa
        self.minimap = None
        if settings.get_setting('editor/minimap'):
            self.minimap = minimap.Minimap(self)
            self.connect(self, SIGNAL("textChanged()"),
                         self.minimap.update_code)
        # Thread que busca palabras
        self.search_thread = editor_helpers.SearchThread()
        self.connect(self.search_thread,
                     SIGNAL("foundWords(PyQt_PyObject)"), self.mark_words)
        # Analizador de estilo de código
        self.checker = None
        if settings.get_setting('editor/style-checker'):
            self.load_checker()
        # Fuente
        font = settings.get_setting('editor/font')
        font_size = settings.get_setting('editor/size-font')
        self.load_font(font, font_size)
        self.setMarginsBackgroundColor(QColor(self.scheme['SidebarBack']))
        self.setMarginsForegroundColor(QColor(self.scheme['SidebarFore']))
        # Línea actual
        self.send("sci_setcaretlinevisible",
                  settings.get_setting('editor/show-caret-line'))
        self.send("sci_setcaretlineback", QColor(self.scheme['CaretLineBack']))
        self.send("sci_setcaretfore", QColor(self.scheme['CaretLineFore']))
        self.send("sci_setcaretlinebackalpha", self.scheme['CaretLineAlpha'])
        # Cursor
        caret_period = settings.get_setting('editor/cursor-period')
        self.send("sci_setcaretperiod", caret_period)
        # Márgen
        if settings.get_setting('editor/show-margin'):
            self.update_margin()
        # Brace matching
        self.setBraceMatching(int(settings.get_setting('editor/match-brace')))
        self.setMatchedBraceBackgroundColor(QColor(
            self.scheme['MatchedBraceBack']))
        self.setMatchedBraceForegroundColor(QColor(
            self.scheme['MatchedBraceFore']))
        self.setUnmatchedBraceBackgroundColor(QColor(
            self.scheme['UnmatchedBraceBack']))
        self.setUnmatchedBraceForegroundColor(QColor(
            self.scheme['UnmatchedBraceFore']))
        # Selecciones Múltiples
        self.send("sci_setadditionalcaretfore", QColor(157, 64, 40))
        self.send("sci_setadditionalcaretsblink", 1)
        self.send("sci_setadditionalselalpha", 100)
        self.send("sci_setmultipleselection", 1)
        self.send("sci_setadditionalselectiontyping", 1)
        # Conexiones
        self.connect(self, SIGNAL("linesChanged()"), self.update_sidebar)
        self.connect(self, SIGNAL("textChanged()"), self._add_marker_modified)
Ejemplo n.º 4
0
    def __init__(self, obj_file):
        super(Editor, self).__init__()
        self.obj_file = obj_file  # Asociación con el objeto EdisFile
        self._font = None
        # Configuración
        use_tabs = settings.get_setting('editor/usetabs')
        self.setIndentationsUseTabs(use_tabs)
        self.setAutoIndent(settings.get_setting('editor/indent'))
        self.setBackspaceUnindents(True)
        # Quita el scrollbar
        self.send("sci_sethscrollbar", 0)
        # Configuración de indicadores
        self.send("sci_indicsetstyle", Editor.WORD_INDICATOR, "indic_box")
        self.send("sci_indicsetfore", Editor.WORD_INDICATOR, QColor("#FF0000"))
        self.send("sci_indicsetstyle", Editor.WARNING_INDICATOR,
                  "indic_squiggle")
        self.send("sci_indicsetfore", Editor.WARNING_INDICATOR,
                  QColor("#0000FF"))
        # Scheme
        self.scheme = editor_scheme.get_scheme(
            settings.get_setting('editor/scheme'))
        # Folding
        self.setFolding(QsciScintilla.PlainFoldStyle)  # en márgen 2
        self.setMarginWidth(3, 5)  # 5px de espacios en márgen 3
        self.send("sci_markersetfore", QsciScintilla.SC_MARKNUM_FOLDER,
                  QColor(self.scheme['FoldMarkerFore']))
        self.send("sci_markersetback", QsciScintilla.SC_MARKNUM_FOLDER,
                  QColor(self.scheme['FoldMarkerBack']))
        self.setFoldMarginColors(QColor(self.scheme['FoldMarginBack']),
                                 QColor(self.scheme['FoldMarginFore']))
        # Marcadores
        self.markerDefine(QsciScintilla.SC_MARK_LEFTRECT,
                          Editor.MARKER_MODIFIED)
        self.setMarkerBackgroundColor(QColor(226, 255, 141),
                                      Editor.MARKER_MODIFIED)
        self.markerDefine(QsciScintilla.SC_MARK_LEFTRECT, Editor.MARKER_SAVED)
        self.setMarkerBackgroundColor(QColor(55, 142, 103),
                                      Editor.MARKER_SAVED)

        # Actualiza flags (espacios en blanco, cursor, sidebar, etc)
        self.update_options()
        # Lexer
        self._lexer = lexer.Lexer()
        self.setLexer(self._lexer)
        # Autocompletado
        self.api = None
        if settings.get_setting('editor/completion'):
            self.active_code_completion()
        # Indentación
        self._indentation = settings.get_setting('editor/width-indent')
        self.send("sci_settabwidth", self._indentation)
        # Minimapa
        self.minimap = None
        if settings.get_setting('editor/minimap'):
            self.minimap = minimap.Minimap(self)
            self.connect(self, SIGNAL("textChanged()"),
                         self.minimap.update_code)
        # Thread que busca palabras
        self.search_thread = editor_helpers.SearchThread()
        self.connect(self.search_thread, SIGNAL("foundWords(PyQt_PyObject)"),
                     self.mark_words)
        # Analizador de estilo de código
        self.checker = None
        if settings.get_setting('editor/style-checker'):
            self.load_checker()
        # Fuente
        font = settings.get_setting('editor/font')
        font_size = settings.get_setting('editor/size-font')
        self.load_font(font, font_size)
        self.setMarginsBackgroundColor(QColor(self.scheme['SidebarBack']))
        self.setMarginsForegroundColor(QColor(self.scheme['SidebarFore']))
        # Línea actual
        self.send("sci_setcaretlinevisible",
                  settings.get_setting('editor/show-caret-line'))
        self.send("sci_setcaretlineback", QColor(self.scheme['CaretLineBack']))
        self.send("sci_setcaretfore", QColor(self.scheme['CaretLineFore']))
        self.send("sci_setcaretlinebackalpha", self.scheme['CaretLineAlpha'])
        # Cursor
        caret_period = settings.get_setting('editor/cursor-period')
        self.send("sci_setcaretperiod", caret_period)
        # Márgen
        if settings.get_setting('editor/show-margin'):
            self.update_margin()
        # Brace matching
        self.setBraceMatching(int(settings.get_setting('editor/match-brace')))
        self.setMatchedBraceBackgroundColor(
            QColor(self.scheme['MatchedBraceBack']))
        self.setMatchedBraceForegroundColor(
            QColor(self.scheme['MatchedBraceFore']))
        self.setUnmatchedBraceBackgroundColor(
            QColor(self.scheme['UnmatchedBraceBack']))
        self.setUnmatchedBraceForegroundColor(
            QColor(self.scheme['UnmatchedBraceFore']))
        # Selecciones Múltiples
        self.send("sci_setadditionalcaretfore", QColor(157, 64, 40))
        self.send("sci_setadditionalcaretsblink", 1)
        self.send("sci_setadditionalselalpha", 100)
        self.send("sci_setmultipleselection", 1)
        self.send("sci_setadditionalselectiontyping", 1)
        # Conexiones
        self.connect(self, SIGNAL("linesChanged()"), self.update_sidebar)
        self.connect(self, SIGNAL("textChanged()"), self._add_marker_modified)