예제 #1
0
 def set_type(self):
     try:
         ext = self.file_name.split(".")[-1]
         print(ext)
     except:
         ext = ""
         self.text_edit_field.setLexer(Qsci.QsciLexerCPP(self))
         pass
     if ext == "py":
         self.text_edit_field.setLexer(Qsci.QsciLexerPython(self))
         self.hide_web()
         print("type python")
     elif ext == "cpp" or ext == "c":
         self.text_edit_field.setLexer(Qsci.QsciLexerCPP(self))
         self.hide_web()
         print("type cpp")
     elif ext == "html":
         self.text_edit_field.setLexer(Qsci.QsciLexerHTML(self))
         self.terminal.setHidden(True)
         self.browser = QWebView(self)
         self.browser.load(QUrl(self.file_name))
         self.browser.move(self.x_y[0] * 66, 30)
         self.browser.setFixedSize(self.x_y[0] * 0.33, self.x_y[1] - 20)
         self.browser.show()
         #self.browser.move(500,0)
         #self.setGeometry((self.screen.width()-self.wd+200)/2,0,self.wd,self.ht-50)
         #self.setFixedSize(self.wd+200,self.ht-50)
         print("type html")
예제 #2
0
    def __init__(self):

        Qsci.QsciScintilla.__init__(self)
        
        # Set the default font
        font = QtGui.QFont()
        font.setFamily('Courier') #Monospace
        font.setFixedPitch(True)
        font.setPointSize(10)
        self.setFont(font)
        self.setMarginsFont(font)
        
        # Margin 0 is used for line numbers 
        fontmetrics = QtGui.QFontMetrics(font)
        self.setMarginsFont(font)
        self.setMarginWidth(0, fontmetrics.width("0000"))
        self.setMarginLineNumbers(10, True)
        self.setMarginsBackgroundColor(QtGui.QColor("#cccccc"))

        
        ################################################
        self.setWhitespaceVisibility(self.WsVisible)
        ################################################

        
        # same-line brace matching....
        self.setBraceMatching(Qsci.QsciScintilla.SloppyBraceMatch)
        
        # Current line visible with special background color
        self.setCaretLineVisible(True)
        self.setCaretLineBackgroundColor(QtGui.QColor("#99ccff"))
        
        # Choosing a lexer (syntax highlighting)
        lexer = Qsci.QsciLexerCPP() # C++ lexer
        lexer.setDefaultFont(font)
        self.setLexer(lexer)
        self.SendScintilla(Qsci.QsciScintilla.SCI_STYLESETFONT, 1, 'Courier')
        
        self.SendScintilla(Qsci.QsciScintilla.SCI_SETHSCROLLBAR, 0)
        #self.SendScintilla(Qsci.QsciScintilla.SCI_SETSCROLLWIDTH, 10)
        #self.SendScintilla(Qsci.QsciScintilla.SCI_SETSCROLLWIDTHTRACKING, 1)
        
        # not too small
        self.setMinimumSize(200, 200)


        ###################################################################

        # set vertical line at character 80 
        self.setEdgeMode(QsciScintilla.EdgeLine)
        self.setEdgeColumn(80)
        self.setEdgeColor(QtGui.QColor("#3333ff"))
예제 #3
0
    def __init__(self, parent):
        Qsci.QsciScintilla.__init__(self)

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

        # Margin 0 is used for line numbers

        fontmetrics = QtGui.QFontMetrics(font)
        self.setMarginsFont(font)
        self.setMarginWidth(0, fontmetrics.width("0000"))
        self.setMarginLineNumbers(10, True)
        self.setMarginsBackgroundColor(QtGui.QColor("#cccccc"))

        self.setWhitespaceVisibility(self.WsVisible)

        self.setBraceMatching(Qsci.QsciScintilla.SloppyBraceMatch)

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

        lexer = Qsci.QsciLexerCPP()
        lexer.setDefaultFont(font)
        self.setLexer(lexer)
        self.SendScintilla(Qsci.QsciScintilla.SCI_STYLESETFONT, 1, 'Courier')

        self.SendScintilla(Qsci.QsciScintilla.SCI_SETHSCROLLBAR, 0)
        #self.SendScintilla(Qsci.QsciScintilla.SCI_SETSCROLLWIDTH, 10)
        #self.SendScintilla(Qsci.QsciScintilla.SCI_SETSCROLLWIDTHTRACKING, 1)

        # not too small
        self.setMinimumSize(200, 200)
예제 #4
0
    def __init__(self, distributedObjects, filename, parent):
        ScintillaWrapper.__init__(self, parent)
        self.breakpointOverlays = {}

        filename = str(filename)
        self.distributedObjects = distributedObjects
        self.debugController = self.distributedObjects.debugController
        self.__bpModel = self.distributedObjects.breakpointModel
        self.tracepointController = self.distributedObjects.tracepointController
        self.signalProxy = self.distributedObjects.signalProxy
        self.filename = filename
        self.lastContextMenuLine = 0
        self.markerBp = QPixmap(":/markers/bp.png")
        self.markerBpDisabled = QPixmap(":/markers/bp_dis.png")
        self.markerTp = QPixmap(":/markers/tp.png")
        self.markerExec = QPixmap(":/markers/exec_pos.png")
        self.markerStack = QPixmap(":/markers/stack_pos.png")
        self.markerExecSignal = QPixmap(":/markers/exec_pos_signal.png")
        self.shown = False

        self.font = QFont("DejaVu Sans Mono", 10)
        self.font.setStyleHint(QFont.TypeWriter)
        self.lexer = Qsci.QsciLexerCPP()
        self.lexer.setFont(self.font)

        self.setToolTip("")
        self.setWhatsThis("")
        self.setLexer(self.lexer)
        self.setMarginLineNumbers(self.MARGIN_NUMBERS, True)
        # set sensitivity
        self.setMarginSensitivity(self.MARGIN_NUMBERS, True)
        self.setMarginSensitivity(self.MARGIN_MARKER_BP, True)
        self.setMarginSensitivity(self.MARGIN_MARKER_TP, True)
        # define symbol
        self.markerDefine(self.markerBp, self.MARGIN_MARKER_BP)
        self.markerDefine(self.markerBpDisabled, self.MARGIN_MARKER_BP_DIS)
        self.markerDefine(self.markerTp, self.MARGIN_MARKER_TP)
        self.markerDefine(self.markerExec, self.MARGIN_MARKER_EXEC)
        self.markerDefine(self.markerStack, self.MARGIN_MARKER_STACK)
        self.markerDefine(self.markerExecSignal,
                          self.MARGIN_MARKER_EXEC_SIGNAL)
        self.markerDefine(Qsci.QsciScintilla.Background,
                          self.MARKER_HIGHLIGHTED_LINE)

        # define width and mask to show margin
        self.setMarginWidth(self.MARGIN_MARKER_BP, 10)
        self.setMarginMarkerMask(
            self.MARGIN_MARKER_BP,
            1 << self.MARGIN_MARKER_BP | 1 << self.MARGIN_MARKER_BP_DIS)
        self.setMarginWidth(self.MARGIN_MARKER_TP, 10)
        self.setMarginMarkerMask(self.MARGIN_MARKER_TP,
                                 1 << self.MARGIN_MARKER_TP)
        self.setMarginWidth(self.MARGIN_MARKER_EXEC, 10)
        self.setMarginMarkerMask(
            self.MARGIN_MARKER_EXEC,
            1 << self.MARGIN_MARKER_EXEC | 1 << self.MARGIN_MARKER_EXEC_SIGNAL
            | 1 << self.MARGIN_MARKER_STACK)
        self.setMarginWidth(self.MARKER_HIGHLIGHTED_LINE, 0)
        self.setMarginMarkerMask(self.MARKER_HIGHLIGHTED_LINE,
                                 1 << self.MARKER_HIGHLIGHTED_LINE)

        self.INDICATOR_TOOLTIP = self.indicatorDefine(self.BoxIndicator)
        self.setIndicatorDrawUnder(True, self.INDICATOR_TOOLTIP)

        self.setReadOnly(False)

        if not (QtCore.QFile.exists(filename)):
            logging.error("Could not open file %s", filename)

        self.file_ = QtCore.QFile(filename)
        self.file_.open(QtCore.QIODevice.ReadOnly | QtCore.QIODevice.Text)
        self.read(self.file_)
        self.file_.close()

        self.changed = False
        self.modificationChanged.connect(self.__setFileModified)

        self.setMarginWidthByLineNumbers()
        self.SendScintilla(Qsci.QsciScintilla.SCI_SETMOUSEDWELLTIME, 500)

        # override scintillas context menu with our own
        self.SendScintilla(Qsci.QsciScintilla.SCI_USEPOPUP, 0)
        self.setContextMenuPolicy(Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self.showContextMenu)

        self.marginClicked.connect(self.onMarginClicked)
        self.SCN_DOUBLECLICK.connect(self.editDoubleClicked)
        self.dwellStart.connect(self.onDwellStart)
        self.dwellEnd.connect(self.onDwellEnd)

        self.__bpModel.rowsInserted.connect(self.breakpointsInserted)
        # don't connect to rowsRemoved here since the breakpoint is already gone
        # from the model when it's emitted
        self.__bpModel.rowsAboutToBeRemoved.connect(self.breakpointsRemoved)
        self.__bpModel.dataChanged.connect(self.breakpointsModified)
        _model = self.tracepointController.model()
        _model.rowsInserted.connect(self.getTracepointsFromModel)
        _model.rowsRemoved.connect(self.getTracepointsFromModel)

        act = self.distributedObjects.actions
        act.ToggleTrace.triggered.connect(self.toggleTracepoint)

        self.distributedObjects.editorController.config.itemsHaveChanged.connect(
            self.updateConfig)
        self.updateConfig()

        # initially, read all breakpoints and tracepoints from the model
        self.getTracepointsFromModel()

        self.__allowToolTip = True
        self.__enableToolTip(True)

        self.__popupMenu = None

        self.__fileWatcher = QFileSystemWatcher([self.filename])
        self.__fileWatcher.fileChanged.connect(self.__fileChanged)

        # this timer is used for a workaround: QFileSystemWatcher will sometimes
        # report a change multiple times; therefore, in self.__fileChanged, we
        # simply start the timer on a notification and discard all notifications
        # while the timer is running
        self.__fileChangedTimer = QTimer()
        self.__fileChangedTimer.setSingleShot(True)
        self.__fileChangedTimer.setInterval(100)

        self.__wordHighlightTimer = QTimer()
        self.cursorPositionChanged.connect(
            lambda: self.__wordHighlightTimer.start())
        self.__wordHighlightTimer.setSingleShot(True)
        self.__wordHighlightTimer.setInterval(250)
        self.__wordHighlightTimer.timeout.connect(
            self.highlightWordFromCursorPosition)
예제 #5
0
    def __init__(self):
        super(sau_edit, self).__init__()
        self.screen = qt.QDesktopWidget().screenGeometry()
        self.ht = (self.screen.height())
        self.wd = (self.screen.width())
        self.setGeometry(0, 0, self.wd, self.ht)
        self.setMinimumSize(self.wd / 2, self.ht / 2)
        #self.setGeometry((self.screen.width()-self.wd)/2,0,self.wd,self.ht-50)
        #self.setFixedSize(self.wd,self.ht-50)
        #self.showMaximized()
        #self.showFullScreen()
        #self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
        self.setWindowTitle("SAU-editor")
        self.setWindowIcon(qt.QIcon("notepad.png"))

        #---------------------------------status label-------------------------------------
        """self.status=qt.QLabel(self)
        self.status.move(750,500)#self.wd-200,self.ht-200)
        self.status.setStyleSheet("QTextEdit {color:red;background-color:white}")"""
        #---------------------------------all menu bar entry--------------------------------
        new_file_key = qt.QAction("&New file", self)
        new_file_key.setShortcut("Ctrl+n")
        new_file_key.setStatusTip('New file')
        new_file_key.triggered.connect(self.new_file)

        new_window_file_key = qt.QAction("&New window", self)
        new_window_file_key.setShortcut("Ctrl+Shift+n")
        new_window_file_key.setStatusTip('New window')
        new_window_file_key.triggered.connect(self.new_window_file)

        open_file_key = qt.QAction("&Open file", self)
        open_file_key.setShortcut("Ctrl+o")
        open_file_key.setStatusTip('Open file')
        open_file_key.triggered.connect(self.open_file)

        save_key = qt.QAction("&Save", self)
        save_key.setShortcut("Ctrl+s")
        save_key.setStatusTip('Save file')
        save_key.triggered.connect(self.save_file)

        quit_key = qt.QAction("&Quit application !", self)
        quit_key.setShortcut("Ctrl+Q")
        quit_key.setStatusTip('Leave The App')
        quit_key.triggered.connect(self.close_application)

        copy_key = qt.QAction("&Copy", self)
        copy_key.setShortcut("Ctrl+c")
        copy_key.setStatusTip('copy')
        copy_key.triggered.connect(self.save_file)

        cut_key = qt.QAction("&Cut", self)
        cut_key.setShortcut("Ctrl+x")
        cut_key.setStatusTip('cut')
        cut_key.triggered.connect(self.save_file)

        paste_key = qt.QAction("&Paste", self)
        paste_key.setShortcut("Ctrl+v")
        paste_key.setStatusTip('paste')
        paste_key.triggered.connect(self.save_file)

        about_key = qt.QAction("&About", self)
        about_key.setStatusTip('About editor')
        about_key.triggered.connect(self.about_info)

        terminal_key = qt.QAction("&Terminal", self)
        terminal_key.setStatusTip('Open terminal')
        terminal_key.triggered.connect(self.show_terminal)

        refresh_key = qt.QAction("&Refresh", self)
        refresh_key.setStatusTip('Refresh html page')
        refresh_key.triggered.connect(self.refresh_fun)

        self.statusBar()
        self.terminal()
        #self.terminal1()
        #-------------------------------------all menu-s-------------------------------------
        mainMenu = self.menuBar()
        fileMenu = mainMenu.addMenu('&File')
        fileMenu.addAction(new_file_key)
        fileMenu.addAction(new_window_file_key)
        fileMenu.addAction(open_file_key)
        fileMenu.addAction(save_key)
        fileMenu.addAction(quit_key)

        edit_menu = mainMenu.addMenu('&Edit')
        edit_menu.addAction(copy_key)
        edit_menu.addAction(cut_key)
        edit_menu.addAction(paste_key)

        tool_menu = mainMenu.addMenu('&Tool')
        tool_menu.addAction(terminal_key)
        tool_menu.addAction(refresh_key)

        help_menu = mainMenu.addMenu('&Help')
        help_menu.addAction(about_key)
        #-------------------------------------textEdit-----------------------------------------
        self.text_edit_field = QsciScintilla(self)
        self.text_edit_field.setLexer(Qsci.QsciLexerCPP(self))
        self.text_edit_field.setMarginType(10, QsciScintilla.NumberMargin)
        self.text_edit_field.setMarginWidth(0, "0000")
        self.text_edit_field.setStyleSheet(
            "QsciScintilla {background-color:red}")
        self.text_edit_field.setIndentationGuides(True)
        self.text_edit_field.setAutoIndent(True)
        self.text_edit_field.setAutoCompletionThreshold(1)
        self.text_edit_field.setAutoCompletionSource(QsciScintilla.AcsDocument)
        self.text_edit_field.setCallTipsStyle(
            QsciScintilla.CallTipsNoAutoCompletionContext)
        #self.text_edit_field.setCaretLineVisible(True)
        self.text_edit_field.setFolding(QsciScintilla.BoxedTreeFoldStyle)
        self.text_edit_field.setMarginsBackgroundColor(QColor("#333333"))
        #self.text_edit_field.setCaretLineBackgroundColor(QColor("#A9A9A9"))
        #self.text_edit_field.setFixedSize(self.wd-500,self.ht-80)
        self.text_edit_field.setMaximumWidth(300)
        try:
            self.text_edit_field.setMinimumSize(self.wd / 2, self.ht / 2)
        except:
            pass
        #self.text_edit_field.showMaximized()
        self.text_edit_field.move(0, 30)
        self.font = qt.QFont()
        self.font.setFamily('Courier')
        self.font.setPointSize(10)
        self.text_edit_field.setFont(self.font)
        #self.text_edit_field.setFontItalic(True)
        self.text_edit_field.setStyleSheet(
            "QsciScintilla {color:green;background-color:black}")
        #highlight = syntax.PythonHighlighter(self.text_edit_field.document())
        self.text_edit_field.show()
        self.file_datail()
        """try:
            with open("last_opened.file","r") as lo:
                self.open_file(lo.read())
                print( str(lo.read()))
        except:
            pass"""
        self.load_previous_file()
        self.show()