Пример #1
0
    def connectJob(self, j):
        """Starts collecting the references of a started Job.

        Output already created by the Job is read and we start
        listening for new output.

        """
        # do not collect errors for auto-engrave jobs if the user has disabled it
        if job.attributes.get(j).hidden and QSettings().value(
                "log/hide_auto_engrave", False, bool):
            return
        self._job = j
        # clear earlier set error marks
        docs = {self.document()}
        for ref in self._refs.values():
            c = ref.cursor(False)
            if c:
                docs.add(c.document())
        for doc in docs:
            bookmarks.bookmarks(doc).clear("error")
        self._refs.clear()
        # take over history and connect
        for msg, type in j.history():
            self.slotJobOutput(msg, type)
        j.output.connect(self.slotJobOutput)
Пример #2
0
 def __init__(self, view):
     super(ViewHighlighter, self).__init__(view)
     self._cursorFormat = QTextCharFormat()
     self._cursorFormat.setProperty(QTextFormat.FullWidthSelection, True)
     app.settingsChanged.connect(self.readSettings)
     self.readSettings()
     bookmarks.bookmarks(view.document()).marksChanged.connect(self.updateMarkedLines)
     self.updateMarkedLines()
     view.cursorPositionChanged.connect(self.updateCursor)
     view.installEventFilter(self)
Пример #3
0
 def __init__(self, view):
     super(ViewHighlighter, self).__init__(view)
     self._cursorFormat = QTextCharFormat()
     self._cursorFormat.setProperty(QTextFormat.FullWidthSelection, True)
     app.settingsChanged.connect(self.readSettings)
     self.readSettings()
     bookmarks.bookmarks(view.document()).marksChanged.connect(
         self.updateMarkedLines)
     self.updateMarkedLines()
     view.cursorPositionChanged.connect(self.updateCursor)
     view.installEventFilter(self)
Пример #4
0
 def __init__(self, view):
     # no need to call the plugin __init__ method
     gadgets.arbitraryhighlighter.ArbitraryHighlighter.__init__(self, view)
     self._cursorFormat = QTextCharFormat()
     self._cursorFormat.setProperty(QTextFormat.FullWidthSelection, True)
     app.settingsChanged.connect(self.readSettings)
     self.readSettings()
     bookmarks.bookmarks(view.document()).marksChanged.connect(self.updateMarkedLines)
     self.updateMarkedLines()
     view.cursorPositionChanged.connect(self.updateCursor)
     view.installEventFilter(self)
Пример #5
0
 def __init__(self, view):
     # no need to call the plugin __init__ method
     gadgets.arbitraryhighlighter.ArbitraryHighlighter.__init__(self, view)
     self._cursorFormat = QTextCharFormat()
     self._cursorFormat.setProperty(QTextFormat.FullWidthSelection, True)
     app.settingsChanged.connect(self.readSettings)
     self.readSettings()
     bookmarks.bookmarks(view.document()).marksChanged.connect(
         self.updateMarkedLines)
     self.updateMarkedLines()
     view.cursorPositionChanged.connect(self.updateCursor)
     view.installEventFilter(self)
Пример #6
0
    def bind(self, document):
        """Called when a document is loaded this Reference points to.

        Creates a QTextCursor so the position is maintained even if the document
        changes.

        """
        b = document.findBlockByNumber(max(0, self._line - 1))
        if b.isValid():
            self._cursor = c = QTextCursor(document)
            c.setPosition(b.position() + self._column)
            document.closed.connect(self.unbind)
            if self._line > 0:
                bookmarks.bookmarks(document).setMark(self._line - 1, "error")
        else:
            self._cursor = None
Пример #7
0
    def bind(self, document):
        """Called when a document is loaded this Reference points to.

        Creates a QTextCursor so the position is maintained even if the document
        changes.

        """
        b = document.findBlockByNumber(max(0, self._line - 1))
        if b.isValid():
            self._cursor = c = QTextCursor(document)
            c.setPosition(b.position() + self._column)
            document.closed.connect(self.unbind)
            if self._line > 0:
                bookmarks.bookmarks(document).setMark(self._line - 1, "error")
        else:
            self._cursor = None
Пример #8
0
 def connectJob(self, job):
     """Starts collecting the references of a started Job.
     
     Output already created by the Job is read and we start
     listening for new output.
     
     """
     # clear earlier set error marks
     docs = set([self.document()])
     for ref in self._refs.values():
         c = ref.cursor(False)
         if c:
             docs.add(c.document())
     for doc in docs:
         bookmarks.bookmarks(doc).clear("error")
     self._refs.clear()
     # take over history and connect
     for msg, type in job.history():
         self.slotJobOutput(msg, type)
     job.output.connect(self.slotJobOutput)
Пример #9
0
 def connectJob(self, job):
     """Starts collecting the references of a started Job.
     
     Output already created by the Job is read and we start
     listening for new output.
     
     """
     # do not collect errors for auto-engrave jobs if the user has disabled it
     if jobattributes.get(job).hidden and QSettings().value("log/hide_auto_engrave", False, bool):
         return
     # clear earlier set error marks
     docs = set([self.document()])
     for ref in self._refs.values():
         c = ref.cursor(False)
         if c:
             docs.add(c.document())
     for doc in docs:
         bookmarks.bookmarks(doc).clear("error")
     self._refs.clear()
     # take over history and connect
     for msg, type in job.history():
         self.slotJobOutput(msg, type)
     job.output.connect(self.slotJobOutput)
Пример #10
0
    def __rebind_bookmarks(self, genome_name):
        """
        (Internal)
        get the bookmarks based on the genome name/identifier
        and bind them into the bookmarks menu
        """
        # get the bookmarks
        self.__bookmarks = bookmarks(genome_name)
        self.__bookmark_lookup = {}

        marks = self.__bookmarks.get_all_bookmarks()

        # the menu to load the bookmarks into
        menu_head = xrc.XRCID("bookmarks")
        menu_head = xrc.XRCCTRL(self.main, "bookmarks")
        menu_head = self.main.GetMenuBar().GetMenu(
            3)  # Bookmarks is 3... IS this stable?

        # clear the previous bookmarks:
        for i in range(50000,
                       50100):  # this is a limit to the number of bookmarks...
            # could you even display 100 bookmarks?
            try:
                menu_head.Delete(id=i)
            except:
                break  # reached the end.

        if not marks:
            # load a 'None' into the menu
            menu_head.Append(50000, text="None")  # how to make inactive?
        else:
            for index, item in enumerate(marks):
                if index > 100:
                    break  # I don't support more than 100 at the current time...
                # 50000 + index = ID, well above any other menu ID.
                menu_head.Append(50000 + index,
                                 text="%s - (%s)" %
                                 (item["loc"], item["notes"]))

                # bind a event
                self.Bind(wx.EVT_MENU, self.OnBookmark, id=50000 + index)
                self.__bookmark_lookup[50000 + index] = item[
                    "loc"]  # maintain a lookback of location versus Id.
Пример #11
0
 def clearAllMarks(self):
     doc = self.mainwindow().currentDocument()
     bookmarks.bookmarks(doc).clear()
Пример #12
0
 def clearErrorMarks(self):
     doc = self.mainwindow().currentDocument()
     bookmarks.bookmarks(doc).clear('error')
Пример #13
0
 def markCurrentLine(self):
     view = self.mainwindow().currentView()
     lineNumber = view.textCursor().blockNumber()
     bookmarks.bookmarks(view.document()).toggleMark(lineNumber, 'mark')
Пример #14
0
 def updateMarkStatus(self):
     view = self.mainwindow().currentView()
     self.actionCollection.view_bookmark.setChecked(
         bookmarks.bookmarks(view.document()).hasMark(view.textCursor().blockNumber(), 'mark'))
Пример #15
0
 def slotDocumentChanged(self, doc, prev=None):
     if prev:
         bookmarks.bookmarks(prev).marksChanged.disconnect(self.updateMarkStatus)
     bookmarks.bookmarks(doc).marksChanged.connect(self.updateMarkStatus)
Пример #16
0
 def updateMarkedLines(self):
     """Called when something changes in the bookmarks."""
     for type, marks in bookmarks.bookmarks(self.parent().document()).marks().items():
         self.highlight(type, marks, -1)
Пример #17
0
 def nextMark(self):
     view = self.mainwindow().currentView()
     cursor = view.textCursor()
     cursor = bookmarks.bookmarks(view.document()).nextMark(cursor)
     if cursor:
         view.gotoTextCursor(cursor)
Пример #18
0
 def slotDocumentChanged(self, doc, prev=None):
     if prev:
         bookmarks.bookmarks(prev).marksChanged.disconnect(
             self.updateMarkStatus)
     bookmarks.bookmarks(doc).marksChanged.connect(self.updateMarkStatus)
Пример #19
0
 def markCurrentLine(self):
     view = self.mainwindow().currentView()
     lineNumber = view.textCursor().blockNumber()
     bookmarks.bookmarks(view.document()).toggleMark(lineNumber, 'mark')
Пример #20
0
 def previousMark(self):
     view = self.mainwindow().currentView()
     cursor = view.textCursor()
     cursor = bookmarks.bookmarks(view.document()).previousMark(cursor)
     if cursor:
         view.setTextCursor(cursor)
Пример #21
0
 def clearAllMarks(self):
     doc = self.mainwindow().currentDocument()
     bookmarks.bookmarks(doc).clear()
Пример #22
0
 def updateMarkStatus(self):
     view = self.mainwindow().currentView()
     self.actionCollection.view_bookmark.setChecked(
         bookmarks.bookmarks(view.document()).hasMark(
             view.textCursor().blockNumber(), 'mark'))
Пример #23
0
 def updateMarkedLines(self):
     """Called when something changes in the bookmarks."""
     for type, marks in bookmarks.bookmarks(
             self.parent().document()).marks().items():
         self.highlight(type, marks, -1)
Пример #24
0
 def clearErrorMarks(self):
     doc = self.mainwindow().currentDocument()
     bookmarks.bookmarks(doc).clear('error')
Пример #25
0
 def previousMark(self):
     view = self.mainwindow().currentView()
     cursor = view.textCursor()
     cursor = bookmarks.bookmarks(view.document()).previousMark(cursor)
     if cursor:
         view.gotoTextCursor(cursor)