1 /*
2   FXiTe - The Free eXtensIble Text Editor
3   Copyright (c) 2009-2011 Jeffrey Pohlmeyer <yetanothergeek@gmail.com>
4 
5   This program is free software; you can redistribute it and/or modify it
6   under the terms of the GNU General Public License version 3 as
7   published by the Free Software Foundation.
8 
9   This software is distributed in the hope that it will be useful,
10   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   GNU General Public License for more details.
13 
14   You should have received a copy of the GNU General Public License
15   along with this program; if not, write to the Free Software
16   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17 */
18 
19 
20 class SciSearchOptions: public FXHorizontalFrame {
FXDECLARE(SciSearchOptions)21   FXDECLARE(SciSearchOptions)
22 protected:
23   SciSearchOptions(){}
24   FXCheckButton*matchcase;
25   FXListBox*modelist;
26 public:
27   SciSearchOptions(FXComposite *p, FXObject *tgt=NULL, FXSelector sel=0);
28   long onToggleChk(FXObject*o, FXSelector sel, void*p);
29   void SetSciFlags(FXuint n);
30   enum {
31     ID_TOGGLE_CHK=FXHorizontalFrame::ID_LAST,
32     ID_EXTERN_MOD,
33     ID_LAST
34   };
35 };
36 
37 
38 typedef enum {
39   SEARCH_WRAP_NEVER,
40   SEARCH_WRAP_ALWAYS,
41   SEARCH_WRAP_ASK
42 } SearchWrapPolicy;
43 
44 
45 typedef enum {
46   SEARCH_GUI_ABOVE,
47   SEARCH_GUI_BELOW,
48   SEARCH_GUI_FLOAT
49 } SearchDialogStyle;
50 
51 
52 class SciReplGui;
53 
54 
55 class SearchDialogs: public FXObject {
56   FXDECLARE(SearchDialogs);
SearchDialogs()57   SearchDialogs() {}
58 private:
59   bool FindText(bool forward, bool wrap);
60   bool DoFind(bool forward);
61   FXHorizontalFrame*srchpan;
62   FXDialogBox*srchdlg;
63   FXComposite*container;
64   SciReplGui*find_gui;
65   SciReplGui*repl_gui;
66   FXComposite*parent;
67   FXSelector message;
68   FXObject*target;
69   bool find_initial;
70   bool repl_initial;
71   bool repl_ready;
72   SearchDialogStyle gui_style;
73   FXObjectList hist_queue;
74   FXuint NextSearch(FXuint code);
75   FXuint NextReplace(FXuint code, bool forward);
76   FXString replacestring;
77   bool SearchFailed();
78   void SetGuiStyle(FXuint style);
79   void SaveHistoryQueue();
80 public:
81   void SearchFailed(FXWindow*w);
82   bool SearchWrapAsk(FXWindow*w);
83   SearchWrapPolicy searchwrap;
84   bool searchverbose;
85   FXuint searchmode;
86   FXuint searchdirn;
87   FXuint defaultsearchmode;
88   FXString searchstring;
89   void SetPrefs(FXuint mode, FXuint wrap, bool verbose, FXuint style);
90   void ShowFindDialog();
91   void ShowReplaceDialog();
92   void FindNext();
93   void FindPrev();
94   void FindPhrase(const char* searchfor, FXuint mode, bool forward);
95   void FindAndReplace(const char*searchfor, const char*replacewith, FXuint searchmode, bool forward);
96   void ReplaceAllInSelection(const char*searchfor, const char*replacewith, FXuint searchmode);
97   void ReplaceAllInDocument(const char*searchfor, const char*replacewith, FXuint searchmode);
98   void FindSelected(bool forward);
99   void setHaveSelection(bool have_sel);
100   bool GoToSelected();
101   bool ShowGoToDialog();
FindDialog()102   FXWindow*FindDialog() { return (FXWindow*)find_gui; }
103   SearchDialogs(FXComposite*p, FXObject*trg=NULL, FXSelector sel=0);
setSelector(FXSelector sel)104   void setSelector(FXSelector sel) { message=sel; }
setTarget(FXObject * trg)105   void setTarget(FXObject*trg) { target=trg; }
106   virtual ~SearchDialogs();
107   long onSearch(FXObject*o, FXSelector sel, void *p);
108   long onSearchDone(FXObject*o, FXSelector sel, void *p);
109   void hide();
110   enum {
111     ID_SEARCH=1,
112     ID_SEARCH_DONE,
113     ID_LAST
114   };
115 };
116 
117 
118 bool GetPrimarySelection(FXString&target);
119 
120