예제 #1
0
    def createCodeGroupBox(self, parent):
        yPos = const.GROUP_BOX_MARGIN_TOP
        width = AlgorithmDescDialog.WINDOW_WIDTH - const.PADDING * 4

        box = WidgetUtil.createGroupBox(parent, title="代码实现",
                                        minSize=QSize(width, AlgorithmDescDialog.DESC_GROUP_BOX_HEIGHT))

        # sizePolicy = WidgetUtil.createSizePolicy()
        splitter = WidgetUtil.createSplitter(box, geometry=QRect(const.PADDING, yPos, width - const.PADDING * 2, 330))

        tabWidget = WidgetUtil.createTabWidget(splitter)
        if self.javaCode:
            tabWidget.addTab(self.createTabWidget(self.javaCode, QsciLexerJava()), "Java")
        if self.javaScriptCode:
            tabWidget.addTab(self.createTabWidget(self.javaScriptCode, QsciLexerJavaScript()), "JavaScript")
        if self.pythonCode:
            tabWidget.addTab(self.createTabWidget(self.pythonCode, QsciLexerPython()), "Python")
        if self.cCode:
            tabWidget.addTab(self.createTabWidget(self.cCode, QsciLexerCPP()), "C")
        if self.cppCode:
            tabWidget.addTab(self.createTabWidget(self.cppCode, QsciLexerCPP()), "C++")
        if self.swiftCode:
            tabWidget.addTab(self.createTabWidget(self.swiftCode, QsciLexerCPP()), "Swift")

        return box
예제 #2
0
 def __init__(self):
   super(GLSLEditor, self).__init__()
   lexer = QsciLexerCPP()
   lexer.setColor(QColor("blue"), 1) 
   self.setMarginLineNumbers(1, True)
   self.setMarginWidth(1, "-----")
   self.setMarginsBackgroundColor(QColor("green"))
   self.setCaretLineVisible(True)
   self.setCaretLineBackgroundColor(QColor("#ffe4e4"))
   self.setLexer(lexer)
   self.show()
예제 #3
0
    def createNewSourceTab(self, source_file):

        editor = QsciScintilla()
        # TABS & READ ONLY
        # ------------------
        editor.setIndentationsUseTabs(False)
        editor.setTabWidth(2)
        editor.setReadOnly(True)

        # CARET
        # -----
        editor.setCaretLineVisible(True)
        editor.setCaretWidth(2)
        editor.setCaretLineBackgroundColor(QColor("#1f0000ff"))

        # MARGIN
        # ------
        editor.setMarginsForegroundColor(QColor("#ff888888"))

        # - LineNumber - margin 0
        editor.setMarginType(0, QsciScintilla.NumberMargin)

        # - LeakMarker - margin 1
        editor.setMarginType(1, QsciScintilla.SymbolMargin)
        editor.setMarginSensitivity(1, True)

        # SIGNALS
        # editor.marginClicked.connect(self.marginLeftClick)

        # INDICATORS
        editor.indicatorDefine(QsciScintilla.HiddenIndicator, 0)
        editor.setIndicatorHoverStyle(QsciScintilla.ThickCompositionIndicator,
                                      0)
        editor.setIndicatorForegroundColor(QColor("#00f"), 0)
        editor.setIndicatorHoverForegroundColor(QColor("#00f"), 0)
        editor.setIndicatorDrawUnder(True, 0)

        # LEXER
        # -----
        lexer = QsciLexerCPP(editor)
        self.lexer_list.append(lexer)
        lexer.setFont(QFont("monospace", default_font_size, QFont.Normal), 0)
        editor.setLexer(lexer)
        self.setSourceCode(editor, source_file)

        # MARGIN AND MARKERS
        # ------
        self.recomputeMarkers(editor)

        tab_index = self.addTab(editor, source_file.name.split("/")[-1])
        return tab_index
예제 #4
0
    def __init__(self, parent=None, caseInsensitiveKeywords=False):
        """
        Constructor
        
        @param parent parent widget of this lexer
        @param caseInsensitiveKeywords flag indicating keywords are case
            insensitive (boolean)
        """
        QsciLexerCPP.__init__(self, parent, caseInsensitiveKeywords)
        Lexer.__init__(self)

        self.commentString = "//"
        self.streamCommentString = {'start': '/* ', 'end': ' */'}
        self.boxCommentString = {'start': '/* ', 'middle': ' * ', 'end': ' */'}
예제 #5
0
    def agregar_tab(self):
        text, okPressed = QInputDialog.getText(self.centralwidget,
                                               "Nuevo archivo", "Nombre:",
                                               QLineEdit.Normal, "")
        if okPressed and text != '':

            tab = QtWidgets.QWidget()
            area = QsciScintilla(tab)
            area.setGeometry(QtCore.QRect(10, 10, 631, 371))
            area.setObjectName("plainTextEdit")
            area.setFont(self.__myFont)
            area.setMarginType(0, QsciScintilla.NumberMargin)
            area.setMarginWidth(0, "00000")
            area.setMarginsForegroundColor(QtGui.QColor("#0C4B72"))
            area.markerDefine(QsciScintilla.RightArrow, 0)
            area.setMarginSensitivity(0, True)
            area.setWrapMode(QsciScintilla.WrapWord)
            area.setWrapVisualFlags(QsciScintilla.WrapFlagByText)
            area.setWrapIndentMode(QsciScintilla.WrapIndentIndented)
            area.setEolMode(QsciScintilla.EolWindows)
            area.setEolVisibility(False)
            area.setWrapVisualFlags(QsciScintilla.WrapFlagByText)
            area.marginClicked.connect(self.on_margin_clicked)
            __lexer = QsciLexerCPP(area)
            area.setLexer(__lexer)
            self.editor.addTab(tab, "")
            area.setObjectName("area")
            self.editor.addTab(tab, text + ".mc")
예제 #6
0
    def set_lexer(self, language):
        r"""
            多语法代码高亮
        :param language:
        :return:
        """
        font = self.font_content['font']
        size = int(self.font_content['size'])
        lexer_font = QFont(font, size)
        if language == 'py':
            self.lxr = QsciLexerPython()
            self.lxr.setFont(lexer_font)
            self.setLexer(self.lxr)
            self.__pythonCompletion()

        elif language == 'c':
            self.lxr = QsciLexerCPP()
            self.lxr.setFont(lexer_font)
            self.setLexer(self.lxr)
            self.__cCompletion()
        elif language == 'md':
            self.lxr = QsciLexerMarkdown()
            self.lxr.setFont(lexer_font)
            self.setLexer(self.lxr)
        else:
            self.setLexer(None)
            self.setText(self.text())
예제 #7
0
    def __init__(self, parent=None):
        super(Editor, self).__init__(parent)
        font = QtGui.QFont()
        font.setFamily('Courier')
        font.setFixedPitch(True)
        font.setPointSize(10)
        self.setFont(font)
        self.setMarginsFont(font)


        # self.setBackgroundColor

        # Margin 0 is used for line numbers
        fontmetrics = QtGui.QFontMetrics(font)
        self.setMarginsFont(font)
        self.setMarginWidth(0, fontmetrics.width("00000") + 6)
        self.setMarginLineNumbers(0, True)
        self.setMarginsBackgroundColor(QtGui.QColor("#cccccc"))

        # Brace matching: enable for a brace immediately before or after
        # the current position
        #
        self.setBraceMatching(QsciScintilla.SloppyBraceMatch)

        # Set the autocompletions to case INsensitive
        self.setAutoCompletionCaseSensitivity(False)
        # Set the autocompletion to not replace the word to the right of the cursor
        self.setAutoCompletionReplaceWord(False)
        # Set the autocompletion source to be the words not only in document but all
        self.setAutoCompletionSource(QsciScintilla.AcsAll)
        # Set the autocompletion dialog to appear as soon as 3 character is typed
        self.setAutoCompletionThreshold(3)


        # Current line visible with special background color
        self.setCaretLineVisible(True)
        self.setCaretLineBackgroundColor(QtGui.QColor("#ffe4e4"))

        # Set Python lexer
        # Set style for Python comments (style number 1) to a fixed-width
        # courier.
        #
        lexer = QsciLexerCPP()
        lexer.setDefaultFont(font)
        self.setLexer(lexer)
        # self.SendScintilla(QsciScintilla.SCI_STYLESETFONT, 1, 'Courier')
        self.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR,0)
예제 #8
0
파일: LexerCPP.py 프로젝트: testmana2/test
 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 QsciLexerCPP.keywords(self, kwSet)
예제 #9
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 QsciLexerCPP.keywords(self, kwSet)
예제 #10
0
    def __init__(self, parent=None):
        super(PMCPPEditor, self).__init__(parent, comment_string='//')
        self._extension_names.append('.c')
        self._init_editor()
        self._init_lexer(QsciLexerCPP(self.textEdit))
        self._init_apis()
        self._init_actions()
        self._init_signals()
        # 编辑器主题
        self.slot_set_theme(self._theme, 'cpp')

        self.last_hint = ''
예제 #11
0
파일: LexerCPP.py 프로젝트: testmana2/test
 def __init__(self, parent=None, caseInsensitiveKeywords=False):
     """
     Constructor
     
     @param parent parent widget of this lexer
     @param caseInsensitiveKeywords flag indicating keywords are case
         insensitive (boolean)
     """
     QsciLexerCPP.__init__(self, parent, caseInsensitiveKeywords)
     Lexer.__init__(self)
     
     self.commentString = "//"
     self.streamCommentString = {
         'start': '/* ',
         'end': ' */'
     }
     self.boxCommentString = {
         'start': '/* ',
         'middle': ' * ',
         'end': ' */'
     }
예제 #12
0
 def abrir_archivo(self):
     try:
         dialog = QtWidgets.QFileDialog().getOpenFileName(
             None, ' Open document', r"C:\Users\\", "All Files (*)")
         ruta = dialog[0]
         trozos = ruta.split("/")
         name = trozos[len(trozos) - 1]
         self.pestañas[name] = ruta
         file = open(ruta, 'r')
         codigo = file.read()
         tab = QtWidgets.QWidget()
         area = QsciScintilla(tab)
         area.setGeometry(QtCore.QRect(10, 10, 631, 371))
         area.setObjectName("plainTextEdit")
         area.setFont(self.__myFont)
         area.setMarginType(0, QsciScintilla.NumberMargin)
         area.setMarginWidth(0, "00000")
         area.setMarginsForegroundColor(QtGui.QColor("#0C4B72"))
         area.markerDefine(QsciScintilla.RightArrow, 0)
         area.setMarginSensitivity(0, True)
         area.setWrapMode(QsciScintilla.WrapWord)
         area.setWrapVisualFlags(QsciScintilla.WrapFlagByText)
         area.setWrapIndentMode(QsciScintilla.WrapIndentIndented)
         area.setEolMode(QsciScintilla.EolWindows)
         area.setEolVisibility(False)
         area.setWrapVisualFlags(QsciScintilla.WrapFlagByText)
         area.marginClicked.connect(self.on_margin_clicked)
         __lexer = QsciLexerCPP(area)
         area.setLexer(__lexer)
         self.editor.addTab(tab, "")
         area.setText(codigo)
         area.setObjectName("area")
         self.editor.addTab(tab, name)
         file.close()
     except:
         em = QtWidgets.QErrorMessage(self.mw)
         em.showMessage("Error al abrir {0}".format(name))
예제 #13
0
    def __init__(self, parent=None):
        super(LogTextWidget, self).__init__(parent)

        # Set the default font
        font = QFont()
        font.setFamily('Consolas')
        font.setFixedPitch(True)
        font.setPointSize(9)
        self.setFont(font)
        self.setMarginsFont(font)

        # Number Line
        fontmetrics = QFontMetrics(font)
        self.setMarginsFont(font)
        self.setMarginWidth(0, fontmetrics.width("00000") + 2)
        self.setMarginLineNumbers(0, True)
        self.setMarginsBackgroundColor(QColor("#cccccc"))

        # Clickable margin 1 for showing markers
        self.setMarginSensitivity(1, True)
        self.marginClicked.connect(self.on_margin_clicked)
        self.markerDefine(QsciScintilla.RightArrow, self.ARROW_MARKER_NUM)
        self.setMarkerBackgroundColor(QColor("#ee1111"), self.ARROW_MARKER_NUM)

        # Brace matching: enable for a brace immediately before or after
        # the current position
        #
        self.setBraceMatching(QsciScintilla.SloppyBraceMatch)

        # Current line visible with special background color
        self.setCaretLineVisible(True)
        self.setCaretLineBackgroundColor(QColor("#ffe4e4"))

        # Set Python lexer
        # Set style for Python comments (style number 1) to a fixed-width
        # courier.
        #

        lexer = QsciLexerCPP()

        lexer.setFoldAtElse(True)
        lexer.setFoldComments(True)
        lexer.setFoldCompact(False)

        lexer.setDefaultFont(font)
        lexer.setPaper(QColor('darkblue'), QsciLexerCPP.Comment)
        self.setLexer(lexer)

        text = bytearray(str.encode("Arial"))
        self.SendScintilla(QsciScintilla.SCI_STYLESETFONT, 1, text)
        self.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0)

        # not too small
        self.setMinimumSize(600, 450)
예제 #14
0
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("Proyecto")
        MainWindow.resize(1074, 588)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.btn_abrir = QtWidgets.QPushButton(self.centralwidget)
        self.btn_abrir.setGeometry(QtCore.QRect(970, 20, 61, 41))
        self.btn_abrir.setObjectName("btn_abrir")
        self.btn_guardar = QtWidgets.QPushButton(self.centralwidget)
        self.btn_guardar.setGeometry(QtCore.QRect(970, 70, 61, 41))
        self.btn_guardar.setObjectName("btn_guardar")
        self.btn_guardar_como = QtWidgets.QPushButton(self.centralwidget)
        self.btn_guardar_como.setGeometry(QtCore.QRect(970, 120, 61, 41))
        self.btn_guardar_como.setObjectName("btn_guardar_como")
        self.btn_ejecutar = QtWidgets.QPushButton(self.centralwidget)
        self.btn_ejecutar.setGeometry(QtCore.QRect(960, 220, 81, 41))
        self.btn_ejecutar.setObjectName("btn_ejecutar")
        self.btn_debug = QtWidgets.QPushButton(self.centralwidget)
        self.btn_debug.setGeometry(QtCore.QRect(970, 320, 61, 41))
        self.btn_debug.setObjectName("btn_debug")
        self.btn_siguiente_paso = QtWidgets.QPushButton(self.centralwidget)
        self.btn_siguiente_paso.setGeometry(QtCore.QRect(970, 370, 61, 41))
        self.btn_siguiente_paso.setObjectName("btn_siguiente_paso")
        self.tabWidget = QtWidgets.QTabWidget(self.centralwidget)
        self.tabWidget.setGeometry(QtCore.QRect(0, 10, 941, 551))
        self.tabWidget.setObjectName("tabWidget")
        self.tab = QtWidgets.QWidget()
        self.tab.setObjectName("tab")
        self.txt_consola = QtWidgets.QTextEdit(self.tab)
        self.txt_consola.setGeometry(QtCore.QRect(10, 410, 511, 101))
        self.txt_consola.setObjectName("txt_consola")
        self.tabWidget_4 = QtWidgets.QTabWidget(self.tab)
        self.tabWidget_4.setGeometry(QtCore.QRect(0, 0, 531, 391))
        self.tabWidget_4.setObjectName("tabWidget_4")
        self.tab_8 = QtWidgets.QWidget()
        self.tab_8.setObjectName("tab_8")
        self.tabWidget_3 = QtWidgets.QTabWidget(self.tab_8)
        self.tabWidget_3.setGeometry(QtCore.QRect(0, 0, 521, 361))
        self.tabWidget_3.setObjectName("tabWidget_3")
        self.tab_10 = QtWidgets.QWidget()
        self.tab_10.setObjectName("tab_10")
        self.frame_txt_entrada = QtWidgets.QFrame(self.tab_10)
        self.frame_txt_entrada.setGeometry(QtCore.QRect(10, 10, 501, 321))
        self.frame_txt_entrada.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frame_txt_entrada.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame_txt_entrada.setObjectName("frame_txt_entrada")
        self.tabWidget_3.addTab(self.tab_10, "")
        self.tab_11 = QtWidgets.QWidget()
        self.tab_11.setObjectName("tab_11")
        self.frame_txt_entrada_sin_optimizar = QtWidgets.QFrame(self.tab_11)
        self.frame_txt_entrada_sin_optimizar.setGeometry(
            QtCore.QRect(10, 10, 501, 321))
        self.frame_txt_entrada_sin_optimizar.setFrameShape(
            QtWidgets.QFrame.StyledPanel)
        self.frame_txt_entrada_sin_optimizar.setFrameShadow(
            QtWidgets.QFrame.Raised)
        self.frame_txt_entrada_sin_optimizar.setObjectName(
            "frame_txt_entrada_sin_optimizar")
        self.tabWidget_3.addTab(self.tab_11, "")
        self.tabWidget_4.addTab(self.tab_8, "")
        self.tabWidget_2 = QtWidgets.QTabWidget(self.tab)
        self.tabWidget_2.setGeometry(QtCore.QRect(540, 20, 391, 491))
        self.tabWidget_2.setObjectName("tabWidget_2")
        self.tab_12 = QtWidgets.QWidget()
        self.tab_12.setObjectName("tab_12")
        self.frame_txt_minor_c = QtWidgets.QFrame(self.tab_12)
        self.frame_txt_minor_c.setGeometry(QtCore.QRect(10, 10, 361, 441))
        self.frame_txt_minor_c.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frame_txt_minor_c.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame_txt_minor_c.setObjectName("frame_txt_minor_c")
        self.tabWidget_2.addTab(self.tab_12, "")
        self.tab_5 = QtWidgets.QWidget()
        self.tab_5.setObjectName("tab_5")
        self.scrollArea_2 = QtWidgets.QScrollArea(self.tab_5)
        self.scrollArea_2.setGeometry(QtCore.QRect(10, 10, 361, 441))
        self.scrollArea_2.setWidgetResizable(True)
        self.scrollArea_2.setObjectName("scrollArea_2")
        self.scrollAreaWidgetContents_2 = QtWidgets.QWidget()
        self.scrollAreaWidgetContents_2.setGeometry(
            QtCore.QRect(0, 0, 518, 422))
        self.scrollAreaWidgetContents_2.setObjectName(
            "scrollAreaWidgetContents_2")
        self.horizontalLayout = QtWidgets.QHBoxLayout(
            self.scrollAreaWidgetContents_2)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.treeView = QtWidgets.QTreeView(self.scrollAreaWidgetContents_2)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum,
                                           QtWidgets.QSizePolicy.Minimum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.treeView.sizePolicy().hasHeightForWidth())
        self.treeView.setSizePolicy(sizePolicy)
        self.treeView.setMinimumSize(QtCore.QSize(500, 0))
        self.treeView.setLayoutDirection(QtCore.Qt.LeftToRight)
        self.treeView.setAnimated(True)
        self.treeView.setObjectName("treeView")
        self.horizontalLayout.addWidget(self.treeView)
        self.scrollArea_2.setWidget(self.scrollAreaWidgetContents_2)
        self.tabWidget_2.addTab(self.tab_5, "")
        self.tabWidget.addTab(self.tab, "")
        self.tab_2 = QtWidgets.QWidget()
        self.tab_2.setObjectName("tab_2")
        self.scrollArea_3 = QtWidgets.QScrollArea(self.tab_2)
        self.scrollArea_3.setGeometry(QtCore.QRect(10, 10, 681, 411))
        self.scrollArea_3.setLayoutDirection(QtCore.Qt.LeftToRight)
        self.scrollArea_3.setWidgetResizable(True)
        self.scrollArea_3.setObjectName("scrollArea_3")
        self.scrollAreaWidgetContents_3 = QtWidgets.QWidget()
        self.scrollAreaWidgetContents_3.setGeometry(
            QtCore.QRect(0, 0, 679, 409))
        self.scrollAreaWidgetContents_3.setObjectName(
            "scrollAreaWidgetContents_3")
        self.verticalLayout_2 = QtWidgets.QVBoxLayout(
            self.scrollAreaWidgetContents_3)
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.lbl_graphviz = QtWidgets.QLabel(self.scrollAreaWidgetContents_3)
        self.lbl_graphviz.setMaximumSize(QtCore.QSize(16777215, 16777215))
        self.lbl_graphviz.setFrameShape(QtWidgets.QFrame.Panel)
        self.lbl_graphviz.setText("")
        self.lbl_graphviz.setScaledContents(False)
        self.lbl_graphviz.setObjectName("lbl_graphviz")
        self.verticalLayout_2.addWidget(self.lbl_graphviz)
        self.scrollArea_3.setWidget(self.scrollAreaWidgetContents_3)
        self.tabWidget.addTab(self.tab_2, "")
        self.tab_3 = QtWidgets.QWidget()
        self.tab_3.setObjectName("tab_3")
        self.scrollArea = QtWidgets.QScrollArea(self.tab_3)
        self.scrollArea.setGeometry(QtCore.QRect(10, 10, 681, 411))
        self.scrollArea.setWidgetResizable(True)
        self.scrollArea.setObjectName("scrollArea")
        self.scrollAreaWidgetContents = QtWidgets.QWidget()
        self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 679, 409))
        self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
        self.tab_reporte = QtWidgets.QTabWidget(self.scrollAreaWidgetContents)
        self.tab_reporte.setGeometry(QtCore.QRect(20, 10, 661, 381))
        self.tab_reporte.setObjectName("tab_reporte")
        self.tab_4 = QtWidgets.QWidget()
        self.tab_4.setObjectName("tab_4")
        self.scrollArea_4 = QtWidgets.QScrollArea(self.tab_4)
        self.scrollArea_4.setGeometry(QtCore.QRect(0, 10, 641, 341))
        self.scrollArea_4.setWidgetResizable(True)
        self.scrollArea_4.setObjectName("scrollArea_4")
        self.scrollAreaWidgetContents_4 = QtWidgets.QWidget()
        self.scrollAreaWidgetContents_4.setGeometry(
            QtCore.QRect(0, 0, 639, 339))
        self.scrollAreaWidgetContents_4.setObjectName(
            "scrollAreaWidgetContents_4")
        self.verticalLayout = QtWidgets.QVBoxLayout(
            self.scrollAreaWidgetContents_4)
        self.verticalLayout.setObjectName("verticalLayout")
        self.tabla_etiqueta = QtWidgets.QTableWidget(
            self.scrollAreaWidgetContents_4)
        self.tabla_etiqueta.setObjectName("tabla_etiqueta")
        self.tabla_etiqueta.setColumnCount(0)
        self.tabla_etiqueta.setRowCount(0)
        self.verticalLayout.addWidget(self.tabla_etiqueta)
        self.scrollArea_4.setWidget(self.scrollAreaWidgetContents_4)
        self.tab_reporte.addTab(self.tab_4, "")
        self.tab_6 = QtWidgets.QWidget()
        self.tab_6.setObjectName("tab_6")
        self.scrollArea_5 = QtWidgets.QScrollArea(self.tab_6)
        self.scrollArea_5.setGeometry(QtCore.QRect(0, 10, 641, 341))
        self.scrollArea_5.setWidgetResizable(True)
        self.scrollArea_5.setObjectName("scrollArea_5")
        self.scrollAreaWidgetContents_5 = QtWidgets.QWidget()
        self.scrollAreaWidgetContents_5.setGeometry(
            QtCore.QRect(0, 0, 639, 339))
        self.scrollAreaWidgetContents_5.setObjectName(
            "scrollAreaWidgetContents_5")
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout(
            self.scrollAreaWidgetContents_5)
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.tabla_error = QtWidgets.QTableWidget(
            self.scrollAreaWidgetContents_5)
        self.tabla_error.setObjectName("tabla_error")
        self.tabla_error.setColumnCount(0)
        self.tabla_error.setRowCount(0)
        self.horizontalLayout_2.addWidget(self.tabla_error)
        self.scrollArea_5.setWidget(self.scrollAreaWidgetContents_5)
        self.tab_reporte.addTab(self.tab_6, "")
        self.tab_9 = QtWidgets.QWidget()
        self.tab_9.setObjectName("tab_9")
        self.textEdit = QtWidgets.QTextEdit(self.tab_9)
        self.textEdit.setGeometry(QtCore.QRect(10, 20, 631, 321))
        self.textEdit.setObjectName("textEdit")
        self.tab_reporte.addTab(self.tab_9, "")
        self.scrollArea.setWidget(self.scrollAreaWidgetContents)
        self.tabWidget.addTab(self.tab_3, "")
        self.tab_13 = QtWidgets.QWidget()
        self.tab_13.setObjectName("tab_13")
        self.tabWidget.addTab(self.tab_13, "")
        self.tab_7 = QtWidgets.QWidget()
        self.tab_7.setObjectName("tab_7")
        self.tabWidget.addTab(self.tab_7, "")
        self.btn_ejecutar_desc = QtWidgets.QPushButton(self.centralwidget)
        self.btn_ejecutar_desc.setGeometry(QtCore.QRect(960, 270, 81, 41))
        self.btn_ejecutar_desc.setObjectName("btn_ejecutar_desc")
        self.btn_ejecutar_minor_c = QtWidgets.QPushButton(self.centralwidget)
        self.btn_ejecutar_minor_c.setGeometry(QtCore.QRect(950, 170, 101, 41))
        self.btn_ejecutar_minor_c.setObjectName("btn_ejecutar_minor_c")
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 1074, 21))
        self.menubar.setObjectName("menubar")
        self.menuArchivo = QtWidgets.QMenu(self.menubar)
        self.menuArchivo.setObjectName("menuArchivo")
        self.menuEditar = QtWidgets.QMenu(self.menubar)
        self.menuEditar.setObjectName("menuEditar")
        self.menuAnalisis = QtWidgets.QMenu(self.menubar)
        self.menuAnalisis.setObjectName("menuAnalisis")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)
        self.actionGuardar = QtWidgets.QAction(MainWindow)
        self.actionGuardar.setObjectName("actionGuardar")
        self.actionGuardar_Como = QtWidgets.QAction(MainWindow)
        self.actionGuardar_Como.setObjectName("actionGuardar_Como")
        self.actionGuardar_Como_2 = QtWidgets.QAction(MainWindow)
        self.actionGuardar_Como_2.setObjectName("actionGuardar_Como_2")
        self.actionAscendente = QtWidgets.QAction(MainWindow)
        self.actionAscendente.setObjectName("actionAscendente")
        self.actionDescendente = QtWidgets.QAction(MainWindow)
        self.actionDescendente.setObjectName("actionDescendente")
        self.actionReiniciar_Debug = QtWidgets.QAction(MainWindow)
        self.actionReiniciar_Debug.setObjectName("actionReiniciar_Debug")
        self.actionSiguiente_Paso_Debug = QtWidgets.QAction(MainWindow)
        self.actionSiguiente_Paso_Debug.setObjectName(
            "actionSiguiente_Paso_Debug")
        self.actionCopiar = QtWidgets.QAction(MainWindow)
        self.actionCopiar.setObjectName("actionCopiar")
        self.actionPegar = QtWidgets.QAction(MainWindow)
        self.actionPegar.setObjectName("actionPegar")
        self.actionBuscar = QtWidgets.QAction(MainWindow)
        self.actionBuscar.setObjectName("actionBuscar")
        self.actionReemplazar = QtWidgets.QAction(MainWindow)
        self.actionReemplazar.setObjectName("actionReemplazar")
        self.menuArchivo.addAction(self.actionGuardar)
        self.menuArchivo.addAction(self.actionGuardar_Como)
        self.menuArchivo.addAction(self.actionGuardar_Como_2)
        self.menuEditar.addAction(self.actionCopiar)
        self.menuEditar.addAction(self.actionPegar)
        self.menuEditar.addAction(self.actionBuscar)
        self.menuEditar.addAction(self.actionReemplazar)
        self.menuAnalisis.addAction(self.actionAscendente)
        self.menuAnalisis.addAction(self.actionDescendente)
        self.menuAnalisis.addAction(self.actionReiniciar_Debug)
        self.menuAnalisis.addAction(self.actionSiguiente_Paso_Debug)
        self.menubar.addAction(self.menuArchivo.menuAction())
        self.menubar.addAction(self.menuEditar.menuAction())
        self.menubar.addAction(self.menuAnalisis.menuAction())

        self.retranslateUi(MainWindow)
        self.tabWidget.setCurrentIndex(0)
        self.tabWidget_4.setCurrentIndex(0)
        self.tabWidget_3.setCurrentIndex(0)
        self.tabWidget_2.setCurrentIndex(0)
        self.tab_reporte.setCurrentIndex(0)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
        self.__myFont = QFont()
        self.__myFont.setPointSize(12)
        #=========================================================EDITORES===================================
        self.txt_minor_c = QsciScintilla()
        self.txt_minor_c.setText("")
        self.txt_minor_c.setUtf8(True)
        self.txt_minor_c.setFont(self.__myFont)

        # AJUSTES DE TEXTO
        self.txt_minor_c.setWrapMode(QsciScintilla.WrapWord)
        self.txt_minor_c.setWrapVisualFlags(QsciScintilla.WrapFlagByText)
        self.txt_minor_c.setWrapIndentMode(QsciScintilla.WrapIndentIndented)

        # FIN DE LINEA
        self.txt_minor_c.setEolMode(QsciScintilla.EolWindows)
        self.txt_minor_c.setEolVisibility(False)

        # SANGRIA
        self.txt_minor_c.setIndentationsUseTabs(False)
        self.txt_minor_c.setTabWidth(4)
        self.txt_minor_c.setIndentationGuides(True)
        self.txt_minor_c.setTabIndents(True)
        self.txt_minor_c.setAutoIndent(True)

        self.txt_minor_c.setCaretForegroundColor(QColor("#ff0000ff"))
        self.txt_minor_c.setCaretLineVisible(True)
        self.txt_minor_c.setCaretLineBackgroundColor(QColor("#1f0000ff"))
        self.txt_minor_c.setCaretWidth(2)

        # MARGENES
        self.txt_minor_c.setMarginType(0, QsciScintilla.NumberMargin)
        self.txt_minor_c.setMarginWidth(
            0, "0000")  # con este se puede quitar la linea
        self.txt_minor_c.setMarginsForegroundColor(QColor("#ff888888"))

        # SE COLOCAN LAS REGLAS DEL EDITOR
        self.__lexer = QsciLexerCPP(self.txt_minor_c)
        self.txt_minor_c.setLexer(self.__lexer)

        self.__lyt = QVBoxLayout()
        self.frame_txt_minor_c.setLayout(self.__lyt)
        self.__lyt.addWidget(self.txt_minor_c)
        #====================================ENTRADA===========================
        self.txt_entrada = QsciScintilla()
        self.txt_entrada.setText("")
        self.txt_entrada.setUtf8(True)
        self.txt_entrada.setFont(self.__myFont)

        # AJUSTES DE TEXTO
        self.txt_entrada.setWrapMode(QsciScintilla.WrapWord)
        self.txt_entrada.setWrapVisualFlags(QsciScintilla.WrapFlagByText)
        self.txt_entrada.setWrapIndentMode(QsciScintilla.WrapIndentIndented)

        # FIN DE LINEA
        self.txt_entrada.setEolMode(QsciScintilla.EolWindows)
        self.txt_entrada.setEolVisibility(False)

        # SANGRIA
        self.txt_entrada.setIndentationsUseTabs(False)
        self.txt_entrada.setTabWidth(4)
        self.txt_entrada.setIndentationGuides(True)
        self.txt_entrada.setTabIndents(True)
        self.txt_entrada.setAutoIndent(True)

        self.txt_entrada.setCaretForegroundColor(QColor("#ff0000ff"))
        self.txt_entrada.setCaretLineVisible(True)
        self.txt_entrada.setCaretLineBackgroundColor(QColor("#1f0000ff"))
        self.txt_entrada.setCaretWidth(2)

        # MARGENES
        self.txt_entrada.setMarginType(0, QsciScintilla.NumberMargin)
        self.txt_entrada.setMarginWidth(
            0, "0000")  # con este se puede quitar la linea
        self.txt_entrada.setMarginsForegroundColor(QColor("#ff888888"))

        # SE COLOCAN LAS REGLAS DEL EDITOR
        self.__lexer = QsciLexerRuby(self.txt_entrada)
        self.txt_entrada.setLexer(self.__lexer)

        self.__lyt = QVBoxLayout()
        self.frame_txt_entrada.setLayout(self.__lyt)
        self.__lyt.addWidget(self.txt_entrada)
        #========================Entrada Sin Optimizar======================
        self.txt_entrada_sin_optimizar = QsciScintilla()
        self.txt_entrada_sin_optimizar.setText("")
        self.txt_entrada_sin_optimizar.setUtf8(True)
        self.txt_entrada_sin_optimizar.setFont(self.__myFont)

        # AJUSTES DE TEXTO
        self.txt_entrada_sin_optimizar.setWrapMode(QsciScintilla.WrapWord)
        self.txt_entrada_sin_optimizar.setWrapVisualFlags(
            QsciScintilla.WrapFlagByText)
        self.txt_entrada_sin_optimizar.setWrapIndentMode(
            QsciScintilla.WrapIndentIndented)

        # FIN DE LINEA
        self.txt_entrada_sin_optimizar.setEolMode(QsciScintilla.EolWindows)
        self.txt_entrada_sin_optimizar.setEolVisibility(False)

        # SANGRIA
        self.txt_entrada_sin_optimizar.setIndentationsUseTabs(False)
        self.txt_entrada_sin_optimizar.setTabWidth(4)
        self.txt_entrada_sin_optimizar.setIndentationGuides(True)
        self.txt_entrada_sin_optimizar.setTabIndents(True)
        self.txt_entrada_sin_optimizar.setAutoIndent(True)

        self.txt_entrada_sin_optimizar.setCaretForegroundColor(
            QColor("#ff0000ff"))
        self.txt_entrada_sin_optimizar.setCaretLineVisible(True)
        self.txt_entrada_sin_optimizar.setCaretLineBackgroundColor(
            QColor("#1f0000ff"))
        self.txt_entrada_sin_optimizar.setCaretWidth(2)

        # MARGENES
        self.txt_entrada_sin_optimizar.setMarginType(
            0, QsciScintilla.NumberMargin)
        self.txt_entrada_sin_optimizar.setMarginWidth(
            0, "0000")  # con este se puede quitar la linea
        self.txt_entrada_sin_optimizar.setMarginsForegroundColor(
            QColor("#ff888888"))

        # SE COLOCAN LAS REGLAS DEL EDITOR
        self.__lexer = QsciLexerRuby(self.txt_entrada_sin_optimizar)
        self.txt_entrada_sin_optimizar.setLexer(self.__lexer)

        self.__lyt = QVBoxLayout()
        self.frame_txt_entrada_sin_optimizar.setLayout(self.__lyt)
        self.__lyt.addWidget(self.txt_entrada_sin_optimizar)

        #======================================================================

        #Para Abrir,Guardar,Como
        self.btn_abrir.clicked.connect(self.abrir_archivo)
        self.actionGuardar.triggered.connect(self.abrir_archivo)
        self.btn_guardar_como.clicked.connect(self.guardar_archivo_como)
        self.actionGuardar_Como_2.triggered.connect(self.guardar_archivo_como)
        self.actionGuardar_Como.triggered.connect(self.guardar_archivo)
        self.btn_guardar.clicked.connect(self.guardar_archivo)
        #Ejecucion
        self.btn_ejecutar.clicked.connect(self.parser)
        self.actionAscendente.triggered.connect(self.parser)
        self.btn_ejecutar_desc.clicked.connect(self.parser_descendente)
        self.actionDescendente.triggered.connect(self.parser_descendente)
        self.btn_debug.clicked.connect(self.parser_paso_iniciar)
        self.actionReiniciar_Debug.triggered.connect(self.parser_paso_iniciar)
        self.btn_siguiente_paso.clicked.connect(self.parser_paso_ejecutar)
        self.actionSiguiente_Paso_Debug.triggered.connect(
            self.parser_paso_ejecutar)

        self.btn_ejecutar_minor_c.clicked.connect(self.ejecutar_main_c)
예제 #15
0
#        print(env_lib)
#        strfilepath= reg_lib.search(env_lib).group()

    if (os.path.isfile(strfilepath + '\\Kernel32.Lib') == False):
        print(strfilepath + '\\Kernel32.Lib')
        cpath = os.getcwd() + '\\Kernel32.Lib'
        if (os.path.isfile(cpath)):
            tpath = strfilepath + '\\Kernel32.Lib'
            shutil.copyfile(cpath, tpath)
        else:
            win32api.MessageBox(
                0,
                "\'Kernel32.Lib\' file is not in the currect folder,please copy it to folder \'VC\\lib\'!",
                "Warring Message", win32con.MB_OK)
            sys.exit()

    if (rs_ide != '' and rs_bin != '' and rs_include != '' and rs_lib != ''):
        app = QtWidgets.QApplication(sys.argv)
        Dialog = QtWidgets.QDialog()
        ui = Ui_Dialog()
        ui.setupUi(Dialog)
        ui.QPlainTextEdit_1.setLexer(QsciLexerCPP())
        #        hightlight=highlinghter.PythonHighlighter(ui.QPlainTextEdit_1.document())
        Dialog.show()
        sys.exit(app.exec_())
    else:
        win32api.MessageBox(
            0, "We have set environment for you,please restart the cpps.exe",
            "Warring Message", win32con.MB_OK)
        sys.exit()
예제 #16
0
 def cppClicked(self):
     fixedWidthFont = QFontDatabase.systemFont(QFontDatabase.FixedFont)
     lexer = QsciLexerCPP()
     lexer.setDefaultFont(fixedWidthFont)
     self.codeEdit.setLexer(lexer)
     self.language = 'cpp'
예제 #17
0
    def __init__(self, parent=None, fileName=None, readOnlyFiles=[]):
        '''
        Constructor
        '''
        super(CppEditor, self).__init__(parent)
        self.parent = parent
        self.roFiles = readOnlyFiles

        self.setAcceptDrops(False) # drag&drop is on its parent

        # Set the default font
        font = QtGui.QFont()
        font.setFamily('Courier')
        font.setFixedPitch(True)
        font.setPointSize(10)
        self.setFont(font)
        self.setMarginsFont(font)

        # C/C++ lexer
        self.lexer = QsciLexerCPP(self,  True)
        self.lexer.setDefaultFont(font)
        self.libraryAPIs = QsciAPIs(QsciLexerCPP(self,True))
        self.setLexer(self.lexer)
        #self.SendScintilla(QsciScintilla.SCI_STYLESETFONT, 1, 'Courier')

        # Auto-indent
        self.setTabWidth(4)
        #self.setIndentationsUseTabs(False)
        self.setAutoIndent(True)

        # Current line visible with special background color
        self.setCaretLineVisible(True)
        self.setCaretLineBackgroundColor(QtGui.QColor("#ffe4e4"))

        # Enable brace matching
        self.setBraceMatching(QsciScintilla.SloppyBraceMatch)

        # Enable folding visual- use boxes
        self.setFolding(QsciScintilla.BoxedTreeFoldStyle)

        # show line numbers
        fontmetrics = QtGui.QFontMetrics(font)
        self.setMarginsFont(font)
        self.setMarginWidth(0, fontmetrics.width("00000") + 4)
        self.setMarginLineNumbers(0, True)
        self.setMarginsBackgroundColor(QtGui.QColor("#ccccee"))

        # not too small
        self.setMinimumSize(400, 200)

        # set the length of the string before the editor tries to auto-complete
        self.setAutoCompletionThreshold(3)
        # tell the editor we are using a QsciAPI for the auto-completion
        self.setAutoCompletionSource(QsciScintilla.AcsAPIs)
        # removed remaining right side characters from the current cursor
        self.setAutoCompletionReplaceWord(True)

        # "CTRL+Space" autocomplete
        self.shortcut_ctrl_space = QtWidgets.QShortcut(QtGui.QKeySequence("Ctrl+Space"), self)
        self.shortcut_ctrl_space.activated.connect(self.autoCompleteFromAll)

        if fileName:
            self.curFile = fileName
            self.loadFile(fileName)
            self.isUntitled = False
        else:
            self.curFile = PROJECT_NONAME + USER_CODE_EXT
            self.setText( __default_content__ )
            self.isUntitled = True

        self.updateApiKeywords()
        self.isModified = False
        self.textChanged.connect(self.onTextChanged )
예제 #18
0
 def c_highlighter(self):
     lexer = QsciLexerCPP()
     self.setDefaultSettings(lexer)
예제 #19
0
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(1349, 806)
        self.mw = MainWindow
        self.puntos_break = []
        self.rutaTemp = ""
        self.pestañas = {}
        self.nombre = ""
        self.gc = False

        palette = QtGui.QPalette()
        brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255, 128))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.PlaceholderText,
                         brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255, 128))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive,
                         QtGui.QPalette.PlaceholderText, brush)
        brush = QtGui.QBrush(QtGui.QColor(120, 120, 120))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 0, 0, 128))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled,
                         QtGui.QPalette.PlaceholderText, brush)
        MainWindow.setPalette(palette)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.new_file = QtWidgets.QPushButton(self.centralwidget)
        self.new_file.setGeometry(QtCore.QRect(0, 0, 71, 61))
        self.new_file.setObjectName("new_file")
        self.new_file.clicked.connect(self.agregar_tab)
        self.save_file = QtWidgets.QPushButton(self.centralwidget)
        self.save_file.setGeometry(QtCore.QRect(70, 0, 71, 61))
        self.save_file.setObjectName("save_file")
        self.save_file.clicked.connect(self.guardar)
        self.save_file_as = QtWidgets.QPushButton(self.centralwidget)
        self.save_file_as.setGeometry(QtCore.QRect(140, 0, 71, 61))
        self.save_file_as.setObjectName("save_file_as")
        self.save_file_as.clicked.connect(self.guardar_como)
        #boton ejecutar
        self.ejecutar = QtWidgets.QPushButton(self.centralwidget)
        self.ejecutar.setGeometry(QtCore.QRect(240, 0, 71, 61))
        self.ejecutar.setObjectName("ejecutar")
        self.ejecutar.clicked.connect(self.Traducir_Alto_nivel)
        #end ejecutar
        #inico depurar
        self.depurar = QtWidgets.QPushButton(self.centralwidget)
        self.depurar.setGeometry(QtCore.QRect(310, 0, 71, 61))
        self.depurar.setObjectName("depurar")
        self.depurar.clicked.connect(self.Depurar_Alto_nivel)
        #end depurar
        self.parar = QtWidgets.QPushButton(self.centralwidget)
        self.parar.setGeometry(QtCore.QRect(380, 0, 71, 61))
        self.parar.setObjectName("parar")
        self.parar.clicked.connect(self.detenerEjecucion)
        #end parar
        self.step_step = QtWidgets.QPushButton(self.centralwidget)
        self.step_step.setGeometry(QtCore.QRect(450, 0, 71, 61))
        self.step_step.setObjectName("step_step")
        self.step_step.clicked.connect(self.setStep)
        #end step
        self.continuar = QtWidgets.QPushButton(self.centralwidget)
        self.continuar.setGeometry(QtCore.QRect(520, 0, 71, 61))
        self.continuar.setObjectName("continuar")
        self.continuar.clicked.connect(self.setContinuar)
        #end continuar
        self.tema = QtWidgets.QPushButton(self.centralwidget)
        self.tema.setGeometry(QtCore.QRect(640, 0, 71, 61))
        self.tema.setObjectName("tema")
        self.tema.clicked.connect(self.setLines)
        self.lineas = QtWidgets.QPushButton(self.centralwidget)
        self.lineas.setGeometry(QtCore.QRect(710, 0, 71, 61))
        self.lineas.setObjectName("lineas")
        self.lineas.clicked.connect(self.ms_help)
        self.editor = QtWidgets.QTabWidget(self.centralwidget)
        self.editor.setGeometry(QtCore.QRect(10, 80, 661, 421))
        self.editor.setObjectName("editor")
        self.editor.setTabsClosable(True)
        self.editor.tabCloseRequested.connect(self.closeTab)
        self.tab = QtWidgets.QWidget()
        self.tab.setObjectName("tab")
        self.__myFont = QtGui.QFont()
        self.__myFont.setPointSize(11)
        #Principio
        self.plainTextEdit = QsciScintilla(self.tab)
        self.plainTextEdit.setGeometry(QtCore.QRect(10, 10, 631, 371))
        self.plainTextEdit.setObjectName("plainTextEdit")
        self.plainTextEdit.setFont(self.__myFont)
        self.plainTextEdit.setMarginType(0, QsciScintilla.NumberMargin)
        self.plainTextEdit.setMarginWidth(0, "00000")
        self.plainTextEdit.setMarginsForegroundColor(QtGui.QColor("#0C4B72"))
        self.plainTextEdit.markerDefine(QsciScintilla.RightArrow, 0)
        self.plainTextEdit.setMarginSensitivity(0, True)
        self.plainTextEdit.setWrapMode(QsciScintilla.WrapWord)
        self.plainTextEdit.setWrapVisualFlags(QsciScintilla.WrapFlagByText)
        self.plainTextEdit.setWrapIndentMode(QsciScintilla.WrapIndentIndented)
        self.plainTextEdit.setEolMode(QsciScintilla.EolWindows)
        self.plainTextEdit.setEolVisibility(False)
        self.plainTextEdit.setWrapVisualFlags(QsciScintilla.WrapFlagByText)
        self.plainTextEdit.marginClicked.connect(self.on_margin_clicked)
        self.__lexer = QsciLexerCPP(self.plainTextEdit)
        self.plainTextEdit.setLexer(self.__lexer)
        self.editor.addTab(self.tab, "")
        #end of de evangelion

        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setGeometry(QtCore.QRect(690, 80, 171, 16))
        palette = QtGui.QPalette()
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText,
                         brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText,
                         brush)
        brush = QtGui.QBrush(QtGui.QColor(120, 120, 120))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText,
                         brush)
        self.label.setPalette(palette)
        self.label.setObjectName("label")
        self.codigo_3d = QtWidgets.QListWidget(self.centralwidget)
        self.codigo_3d.setGeometry(QtCore.QRect(680, 100, 211, 401))
        palette = QtGui.QPalette()
        brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 0, 0, 128))
        brush.setStyle(QtCore.Qt.NoBrush)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.PlaceholderText,
                         brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 0, 0, 128))
        brush.setStyle(QtCore.Qt.NoBrush)
        palette.setBrush(QtGui.QPalette.Inactive,
                         QtGui.QPalette.PlaceholderText, brush)
        brush = QtGui.QBrush(QtGui.QColor(120, 120, 120))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 0, 0, 128))
        brush.setStyle(QtCore.Qt.NoBrush)
        palette.setBrush(QtGui.QPalette.Disabled,
                         QtGui.QPalette.PlaceholderText, brush)
        self.codigo_3d.setPalette(palette)
        self.codigo_3d.setObjectName("codigo_3d")
        self.consola = PlainTextEdit(self.centralwidget)
        self.consola.setGeometry(QtCore.QRect(10, 530, 661, 221))
        palette = QtGui.QPalette()
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush)
        brush = QtGui.QBrush(QtGui.QColor(29, 29, 29))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush)
        brush = QtGui.QBrush(QtGui.QColor(29, 29, 29))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush)
        brush = QtGui.QBrush(QtGui.QColor(120, 120, 120))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush)
        ###########################
        self.consola.setPalette(palette)
        self.consola.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
        self.consola.setObjectName("consola")
        ###########################
        self.label_2 = QtWidgets.QLabel(self.centralwidget)
        self.label_2.setGeometry(QtCore.QRect(890, 80, 171, 16))
        palette = QtGui.QPalette()
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText,
                         brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText,
                         brush)
        brush = QtGui.QBrush(QtGui.QColor(120, 120, 120))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText,
                         brush)
        self.label_2.setPalette(palette)
        self.label_2.setObjectName("label_2")
        self.tabla_cuadruplos = QtWidgets.QTableWidget(self.centralwidget)
        self.tabla_cuadruplos.setGeometry(QtCore.QRect(680, 530, 431, 221))
        self.tabla_cuadruplos.setObjectName("tabla_cuadruplos")
        self.tabla_cuadruplos.setColumnCount(4)
        self.tabla_cuadruplos.setRowCount(0)
        item = QtWidgets.QTableWidgetItem()
        self.tabla_cuadruplos.setHorizontalHeaderItem(0, item)
        item = QtWidgets.QTableWidgetItem()
        self.tabla_cuadruplos.setHorizontalHeaderItem(1, item)
        item = QtWidgets.QTableWidgetItem()
        self.tabla_cuadruplos.setHorizontalHeaderItem(2, item)
        item = QtWidgets.QTableWidgetItem()
        self.tabla_cuadruplos.setHorizontalHeaderItem(3, item)
        self.label_3 = QtWidgets.QLabel(self.centralwidget)
        self.label_3.setGeometry(QtCore.QRect(690, 510, 71, 16))
        palette = QtGui.QPalette()
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText,
                         brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText,
                         brush)
        brush = QtGui.QBrush(QtGui.QColor(120, 120, 120))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText,
                         brush)
        self.label_3.setPalette(palette)
        self.label_3.setObjectName("label_3")
        self.tabla_simbolos = QtWidgets.QTableWidget(self.centralwidget)
        self.tabla_simbolos.setGeometry(QtCore.QRect(1120, 100, 211, 651))
        self.tabla_simbolos.setObjectName("tabla_simbolos")
        self.tabla_simbolos.setColumnCount(2)
        self.tabla_simbolos.setRowCount(0)
        item = QtWidgets.QTableWidgetItem()
        self.tabla_simbolos.setHorizontalHeaderItem(0, item)
        item = QtWidgets.QTableWidgetItem()
        self.tabla_simbolos.setHorizontalHeaderItem(1, item)
        self.label_4 = QtWidgets.QLabel(self.centralwidget)
        self.label_4.setGeometry(QtCore.QRect(10, 510, 47, 13))
        palette = QtGui.QPalette()
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText,
                         brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText,
                         brush)
        brush = QtGui.QBrush(QtGui.QColor(120, 120, 120))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText,
                         brush)
        self.label_4.setPalette(palette)
        self.label_4.setObjectName("label_4")
        self.codigo_3d_optimizado = QtWidgets.QListWidget(self.centralwidget)
        self.codigo_3d_optimizado.setGeometry(QtCore.QRect(900, 100, 211, 401))
        palette = QtGui.QPalette()
        brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 0, 0, 128))
        brush.setStyle(QtCore.Qt.NoBrush)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.PlaceholderText,
                         brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 0, 0, 128))
        brush.setStyle(QtCore.Qt.NoBrush)
        palette.setBrush(QtGui.QPalette.Inactive,
                         QtGui.QPalette.PlaceholderText, brush)
        brush = QtGui.QBrush(QtGui.QColor(120, 120, 120))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 0, 0, 128))
        brush.setStyle(QtCore.Qt.NoBrush)
        palette.setBrush(QtGui.QPalette.Disabled,
                         QtGui.QPalette.PlaceholderText, brush)
        self.codigo_3d_optimizado.setPalette(palette)
        self.codigo_3d_optimizado.setObjectName("codigo_3d_optimizado")
        MainWindow.setCentralWidget(self.centralwidget)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 1349, 21))
        self.menubar.setObjectName("menubar")
        self.menuFile = QtWidgets.QMenu(self.menubar)
        self.menuFile.setObjectName("menuFile")
        self.menuReporte = QtWidgets.QMenu(self.menubar)
        self.menuReporte.setObjectName("menuReporte")
        self.menuRun = QtWidgets.QMenu(self.menubar)
        self.menuRun.setObjectName("menuRun")
        self.menuayuda = QtWidgets.QMenu(self.menubar)
        self.menuayuda.setObjectName("menuayuda")
        self.menuAUGUS = QtWidgets.QMenu(self.menubar)
        self.menuAUGUS.setObjectName("menuAUGUS")
        MainWindow.setMenuBar(self.menubar)
        self.actionEjecutar = QtWidgets.QAction(MainWindow)
        self.actionEjecutar.setObjectName("actionEjecutar")
        self.actionEjecutar.triggered.connect(self.ejecutar_optimizado)
        self.actionDebug = QtWidgets.QAction(MainWindow)
        self.actionDebug.setObjectName("actionDebug")
        self.actionArbol_Ascendente = QtWidgets.QAction(MainWindow)
        self.actionArbol_Ascendente.setObjectName("actionArbol_Ascendente")
        ############
        self.actionArbol_Ascendente.triggered.connect(self.show_ast)
        ############
        self.actionDGA = QtWidgets.QAction(MainWindow)
        self.actionDGA.setObjectName("actionDGA")
        ############
        self.actionDGA.triggered.connect(self.show_dga)
        ############
        self.actionAbrir = QtWidgets.QAction(MainWindow)
        self.actionAbrir.setObjectName("actionAbrir")
        self.actionAbrir.triggered.connect(self.abrir_archivo)
        self.actionGuardar = QtWidgets.QAction(MainWindow)
        self.actionGuardar.setObjectName("actionGuardar")
        self.actionGuardar_como = QtWidgets.QAction(MainWindow)
        self.actionGuardar_como.setObjectName("actionGuardar_como")
        self.actionBuscar = QtWidgets.QAction(MainWindow)
        self.actionBuscar.setObjectName("actionBuscar")
        self.actionReemplazar = QtWidgets.QAction(MainWindow)
        self.actionReemplazar.setObjectName("actionReemplazar")
        self.actionTabla_de_Simbolos = QtWidgets.QAction(MainWindow)
        self.actionTabla_de_Simbolos.setObjectName("actionTabla_de_Simbolos")
        ############
        self.actionTabla_de_Simbolos.triggered.connect(self.show_TS)
        ############
        self.actionErrores_Lexicos_y_Sintacticos = QtWidgets.QAction(
            MainWindow)
        self.actionErrores_Lexicos_y_Sintacticos.setObjectName(
            "actionErrores_Lexicos_y_Sintacticos")
        ############
        self.actionErrores_Lexicos_y_Sintacticos.triggered.connect(
            self.show_errores)
        ############
        self.actionReporte_Gramatical = QtWidgets.QAction(MainWindow)
        self.actionReporte_Gramatical.setObjectName("actionReporte_Gramatical")
        ############
        self.actionReporte_Gramatical.triggered.connect(self.show_RO)
        ############
        self.actionLexicos_y_Sintacticos = QtWidgets.QAction(MainWindow)
        self.actionLexicos_y_Sintacticos.setObjectName(
            "actionLexicos_y_Sintacticos")
        self.actionSemanticos = QtWidgets.QAction(MainWindow)
        self.actionSemanticos.setObjectName("actionSemanticos")
        self.actionTabla_de_simbolos = QtWidgets.QAction(MainWindow)
        self.actionTabla_de_simbolos.setObjectName("actionTabla_de_simbolos")
        self.actionArbol = QtWidgets.QAction(MainWindow)
        self.actionArbol.setObjectName("actionArbol")
        self.actionGramatical = QtWidgets.QAction(MainWindow)
        self.actionGramatical.setObjectName("actionGramatical")
        self.actionGramatical.triggered.connect(self.show_RG)
        self.menuFile.addAction(self.actionAbrir)
        self.menuFile.addAction(self.actionGuardar)
        self.menuFile.addAction(self.actionGuardar_como)
        self.menuFile.addAction(self.actionBuscar)
        self.menuFile.addAction(self.actionReemplazar)
        self.menuReporte.addAction(self.actionArbol_Ascendente)
        self.menuReporte.addAction(self.actionDGA)
        self.menuReporte.addAction(self.actionTabla_de_Simbolos)
        self.menuReporte.addAction(self.actionErrores_Lexicos_y_Sintacticos)
        self.menuReporte.addAction(self.actionReporte_Gramatical)
        self.menuRun.addAction(self.actionEjecutar)
        self.menuRun.addAction(self.actionDebug)
        self.menuAUGUS.addAction(self.actionLexicos_y_Sintacticos)
        self.menuAUGUS.addAction(self.actionSemanticos)
        self.menuAUGUS.addAction(self.actionTabla_de_simbolos)
        self.menuAUGUS.addAction(self.actionArbol)
        self.menuReporte.addAction(self.actionGramatical)
        self.menubar.addAction(self.menuFile.menuAction())
        self.menubar.addAction(self.menuReporte.menuAction())
        self.menubar.addAction(self.menuRun.menuAction())
        self.menubar.addAction(self.menuAUGUS.menuAction())
        self.menubar.addAction(self.menuayuda.menuAction())

        self.retranslateUi(MainWindow)
        self.editor.setCurrentIndex(0)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
예제 #20
0
 def cppClicked(self):
     fixedWidthFont = QFontDatabase.systemFont(QFontDatabase.FixedFont)
     lexer = QsciLexerCPP()
     lexer.setDefaultFont(fixedWidthFont)
     self.codeEdit.setLexer(lexer)
     self.language = 'cpp'
예제 #21
0
 def __init__(self, parent=None, caseInsensitiveKeywords=False):
     """
     Constructor
     
     @param parent parent widget of this lexer
     @param caseInsensitiveKeywords flag indicating keywords are case
         insensitive (boolean)
     """
     QsciLexerCPP.__init__(self, parent, caseInsensitiveKeywords)
     SubstyledLexer.__init__(self)
     
     self.commentString = "//"
     self.streamCommentString = {
         'start': '/* ',
         'end': ' */'
     }
     self.boxCommentString = {
         'start': '/* ',
         'middle': ' * ',
         'end': ' */'
     }
     
     self.keywordSetDescriptions = [
         self.tr("Primary keywords and identifiers"),
         self.tr("Secondary keywords and identifiers"),
         self.tr("Documentation comment keywords"),
         self.tr("Global classes and typedefs"),
         self.tr("Preprocessor definitions"),
         self.tr("Task marker and error marker keywords"),
     ]
     
     ##############################################################
     ## default sub-style definitions
     ##############################################################
     
     diffToSecondary = 0x40
     # This may need to be changed to be in line with Scintilla C++ lexer.
     
     # list of style numbers, that support sub-styling
     self.baseStyles = [11, 17, 11 + diffToSecondary, 17 + diffToSecondary]
     
     self.defaultSubStyles = {
         11: {
             0: {
                 "Description": self.tr("Additional Identifier"),
                 "Words": "std map string vector",
                 "Style": {
                     "fore": 0xEE00AA,
                 }
             },
         },
         17: {
             0: {
                 "Description": self.tr("Additional JavaDoc keyword"),
                 "Words": "check",
                 "Style": {
                     "fore": 0x00AAEE,
                 }
             },
         },
         11 + diffToSecondary: {
             0: {
                 "Description": self.tr("Inactive additional identifier"),
                 "Words": "std map string vector",
                 "Style": {
                     "fore": 0xBB6666,
                 }
             },
         },
         17 + diffToSecondary: {
             0: {
                 "Description": self.tr(
                     "Inactive additional JavaDoc keyword"),
                 "Words": "check",
                 "Style": {
                     "fore": 0x6699AA,
                 }
             },
         },
     }
예제 #22
0
class CppEditor(QsciScintilla):
    '''
    classdocs
    '''
    def __init__(self, parent=None, fileName=None, readOnlyFiles=[]):
        '''
        Constructor
        '''
        super(CppEditor, self).__init__(parent)
        self.parent = parent
        self.roFiles = readOnlyFiles

        self.setAcceptDrops(False) # drag&drop is on its parent

        # Set the default font
        font = QtGui.QFont()
        font.setFamily('Courier')
        font.setFixedPitch(True)
        font.setPointSize(10)
        self.setFont(font)
        self.setMarginsFont(font)

        # C/C++ lexer
        self.lexer = QsciLexerCPP(self,  True)
        self.lexer.setDefaultFont(font)
        self.libraryAPIs = QsciAPIs(QsciLexerCPP(self,True))
        self.setLexer(self.lexer)
        #self.SendScintilla(QsciScintilla.SCI_STYLESETFONT, 1, 'Courier')

        # Auto-indent
        self.setTabWidth(4)
        #self.setIndentationsUseTabs(False)
        self.setAutoIndent(True)

        # Current line visible with special background color
        self.setCaretLineVisible(True)
        self.setCaretLineBackgroundColor(QtGui.QColor("#ffe4e4"))

        # Enable brace matching
        self.setBraceMatching(QsciScintilla.SloppyBraceMatch)

        # Enable folding visual- use boxes
        self.setFolding(QsciScintilla.BoxedTreeFoldStyle)

        # show line numbers
        fontmetrics = QtGui.QFontMetrics(font)
        self.setMarginsFont(font)
        self.setMarginWidth(0, fontmetrics.width("00000") + 4)
        self.setMarginLineNumbers(0, True)
        self.setMarginsBackgroundColor(QtGui.QColor("#ccccee"))

        # not too small
        self.setMinimumSize(400, 200)

        # set the length of the string before the editor tries to auto-complete
        self.setAutoCompletionThreshold(3)
        # tell the editor we are using a QsciAPI for the auto-completion
        self.setAutoCompletionSource(QsciScintilla.AcsAPIs)
        # removed remaining right side characters from the current cursor
        self.setAutoCompletionReplaceWord(True)

        # "CTRL+Space" autocomplete
        self.shortcut_ctrl_space = QtWidgets.QShortcut(QtGui.QKeySequence("Ctrl+Space"), self)
        self.shortcut_ctrl_space.activated.connect(self.autoCompleteFromAll)

        if fileName:
            self.curFile = fileName
            self.loadFile(fileName)
            self.isUntitled = False
        else:
            self.curFile = PROJECT_NONAME + USER_CODE_EXT
            self.setText( __default_content__ )
            self.isUntitled = True

        self.updateApiKeywords()
        self.isModified = False
        self.textChanged.connect(self.onTextChanged )

    def onTextChanged(self):
        self.isModified = True
        self.parent.onChildContentChanged()

    def loadFile(self, fileName):
        try:
            self.clear()
            with open(fileName, 'r') as f:
                for line in f.readlines():
                    self.append(line)
            return True
        except:
            QtWidgets.QMessageBox.warning(self, PROJECT_ALIAS,
                    "failed to read %s." % fileName )
            return False


    def saveFile(self, fileName):
        if fileName.find(' ')>=0:
            QtWidgets.QMessageBox.warning(self, PROJECT_ALIAS,
                    'File path "%s" contains space(s). Please save to a valid location.'%fileName)
            return None

        try:
            with open(fileName, 'wt') as f:
                f.write(self.text())
        except:
            QtWidgets.QMessageBox.warning(self, PROJECT_ALIAS,
                    "Failed to save %s." % fileName )
            return None

        self.curFile = fileName
        self.isUntitled = False
        self.isModified = False
        return fileName

    def saveAs(self):
        fileName, _ = QtWidgets.QFileDialog.getSaveFileName(self, "Save As",
                self.curFile, PROJECT_ALIAS + " (*" + USER_CODE_EXT + ");;" +
                    "C source (*.c);;C++ source (*.cpp);;Text File (*.txt);;All files (*.*)" )
        if not fileName:
            return None
        return self.saveFile(fileName)

    def save(self):
        f1 = os.path.abspath(self.curFile)
        for fname in self.roFiles:
            if f1 == os.path.abspath(fname): # same file
                if QtWidgets.QMessageBox.question(self.parent, "Project is read-only",
                        "This project is marked as \"read-only\".\n" + \
                        "Please click \"Cancel\" and save this to another location.\n\n" + \
                        "Continue saving the current project anyway?", "OK", "Cancel"):
                    return None
                #return self.saveAs()
                return self.saveFile(self.curFile)
        if self.isUntitled:
            return self.saveAs()
        else:
            return self.saveFile(self.curFile)

    def currentFile(self):
        return self.curFile

    def modified(self):
        return self.isModified

    def updateApiKeywords(self):
        self.libraryAPIs.clear()
        self.apiKeywords = self.parent.getDefaultKeywords()
        headerfiles = []
        for line in range(self.lines()):
            txt = str(self.text(line)).strip()
            if txt.find('int') == 0: # e.g. reached "int main()"
                break
            elif txt.find('#include') == 0:
                txt = ''.join(txt.split())
                temp = txt[len('#includes')-1 : ]
                header = temp[1:-1] # get the header file
                hfile = os.path.join('libraries', header[:-2], header)
                if os.path.isfile(hfile):
                    if not (hfile in headerfiles): headerfiles.append( hfile )
        if len( headerfiles ):
            #print 'parsing: ', headerfiles
            self.apiKeywords += getLibraryKeywords( headerfiles )
        #self.apiKeywords = list(set(self.apiKeywords)) # remove duplicates
        for keyword in self.apiKeywords:
            self.libraryAPIs.add( keyword )
        self.libraryAPIs.prepare()
        self.lexer.setAPIs(self.libraryAPIs)

    def insertIncludeDirective(self, library=''):
        directive =  '#include <' + library + '.h>\r\n'
        insert_pos = 0
        found_inc = False
        for line in range(self.lines()):
            txt = str(self.text(line)).strip()
            if txt.find('int') == 0: # e.g. reached "int main()"
                insert_pos = line - 1
                break
            elif txt.find('#include') == 0:
                found_inc = True
            elif found_inc:
                insert_pos = line
                break
        if insert_pos < 0 or insert_pos >= self.lines():
            insert_pos = 0
        self.insertAt(directive, insert_pos, 0)
        self.updateApiKeywords()