QScintilla/Shell.py

changeset 2640
dedcd4f987e0
parent 2474
8727522a69d5
child 2677
3d4277929fb3
child 2940
e9348df06994
--- a/QScintilla/Shell.py	Sun Apr 28 15:38:35 2013 +0200
+++ b/QScintilla/Shell.py	Wed May 01 14:47:38 2013 +0200
@@ -138,6 +138,7 @@
         ))
         
         self.userListActivated.connect(self.__completionListSelected)
+        self.linesChanged.connect(self.__resizeLinenoMargin)
         
         self.__showStdOutErr = Preferences.getShell("ShowStdOutErr")
         if self.__showStdOutErr:
@@ -154,7 +155,7 @@
         dbs.clientSyntaxError.connect(self.__clientError)
         self.dbs = dbs
         
-        # Initialise instance variables.
+        # Initialize instance variables.
         self.__initialise()
         self.prline = 0
         self.prcol = 0
@@ -273,6 +274,14 @@
         
         self.grabGesture(Qt.PinchGesture)
         
+    def __resizeLinenoMargin(self):
+        """
+        Private slot to resize the line numbers margin.
+        """
+        linenoMargin = Preferences.getShell("LinenoMargin")
+        if linenoMargin:
+            self.setMarginWidth(0, '8' * (len(str(self.lines())) + 1))
+        
     def closeShell(self):
         """
         Public method to shutdown the shell.
@@ -331,7 +340,7 @@
         linenoMargin = Preferences.getShell("LinenoMargin")
         self.setMarginLineNumbers(0, linenoMargin)
         if linenoMargin:
-            self.setMarginWidth(0, ' ' + '8' * Preferences.getShell("LinenoWidth"))
+            self.__resizeLinenoMargin()
         else:
             self.setMarginWidth(0, 0)
         

eric ide

mercurial