24#include "../lout/debug.hh"
25#include "../lout/msg.h"
86 if (this->key == NULL || this->caseSens !=
caseSens ||
87 strcmp (this->key,
key) != 0) {
112 bool firstTrial = !wasHighlighted || newKey;
114 if (
search0 (backwards, firstTrial)) {
117 for (
int i = 0;
key[i]; i++)
168 int len = strlen(str);
169 char *nstr =
new char[len+1];
170 for (
int i = 0; i < len; ++i)
171 nstr[i] = str[len-1 -i];
182 key = (backwards) ?
rev(needle) : needle;
185 int l = strlen (
key);
212 for (
int i = 0;
key[i]; i++)
231 const char* searchKey = (backwards) ?
rev(
key) :
key;
234 int l = strlen (
key);
236 if (backwards && !firstTrial) {
237 _MSG(
"Having to do.");
261 for (
int i=0; i<l-3; i++) {
266 }
else if (backwards && l==1) {
277 }
while (nextit && j < l);
285 for (
int i = 0; i < l; i++)
static void highlight(CharIterator *it1, CharIterator *it2, HighlightLayer layer)
CharIterator * cloneCharIterator()
static void unhighlight(CharIterator *it1, CharIterator *it2, HighlightLayer layer)
static void scrollTo(CharIterator *it1, CharIterator *it2, HPosition hpos, VPosition vpos)
static int * createNexttab(const char *needle, bool caseSens, bool backwards)
CharIterator * hlIterator
The position from where the characters are highlighted.
int * nexttab
The table used for KMP search.
void resetSearch()
This method is called when the user closes the "find text" dialog.
bool search0(bool backwards, bool firstTrial)
@ SUCCESS
The next occurrence of the pattern has been found.
@ NOT_FOUND
The patten does not at all occur in the text.
@ RESTART
There is no further occurrence of the pattern, instead, the first occurrence has been selected.
Result search(const char *key, bool caseSens, bool backwards)
CharIterator * iterator
The position from where the next search will start.
bool unhighlight()
Unhighlight, and return whether a region was highlighted.
static bool charsEqual(char c1, char c2, bool caseSens)
static const char * rev(const char *_str)
char * key
The key used for the last search.
bool caseSens
Whether the last search was case sensitive.
void setWidget(Widget *widget)
Widget * widget
The top of the widget tree, in which the search is done.
#define DBG_OBJ_CREATE(klass)
char * dStrdup(const char *s)
Dw is in this namespace, or sub namespaces of this one.