File indexing completed on 2024-05-19 05:28:16

0001 /*
0002     SPDX-FileCopyrightText: 2013 Christian Surlykke
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 
0006     This program is distributed in the hope that it will be useful,
0007     but WITHOUT ANY WARRANTY; without even the implied warranty of
0008     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0009     GNU General Public License for more details.
0010 
0011     You should have received a copy of the GNU General Public License
0012     along with this program; if not, write to the Free Software
0013     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0014     02110-1301  USA.
0015 */
0016 #ifndef TASK_H
0017 #define TASK_H
0018 
0019 #include <QMap>
0020 #include <QObject>
0021 #include <QPointer>
0022 #include <QRegExp>
0023 
0024 #include <ScreenWindow.h>
0025 #include <Session.h>
0026 
0027 #include "Emulation.h"
0028 #include "TerminalCharacterDecoder.h"
0029 
0030 class QRegExp;
0031 
0032 using namespace Konsole;
0033 
0034 typedef QPointer<Emulation> EmulationPtr;
0035 
0036 class HistorySearch : public QObject
0037 {
0038     Q_OBJECT
0039 
0040 public:
0041     explicit HistorySearch(EmulationPtr emulation, const QRegExp &regExp, bool forwards, int startColumn, int startLine, QObject *parent);
0042 
0043     ~HistorySearch() override;
0044 
0045     void search();
0046 
0047 Q_SIGNALS:
0048     void matchFound(int startColumn, int startLine, int endColumn, int endLine);
0049     void noMatchFound();
0050 
0051 private:
0052     bool search(int startColumn, int startLine, int endColumn, int endLine);
0053     int findLineNumberInString(QList<int> linePositions, int position);
0054 
0055     EmulationPtr m_emulation;
0056     QRegExp m_regExp;
0057     bool m_forwards;
0058     int m_startColumn;
0059     int m_startLine;
0060 
0061     int m_foundStartColumn;
0062     int m_foundStartLine;
0063     int m_foundEndColumn;
0064     int m_foundEndLine;
0065 };
0066 
0067 #endif /* TASK_H */