-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFindText.hpp
230 lines (177 loc) · 5.64 KB
/
FindText.hpp
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#ifndef WAYROUND_I2P_20241223_224139_493134
#define WAYROUND_I2P_20241223_224139_493134
#include <future>
#include <memory>
#include <gtkmm.h>
#include <unicode/stringpiece.h>
#include <unicode/unistr.h>
#include "forward_declarations.hpp"
#include "utils.hpp"
#include "FindTypes.hpp"
namespace wayround_i2p::ccedit
{
enum FindTextWidgetMode : unsigned char
{
SEARCH,
EDIT
};
class FindTextWidget : public Gtk::Box
{
public:
FindTextWidget(FindTextWidgetMode mode = SEARCH);
~FindTextWidget();
FindTextQuery getFindTextQuery();
int setFindTextQuery(FindTextQuery q);
FindTextSearchMethod getSearchMethod();
int setSearchMethod(FindTextSearchMethod meth);
int search_in_text(
const icu::UnicodeString in_text,
std::shared_ptr<LineStartsICU> in_text_ls,
std::function<bool()> check_stop_flag,
std::function<
int(
unsigned int line,
icu::UnicodeString text,
unsigned int start_offset,
unsigned int end_offset
)>
here_s_new_occurance
);
void setMode(FindTextWidgetMode mode = SEARCH);
FindTextWidgetMode getMode();
private:
FindTextWidgetMode mode = SEARCH;
Gtk::Frame query_frame;
Gtk::Frame replace_frame;
Gtk::Entry query;
Gtk::Entry replace;
// ----------
// Gtk::Frame plain_settings_frame;
// Gtk::FlowBox plain_settings_box;
Gtk::Frame main_settings_frame;
Gtk::FlowBox main_settings_box;
Gtk::DropDown search_method;
Gtk::CheckButton casesensitive;
Gtk::CheckButton stop_after_first_match;
// ----------
Gtk::Frame std_re_mod_frame;
Gtk::FlowBox std_re_mod_box;
Gtk::CheckButton std_re_mod_icase;
Gtk::CheckButton std_re_mod_nosubs;
Gtk::CheckButton std_re_mod_optimize;
Gtk::CheckButton std_re_mod_collate;
Gtk::CheckButton std_re_mod_multiline;
// ----------
Gtk::Frame boost_re_perl_mod_frame;
Gtk::FlowBox boost_re_perl_mod_box;
Gtk::CheckButton boost_re_perl_mod_no_mod_m;
Gtk::CheckButton boost_re_perl_mod_no_mod_s;
Gtk::CheckButton boost_re_perl_mod_mod_s;
Gtk::CheckButton boost_re_perl_mod_mod_x;
// ----------
Gtk::Frame boost_re_posix_mod_frame;
Gtk::FlowBox boost_re_posix_mod_box;
Gtk::CheckButton boost_re_posix_mod_bk_plus_qm;
Gtk::CheckButton boost_re_posix_mod_bk_vbar;
Gtk::CheckButton boost_re_posix_mod_no_char_classes;
Gtk::CheckButton boost_re_posix_mod_no_intervals;
// ----------
Gtk::Frame boost_re_common_mod_frame;
Gtk::FlowBox boost_re_common_mod_box;
Gtk::CheckButton boost_re_common_mod_nosubs;
Gtk::CheckButton boost_re_common_mod_optimize;
Gtk::CheckButton boost_re_common_mod_collate;
Gtk::CheckButton boost_re_common_mod_newline_alt;
// Gtk::CheckButton boost_re_common_mod_no_except;
FindTextSearchMethod getVisualSelectedFindTextSearchMethod();
void setVisualSelectedFindTextSearchMethod(
FindTextSearchMethod m
);
void setup_search_method_list();
void apply_search_method_visual();
void on_search_method_changed();
void on_search_method_btn_clicked();
};
class TextSearchMethodListItem : public Glib::Object
{
public:
static Glib::RefPtr<TextSearchMethodListItem> create(
FindTextSearchMethod value
)
{
auto ret = Glib::make_refptr_for_instance<TextSearchMethodListItem>(
new TextSearchMethodListItem(value)
);
return ret;
}
const FindTextSearchMethod value;
protected:
TextSearchMethodListItem(FindTextSearchMethod value) :
Glib::ObjectBase(typeid(TextSearchMethodListItem)),
value(value)
{
}
};
class TextSearchMethodListItemWidget : public Gtk::Label
{
public:
TextSearchMethodListItemWidget(
const Glib::RefPtr<Gtk::ListItem> &list_item
);
~TextSearchMethodListItemWidget();
void bind(const Glib::RefPtr<Gtk::ListItem> &list_item);
};
class FindText
{
public:
static FindText_shared create(
CodeEditorAbstract_shared editor_window
);
protected:
FindText(
CodeEditorAbstract_shared editor_window
);
public:
~FindText();
FindTextQuery getFindTextQuery();
int setFindTextQuery(FindTextQuery q);
void show();
void destroy();
private:
FindText_shared own_ptr;
RunOnce destroyer;
ProjectCtl_weak p_ctl;
CodeEditorAbstract_weak editor_window;
unsigned int saved_cursor_line;
Gtk::Window win;
Gtk::Box main_box;
Gtk::Expander search_ex;
Gtk::Box search_box;
FindTextWidget find_text_widget;
Gtk::Box text_search_btn_box;
Gtk::Box text_search_btn_box1;
Gtk::Box text_search_btn_box2;
Gtk::Button start_btn;
Gtk::Button stop_btn;
Gtk::Button acquire_cursor_position_btn;
Gtk::Button restore_cursor_position_btn;
Gtk::Frame result_frame;
Gtk::ScrolledWindow result_sw;
Gtk::ListView result_list_view;
void setup_result_linelist();
void saveEditorLine();
FindTextQuery work_time_query;
bool search_stop_flag = false;
bool search_working = false;
int start_search_thread();
void stop_search_thread();
void search_thread();
void on_start_btn();
void on_stop_btn();
void on_acquire_cursor_position();
void on_restore_cursor_position();
void on_destroy_sig();
bool on_signal_close_request();
};
} // namespace wayround_i2p::ccedit
#endif