def __init__(self, parent=None):
        super(panelCodigo, self).__init__(parent)
        # Definir propiedades graficas
        fuente = QFont()
        fuente.setFamily('Roboto')
        fuente.setFixedPitch(True)
        fuente.setPointSize(8)
        self.setFont(fuente)
        self.setMarginsFont(fuente)
        fuenteEditor = QFontMetrics(fuente)
        self.setMarginsFont(fuente)
        self.setMarginWidth(0, fuenteEditor.width("00000") - 15)
        self.setMarginLineNumbers(0, True)
        self.setMarginsBackgroundColor(QColor("#E0E0E0"))
        self.setMarginSensitivity(1, True)
        # Ocultar scrollbar inferior
        self.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0)
        # Dimension del panel donde se edita el codigo
        self.setMinimumSize(600, 360)
        # funcion(señal) para la linea marcada
        self.marginClicked.connect(self.asignarBreak)
        # Icono que se mostrara en la linea marcada
        self.markerDefine(QsciScintilla.Rectangle, self.CONTROL_LINEA_MARCADA)
        self.setMarkerBackgroundColor(QColor("#F90000"),
                                      self.CONTROL_LINEA_MARCADA)
        # Dar valor a los caracteres especiales
        self.setBraceMatching(QsciScintilla.SloppyBraceMatch)

        # Identificar la linea donde se encuentra la ejecucion
        self.setCaretLineVisible(True)
        self.setCaretLineBackgroundColor(QColor("#00ff22"))

        # Funciones para identar las lineas del editor de codigo
        self.setAutoIndent(True)
        self.setIndentationGuides(True)
        self.setIndentationsUseTabs(True)
        self.setIndentationWidth(4)

        # Resaltado y fuente del lexer
        self.lexer = QsciLexerPascal()
        self.lexer.setDefaultFont(fuente)

        # Autocompletar haciendo uso de la API Qsci
        api = QsciAPIs(self.lexer)
        self.palabrasGramatica(api)  #flta
        api.prepare()
        # Asignar colores a las keywords de la gramatica
        self.asignarColores()  #falta
        self.setLexer(self.lexer)
        self.setAutoCompletionThreshold(1)
        self.setAutoCompletionSource(QsciScintilla.AcsAPIs)

        # Lineas marcadas
        self.controlLineasM = []
示例#2
0
    def __init__(self, parent=None):
        """
        Constructor
        
        @param parent parent widget of this lexer
        """
        QsciLexerPascal.__init__(self, parent)
        Lexer.__init__(self)

        self.commentString = "//"
        self.streamCommentString = {'start': '{ ', 'end': ' }'}
示例#3
0
 def __init__(self, parent=None):
     """
     Constructor
     
     @param parent parent widget of this lexer
     """
     QsciLexerPascal.__init__(self, parent)
     Lexer.__init__(self)
     
     self.commentString = "//"
     self.streamCommentString = {
         'start': '{ ',
         'end': ' }'
     }
示例#4
0
    def __init__(self, parent=None):
        """
        Constructor
        
        @param parent parent widget of this lexer
        """
        QsciLexerPascal.__init__(self, parent)
        Lexer.__init__(self)

        self.commentString = "//"
        self.streamCommentString = {'start': '{ ', 'end': ' }'}

        self.keywordSetDescriptions = [
            self.tr("Keywords"),
        ]
示例#5
0
 def defaultKeywords(self, kwSet):
     """
     Public method to get the default keywords.
     
     @param kwSet number of the keyword set (integer)
     @return string giving the keywords (string) or None
     """
     return QsciLexerPascal.keywords(self, kwSet)
示例#6
0
 def defaultKeywords(self, kwSet):
     """
     Public method to get the default keywords.
     
     @param kwSet number of the keyword set (integer)
     @return string giving the keywords (string) or None
     """
     return QsciLexerPascal.keywords(self, kwSet)
class panelCodigo(QsciScintilla):
    # Control de la linea marcada, activa en 1
    CONTROL_LINEA_MARCADA = 1

    def __init__(self, parent=None):
        super(panelCodigo, self).__init__(parent)
        # Definir propiedades graficas
        fuente = QFont()
        fuente.setFamily('Roboto')
        fuente.setFixedPitch(True)
        fuente.setPointSize(8)
        self.setFont(fuente)
        self.setMarginsFont(fuente)
        fuenteEditor = QFontMetrics(fuente)
        self.setMarginsFont(fuente)
        self.setMarginWidth(0, fuenteEditor.width("00000") - 15)
        self.setMarginLineNumbers(0, True)
        self.setMarginsBackgroundColor(QColor("#E0E0E0"))
        self.setMarginSensitivity(1, True)
        # Ocultar scrollbar inferior
        self.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0)
        # Dimension del panel donde se edita el codigo
        self.setMinimumSize(600, 360)
        # funcion(señal) para la linea marcada
        self.marginClicked.connect(self.asignarBreak)
        # Icono que se mostrara en la linea marcada
        self.markerDefine(QsciScintilla.Rectangle, self.CONTROL_LINEA_MARCADA)
        self.setMarkerBackgroundColor(QColor("#F90000"),
                                      self.CONTROL_LINEA_MARCADA)
        # Dar valor a los caracteres especiales
        self.setBraceMatching(QsciScintilla.SloppyBraceMatch)

        # Identificar la linea donde se encuentra la ejecucion
        self.setCaretLineVisible(True)
        self.setCaretLineBackgroundColor(QColor("#00ff22"))

        # Funciones para identar las lineas del editor de codigo
        self.setAutoIndent(True)
        self.setIndentationGuides(True)
        self.setIndentationsUseTabs(True)
        self.setIndentationWidth(4)

        # Resaltado y fuente del lexer
        self.lexer = QsciLexerPascal()
        self.lexer.setDefaultFont(fuente)

        # Autocompletar haciendo uso de la API Qsci
        api = QsciAPIs(self.lexer)
        self.palabrasGramatica(api)  #flta
        api.prepare()
        # Asignar colores a las keywords de la gramatica
        self.asignarColores()  #falta
        self.setLexer(self.lexer)
        self.setAutoCompletionThreshold(1)
        self.setAutoCompletionSource(QsciScintilla.AcsAPIs)

        # Lineas marcadas
        self.controlLineasM = []

    # Asignar breackpoints a la linea marcada
    def asignarBreak(self, nmargin, nline, modifiers):
        #SI LA LINEA YA ESTA MARCADA SE BORRA DE LAS
        #LINEAS MARACADAS, SI NO, SE ADICIONA
        if self.markersAtLine(nline) != 0:
            self.markerDelete(
                nline, self.CONTROL_LINEA_MARCADA
            )  # se agrega el breackpoint al editor para visualizarlo
            if self.controlLineasM.__contains__(nline):
                self.controlLineasM.remove(
                    nline)  #se agrega el breackpoint al aplicativo
        else:
            #se desmarca el breackpoint
            self.markerAdd(nline, self.CONTROL_LINEA_MARCADA)
            if not self.controlLineasM.__contains__(nline):
                self.controlLineasM.append(nline)

    # Obtener las palabras definidas en la gramatica para autocompletar el codigo del edito
    def palabrasGramatica(self, asignarAPI):
        analizadorLex = Lexico()
        keywords = analizadorLex.consultarPalabras()
        for i in keywords:
            asignarAPI.add(i)

    # Asignar colores a las palabras reservadas para que se diferencien en el codigo
    def asignarColores(self):
        self.lexer.setColor(QColor('#F44336'), QsciLexerPascal.Number)
        self.lexer.setColor(QColor('#34495e'), QsciLexerPascal.Keyword)
        self.lexer.setColor(QColor('#42A5F5'),
                            QsciLexerPascal.SingleQuotedString)
        self.lexer.setColor(QColor('#F06292'), QsciLexerPascal.Operator)
        self.lexer.setColor(QColor('#3498db'), QsciLexerPascal.Character)

    # Retornar la posicion del cursos con una funcion de QsciSCintilla
    def getPosicionCursor(self):
        return self.getCursorPosition()

    # Modificar la poscion del cursor
    def setPosicionCursor(self):
        posicionN = self.getPosicionCursor()
        self.setCursorPosition(posicionN[0], posicionN[1])

    # Retornar las lineas marcadas de la estructura controlLineasM
    def getLineasMarcadas(self):
        return self.controlLineasM
示例#8
0
文件: editor.py 项目: codeadd/codebug
    def __init__(self, parent=None):
        #CONSTRUCTOR DE LA CLASE HEREDADA
        super(editor, self).__init__(parent)

        #DEFINICION DE LA FUENTE Y SUS PROPIEDADES
        font = QFont()
        #font.setFamily('Courier')
        font.setFixedPitch(True)
        font.setPointSize(10)
        self.setFont(font)
        self.setMarginsFont(font)
        self.lineas_marcadas = []

        #PROFIEDADES AVANZADAS DE LA FUENTE DEL EDITOR
        fontmetrics = QFontMetrics(font)
        self.setMarginsFont(font)
        #SE CAMBIA EL MARGEN ANCHO DE LA FUNETE
        self.setMarginWidth(0, fontmetrics.width("00000") - 15)
        #MARGEN DE LOS NUMEROS DE LINEA
        self.setMarginLineNumbers(0, True)
        #COLOR DE FONDO DE LOS NUMEROS DE LINEA
        self.setMarginsBackgroundColor(QColor("#E0E0E0"))

        self.setMarginSensitivity(1, True)

        #CREAMOS LA SEÑA PARA AGREGAR LINEA MARCADA
        self.marginClicked.connect(self.on_margin_clicked)

        #SE DEFINE EL ICONO A MOSTRAR EN LA LINEA MARCADA
        self.markerDefine(QsciScintilla.Circle, self.ARROW_MARKER_NUM)
        self.setMarkerBackgroundColor(QColor("#FF6C3B"), self.ARROW_MARKER_NUM)

        #RESALTADO DE PARENTECIS,CORCHETES Y OTROS
        self.setBraceMatching(QsciScintilla.SloppyBraceMatch)

        #RESALTADO DE LA LINEA DONDE SE ENCUENTRA EL CURSOR
        self.setCaretLineVisible(True)
        self.setCaretLineBackgroundColor(QColor("#32f24c"))

        #AUTOIDENTACION
        self.setAutoIndent(True)
        self.setIndentationGuides(True)
        self.setIndentationsUseTabs(True)
        self.setIndentationWidth(4)

        #DEFINIMOS EL RESALTADO O LEXER
        self.lexer = QsciLexerPascal()
        self.lexer.setDefaultFont(font)  #FUENTE DEL LEXER

        #API PARA EL AUTOCOMPETADO
        api = QsciAPIs(self.lexer)
        self.palabraAutocompletar(api)
        api.prepare()

        self.cambiarColores()
        self.setLexer(self.lexer)
        self.setAutoCompletionThreshold(1)
        self.setAutoCompletionSource(QsciScintilla.AcsAPIs)

        #ESCONDER SCROLLBAR HORIZONTAL
        self.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0)
        #TAMAÑO MINIMO DEL EDITOR
        self.setMinimumSize(600, 360)
示例#9
0
文件: editor.py 项目: codeadd/codebug
class editor(QsciScintilla):
    #CONSTANTE QUE PERMITE MOSTRAR ICONO
    #DE LINEA MARCADA SI ES -1 NO SE MUESTRA EL ICONO
    ARROW_MARKER_NUM = 1

    #CONSTRUCTOR DE LA CLASE
    # -------------------------------------------------------------------------------------------------
    #       constructor de la clase
    # -------------------------------------------------------------------------------------------------
    def __init__(self, parent=None):
        #CONSTRUCTOR DE LA CLASE HEREDADA
        super(editor, self).__init__(parent)

        #DEFINICION DE LA FUENTE Y SUS PROPIEDADES
        font = QFont()
        #font.setFamily('Courier')
        font.setFixedPitch(True)
        font.setPointSize(10)
        self.setFont(font)
        self.setMarginsFont(font)
        self.lineas_marcadas = []

        #PROFIEDADES AVANZADAS DE LA FUENTE DEL EDITOR
        fontmetrics = QFontMetrics(font)
        self.setMarginsFont(font)
        #SE CAMBIA EL MARGEN ANCHO DE LA FUNETE
        self.setMarginWidth(0, fontmetrics.width("00000") - 15)
        #MARGEN DE LOS NUMEROS DE LINEA
        self.setMarginLineNumbers(0, True)
        #COLOR DE FONDO DE LOS NUMEROS DE LINEA
        self.setMarginsBackgroundColor(QColor("#E0E0E0"))

        self.setMarginSensitivity(1, True)

        #CREAMOS LA SEÑA PARA AGREGAR LINEA MARCADA
        self.marginClicked.connect(self.on_margin_clicked)

        #SE DEFINE EL ICONO A MOSTRAR EN LA LINEA MARCADA
        self.markerDefine(QsciScintilla.Circle, self.ARROW_MARKER_NUM)
        self.setMarkerBackgroundColor(QColor("#FF6C3B"), self.ARROW_MARKER_NUM)

        #RESALTADO DE PARENTECIS,CORCHETES Y OTROS
        self.setBraceMatching(QsciScintilla.SloppyBraceMatch)

        #RESALTADO DE LA LINEA DONDE SE ENCUENTRA EL CURSOR
        self.setCaretLineVisible(True)
        self.setCaretLineBackgroundColor(QColor("#32f24c"))

        #AUTOIDENTACION
        self.setAutoIndent(True)
        self.setIndentationGuides(True)
        self.setIndentationsUseTabs(True)
        self.setIndentationWidth(4)

        #DEFINIMOS EL RESALTADO O LEXER
        self.lexer = QsciLexerPascal()
        self.lexer.setDefaultFont(font)  #FUENTE DEL LEXER

        #API PARA EL AUTOCOMPETADO
        api = QsciAPIs(self.lexer)
        self.palabraAutocompletar(api)
        api.prepare()

        self.cambiarColores()
        self.setLexer(self.lexer)
        self.setAutoCompletionThreshold(1)
        self.setAutoCompletionSource(QsciScintilla.AcsAPIs)

        #ESCONDER SCROLLBAR HORIZONTAL
        self.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0)
        #TAMAÑO MINIMO DEL EDITOR
        self.setMinimumSize(600, 360)

    # -------------------------------------------------------------------------------------------------
    #           metodo para marcar las lineas-> asignar breackpoints
    # -------------------------------------------------------------------------------------------------
    def on_margin_clicked(self, nmargin, nline, modifiers):
        #SI LA LINEA YA ESTA MARCADA SE BORRA DE LAS
        #LINEAS MARACADAS, SI NO, SE ADICIONA
        if self.markersAtLine(nline) != 0:
            self.markerDelete(
                nline, self.ARROW_MARKER_NUM
            )  # se agrega el breackpoint al editor para visualizarlo
            if self.lineas_marcadas.__contains__(nline):
                self.lineas_marcadas.remove(
                    nline)  #se agrega el breackpoint al aplicativo
        else:
            #se desmarca el breackpoint
            self.markerAdd(nline, self.ARROW_MARKER_NUM)
            if not self.lineas_marcadas.__contains__(nline):
                self.lineas_marcadas.append(nline)

    # -------------------------------------------------------------------------------------------------
    #       metodo que inicializa la api, con el contenido de los tokens de la clase Lexico
    #       para el autocompletado del editor
    # -------------------------------------------------------------------------------------------------
    def palabraAutocompletar(self, api):
        lex = Lexico()
        palabras = lex.getpalbras()
        for i in palabras:
            api.add(i)

    # -------------------------------------------------------------------------------------------------
    #      metodo que asigna los colores para las palabras y caracteres reservados
    # -------------------------------------------------------------------------------------------------
    def cambiarColores(self):
        self.lexer.setColor(QColor('#F44336'), QsciLexerPascal.Number)
        self.lexer.setColor(QColor('#34495e'), QsciLexerPascal.Keyword)
        self.lexer.setColor(QColor('#42A5F5'),
                            QsciLexerPascal.SingleQuotedString)
        self.lexer.setColor(QColor('#F06292'), QsciLexerPascal.Operator)
        self.lexer.setColor(QColor('#3498db'), QsciLexerPascal.Character)

    # -------------------------------------------------------------------------------------------------
    #       metodo para obtener la posicion del cursor
    # -------------------------------------------------------------------------------------------------
    def getPosicion(self):
        return self.getCursorPosition()

    # -------------------------------------------------------------------------------------------------
    #       metod para cambiar la posicion del cursor
    # -------------------------------------------------------------------------------------------------
    def set_posicion(self):
        pos = self.getPosicion()
        self.setCursorPosition(pos[0], pos[1])

    # -------------------------------------------------------------------------------------------------
    #       metodo para obtener las lineas marcadas del editor
    # -------------------------------------------------------------------------------------------------
    def getMarcadas(self):
        return self.lineas_marcadas