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)
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)
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)
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)
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)
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
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)
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)
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.
def clearAllMarks(self): doc = self.mainwindow().currentDocument() bookmarks.bookmarks(doc).clear()
def clearErrorMarks(self): doc = self.mainwindow().currentDocument() bookmarks.bookmarks(doc).clear('error')
def markCurrentLine(self): view = self.mainwindow().currentView() lineNumber = view.textCursor().blockNumber() bookmarks.bookmarks(view.document()).toggleMark(lineNumber, 'mark')
def updateMarkStatus(self): view = self.mainwindow().currentView() self.actionCollection.view_bookmark.setChecked( bookmarks.bookmarks(view.document()).hasMark(view.textCursor().blockNumber(), 'mark'))
def slotDocumentChanged(self, doc, prev=None): if prev: bookmarks.bookmarks(prev).marksChanged.disconnect(self.updateMarkStatus) bookmarks.bookmarks(doc).marksChanged.connect(self.updateMarkStatus)
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)
def nextMark(self): view = self.mainwindow().currentView() cursor = view.textCursor() cursor = bookmarks.bookmarks(view.document()).nextMark(cursor) if cursor: view.gotoTextCursor(cursor)
def slotDocumentChanged(self, doc, prev=None): if prev: bookmarks.bookmarks(prev).marksChanged.disconnect( self.updateMarkStatus) bookmarks.bookmarks(doc).marksChanged.connect(self.updateMarkStatus)
def previousMark(self): view = self.mainwindow().currentView() cursor = view.textCursor() cursor = bookmarks.bookmarks(view.document()).previousMark(cursor) if cursor: view.setTextCursor(cursor)
def updateMarkStatus(self): view = self.mainwindow().currentView() self.actionCollection.view_bookmark.setChecked( bookmarks.bookmarks(view.document()).hasMark( view.textCursor().blockNumber(), 'mark'))
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)
def previousMark(self): view = self.mainwindow().currentView() cursor = view.textCursor() cursor = bookmarks.bookmarks(view.document()).previousMark(cursor) if cursor: view.gotoTextCursor(cursor)