@@ -152,6 +152,8 @@ class SearchWidget : TabWidget {
152
152
SearchLogWidget _resultLog;
153
153
int _resultLogMatchIndex;
154
154
ComboBox _searchScope;
155
+ ImageCheckButton _cbCaseSensitive;
156
+ ImageCheckButton _cbWholeWords;
155
157
156
158
protected IDEFrame _frame;
157
159
protected SearchMatchList[] _matchedList;
@@ -206,6 +208,18 @@ class SearchWidget : TabWidget {
206
208
_searchScope = new ComboBox(" searchScope" , [" File" d, " Project" d, " Dependencies" d, " Everywhere" d]);
207
209
_searchScope.selectedItemIndex = 0 ;
208
210
_layout.addChild(_searchScope);
211
+
212
+ _cbCaseSensitive = new ImageCheckButton(" cbCaseSensitive" , " find_case_sensitive" );
213
+ _cbCaseSensitive.tooltipText = " EDIT_FIND_CASE_SENSITIVE" ;
214
+ _cbCaseSensitive.styleId = " TOOLBAR_BUTTON" ;
215
+ _cbCaseSensitive.checked = true ;
216
+ _layout.addChild(_cbCaseSensitive);
217
+
218
+ _cbWholeWords = new ImageCheckButton(" cbWholeWords" , " find_whole_words" );
219
+ _cbWholeWords.tooltipText = " EDIT_FIND_WHOLE_WORDS" ;
220
+ _cbWholeWords.styleId = " TOOLBAR_BUTTON" ;
221
+ _layout.addChild(_cbWholeWords);
222
+
209
223
addChild(_layout);
210
224
211
225
_resultLog = new SearchLogWidget(" SearchLogWidget" );
@@ -250,9 +264,11 @@ class SearchWidget : TabWidget {
250
264
251
265
switch (_searchScope.text) {
252
266
case " File" :
253
- SearchMatchList match = findMatches(_frame.currentEditor.filename, source);
254
- if (match.matches.length > 0 )
255
- _matchedList ~= match;
267
+ if (_frame.currentEditor) {
268
+ SearchMatchList match = findMatches(_frame.currentEditor.filename, source);
269
+ if (match.matches.length > 0 )
270
+ _matchedList ~= match;
271
+ }
256
272
break ;
257
273
case " Project" :
258
274
foreach (Project project; _frame._wsPanel.workspace.projects) {
@@ -302,23 +318,41 @@ class SearchWidget : TabWidget {
302
318
}
303
319
super .onDraw(buf);
304
320
}
305
-
321
+
322
+ void checkSearchMode () {
323
+ if (! _frame.currentEditor && _searchScope.selectedItemIndex == 0 )
324
+ _searchScope.selectedItemIndex = 1 ;
325
+ }
326
+
327
+ uint makeSearchFlags () {
328
+ uint res = 0 ;
329
+ if (_cbCaseSensitive.checked)
330
+ res |= TextSearchFlag.CaseSensitive;
331
+ if (_cbWholeWords.checked)
332
+ res |= TextSearchFlag.WholeWords;
333
+ return res;
334
+ }
335
+
306
336
// Find the match/matchList that corrosponds to the line in _resultLog
307
337
bool onMatchClick (int line) {
308
338
line++ ;
309
339
foreach (matchList; _matchedList){
310
340
line-- ;
311
341
if (line == 0 ) {
312
- _frame.openSourceFile(matchList.filename);
313
- _frame.currentEditor.setFocus();
342
+ if (_frame.openSourceFile(matchList.filename)) {
343
+ _frame.currentEditor.setTextToHighlight(_findText.text, makeSearchFlags);
344
+ _frame.currentEditor.setFocus();
345
+ }
314
346
return true ;
315
347
}
316
348
foreach (match; matchList.matches) {
317
349
line-- ;
318
350
if (line == 0 ) {
319
- _frame.openSourceFile(matchList.filename);
320
- _frame.currentEditor.setCaretPos(match.line, to! int (match.col));
321
- _frame.currentEditor.setFocus();
351
+ if (_frame.openSourceFile(matchList.filename)) {
352
+ _frame.currentEditor.setCaretPos(match.line, to! int (match.col));
353
+ _frame.currentEditor.setTextToHighlight(_findText.text, makeSearchFlags);
354
+ _frame.currentEditor.setFocus();
355
+ }
322
356
return true ;
323
357
}
324
358
}
0 commit comments