File indexing completed on 2025-01-19 04:23:26

0001 /*
0002     Copyright 2013 Christian Surlykke
0003 
0004     This program is free software; you can redistribute it and/or modify
0005     it under the terms of the GNU General Public License as published by
0006     the Free Software Foundation; either version 2 of the License, or
0007     (at your option) any later version.
0008 
0009     This program is distributed in the hope that it will be useful,
0010     but WITHOUT ANY WARRANTY; without even the implied warranty of
0011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012     GNU General Public License for more details.
0013 
0014     You should have received a copy of the GNU General Public License
0015     along with this program; if not, write to the Free Software
0016     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0017     02110-1301  USA.
0018 */
0019 #ifndef TASK_H
0020 #define TASK_H
0021 
0022 #include <QObject>
0023 #include <QPointer>
0024 #include <QMap>
0025 
0026 #include <Session.h>
0027 #include <ScreenWindow.h>
0028 
0029 #include "Emulation.h"
0030 #include "TerminalCharacterDecoder.h"
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, QRegExp regExp, bool forwards,
0042                            int startColumn, int startLine, QObject* parent);
0043 
0044     ~HistorySearch();
0045 
0046     void search();
0047 
0048 Q_SIGNALS:
0049     void matchFound(int startColumn, int startLine, int endColumn, int endLine);
0050     void noMatchFound();
0051 
0052 private:
0053     bool search(int startColumn, int startLine, int endColumn, int endLine);
0054     int findLineNumberInString(QList<int> linePositions, int position);
0055 
0056 
0057     EmulationPtr m_emulation;
0058     QRegExp m_regExp;
0059     bool m_forwards;
0060     int m_startColumn;
0061     int m_startLine;
0062 
0063     int m_foundStartColumn;
0064     int m_foundStartLine;
0065     int m_foundEndColumn;
0066     int m_foundEndLine;
0067 };
0068 
0069 #endif  /* TASK_H */
0070