Example #1
0
class MarkActivator(QObject):
    def __init__(self):
        super().__init__()
        app.view_added.connect(self.new_view)
    
    @pyqtSlot(QWidget)
    def new_view(self, obj):
        obj.textChanged.connect(self.text_changed)
        
    @pyqtSlot()
    def text_changed(self):
        try:
            mark_prev = app.globals.mark.cur()
        except IndexError:
            mark_prev = None
        app.globals.mark.new()
        mark_cur = app.globals.mark.cur()
        if mark_prev:
            if (mark_cur.editor == mark_prev.editor) \
                and (mark_cur.line == mark_prev.line):
                app.globals.mark.pop()
            
            
            
        
#     def new_view(self):
#         print("VIEW ADDED!")

app.register_global("mark_activator", MarkActivator())
# app.view_added.connect(app.globals.mark_activator.new_view)
Example #2
0
            mark.editor.setFocus()
#             print(self.sets[ring])
#             print(self.sets[ring].pos)
#             print("PREV")
        except IndexError:
            pass
        
    def next(self, set_name='global'):
        try:
            mark = self.sets[set_name].next()
            mark.editor.setCursorPosition(mark.line, mark.pos)
            mark.editor.setFocus()
#             print(self.sets[set_name])
#             print(self.sets[set_name].pos)
#             print("NEXT")
        except IndexError:
            pass
        
    
    def pop(self, set_name='global'):
        mark = self.sets[set_name].pop()
#         print(self.sets[set_name])
#         print(self.sets[set_name].pos)
#         print("POP")
        return mark
    
    def cur(self, set_name='global'):
        return self.sets[set_name].cur()
        
app.register_global("mark", MarkAction())