예제 #1
0
    def __init__(self, parent=None):
        QsciScintilla.__init__(self, parent)

        self.setUtf8(True)
        self.setFont(QFont('Consolas', 10))
        self.setLexer(QsciLexerPython())

        self.setMarginLineNumbers(1, True)

        self.setTabWidth(4)
        self.setAutoIndent(True)
        self.setIndentationGuides(True)
        self.setIndentationsUseTabs(False)
        self.setBackspaceUnindents(True)

        self.setWrapMode(QsciScintilla.WrapWord)
        self.setWrapIndentMode(QsciScintilla.WrapIndentIndented)

        self.setBraceMatching(QsciScintilla.SloppyBraceMatch)
        self.setFolding(QsciScintilla.PlainFoldStyle)

        self.context_menu = None
        self.setContextMenuPolicy(Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self.onContextMenuRequested)

        self.linesChanged.connect(
            lambda: self.setMarginWidth(1, ' %d' % self.lines())
        )
예제 #2
0
 def __init__(self, parent=None):
     QsciScintilla.__init__(self, parent)
     self.complete = AutoComplete()
     self.complete.prepare.connect(self.update_completes)
     self.lexer = text_lexer(self)
     self.setLexer(self.lexer)
     self.api = QsciAPIs(self.lexer)
     self.setAutoIndent(True)
     self.setMarginLineNumbers(0, True)
     self.setEdgeMode(QsciScintilla.EdgeLine)
     self.setEdgeColumn(79)
     self.setEdgeColor(QColor(0, 0, 0))
     """
     self.setIndentationsUseTabs(True)
     self.setIndentationWidth(get_configs()['tab_width'])
     self.setTabWidth(get_configs()['tab_width'])
     self.setTabIndents(get_configs()['indent_with_tabs'])
     self.setBackspaceUnindents(True)
     self.setCaretLineVisible(True)
     self.setIndentationGuides(True)
     self.setCaretForegroundColor(QColor(get_configs()['cursor_color']))
     self.setCaretLineBackgroundColor(QColor(get_configs()['line_background_color']))
     self.setCaretWidth(6)
     self.setWrapMode(QsciScintilla.WrapNone if not get_configs()['text_wrap'] else QsciScintilla.WrapWhitespace)
     self.setEolMode(get_eol_mode(get_configs()['eol_mode']))
     # self.setMarginsForegroundColor(QColor("#ff888888"))
     """
     self.setMarginWidth(0, len(str(len(self.text().split('\n')))) * 20)
     self.setFolding(QsciScintilla.PlainFoldStyle)
     self.setAutoCompletionSource(QsciScintilla.AcsAll)
     self.setAutoCompletionCaseSensitivity(True)
     self.setAutoCompletionReplaceWord(True)
     self.autoCompleteFromAll()
     self.setAutoCompletionThreshold(1)
     self.setAutoCompletionSource(QsciScintilla.AcsAll)
     self.setUtf8(True)
     self.setBraceMatching(QsciScintilla.StrictBraceMatch)
     self.setMatchedBraceForegroundColor(
         QColor(self.lexer.styles[Name.Decorator]))
     self.setMatchedBraceBackgroundColor(RGB(0, 255, 0).to_pyqt_color())
     self.setCallTipsVisible(-1)
예제 #3
0
    def __init__(self, interpreter, message="", log='', parent=None):
        """Constructor.
        @param interpreter : InteractiveInterpreter in which
        the code will be executed

        @param message : welcome message string
        
        @param  'parent' : specifies the parent widget.
        If no parent widget has been specified, it is possible to
        exit the interpreter by Ctrl-D.
        """

        QsciScintilla.__init__(self, parent)
        self.interpreter = interpreter

        # user interface setup
        self.setAutoIndent(True)
        self.setAutoCompletionThreshold(4)
        self.setAutoCompletionSource(QsciScintilla.AcsDocument)
        # Lexer
        self.setLexer(QsciLexerPython(self))

        # Search
        self.incrementalSearchString = ""
        self.incrementalSearchActive = False
        self.inRawMode = False
        self.echoInput = True

        # Initialize history
        self.historyLists = {}
        self.maxHistoryEntries = 1000
        self.H = History("%s/.ghist" % os.environ['HOME'])  # Added by vb
        self.history = self.H.load(self.maxHistoryEntries)  # Added by vb
        #        self.history = []
        self.histidx = -1

        # # capture all interactive input/output
        sys.stdout = self
        sys.stderr = MultipleRedirection((sys.stderr, self))
        sys.stdin = self

        self.reading = 0
        # interpreter prompt.
        try:
            sys.ps1
        except AttributeError:
            sys.ps1 = ">>> "
        try:
            sys.ps2
        except AttributeError:
            sys.ps2 = "... "

        #self.completionText = ""
        # Excecution Status
        self.more = False
        # Multi line execution Buffer
        self.execlines = []

        # interpreter banner
        self.write('The shell running Python %s on %s.\n' %
                   (sys.version, sys.platform))
        self.write('Type "copyright", "credits" or "license"'
                   ' for more information on Python.\n')
        self.write(message + '\n\n')
        self.write(sys.ps1)

        #self.standardCommands().clearKeys()
        self.keymap = {
            Qt.Key_Backspace: self.__QScintillaDeleteBack,
            Qt.Key_Delete: self.__QScintillaDelete,
            Qt.Key_Return: self.__QScintillaNewline,
            Qt.Key_Enter: self.__QScintillaNewline,
            Qt.Key_Tab: self.__QScintillaTab,
            Qt.Key_Left: self.__QScintillaCharLeft,
            Qt.Key_Right: self.__QScintillaCharRight,
            Qt.Key_Up: self.__QScintillaLineUp,
            Qt.Key_Down: self.__QScintillaLineDown,
            Qt.Key_Home: self.__QScintillaVCHome,
            Qt.Key_End: self.__QScintillaLineEnd,
        }

        self.connect(self,
                     QtCore.SIGNAL('userListActivated(int, const QString)'),
                     self.__completionListSelected)
예제 #4
0
 def __init__(self, parent=None):
     QsciScintilla.__init__(self, parent)
예제 #5
0
 def __init__(self, parent=None):
     QsciScintilla.__init__(self, parent)
     self.font = None
     self.lexer = None