00001 #ifndef __DW_FINDTEXT_STATE_H__
00002 #define __DW_FINDTEXT_STATE_H__
00003
00004 #ifndef __INCLUDED_FROM_DW_CORE_HH__
00005 # error Do not include this file directly, use "core.hh" instead.
00006 #endif
00007
00008 #include <ctype.h>
00009
00010 namespace dw {
00011 namespace core {
00012
00013 class FindtextState
00014 {
00015 public:
00016 typedef enum {
00018 SUCCESS,
00019
00024 RESTART,
00025
00027 NOT_FOUND
00028 } Result;
00029
00030 private:
00037 char *key;
00038
00040 bool caseSens;
00041
00043 int *nexttab;
00044
00050 Widget *widget;
00051
00053 CharIterator *iterator;
00054
00060 CharIterator *hlIterator;
00061
00062 static const char* rev(const char* _str);
00063
00064 static int *createNexttab (const char *needle,bool caseSens,bool backwards);
00065 bool unhighlight ();
00066 bool search0 (bool backwards, bool firstTrial);
00067
00068 inline static bool charsEqual (char c1, char c2, bool caseSens)
00069 { return caseSens ? c1 == c2 : tolower (c1) == tolower (c2) ||
00070 (isspace (c1) && isspace (c2)); }
00071
00072 public:
00073 FindtextState ();
00074 ~FindtextState ();
00075
00076 void setWidget (Widget *widget);
00077 Result search (const char *key, bool caseSens, bool backwards);
00078 void resetSearch ();
00079 };
00080
00081 }
00082 }
00083
00084 #endif // __DW_FINDTEXT_STATE_H__