ViewManager/ViewManager.py

changeset 372
237c3fe739f5
parent 365
0686ac00256e
child 432
497e188ee86e
--- a/ViewManager/ViewManager.py	Mon Jun 28 19:02:47 2010 +0200
+++ b/ViewManager/ViewManager.py	Mon Jun 28 20:00:21 2010 +0200
@@ -5052,3 +5052,54 @@
                 curline, curindex = aw.getCursorPosition()
                 aw.insert(txt)
                 aw.setCursorPosition(curline, curindex + len(txt))
+    
+    #######################################################################
+    ## Numbers viewer related methods
+    #######################################################################
+    
+    def insertNumber(self, txt):
+        """
+        Private slot to insert a number text into the active window.
+        
+        @param txt text to be inserted (string)
+        """
+        if self.__lastFocusWidget == e5App().getObject("Shell"):
+            aw = e5App().getObject("Shell")
+            if aw.hasSelectedText():
+                aw.removeSelectedText()
+            aw.insert(txt)
+        elif self.__lastFocusWidget == e5App().getObject("Terminal"):
+            aw = e5App().getObject("Terminal")
+            if aw.hasSelectedText():
+                aw.removeSelectedText()
+            aw.insert(txt)
+        else:
+            aw = self.activeWindow()
+            if aw is not None:
+                if aw.hasSelectedText():
+                    aw.removeSelectedText()
+                curline, curindex = aw.getCursorPosition()
+                aw.insert(txt)
+                aw.setCursorPosition(curline, curindex + len(txt))
+    
+    def getNumber(self):
+        """
+        Public method to get a number from the active window.
+        
+        @return selected text of the active window (string)
+        """
+        txt = ""
+        if self.__lastFocusWidget == e5App().getObject("Shell"):
+            aw = e5App().getObject("Shell")
+            if aw.hasSelectedText():
+                txt = aw.selectedText()
+        elif self.__lastFocusWidget == e5App().getObject("Terminal"):
+            aw = e5App().getObject("Terminal")
+            if aw.hasSelectedText():
+                txt = aw.selectedText()
+        else:
+            aw = self.activeWindow()
+            if aw is not None:
+                if aw.hasSelectedText():
+                    txt = aw.selectedText()
+        return txt

eric ide

mercurial