1 | /* |
---|
2 | Copyright 2013 Christian Surlykke |
---|
3 | |
---|
4 | This program is free software; you can redistribute it and/or modify |
---|
5 | it under the terms of the GNU General Public License as published by |
---|
6 | the Free Software Foundation; either version 2 of the License, or |
---|
7 | (at your option) any later version. |
---|
8 | |
---|
9 | This program is distributed in the hope that it will be useful, |
---|
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
12 | GNU General Public License for more details. |
---|
13 | |
---|
14 | You should have received a copy of the GNU General Public License |
---|
15 | along with this program; if not, write to the Free Software |
---|
16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
---|
17 | 02110-1301 USA. |
---|
18 | */ |
---|
19 | #ifndef TASK_H |
---|
20 | #define TASK_H |
---|
21 | |
---|
22 | #include <QObject> |
---|
23 | #include <QPointer> |
---|
24 | #include <QMap> |
---|
25 | |
---|
26 | #include <Session.h> |
---|
27 | #include <ScreenWindow.h> |
---|
28 | |
---|
29 | #include "Emulation.h" |
---|
30 | #include "TerminalCharacterDecoder.h" |
---|
31 | |
---|
32 | #if QT_VERSION >= 0x060000 |
---|
33 | #include <QRegularExpression> |
---|
34 | #include <QtCore5Compat/QRegExp> |
---|
35 | #endif |
---|
36 | |
---|
37 | using namespace Konsole; |
---|
38 | |
---|
39 | typedef QPointer<Emulation> EmulationPtr; |
---|
40 | #if QT_VERSION >= 0x060000 |
---|
41 | typedef QRegularExpression RegExp; |
---|
42 | #else |
---|
43 | typedef QRegExp RegExp; |
---|
44 | #endif |
---|
45 | class HistorySearch : public QObject |
---|
46 | { |
---|
47 | Q_OBJECT |
---|
48 | |
---|
49 | public: |
---|
50 | explicit HistorySearch(EmulationPtr emulation, const RegExp& regExp, bool forwards, |
---|
51 | int startColumn, int startLine, QObject* parent); |
---|
52 | |
---|
53 | ~HistorySearch() override; |
---|
54 | |
---|
55 | void search(); |
---|
56 | |
---|
57 | signals: |
---|
58 | void matchFound(int startColumn, int startLine, int endColumn, int endLine); |
---|
59 | void noMatchFound(); |
---|
60 | |
---|
61 | private: |
---|
62 | bool search(int startColumn, int startLine, int endColumn, int endLine); |
---|
63 | int findLineNumberInString(QList<int> linePositions, int position); |
---|
64 | |
---|
65 | |
---|
66 | EmulationPtr m_emulation; |
---|
67 | RegExp m_regExp; |
---|
68 | bool m_forwards; |
---|
69 | int m_startColumn; |
---|
70 | int m_startLine; |
---|
71 | |
---|
72 | int m_foundStartColumn; |
---|
73 | int m_foundStartLine; |
---|
74 | int m_foundEndColumn; |
---|
75 | int m_foundEndLine; |
---|
76 | }; |
---|
77 | |
---|
78 | #endif /* TASK_H */ |
---|
79 | |
---|