5050 aw = self.activeWindow() |
5050 aw = self.activeWindow() |
5051 if aw is not None: |
5051 if aw is not None: |
5052 curline, curindex = aw.getCursorPosition() |
5052 curline, curindex = aw.getCursorPosition() |
5053 aw.insert(txt) |
5053 aw.insert(txt) |
5054 aw.setCursorPosition(curline, curindex + len(txt)) |
5054 aw.setCursorPosition(curline, curindex + len(txt)) |
|
5055 |
|
5056 ####################################################################### |
|
5057 ## Numbers viewer related methods |
|
5058 ####################################################################### |
|
5059 |
|
5060 def insertNumber(self, txt): |
|
5061 """ |
|
5062 Private slot to insert a number text into the active window. |
|
5063 |
|
5064 @param txt text to be inserted (string) |
|
5065 """ |
|
5066 if self.__lastFocusWidget == e5App().getObject("Shell"): |
|
5067 aw = e5App().getObject("Shell") |
|
5068 if aw.hasSelectedText(): |
|
5069 aw.removeSelectedText() |
|
5070 aw.insert(txt) |
|
5071 elif self.__lastFocusWidget == e5App().getObject("Terminal"): |
|
5072 aw = e5App().getObject("Terminal") |
|
5073 if aw.hasSelectedText(): |
|
5074 aw.removeSelectedText() |
|
5075 aw.insert(txt) |
|
5076 else: |
|
5077 aw = self.activeWindow() |
|
5078 if aw is not None: |
|
5079 if aw.hasSelectedText(): |
|
5080 aw.removeSelectedText() |
|
5081 curline, curindex = aw.getCursorPosition() |
|
5082 aw.insert(txt) |
|
5083 aw.setCursorPosition(curline, curindex + len(txt)) |
|
5084 |
|
5085 def getNumber(self): |
|
5086 """ |
|
5087 Public method to get a number from the active window. |
|
5088 |
|
5089 @return selected text of the active window (string) |
|
5090 """ |
|
5091 txt = "" |
|
5092 if self.__lastFocusWidget == e5App().getObject("Shell"): |
|
5093 aw = e5App().getObject("Shell") |
|
5094 if aw.hasSelectedText(): |
|
5095 txt = aw.selectedText() |
|
5096 elif self.__lastFocusWidget == e5App().getObject("Terminal"): |
|
5097 aw = e5App().getObject("Terminal") |
|
5098 if aw.hasSelectedText(): |
|
5099 txt = aw.selectedText() |
|
5100 else: |
|
5101 aw = self.activeWindow() |
|
5102 if aw is not None: |
|
5103 if aw.hasSelectedText(): |
|
5104 txt = aw.selectedText() |
|
5105 return txt |