Dillo
findtext.hh
Go to the documentation of this file.
1 #ifndef __DW_FINDTEXT_STATE_H__
2 #define __DW_FINDTEXT_STATE_H__
3 
4 #ifndef __INCLUDED_FROM_DW_CORE_HH__
5 # error Do not include this file directly, use "core.hh" instead.
6 #endif
7 
8 #include <ctype.h>
9 
10 namespace dw {
11 namespace core {
12 
14 {
15 public:
16  typedef enum {
19 
25 
28  } Result;
29 
30 private:
37  char *key;
38 
40  bool caseSens;
41 
43  int *nexttab;
44 
51 
54 
61 
62  static const char* rev(const char* _str); /* reverse a C string */
63 
64  static int *createNexttab (const char *needle,bool caseSens,bool backwards);
65  bool unhighlight ();
66  bool search0 (bool backwards, bool firstTrial);
67 
68  inline static bool charsEqual (char c1, char c2, bool caseSens)
69  { return caseSens ? c1 == c2 : tolower (c1) == tolower (c2) ||
70  (isspace (c1) && isspace (c2)); }
71 
72 public:
73  FindtextState ();
74  ~FindtextState ();
75 
76  void setWidget (Widget *widget);
77  Result search (const char *key, bool caseSens, bool backwards);
78  void resetSearch ();
79 };
80 
81 } // namespace core
82 } // namespace dw
83 
84 #endif // __DW_FINDTEXT_STATE_H__
~FindtextState()
Definition: findtext.cc:40
bool unhighlight()
Unhighlight, and return whether a region was highlighted.
Definition: findtext.cc:207
bool search0(bool backwards, bool firstTrial)
Definition: findtext.cc:224
bool caseSens
Whether the last search was case sensitive.
Definition: findtext.hh:40
CharIterator * hlIterator
The position from where the characters are highlighted.
Definition: findtext.hh:60
static int * createNexttab(const char *needle, bool caseSens, bool backwards)
Definition: findtext.cc:176
CharIterator * iterator
The position from where the next search will start.
Definition: findtext.hh:53
Result search(const char *key, bool caseSens, bool backwards)
Definition: findtext.cc:74
static const char * rev(const char *_str)
Definition: findtext.cc:162
static bool charsEqual(char c1, char c2, bool caseSens)
Definition: findtext.hh:68
The next occurrence of the pattern has been found.
Definition: findtext.hh:18
Widget * widget
The top of the widget tree, in which the search is done.
Definition: findtext.hh:50
int * nexttab
The table used for KMP search.
Definition: findtext.hh:43
FindtextState()
Definition: findtext.cc:29
The base class of all dillo widgets.
Definition: widget.hh:23
void resetSearch()
This method is called when the user closes the "find text" dialog.
Definition: findtext.cc:150
Definition: findtext.hh:13
void setWidget(Widget *widget)
Definition: findtext.cc:54
char * key
The key used for the last search.
Definition: findtext.hh:37
The patten does not at all occur in the text.
Definition: findtext.hh:27
Result
Definition: findtext.hh:16
Dw is in this namespace, or sub namespaces of this one.
Definition: alignedtablecell.cc:28
There is no further occurrence of the pattern, instead, the first occurrence has been selected...
Definition: findtext.hh:24
Definition: iterator.hh:230