UI/LogView.py

Thu, 10 Jan 2019 14:18:48 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 10 Jan 2019 14:18:48 +0100
changeset 6645
ad476851d7e0
parent 6573
ccac2d1f6858
permissions
-rw-r--r--

Updated copyright for 2019.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
3 # Copyright (c) 2006 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the log viewer widget and the log widget.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3057
diff changeset
10 from __future__ import unicode_literals
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2409
diff changeset
11
6573
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
12 from PyQt5.QtCore import pyqtSignal, Qt, QRegExp
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
13 from PyQt5.QtGui import QBrush, QTextCursor, QTextDocument
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
14 from PyQt5.QtWidgets import QTextEdit, QApplication, QMenu, QWidget, \
6387
a168b5f26a14 Shell, ShellWindow, LogViewer: fixed the layouts, an ambigous shortcut and added a missing method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
15 QHBoxLayout, QSizePolicy
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 53
diff changeset
17 from E5Gui.E5Application import e5App
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
6573
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
19 from Globals import qVersionTuple
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
20
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 import UI.PixmapCache
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 import Preferences
5020
d0afdfd8e45b Added capability to filter ANSI escape sequences out of output strings. This is limited to color sequences at the moment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
23 import Utilities
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
25
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
26 class LogViewer(QWidget):
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
27 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
28 Class implementing the containing widget for the log viewer.
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
29 """
4083
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
30 def __init__(self, ui, parent=None):
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
31 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
32 Constructor
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
33
4083
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
34 @param ui reference to the main window (UserInterface)
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
35 @param parent reference to the parent widget (QWidget)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
36 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2409
diff changeset
37 super(LogViewer, self).__init__(parent)
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
38
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
39 self.setWindowIcon(UI.PixmapCache.getIcon("eric.png"))
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
40
4083
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
41 self.__ui = ui
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
42
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
43 self.__logViewer = LogViewerEdit(self)
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
44 from .SearchWidget import SearchWidget
6573
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
45 self.__searchWidget = SearchWidget(
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
46 self.__logViewer, self, hideRegExp=qVersionTuple() < (5, 3, 0))
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
47 self.__searchWidget.setSizePolicy(
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
48 QSizePolicy.Fixed, QSizePolicy.Preferred)
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
49 self.__searchWidget.hide()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
50
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
51 self.__layout = QHBoxLayout(self)
1829
fa72a573967f Some fine adjustments to the new search function of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
52 self.__layout.setContentsMargins(1, 1, 1, 1)
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
53 self.__layout.addWidget(self.__logViewer)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
54 self.__layout.addWidget(self.__searchWidget)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
55
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
56 self.__searchWidget.searchNext.connect(self.__logViewer.searchNext)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
57 self.__searchWidget.searchPrevious.connect(self.__logViewer.searchPrev)
3012
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
58 self.__logViewer.searchStringFound.connect(
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
59 self.__searchWidget.searchStringFound)
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
60
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
61 def appendToStdout(self, txt):
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
62 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
63 Public slot to appand text to the "stdout" tab.
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
64
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
65 @param txt text to be appended (string)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
66 """
4083
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
67 added = self.__logViewer.appendToStdout(txt)
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
68 if added:
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
69 self.__ui.showLogViewer()
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
70
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
71 def appendToStderr(self, txt):
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
72 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
73 Public slot to appand text to the "stderr" tab.
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
74
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
75 @param txt text to be appended (string)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
76 """
4083
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
77 added = self.__logViewer.appendToStderr(txt)
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
78 if added:
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
79 self.__ui.showLogViewer()
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
80
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
81 def preferencesChanged(self):
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
82 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
83 Public slot to handle a change of the preferences.
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
84 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
85 self.__logViewer.preferencesChanged()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
86
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
87 def showFind(self, txt=""):
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
88 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
89 Public method to display the search widget.
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
90
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
91 @param txt text to be shown in the combo (string)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
92 """
1830
f2fccb8c2ab4 Added the capability to search in the output of the terminal window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1829
diff changeset
93 self.__searchWidget.showFind(txt)
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
94
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
95
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
96 class LogViewerEdit(QTextEdit):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 Class providing a specialized text edit for displaying logging information.
1830
f2fccb8c2ab4 Added the capability to search in the output of the terminal window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1829
diff changeset
99
3012
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
100 @signal searchStringFound(found) emitted to indicate the search result
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
101 (boolean)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 """
1830
f2fccb8c2ab4 Added the capability to search in the output of the terminal window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1829
diff changeset
103 searchStringFound = pyqtSignal(bool)
f2fccb8c2ab4 Added the capability to search in the output of the terminal window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1829
diff changeset
104
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
105 def __init__(self, parent=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 @param parent reference to the parent widget (QWidget)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2409
diff changeset
111 super(LogViewerEdit, self).__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 self.setAcceptRichText(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 self.setLineWrapMode(QTextEdit.NoWrap)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 self.setReadOnly(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
116 self.__mainWindow = parent
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
117 self.__lastSearch = ()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 # create the context menu
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 self.__menu = QMenu(self)
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
121 self.__menu.addAction(self.tr('Clear'), self.clear)
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
122 self.__menu.addAction(self.tr('Copy'), self.copy)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 self.__menu.addSeparator()
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
124 self.__menu.addAction(self.tr('Find'), self.__find)
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
125 self.__menu.addSeparator()
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
126 self.__menu.addAction(self.tr('Select All'), self.selectAll)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 self.__menu.addSeparator()
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
128 self.__menu.addAction(self.tr("Configure..."), self.__configure)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 self.setContextMenuPolicy(Qt.CustomContextMenu)
458
1695e7a2db54 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
131 self.customContextMenuRequested.connect(self.__handleShowContextMenu)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 self.cNormalFormat = self.currentCharFormat()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 self.cErrorFormat = self.currentCharFormat()
3012
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
135 self.cErrorFormat.setForeground(
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
136 QBrush(Preferences.getUI("LogStdErrColour")))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137
4083
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
138 self.__stdoutFilter = Preferences.getUI("LogViewerStdoutFilter")
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
139 self.__stderrFilter = Preferences.getUI("LogViewerStderrFilter")
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
140 self.__stdxxxFilter = Preferences.getUI("LogViewerStdxxxFilter")
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
141
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 def __handleShowContextMenu(self, coord):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 Private slot to show the context menu.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 @param coord the position of the mouse pointer (QPoint)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 coord = self.mapToGlobal(coord)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 self.__menu.popup(coord)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150
4083
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
151 def __appendText(self, txt, isErrorMessage=False):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
153 Private method to append text to the end.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 @param txt text to insert (string)
4083
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
156 @param isErrorMessage flag indicating to insert error text (boolean)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 tc = self.textCursor()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 tc.movePosition(QTextCursor.End)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 self.setTextCursor(tc)
4083
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
161 if isErrorMessage:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 self.setCurrentCharFormat(self.cErrorFormat)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 self.setCurrentCharFormat(self.cNormalFormat)
5020
d0afdfd8e45b Added capability to filter ANSI escape sequences out of output strings. This is limited to color sequences at the moment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
165 self.insertPlainText(Utilities.filterAnsiSequences(txt))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 self.ensureCursorVisible()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167
4083
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
168 def __filterMessage(self, message, isErrorMessage=False):
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
169 """
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
170 Private method to filter messages.
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
171
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
172 @param message message to be checked (string)
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
173 @param isErrorMessage flag indicating to check an error message
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
174 (boolean)
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
175 @return flag indicating that the message should be filtered out
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
176 (boolean)
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
177 """
5020
d0afdfd8e45b Added capability to filter ANSI escape sequences out of output strings. This is limited to color sequences at the moment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
178 message = Utilities.filterAnsiSequences(message)
d0afdfd8e45b Added capability to filter ANSI escape sequences out of output strings. This is limited to color sequences at the moment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
179
4083
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
180 if isErrorMessage:
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
181 filters = self.__stderrFilter + self.__stdxxxFilter
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
182 else:
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
183 filters = self.__stdoutFilter + self.__stdxxxFilter
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
184 for msgFilter in filters:
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
185 if msgFilter in message:
4083
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
186 return True
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
187
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
188 return False
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
189
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 def appendToStdout(self, txt):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 Public slot to appand text to the "stdout" tab.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 @param txt text to be appended (string)
4083
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
195 @return flag indicating text was appended (boolean)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 """
4083
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
197 if self.__filterMessage(txt, isErrorMessage=False):
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
198 return False
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
199
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
200 self.__appendText(txt, isErrorMessage=False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 QApplication.processEvents()
4083
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
202 return True
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 def appendToStderr(self, txt):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 Public slot to appand text to the "stderr" tab.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 @param txt text to be appended (string)
4083
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
209 @return flag indicating text was appended (boolean)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 """
4083
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
211 if self.__filterMessage(txt, isErrorMessage=True):
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
212 return False
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
213
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
214 self.__appendText(txt, isErrorMessage=True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 QApplication.processEvents()
4083
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
216 return True
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 def preferencesChanged(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 Public slot to handle a change of the preferences.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 """
3012
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
222 self.cErrorFormat.setForeground(
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
223 QBrush(Preferences.getUI("LogStdErrColour")))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224
4083
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
225 self.__stdoutFilter = Preferences.getUI("LogViewerStdoutFilter")
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
226 self.__stderrFilter = Preferences.getUI("LogViewerStderrFilter")
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
227 self.__stdxxxFilter = Preferences.getUI("LogViewerStdxxxFilter")
4418377391bc Added a message filter to the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
228
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 def __configure(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 Private method to open the configuration dialog.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 """
4095
c78cdc1a3c14 Added a configuration page for the log viewer to the configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4083
diff changeset
233 e5App().getObject("UserInterface").showPreferences("logViewerPage")
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
234
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
235 def __find(self):
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
236 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
237 Private slot to show the find widget.
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
238 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
239 txt = self.textCursor().selectedText()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
240 self.__mainWindow.showFind(txt)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
241
6573
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
242 def searchNext(self, txt, caseSensitive, wholeWord, regexp):
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
243 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
244 Public method to search the next occurrence of the given text.
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
245
6573
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
246 @param txt text to search for
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
247 @type str
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
248 @param caseSensitive flag indicating to perform a case sensitive
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
249 search
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
250 @type bool
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
251 @param wholeWord flag indicating to search for whole words
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
252 only
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
253 @type bool
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
254 @param regexp flag indicating a regular expression search
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
255 @type bool
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
256 """
6573
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
257 self.__lastSearch = (txt, caseSensitive, wholeWord, regexp)
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
258 flags = QTextDocument.FindFlags()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
259 if caseSensitive:
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
260 flags |= QTextDocument.FindCaseSensitively
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
261 if wholeWord:
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
262 flags |= QTextDocument.FindWholeWords
6573
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
263 if regexp:
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
264 ok = self.find(QRegExp(
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
265 txt,
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
266 Qt.CaseSensitive if caseSensitive else Qt.CaseInsensitive),
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
267 flags
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
268 )
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
269 else:
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
270 ok = self.find(txt, flags)
1830
f2fccb8c2ab4 Added the capability to search in the output of the terminal window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1829
diff changeset
271 self.searchStringFound.emit(ok)
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
272
6573
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
273 def searchPrev(self, txt, caseSensitive, wholeWord, regexp):
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
274 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
275 Public method to search the previous occurrence of the given text.
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
276
6573
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
277 @param txt text to search for
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
278 @type str
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
279 @param caseSensitive flag indicating to perform a case sensitive
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
280 search
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
281 @type bool
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
282 @param wholeWord flag indicating to search for whole words
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
283 only
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
284 @type bool
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
285 @param regexp flag indicating a regular expression search
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
286 @type bool
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
287 """
6573
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
288 self.__lastSearch = (txt, caseSensitive, wholeWord, regexp)
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
289 flags = QTextDocument.FindFlags(QTextDocument.FindBackward)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
290 if caseSensitive:
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
291 flags |= QTextDocument.FindCaseSensitively
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
292 if wholeWord:
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
293 flags |= QTextDocument.FindWholeWords
6573
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
294 if regexp:
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
295 ok = self.find(QRegExp(
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
296 txt,
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
297 Qt.CaseSensitive if caseSensitive else Qt.CaseInsensitive),
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
298 flags
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
299 )
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
300 else:
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
301 ok = self.find(txt, flags)
1830
f2fccb8c2ab4 Added the capability to search in the output of the terminal window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1829
diff changeset
302 self.searchStringFound.emit(ok)
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
303
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
304 def keyPressEvent(self, evt):
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
305 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
306 Protected method handling key press events.
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
307
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
308 @param evt key press event (QKeyEvent)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
309 """
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
310 if evt.modifiers() == Qt.ControlModifier:
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
311 if evt.key() == Qt.Key_F:
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
312 self.__find()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
313 evt.accept()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
314 return
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
315 elif evt.key() == Qt.Key_C:
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
316 self.copy()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
317 evt.accept()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
318 return
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
319 elif evt.key() == Qt.Key_A:
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
320 self.selectAll()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
321 evt.accept()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
322 return
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
323 elif evt.modifiers() == Qt.NoModifier:
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
324 if evt.key() == Qt.Key_F3 and self.__lastSearch:
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
325 self.searchNext(*self.__lastSearch)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
326 evt.accept()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
327 return
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
328 elif evt.modifiers() == Qt.ShiftModifier and self.__lastSearch:
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
329 if evt.key() == Qt.Key_F3 and self.__lastSearch:
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
330 self.searchPrev(*self.__lastSearch)
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
331 evt.accept()
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
332 return

eric ide

mercurial