Plugins/ViewManagerPlugins/Tabview/Tabview.py

changeset 2769
8cbebde7a984
parent 2763
e4794166ad70
child 2770
fd5ee85f0450
--- a/Plugins/ViewManagerPlugins/Tabview/Tabview.py	Wed Jul 03 19:34:42 2013 +0200
+++ b/Plugins/ViewManagerPlugins/Tabview/Tabview.py	Fri Jul 05 19:17:29 2013 +0200
@@ -341,6 +341,7 @@
         if not editor in self.editors:
             self.editors.append(editor)
             editor.captionChanged.connect(self.__captionChange)
+            editor.cursorLineChanged.connect(self.__cursorLineChanged)
         
         emptyIndex = self.indexOf(self.emptyLabel)
         if emptyIndex > -1:
@@ -369,7 +370,7 @@
         if not editor in self.editors:
             self.editors.append(editor)
             editor.captionChanged.connect(self.__captionChange)
-        
+            editor.cursorLineChanged.connect(self.__cursorLineChanged)        
         emptyIndex = self.indexOf(self.emptyLabel)
         if emptyIndex > -1:
             self.removeTab(emptyIndex)
@@ -378,7 +379,7 @@
         
     def __captionChange(self, cap, editor):
         """
-        Private method to handle Caption change signals from the editor.
+        Private slot to handle Caption change signals from the editor.
         
         Updates the tab text and tooltip text to reflect the new caption information.
         
@@ -404,6 +405,18 @@
                 self.setTabText(index, txt)
                 self.setTabToolTip(index, fn)
         
+    def __cursorLineChanged(self, lineno):
+        """
+        Private slot to handle a change of the current editor's cursor line.
+        
+        @param lineno line number of the current editor's cursor (zero based)
+        """
+        editor = self.sender()
+        if editor:
+            fn = editor.getFileName()
+            if fn:
+                self.vm.editorLineChanged.emit(fn, lineno + 1)
+        
     def removeWidget(self, object):
         """
         Public method to remove a widget.
@@ -411,6 +424,7 @@
         @param object object to be removed (QWidget)
         """
         if isinstance(object, QScintilla.Editor.Editor):
+            object.cursorLineChanged.disconnect(self.__cursorLineChanged)
             object.captionChanged.disconnect(self.__captionChange)
             self.editors.remove(object)
             index = self.indexOf(object.parent())
@@ -680,6 +694,8 @@
     @signal editorLanguageChanged(Editor) emitted to signal a change of an
             editors language
     @signal editorTextChanged(Editor) emitted to signal a change of an editor's text
+    @signal editorLineChanged(str,int) emitted to signal a change of an editor's
+            current line (line is given one based)
     """
     changeCaption = pyqtSignal(str)
     editorChanged = pyqtSignal(str)
@@ -698,6 +714,7 @@
     previewStateChanged = pyqtSignal(bool)
     editorLanguageChanged = pyqtSignal(Editor)
     editorTextChanged = pyqtSignal(Editor)
+    editorLineChanged = pyqtSignal(str, int)
     
     def __init__(self, parent):
         """
@@ -798,6 +815,7 @@
         if fn:
             self.changeCaption.emit(fn)
             self.editorChanged.emit(fn)
+            self.editorLineChanged.emit(fn, aw.getCursorPosition()[0] + 1)
         else:
             self.changeCaption.emit("")
         self.editorChangedEd.emit(aw)
@@ -835,6 +853,7 @@
         if fn:
             self.changeCaption.emit(fn)
             self.editorChanged.emit(fn)
+            self.editorLineChanged.emit(fn, editor.getCursorPosition()[0] + 1)
         else:
             self.changeCaption.emit("")
         self.editorChangedEd.emit(editor)
@@ -873,6 +892,7 @@
         if fn:
             self.changeCaption.emit(fn)
             self.editorChanged.emit(fn)
+            self.editorLineChanged.emit(fn, editor.getCursorPosition()[0] + 1)
         else:
             self.changeCaption.emit("")
         self.editorChangedEd.emit(editor)
@@ -1104,6 +1124,7 @@
             self.changeCaption.emit(fn)
             if not self.__inRemoveView:
                 self.editorChanged.emit(fn)
+                self.editorLineChanged.emit(fn, editor.getCursorPosition()[0] + 1)
         else:
             self.changeCaption.emit("")
         self.editorChangedEd.emit(editor)
@@ -1145,6 +1166,7 @@
                     self.changeCaption.emit(fn)
                     if switched:
                         self.editorChanged.emit(fn)
+                        self.editorLineChanged.emit(fn, aw.getCursorPosition()[0] + 1)
                 else:
                     self.changeCaption.emit("")
                 self.editorChangedEd.emit(aw)

eric ide

mercurial