src/eric7/UI/LogView.py

branch
eric7
changeset 10433
328f3ec4b77a
parent 9653
e67609152c5e
child 10439
21c28b0f9e41
equal deleted inserted replaced
10432:2fe91fe443dd 10433:328f3ec4b77a
32 32
33 def __init__(self, ui, parent=None): 33 def __init__(self, ui, parent=None):
34 """ 34 """
35 Constructor 35 Constructor
36 36
37 @param ui reference to the main window (UserInterface) 37 @param ui reference to the main window
38 @param parent reference to the parent widget (QWidget) 38 @type UserInterface
39 @param parent reference to the parent widget
40 @type QWidget
39 """ 41 """
40 super().__init__(parent) 42 super().__init__(parent)
41 43
42 self.setWindowIcon(EricPixmapCache.getIcon("eric")) 44 self.setWindowIcon(EricPixmapCache.getIcon("eric"))
43 45
63 65
64 def appendToStdout(self, txt): 66 def appendToStdout(self, txt):
65 """ 67 """
66 Public slot to appand text to the "stdout" tab. 68 Public slot to appand text to the "stdout" tab.
67 69
68 @param txt text to be appended (string) 70 @param txt text to be appended
71 @type str
69 """ 72 """
70 added = self.__logViewer.appendToStdout(txt) 73 added = self.__logViewer.appendToStdout(txt)
71 if added: 74 if added:
72 self.__ui.showLogViewer() 75 self.__ui.showLogViewer()
73 76
74 def appendToStderr(self, txt): 77 def appendToStderr(self, txt):
75 """ 78 """
76 Public slot to appand text to the "stderr" tab. 79 Public slot to appand text to the "stderr" tab.
77 80
78 @param txt text to be appended (string) 81 @param txt text to be appended
82 @type str
79 """ 83 """
80 added = self.__logViewer.appendToStderr(txt) 84 added = self.__logViewer.appendToStderr(txt)
81 if added: 85 if added:
82 self.__ui.showLogViewer() 86 self.__ui.showLogViewer()
83 87
89 93
90 def showFind(self, txt=""): 94 def showFind(self, txt=""):
91 """ 95 """
92 Public method to display the search widget. 96 Public method to display the search widget.
93 97
94 @param txt text to be shown in the combo (string) 98 @param txt text to be shown in the combo
99 @type str
95 """ 100 """
96 self.__searchWidget.showFind(txt) 101 self.__searchWidget.showFind(txt)
97 102
98 103
99 class LogViewerEdit(QTextEdit): 104 class LogViewerEdit(QTextEdit):
108 113
109 def __init__(self, parent=None): 114 def __init__(self, parent=None):
110 """ 115 """
111 Constructor 116 Constructor
112 117
113 @param parent reference to the parent widget (QWidget) 118 @param parent reference to the parent widget
119 @type QWidget
114 """ 120 """
115 super().__init__(parent) 121 super().__init__(parent)
116 self.setAcceptRichText(False) 122 self.setAcceptRichText(False)
117 self.setLineWrapMode(QTextEdit.LineWrapMode.NoWrap) 123 self.setLineWrapMode(QTextEdit.LineWrapMode.NoWrap)
118 self.setReadOnly(True) 124 self.setReadOnly(True)
144 150
145 def __handleShowContextMenu(self, coord): 151 def __handleShowContextMenu(self, coord):
146 """ 152 """
147 Private slot to show the context menu. 153 Private slot to show the context menu.
148 154
149 @param coord the position of the mouse pointer (QPoint) 155 @param coord the position of the mouse pointer
156 @type QPoint
150 """ 157 """
151 coord = self.mapToGlobal(coord) 158 coord = self.mapToGlobal(coord)
152 self.__menu.popup(coord) 159 self.__menu.popup(coord)
153 160
154 def __appendText(self, txt, isErrorMessage=False): 161 def __appendText(self, txt, isErrorMessage=False):
155 """ 162 """
156 Private method to append text to the end. 163 Private method to append text to the end.
157 164
158 @param txt text to insert (string) 165 @param txt text to insert
159 @param isErrorMessage flag indicating to insert error text (boolean) 166 @type str
167 @param isErrorMessage flag indicating to insert error text
168 @type bool
160 """ 169 """
161 tc = self.textCursor() 170 tc = self.textCursor()
162 tc.movePosition(QTextCursor.MoveOperation.End) 171 tc.movePosition(QTextCursor.MoveOperation.End)
163 self.setTextCursor(tc) 172 self.setTextCursor(tc)
164 if isErrorMessage: 173 if isErrorMessage:
170 179
171 def __filterMessage(self, message, isErrorMessage=False): 180 def __filterMessage(self, message, isErrorMessage=False):
172 """ 181 """
173 Private method to filter messages. 182 Private method to filter messages.
174 183
175 @param message message to be checked (string) 184 @param message message to be checked
185 @type str
176 @param isErrorMessage flag indicating to check an error message 186 @param isErrorMessage flag indicating to check an error message
177 (boolean) 187 @type bool
178 @return flag indicating that the message should be filtered out 188 @return flag indicating that the message should be filtered out
179 (boolean) 189 @rtype bool
180 """ 190 """
181 message = Utilities.filterAnsiSequences(message) 191 message = Utilities.filterAnsiSequences(message)
182 192
183 filters = ( 193 filters = (
184 self.__stderrFilter + self.__stdxxxFilter 194 self.__stderrFilter + self.__stdxxxFilter
188 198
189 return any(msgFilter in message for msgFilter in filters) 199 return any(msgFilter in message for msgFilter in filters)
190 200
191 def appendToStdout(self, txt): 201 def appendToStdout(self, txt):
192 """ 202 """
193 Public slot to appand text to the "stdout" tab. 203 Public slot to append text to the "stdout" tab.
194 204
195 @param txt text to be appended (string) 205 @param txt text to be appended
196 @return flag indicating text was appended (boolean) 206 @type str
207 @return flag indicating text was appended
208 @rtype bool
197 """ 209 """
198 if self.__filterMessage(txt, isErrorMessage=False): 210 if self.__filterMessage(txt, isErrorMessage=False):
199 return False 211 return False
200 212
201 self.__appendText(txt, isErrorMessage=False) 213 self.__appendText(txt, isErrorMessage=False)
202 QApplication.processEvents() 214 QApplication.processEvents()
203 return True 215 return True
204 216
205 def appendToStderr(self, txt): 217 def appendToStderr(self, txt):
206 """ 218 """
207 Public slot to appand text to the "stderr" tab. 219 Public slot to append text to the "stderr" tab.
208 220
209 @param txt text to be appended (string) 221 @param txt text to be appended
210 @return flag indicating text was appended (boolean) 222 @type str
223 @return flag indicating text was appended
224 @rtype bool
211 """ 225 """
212 if self.__filterMessage(txt, isErrorMessage=True): 226 if self.__filterMessage(txt, isErrorMessage=True):
213 return False 227 return False
214 228
215 self.__appendText(txt, isErrorMessage=True) 229 self.__appendText(txt, isErrorMessage=True)
243 """ 257 """
244 Public method to search the next occurrence of the given text. 258 Public method to search the next occurrence of the given text.
245 259
246 @param txt text to search for 260 @param txt text to search for
247 @type str 261 @type str
248 @param caseSensitive flag indicating to perform a case sensitive 262 @param caseSensitive flag indicating to perform a case sensitive search
249 search 263 @type bool
250 @type bool 264 @param wholeWord flag indicating to search for whole words only
251 @param wholeWord flag indicating to search for whole words
252 only
253 @type bool 265 @type bool
254 @param regexp flag indicating a regular expression search 266 @param regexp flag indicating a regular expression search
255 @type bool 267 @type bool
256 """ 268 """
257 self.__lastSearch = (txt, caseSensitive, wholeWord, regexp) 269 self.__lastSearch = (txt, caseSensitive, wholeWord, regexp)
279 """ 291 """
280 Public method to search the previous occurrence of the given text. 292 Public method to search the previous occurrence of the given text.
281 293
282 @param txt text to search for 294 @param txt text to search for
283 @type str 295 @type str
284 @param caseSensitive flag indicating to perform a case sensitive 296 @param caseSensitive flag indicating to perform a case sensitive search
285 search 297 @type bool
286 @type bool 298 @param wholeWord flag indicating to search for whole words only
287 @param wholeWord flag indicating to search for whole words
288 only
289 @type bool 299 @type bool
290 @param regexp flag indicating a regular expression search 300 @param regexp flag indicating a regular expression search
291 @type bool 301 @type bool
292 """ 302 """
293 self.__lastSearch = (txt, caseSensitive, wholeWord, regexp) 303 self.__lastSearch = (txt, caseSensitive, wholeWord, regexp)
313 323
314 def keyPressEvent(self, evt): 324 def keyPressEvent(self, evt):
315 """ 325 """
316 Protected method handling key press events. 326 Protected method handling key press events.
317 327
318 @param evt key press event (QKeyEvent) 328 @param evt key press event
329 @type QKeyEvent
319 """ 330 """
320 if evt.modifiers() == Qt.KeyboardModifier.ControlModifier: 331 if evt.modifiers() == Qt.KeyboardModifier.ControlModifier:
321 if evt.key() == Qt.Key.Key_F: 332 if evt.key() == Qt.Key.Key_F:
322 self.__find() 333 self.__find()
323 evt.accept() 334 evt.accept()

eric ide

mercurial