8#ifndef KATE_SEARCH_BAR_H
9#define KATE_SEARCH_BAR_H 1
11#include "kateviewhelpers.h"
12#include <ktexteditor_export.h>
14#include <ktexteditor/attribute.h>
15#include <ktexteditor/document.h>
27class IncrementalSearchBar;
37class KTEXTEDITOR_EXPORT KateSearchBar :
public KateViewBarWidget
41 friend class SearchBarTest;
49 MODE_ESCAPE_SEQUENCES = 2,
62 enum SearchDirection {
68 explicit KateSearchBar(
bool initAsPower, KTextEditor::ViewPrivate *view, KateViewConfig *config);
69 ~KateSearchBar()
override;
71 void closed()
override;
76 QString replacementPattern()
const;
78 bool selectionOnly()
const;
79 bool matchCase()
const;
81 void nextMatchForSelection(KTextEditor::ViewPrivate *view, SearchDirection searchDirection);
88 void setSearchPattern(
const QString &searchPattern);
94 void setReplacementPattern(
const QString &replacementPattern);
96 void setSearchMode(SearchMode mode);
97 void setSelectionOnly(
bool selectionOnly);
98 void setMatchCase(
bool matchCase);
110 void enterPowerMode();
111 void enterIncrementalMode();
113 bool clearHighlights();
114 void updateHighlightColors();
117 void slotReadWriteChanged();
125 void onIncPatternChanged(
const QString &pattern);
126 void onMatchCaseToggled(
bool matchCase);
128 void onReturnPressed();
129 void updateSelectionOnly();
130 void updateIncInitCursor();
132 void onPowerPatternChanged(
const QString &pattern);
133 void onPowerModeChanged(
int index);
134 void onPowerPatternContextMenuRequest();
135 void onPowerPatternContextMenuRequest(
const QPoint &);
136 void onPowerReplacmentContextMenuRequest();
137 void onPowerReplacmentContextMenuRequest(
const QPoint &);
138 void onPowerCancelFindOrReplace();
145 void findOrReplaceAll();
151 void endFindOrReplaceAll();
157 void findOrReplaceAllFinished();
161 bool find(SearchDirection searchDirection = SearchForward)
163 return findOrReplace(searchDirection,
nullptr);
165 KTEXTEDITOR_NO_EXPORT
166 bool findOrReplace(SearchDirection searchDirection,
const QString *replacement);
172 KTEXTEDITOR_NO_EXPORT
174 KTEXTEDITOR_NO_EXPORT
177 beginFindOrReplaceAll(inputRange,
QString(),
false);
180 KTEXTEDITOR_NO_EXPORT
181 bool isPatternValid()
const;
183 KTEXTEDITOR_NO_EXPORT
186 KTEXTEDITOR_NO_EXPORT
188 KTEXTEDITOR_NO_EXPORT
190 KTEXTEDITOR_NO_EXPORT
191 void indicateMatch(MatchResult matchResult);
192 KTEXTEDITOR_NO_EXPORT
194 KTEXTEDITOR_NO_EXPORT
197 KTEXTEDITOR_NO_EXPORT
199 KTEXTEDITOR_NO_EXPORT
200 void showExtendedContextMenu(
bool forPattern,
const QPoint &pos);
202 KTEXTEDITOR_NO_EXPORT
203 void givePatternFeedback();
204 KTEXTEDITOR_NO_EXPORT
205 void addCurrentTextToHistory(
QComboBox *combo);
206 KTEXTEDITOR_NO_EXPORT
207 void backupConfig(
bool ofPower);
208 KTEXTEDITOR_NO_EXPORT
211 KTEXTEDITOR_NO_EXPORT
212 void showResultMessage();
215 KTextEditor::ViewPrivate *
const m_view;
216 KateViewConfig *
const m_config;
223 QString m_unfinishedSearchText;
226 Ui::IncrementalSearchBar *m_incUi;
230 Ui::PowerSearchBar *m_powerUi =
nullptr;
234 uint m_matchCounter = 0;
235 bool m_replaceMode =
false;
236 bool m_cancelFindOrReplace =
true;
237 bool m_selectionChangedByUndoRedo =
false;
238 std::vector<KTextEditor::Range> m_highlightRanges;
245 bool m_incHighlightAll : 1;
246 bool m_incFromCursor : 1;
247 bool m_incMatchCase : 1;
248 bool m_powerMatchCase : 1;
249 bool m_powerFromCursor : 1;
250 bool m_powerHighlightAll : 1;
251 unsigned int m_powerMode : 2;
The Cursor represents a position in a Document.
A range that is bound to a specific Document, and maintains its position.
An object representing a section of text, from one Cursor to another.
QAction * findNext(const QObject *recvr, const char *slot, QObject *parent)
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
virtual bool eventFilter(QObject *watched, QEvent *event)