class ScriptView(QVBox):
    def __init__(self, parent, mainwin, script):
        self.script = script
        QVBox.__init__(self, parent)
        self.resize(500, 300)
        self.setIcon(getimage('script'))

        split = QSplitter(QSplitter.Vertical, self)
        self.editor = QextScintilla(split)
        self.output = QTextBrowser(split)
        self.editor.setText(self.script.text)
        self.connect(self.editor, SIGNAL('textChanged()'), self.on_text_changed)

        lex = QextScintillaLexerPython()
        lex.setDefaultFont(QApplication.font())
        lex.setFont(QApplication.font(), -2)
        self.editor.setLexer(lex)

        self.script.project.connect('remove-item', self.on_project_remove_item)

    def on_run(self):
        self.script.run()

    def on_text_changed(self):
        self.script.text = unicode(self.editor.text())

    def on_project_remove_item(self, item):
        if item == self.script:
            self.close()
示例#2
0
 def setText(self, text):
     line = text.split('\n')[0]
     if 'python' in line:
         self.setLexer(self.pylex)
     else:
         self.setLexer(self.lex)
     QextScintilla.setText(self, text)
示例#3
0
 def setText(self, text):
     line = text.split('\n')[0]
     if 'python' in line:
         self.setLexer(self.pylex)
     else:
         self.setLexer(self.lex)
     QextScintilla.setText(self, text)
示例#4
0
 def setText(self, text):
     # ugly hack to highlight python code
     # grab the first line
     line = text.split('\n')[0]
     if 'python' in line:
         self.setLexer(self.pylex)
     else:
         self.setLexer(self.lex)
     QextScintilla.setText(self, text)
示例#5
0
 def __init__(self, parent, owner):
     QextScintilla.__init__(self, parent, "sourceEditor")
     self.parent = owner
     self.setUtf8(1)
     self.SendScintilla(QextScintilla.SCI_SETWRAPMODE,
                        QextScintilla.SC_WRAP_WORD)
     self.setLexer(QextScintillaLexerHTML(parent))
     self.setMonospaced()
     self.connect(self, SIGNAL("selectionChanged()"),
                  self.parent.handleContextMenu)
示例#6
0
    def __init__(self, parent, locals={}, log=''):
        QextScintilla.__init__(self, parent, 'Console')

        self.locals = mydict(locals)
        self.interpreter = Interpreter(self.locals)

        self.resize(500, 300)

        lex = QextScintillaLexerPython()
#        font = QFont(QApplication.font())
#        font.setPointSize(.8*font.pointSize())
#        lex.setDefaultFont(font)
#        lex.setFont(font, 0)
        self.setLexer(lex)
        self.zoomOut()
        self.zoomOut()

#        self.SendScintilla(self.SCI_SETHSCROLLBAR, False)
        self.SendScintilla(self.SCI_SETSCROLLWIDTH, 100)
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

        sys.stdout = self
        sys.stdin = self

        self.last_lines = []

        self.more = False
        self.reading = False

        # history
        self.history = settings.get('script', 'history')
#        self.history = project.settings['/grafit/console/history']
        if self.history is None:
            self.history = []
        else:
            self.history = self.history.split('\n')
        self.pointer = 0

        sys.ps1 = '>>> '
        sys.ps2 = '... '


        self.completer = rlcompleter.Completer()

        self.current_object = None
        self.set_current_object(None)
        self.locals['go'] = self.set_current_object

        self.write(sys.ps1)
 def focusNextPrevChild(self, next):
     """
     Suppress tabbing to the next window in multi-line commands. 
     """
     if next and self.more:
         return 0
     return QextScintilla.focusNextPrevChild(self, next)
示例#8
0
 def focusNextPrevChild(self, next):
     """
     Suppress tabbing to the next window in multi-line commands. 
     """
     if next and self.more:
         return 0
     return QextScintilla.focusNextPrevChild(self, next)
    def __init__(self, parent, locals={}, log=''):
        QextScintilla.__init__(self, parent, 'Console')
        self.interpreter = Interpreter(locals)
        self.locals = locals

        self.resize (500, 300)

        lex = QextScintillaLexerPython()
        lex.setDefaultFont (QApplication.font())
        lex.setFont (QApplication.font(), -1)
        self.setLexer (lex)

#        self.SendScintilla(self.SCI_SETHSCROLLBAR, False)
        self.SendScintilla(self.SCI_SETSCROLLWIDTH, 100)
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

        sys.stdout   = self
        sys.stdin    = self

        self.last_lines   = []

        self.more = False
        self.reading = False

        # history
        self.history = settings.get('script', 'history')
#        self.history = project.settings['/grafit/console/history']
        if self.history is None:
            self.history = []
        else:
            self.history = self.history.split('\n')
        self.pointer = 0

        sys.ps1 = '>>> '
        sys.ps2 = '... '

        self.clear ()
        self.write ('# Welcome to Grafity\n>>> ')

        self.completer = rlcompleter.Completer()
示例#10
0
    def __init__(self, parent, locals=project.main_dict, log=''):
        QextScintilla.__init__(self, parent, 'Console')
        self.interpreter = Interpreter(locals)
        self.locals = locals

        self.resize(500, 300)

        lex = QextScintillaLexerPython()
        lex.setDefaultFont(QApplication.font())
        lex.setFont(QApplication.font(), -1)
        self.setLexer(lex)

        #        self.SendScintilla(self.SCI_SETHSCROLLBAR, False)
        self.SendScintilla(self.SCI_SETSCROLLWIDTH, 100)
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

        sys.stdout = self
        sys.stdin = self

        self.last_lines = []

        self.more = False
        self.reading = False

        # history
        self.history = project.settings['/grafit/console/history']
        if self.history is None:
            self.history = []
        else:
            self.history = self.history.split('\n')
        self.pointer = 0

        sys.ps1 = '>>> '
        sys.ps2 = '... '

        self.clear()
        self.write('# Welcome to Grafit\n>>> ')

        self.completer = rlcompleter.Completer()
示例#11
0
 def setEditWidget(parent):
     parent.sourceEditor.hide()
     parent.sourceEditor = QextScintilla(parent.Source)
     parent.sourceEditor.setUtf8(1)
     parent.sourceEditor.SendScintilla(QextScintilla.SCI_SETWRAPMODE,
                                       QextScintilla.SC_WRAP_WORD)
     parent.sourceEditor.setLexer(QextScintillaLexerHTML(parent))
     parent.sourceEditor.SendScintilla(QextScintilla.SCI_ASSIGNCMDKEY,
                                       QextScintilla.SCK_END,
                                       QextScintilla.SCI_LINEENDWRAP)
     parent.sourceEditor.SendScintilla(QextScintilla.SCI_ASSIGNCMDKEY,
                                       QextScintilla.SCK_HOME,
                                       QextScintilla.SCI_VCHOMEWRAP)
     setMonospaced(parent.sourceEditor)
     parent.Source.layout().addWidget(parent.sourceEditor)
     parent.connect(parent.sourceEditor, SIGNAL("textChanged()"),
                    parent.sourceEditor_textChanged)
示例#12
0
    def keyPressEvent(self, e):
        """
        Handle user input a key at a time.
        """

        text = e.text()
        key = e.key()
        ascii = e.ascii()
        y, x = self.getCursorPosition()

        if self.autoCompletionActive():
            return QextScintilla.keyPressEvent(self, e)

        if text.length() and ascii >= 32 and ascii < 127:
            QextScintilla.keyPressEvent(self, e)
            self.complete()
            return

        if e.state() & Qt.ControlButton or e.state() & Qt.ShiftButton:
            e.ignore()
            return

        if key == Qt.Key_Backspace:
            if x > 4:
                QextScintilla.keyPressEvent(self, e)
        elif key == Qt.Key_Delete:
            QextScintilla.keyPressEvent(self, e)
        elif key == Qt.Key_Return or key == Qt.Key_Enter:
            if self.autoCompletionActive():
                QextScintilla.keyPressEvent(self, e)
            else:
                if self.reading:
                    self.reading = False
                else:
                    self.write('\n')
                    self.run()
        elif key == Qt.Key_Tab:
            self.complete()
#            self.__insertText(text)
        elif key == Qt.Key_Left:
            if x > 4:
                QextScintilla.keyPressEvent(self, e)
        elif key == Qt.Key_Right:
            QextScintilla.keyPressEvent(self, e)
        elif key == Qt.Key_Home:
            self.setCursorPosition(y, 4)
        elif key == Qt.Key_End:
            QextScintilla.keyPressEvent(self, e)
        elif key == Qt.Key_Up:
            if len(self.history):
                if self.pointer == 0:
                    self.pointer = len(self.history)
                self.pointer -= 1
                self.__recall()
        elif key == Qt.Key_Down:
            if len(self.history):
                self.pointer += 1
                if self.pointer == len(self.history):
                    self.pointer = 0
                self.__recall()
        else:
            e.ignore()
示例#13
0
 def __init__(self, app, parent):
     QextScintilla.__init__(self, parent)
     self.app = app
     self.pylex = QextScintillaLexerPython(self)
     self.lex = QextScintillaLexer(self)
示例#14
0
 def eventFilter(self, obj, event):
     ret = QextScintilla.eventFilter(self, obj, event)
     if event.type() == QEvent.MouseButtonPress:
         self.mousePressEvent(event)
         return False
     return ret
示例#15
0
    def keyPressEvent(self, e):
        """
        Handle user input a key at a time.
        """

        text  = e.text()
        key   = e.key()
        ascii = e.ascii()
        y, x = self.getCursorPosition()

        if self.autoCompletionActive():
            return QextScintilla.keyPressEvent(self, e)

        if text.length() and ascii>=32 and ascii<127:
            QextScintilla.keyPressEvent(self, e)
            self.complete()
            return

        if e.state() & Qt.ControlButton or e.state() & Qt.ShiftButton:
            e.ignore()
            return

        if key == Qt.Key_Backspace:
            if x > 4:
                QextScintilla.keyPressEvent (self, e)
        elif key == Qt.Key_Delete:
            QextScintilla.keyPressEvent (self, e)
        elif key == Qt.Key_Return or key == Qt.Key_Enter:
            if self.autoCompletionActive():
                QextScintilla.keyPressEvent(self, e)
            else:
                if self.reading:
                    self.reading = False
                else:
                    self.write('\n')
                    self.run()
        elif key == Qt.Key_Tab:
            self.complete()
#            self.__insertText(text)
        elif key == Qt.Key_Left:
            if x > 4:
                QextScintilla.keyPressEvent (self, e)
        elif key == Qt.Key_Right:
            QextScintilla.keyPressEvent (self, e)
        elif key == Qt.Key_Home:
            self.setCursorPosition(y, 4)
        elif key == Qt.Key_End:
            QextScintilla.keyPressEvent (self, e)
        elif key == Qt.Key_Up:
            if len(self.history):
                if self.pointer == 0:
                    self.pointer = len(self.history)
                self.pointer -= 1
                self.__recall()
        elif key == Qt.Key_Down:
            if len(self.history):
                self.pointer += 1
                if self.pointer == len(self.history):
                    self.pointer = 0
                self.__recall()
        else:
            e.ignore()
示例#16
0
 def __init__(self, parent, name='HighlightTextView'):
     QextScintilla.__init__(self, parent, name)
     self.pylex = QextScintillaLexerPython(self)
     self.lex = QextScintillaLexer(self)
示例#17
0
 def eventFilter(self, obj, event):
     ret = QextScintilla.eventFilter(self, obj, event)
     if event.type() == QEvent.MouseButtonPress:
         self.mousePressEvent(event)
         return False
     return ret
示例#18
0
 def __init__(self, app, parent):
     QextScintilla.__init__(self, parent)
     self.app = app
     self.pylex = QextScintillaLexerPython(self)
     self.lex = QextScintillaLexer(self)
示例#19
0
 def keyPressEvent(self, evt):
     res = False
     if hasattr(self, "manager"):
         res = self.manager.handleEvent(EventType.TEXTCHANGED, evt)
     if not res:
         QextScintilla.keyPressEvent(self, evt)