예제 #1
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        boxlayout = QHBoxLayout(self)
        self.scrollarea = ScopeScrollArea(self)
        self.editor = NodeEditor(self)
        self.editor.setFocusPolicy(QtCore.Qt.WheelFocus)

        self.scrollarea.setWidget(self.editor)
        self.scrollarea.setWidgetResizable(True)
        self.scrollarea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
        self.scrollarea.setHorizontalScrollBarPolicy(
            QtCore.Qt.ScrollBarAlwaysOn)
        self.scrollarea.update_theme()

        self.linenumbers = LineNumbers(self)
        self.linenumbers.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu)

        boxlayout.addWidget(self.linenumbers)
        boxlayout.addWidget(self.scrollarea)

        self.connect(self.scrollarea.verticalScrollBar(),
                     SIGNAL("valueChanged(int)"), self.editor.sliderChanged)
        self.connect(self.scrollarea.horizontalScrollBar(),
                     SIGNAL("valueChanged(int)"), self.editor.sliderXChanged)
        self.connect(self.editor, SIGNAL("painted()"), self.painted)
        self.connect(self.editor, SIGNAL("keypress(QKeyEvent)"), self.keypress)
        self.connect(self.linenumbers, SIGNAL("breakpoint"),
                     self.toggle_breakpoint)
        self.connect(self.linenumbers, SIGNAL("breakcondition"),
                     self.set_breakpoint_condition)

        self.filename = self.export_path = None
        self.debugging = False
        self.breakpoints = {'keep': [], 'del': []}
예제 #2
0
파일: editortab.py 프로젝트: Britefury/eco
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        boxlayout = QHBoxLayout(self)
        self.scrollarea = ScopeScrollArea(self)
        self.editor = NodeEditor(self)
        self.editor.setFocusPolicy(QtCore.Qt.WheelFocus)

        self.scrollarea.setWidget(self.editor)
        self.scrollarea.setWidgetResizable(True)
        self.scrollarea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
        self.scrollarea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
        self.scrollarea.update_theme()

        self.linenumbers = LineNumbers(self)

        boxlayout.addWidget(self.linenumbers)
        boxlayout.addWidget(self.scrollarea)

        self.connect(self.scrollarea.verticalScrollBar(), SIGNAL("valueChanged(int)"), self.editor.sliderChanged)
        self.connect(self.scrollarea.horizontalScrollBar(), SIGNAL("valueChanged(int)"), self.editor.sliderXChanged)
        self.connect(self.editor, SIGNAL("painted()"), self.painted)
        self.connect(self.editor, SIGNAL("keypress(QKeyEvent)"), self.keypress)

        self.filename = self.export_path = None
예제 #3
0
class EditorTab(QWidget):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        boxlayout = QHBoxLayout(self)
        self.scrollarea = ScopeScrollArea(self)
        self.editor = NodeEditor(self)
        self.editor.setFocusPolicy(QtCore.Qt.WheelFocus)

        self.scrollarea.setWidget(self.editor)
        self.scrollarea.setWidgetResizable(True)
        self.scrollarea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
        self.scrollarea.setHorizontalScrollBarPolicy(
            QtCore.Qt.ScrollBarAlwaysOn)
        self.scrollarea.update_theme()

        self.linenumbers = LineNumbers(self)
        self.linenumbers.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu)

        boxlayout.addWidget(self.linenumbers)
        boxlayout.addWidget(self.scrollarea)

        self.connect(self.scrollarea.verticalScrollBar(),
                     SIGNAL("valueChanged(int)"), self.editor.sliderChanged)
        self.connect(self.scrollarea.horizontalScrollBar(),
                     SIGNAL("valueChanged(int)"), self.editor.sliderXChanged)
        self.connect(self.editor, SIGNAL("painted()"), self.painted)
        self.connect(self.editor, SIGNAL("keypress(QKeyEvent)"), self.keypress)
        self.connect(self.linenumbers, SIGNAL("breakpoint"),
                     self.toggle_breakpoint)
        self.connect(self.linenumbers, SIGNAL("breakcondition"),
                     self.set_breakpoint_condition)

        self.filename = self.export_path = None
        self.debugging = False
        self.breakpoints = {'keep': [], 'del': []}

    def update_theme(self):
        self.scrollarea.update_theme()
        self.editor.update()

    def changed(self):
        return self.editor.tm.changed

    def painted(self):
        self.linenumbers.update()
        self.scrollarea.update()
        if self.filename:
            filename = os.path.basename(str(self.filename))
        else:
            filename = "[No name]"
        if self.editor.tm.changed:
            filename += "*"
        tabwidget = self.parent().parent()
        index = tabwidget.indexOf(self)
        if tabwidget.tabText(index) != filename:
            tabwidget.setTabText(index, filename)

    def keypress(self, e=None, center=False):
        if (e and e.key() == Qt.Key_PageUp):
            self.scrollarea.decVSlider(True)
        elif (e and e.key() == Qt.Key_PageDown):
            self.scrollarea.incVSlider(True)
        else:
            self.editor.getScrollSizes()
            self.scrollarea.update()
            self.scrollarea.fix(center=center)

    def set_language(self, lang, whitespace):
        if isinstance(lang, Language):
            lrp = IncParser(str(lang.grammar), 1, whitespace)
            lrp.init_ast()
            lexer = IncrementalLexer(str(lang.priorities))
            self.editor.set_mainlanguage(lrp, lexer, lang.name)
        elif isinstance(lang, EcoGrammar):
            bootstrap = BootstrapParser(lr_type=1, whitespaces=whitespace)
            bootstrap.parse(lang.grammar)
            self.editor.set_mainlanguage(bootstrap.incparser,
                                         bootstrap.inclexer, lang.name)
        elif isinstance(lang, EcoFile):
            incparser, inclexer = lang.load()
            self.editor.set_mainlanguage(incparser, inclexer, lang.name)

    def toggle_breakpoint(self, isTemp, number, from_click):
        self.emit(SIGNAL("breakpoint"), isTemp, number, from_click)

    def set_breakpoint_condition(self, number):
        self.emit(SIGNAL("breakcondition"), number)

    def is_debugging(self, isDebugging):
        self.debugging = isDebugging
        if not isDebugging:
            self.breakpoints = {'keep': [], 'del': []}

    def set_breakpoints(self, bps):
        self.breakpoints = bps
예제 #4
0
파일: editortab.py 프로젝트: Britefury/eco
class EditorTab(QWidget):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        boxlayout = QHBoxLayout(self)
        self.scrollarea = ScopeScrollArea(self)
        self.editor = NodeEditor(self)
        self.editor.setFocusPolicy(QtCore.Qt.WheelFocus)

        self.scrollarea.setWidget(self.editor)
        self.scrollarea.setWidgetResizable(True)
        self.scrollarea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
        self.scrollarea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
        self.scrollarea.update_theme()

        self.linenumbers = LineNumbers(self)

        boxlayout.addWidget(self.linenumbers)
        boxlayout.addWidget(self.scrollarea)

        self.connect(self.scrollarea.verticalScrollBar(), SIGNAL("valueChanged(int)"), self.editor.sliderChanged)
        self.connect(self.scrollarea.horizontalScrollBar(), SIGNAL("valueChanged(int)"), self.editor.sliderXChanged)
        self.connect(self.editor, SIGNAL("painted()"), self.painted)
        self.connect(self.editor, SIGNAL("keypress(QKeyEvent)"), self.keypress)

        self.filename = self.export_path = None

    def update_theme(self):
        self.scrollarea.update_theme()

    def changed(self):
        return self.editor.tm.changed

    def painted(self):
        self.linenumbers.update()
        self.scrollarea.update()
        if self.filename:
            filename = os.path.basename(str(self.filename))
        else:
            filename = "[No name]"
        if self.editor.tm.changed:
            filename += "*"
        tabwidget = self.parent().parent()
        index = tabwidget.indexOf(self)
        if tabwidget.tabText(index) != filename:
            tabwidget.setTabText(index, filename)

    def keypress(self, e=None, center=False):
        if(e and e.key() == Qt.Key_PageUp):
            self.scrollarea.decVSlider(True)
        elif(e and e.key() == Qt.Key_PageDown):
            self.scrollarea.incVSlider(True)
        else:
            self.editor.getScrollSizes()
            self.scrollarea.update()
            self.scrollarea.fix(center=center)

    def set_language(self, lang, whitespace):
        if isinstance(lang, Language):
            grammar = str(lang.grammar)
            new_priorities = str(lang.priorities)
            lrp = IncParser(str(lang.grammar), 1, whitespace)
            lrp.init_ast()
            lexer = IncrementalLexer(str(lang.priorities))
            self.editor.set_mainlanguage(lrp, lexer, lang.name)
        elif isinstance(lang, EcoGrammar):
            bootstrap = BootstrapParser(lr_type=1, whitespaces=whitespace)
            bootstrap.parse(lang.grammar)
            self.editor.set_mainlanguage(bootstrap.incparser, bootstrap.inclexer, lang.name)
        elif isinstance(lang, EcoFile):
            incparser, inclexer = lang.load()
            self.editor.set_mainlanguage(incparser, inclexer, lang.name)