-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
TextSearch.h
53 lines (42 loc) · 1.62 KB
/
TextSearch.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* Copyright 2022 the SumatraPDF project authors (see AUTHORS file).
License: GPLv3 */
struct TextSearch : public TextSelection {
enum class Direction : bool { Backward = false, Forward = true };
TextSearch(EngineBase* engine, DocumentTextCache* textCache);
~TextSearch();
void SetSensitive(bool sensitive);
void SetDirection(Direction direction);
void SetLastResult(TextSelection* sel);
TextSel* FindFirst(int page, const WCHAR* text);
TextSel* FindNext();
int GetCurrentPageNo() const;
int GetSearchHitStartPageNo() const;
ProgressUpdateCb progressCb;
// Lightweight container for page and offset within the page to use as return value of MatchEnd
struct PageAndOffset {
int page;
int offset;
};
WCHAR* findText = nullptr;
WCHAR* anchor = nullptr;
int findPage = 0;
int searchHitStartAt = 0; // when text found spans several pages, searchHitStartAt < findPage
bool forward = true;
bool caseSensitive = false;
// these two options are implicitly set when the search text begins
// resp. ends in a single space (many users already search that way),
// combining them yields a 'Whole words' search
bool matchWordStart = false;
bool matchWordEnd = false;
void SetText(const WCHAR* text);
bool FindTextInPage(int pageNo, PageAndOffset* finalGlyph);
bool FindStartingAtPage(int pageNo);
PageAndOffset MatchEnd(const WCHAR* start) const;
void Clear();
void Reset();
const WCHAR* pageText = nullptr;
int findIndex = 0;
WCHAR* lastText = nullptr;
int nPages = 0;
Vec<bool> pagesToSkip;
};