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,
53 enum MatchResult { MatchFound, MatchWrappedForward, MatchWrappedBackward, MatchMismatch, MatchNothing, MatchNeutral };
55 enum SearchDirection { SearchForward, SearchBackward };
58 explicit KateSearchBar(
bool initAsPower, KTextEditor::ViewPrivate *view, KateViewConfig *config);
59 ~KateSearchBar()
override;
61 void closed()
override;
66 QString replacementPattern()
const;
68 bool selectionOnly()
const;
69 bool matchCase()
const;
71 void nextMatchForSelection(KTextEditor::ViewPrivate *view, SearchDirection searchDirection);
78 void setSearchPattern(
const QString &searchPattern);
84 void setReplacementPattern(
const QString &replacementPattern);
86 void setSearchMode(SearchMode mode);
87 void setSelectionOnly(
bool selectionOnly);
88 void setMatchCase(
bool matchCase);
100 void enterPowerMode();
101 void enterIncrementalMode();
103 bool clearHighlights();
104 void updateHighlightColors();
107 void slotReadWriteChanged();
115 void onIncPatternChanged(
const QString &pattern);
116 void onMatchCaseToggled(
bool matchCase);
118 void onReturnPressed();
119 void updateSelectionOnly();
120 void updateIncInitCursor();
122 void onPowerPatternChanged(
const QString &pattern);
123 void onPowerModeChanged(
int index);
124 void onPowerPatternContextMenuRequest();
125 void onPowerPatternContextMenuRequest(
const QPoint &);
126 void onPowerReplacmentContextMenuRequest();
127 void onPowerReplacmentContextMenuRequest(
const QPoint &);
128 void onPowerCancelFindOrReplace();
135 void findOrReplaceAll();
141 void endFindOrReplaceAll();
147 void findOrReplaceAllFinished();
151 bool find(SearchDirection searchDirection = SearchForward)
153 return findOrReplace(searchDirection,
nullptr);
155 KTEXTEDITOR_NO_EXPORT
156 bool findOrReplace(SearchDirection searchDirection,
const QString *replacement);
162 KTEXTEDITOR_NO_EXPORT
164 KTEXTEDITOR_NO_EXPORT
167 beginFindOrReplaceAll(inputRange,
QString(),
false);
170 KTEXTEDITOR_NO_EXPORT
171 bool isPatternValid()
const;
173 KTEXTEDITOR_NO_EXPORT
176 KTEXTEDITOR_NO_EXPORT
178 KTEXTEDITOR_NO_EXPORT
180 KTEXTEDITOR_NO_EXPORT
181 void indicateMatch(MatchResult matchResult);
182 KTEXTEDITOR_NO_EXPORT
184 KTEXTEDITOR_NO_EXPORT
187 KTEXTEDITOR_NO_EXPORT
189 KTEXTEDITOR_NO_EXPORT
190 void showExtendedContextMenu(
bool forPattern,
const QPoint &pos);
192 KTEXTEDITOR_NO_EXPORT
193 void givePatternFeedback();
194 KTEXTEDITOR_NO_EXPORT
195 void addCurrentTextToHistory(
QComboBox *combo);
196 KTEXTEDITOR_NO_EXPORT
197 void backupConfig(
bool ofPower);
198 KTEXTEDITOR_NO_EXPORT
201 KTEXTEDITOR_NO_EXPORT
202 void showResultMessage();
205 KTextEditor::ViewPrivate *
const m_view;
206 KateViewConfig *
const m_config;
213 QString m_unfinishedSearchText;
216 Ui::IncrementalSearchBar *m_incUi;
220 Ui::PowerSearchBar *m_powerUi =
nullptr;
224 uint m_matchCounter = 0;
225 bool m_replaceMode =
false;
226 bool m_cancelFindOrReplace =
true;
227 bool m_selectionChangedByUndoRedo =
false;
228 std::vector<KTextEditor::Range> m_highlightRanges;
235 bool m_incHighlightAll : 1;
236 bool m_incFromCursor : 1;
237 bool m_incMatchCase : 1;
238 bool m_powerMatchCase : 1;
239 bool m_powerFromCursor : 1;
240 bool m_powerHighlightAll : 1;
241 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.
QFlags< SearchOption > SearchOptions
Stores a combination of #SearchOption values.
const QList< QKeySequence > & findNext()
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
virtual bool eventFilter(QObject *watched, QEvent *event)