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 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262
|
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// copyright : (C) 2008 by Eran Ifrah
// file name : quickfindbar.cpp
//
// -------------------------------------------------------------------------
// A
// _____ _ _ _ _
// / __ \ | | | | (_) |
// | / \/ ___ __| | ___| | _| |_ ___
// | | / _ \ / _ |/ _ \ | | | __/ _ )
// | \__/\ (_) | (_| | __/ |___| | || __/
// \____/\___/ \__,_|\___\_____/_|\__\___|
//
// F i l e
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// clang-format off
#include "bitmap_loader.h"
#include "bookmark_manager.h"
#include "clBitmapOverlayCtrl.h"
#include "cl_config.h"
#include "codelite_events.h"
#include "drawingutils.h"
#include "editor_config.h"
#include "event_notifier.h"
#include "globals.h"
#include "imanager.h"
#include "plugin.h"
#include "clPluginsFindBar.h"
#include "stringsearcher.h"
#include <wx/dcbuffer.h>
#include <wx/gdicmn.h>
#include <wx/regex.h>
#include <wx/statline.h>
#include <wx/stc/stc.h>
#include <wx/textctrl.h>
#include <wx/wupdlock.h>
#include <wx/xrc/xmlres.h>
#include "clSystemSettings.h"
#include <wx/stattext.h>
// clang-format on
DEFINE_EVENT_TYPE(QUICKFIND_COMMAND_EVENT)
#define MARKER_FIND_BAR_WORD_HIGHLIGHT 5
#define CHECK_FOCUS_WIN(evt) \
{ \
wxWindow* focus = wxWindow::FindFocus(); \
if(focus != m_sci && focus != m_textCtrlFind) { \
evt.Skip(); \
return; \
} \
\
if(!m_sci || m_sci->GetLength() == 0) { \
evt.Skip(); \
return; \
} \
}
void PostCommandEvent(wxWindow* destination, wxWindow* FocusedControl)
{
// Posts an event that signals for SelectAll() to be done after a delay
// This is often needed in >2.9, as scintilla seems to steal the selection
const static int DELAY_COUNT = 10;
wxCommandEvent event(QUICKFIND_COMMAND_EVENT);
event.SetInt(DELAY_COUNT);
event.SetEventObject(FocusedControl);
wxPostEvent(destination, event);
}
namespace
{
wxBorder get_border_simple_theme_aware_bit()
{
#ifdef __WXMAC__
return wxBORDER_SIMPLE;
#elif defined(__WXGTK__)
return wxBORDER_STATIC;
#else
return clSystemSettings::Get().IsDark() ? wxBORDER_SIMPLE : wxBORDER_STATIC;
#endif
}
} // namespace
clPluginsFindBar::clPluginsFindBar(wxWindow* parent, wxWindowID id)
: QuickFindBarBase(parent, id, wxDefaultPosition, wxDefaultSize,
wxTAB_TRAVERSAL | get_border_simple_theme_aware_bit())
, m_sci(NULL)
, m_lastTextPtr(NULL)
, m_eventsConnected(false)
, m_regexType(kRegexNone)
, m_disableTextUpdateEvent(false)
, m_searchFlags(0)
, m_highlightMatches(false)
, m_replaceInSelection(false)
{
// Handle Edit events
m_findEventsHandler.Reset(new clEditEventsHandler(m_textCtrlFind));
m_replaceEventsHandler.Reset(new clEditEventsHandler(m_textCtrlReplace));
m_findEventsHandler->NoUnbind();
m_replaceEventsHandler->NoUnbind();
m_toolbar->SetMiniToolBar(true);
clBitmapList* bitmaps = new clBitmapList;
m_toolbar->AddTool(ID_TOOL_CLOSE, _("Close"), bitmaps->Add("file_close"), _("Close"), wxITEM_NORMAL);
m_toolbar->AddSeparator();
m_matchesFound = new wxStaticText(m_toolbar, wxID_ANY, "", wxDefaultPosition, wxSize(250, -1),
wxST_NO_AUTORESIZE | wxALIGN_LEFT);
m_toolbar->AddControl(m_matchesFound);
m_toolbar->AddStretchableSpace();
m_toolbar->AddTool(XRCID("case-sensitive"), _("Case Sensitive"), bitmaps->Add("case-sensitive"), "", wxITEM_CHECK);
m_toolbar->AddTool(XRCID("whole-word"), _("Whole word"), bitmaps->Add("whole-word"), "", wxITEM_CHECK);
m_toolbar->AddTool(XRCID("use-regex"), _("Regex"), bitmaps->Add("regular-expression"), "", wxITEM_CHECK);
m_toolbar->AddTool(XRCID("highlight-matches"), _("Highlight matches"), bitmaps->Add("marker"), "", wxITEM_CHECK);
m_toolbar->AddTool(XRCID("replace-in-selection"), _("Replace In Selection"), bitmaps->Add("text_selection"), "",
wxITEM_CHECK);
m_toolbar->AssignBitmaps(bitmaps);
m_toolbar->Realize();
m_toolbar->Bind(wxEVT_TOOL, &clPluginsFindBar::OnHide, this, ID_TOOL_CLOSE);
m_toolbar->Bind(
wxEVT_TOOL,
[&](wxCommandEvent& e) {
if(e.IsChecked()) {
m_searchFlags |= wxSTC_FIND_MATCHCASE;
} else {
m_searchFlags &= ~wxSTC_FIND_MATCHCASE;
}
},
XRCID("case-sensitive"));
m_toolbar->Bind(
wxEVT_TOOL,
[&](wxCommandEvent& e) {
if(e.IsChecked()) {
m_searchFlags |= wxSTC_FIND_WHOLEWORD;
} else {
m_searchFlags &= ~wxSTC_FIND_WHOLEWORD;
}
},
XRCID("whole-word"));
m_toolbar->Bind(
wxEVT_TOOL,
[&](wxCommandEvent& e) {
if(e.IsChecked()) {
m_searchFlags |= wxSTC_FIND_REGEXP;
} else {
m_searchFlags &= ~wxSTC_FIND_REGEXP;
}
},
XRCID("use-regex"));
m_toolbar->Bind(
wxEVT_TOOL,
[&](wxCommandEvent& e) {
m_highlightMatches = e.IsChecked();
DoHighlightMatches(m_highlightMatches);
},
XRCID("highlight-matches"));
m_toolbar->Bind(
wxEVT_TOOL, [&](wxCommandEvent& e) { m_replaceInSelection = e.IsChecked(); }, XRCID("replace-in-selection"));
m_toolbar->Bind(
wxEVT_UPDATE_UI, [&](wxUpdateUIEvent& e) { e.Check(m_searchFlags & wxSTC_FIND_MATCHCASE); },
XRCID("case-sensitive"));
m_toolbar->Bind(
wxEVT_UPDATE_UI, [&](wxUpdateUIEvent& e) { e.Check(m_searchFlags & wxSTC_FIND_REGEXP); }, XRCID("use-regex"));
m_toolbar->Bind(
wxEVT_UPDATE_UI, [&](wxUpdateUIEvent& e) { e.Check(m_searchFlags & wxSTC_FIND_WHOLEWORD); },
XRCID("whole-word"));
m_toolbar->Bind(
wxEVT_UPDATE_UI, [&](wxUpdateUIEvent& e) { e.Check(m_highlightMatches); }, XRCID("highlight-matches"));
m_toolbar->Bind(
wxEVT_UPDATE_UI, [&](wxUpdateUIEvent& e) { e.Check(m_replaceInSelection); }, XRCID("replace-in-selection"));
wxTheApp->Bind(wxEVT_MENU, &clPluginsFindBar::OnFindNextCaret, this, XRCID("find_next_at_caret"));
wxTheApp->Bind(wxEVT_MENU, &clPluginsFindBar::OnFindPreviousCaret, this, XRCID("find_previous_at_caret"));
EventNotifier::Get()->Bind(wxEVT_FINDBAR_RELEASE_EDITOR, &clPluginsFindBar::OnReleaseEditor, this);
Connect(QUICKFIND_COMMAND_EVENT, wxCommandEventHandler(clPluginsFindBar::OnQuickFindCommandEvent), NULL, this);
// Initialize the list with the history
m_searchHistory.SetItems(clConfig::Get().GetQuickFindSearchItems());
m_replaceHistory.SetItems(clConfig::Get().GetQuickFindReplaceItems());
// Update the search flags
m_searchFlags = clConfig::Get().Read("FindBar/SearchFlags", 0);
m_highlightMatches = clConfig::Get().Read("FindBar/HighlightOccurences", false);
// Make sure that the 'Replace' field is selected when we hit TAB while in the 'Find' field
m_textCtrlReplace->MoveAfterInTabOrder(m_textCtrlFind);
// Bind(wxEVT_PAINT, &clPluginsFindBar::OnPaint, this);
// Bind(wxEVT_ERASE_BACKGROUND, [](wxEraseEvent& e) { wxUnusedVar(e); });
GetSizer()->Fit(this);
Layout();
}
clPluginsFindBar::~clPluginsFindBar()
{
// Remember the buttons clicked
clConfig::Get().Write("FindBar/SearchFlags", (int)DoGetSearchFlags());
clConfig::Get().Write("FindBar/HighlightOccurences", m_highlightMatches);
wxTheApp->Unbind(wxEVT_MENU, &clPluginsFindBar::OnFindNextCaret, this, XRCID("find_next_at_caret"));
wxTheApp->Unbind(wxEVT_MENU, &clPluginsFindBar::OnFindPreviousCaret, this, XRCID("find_previous_at_caret"));
EventNotifier::Get()->Unbind(wxEVT_FINDBAR_RELEASE_EDITOR, &clPluginsFindBar::OnReleaseEditor, this);
EventNotifier::Get()->Unbind(wxEVT_ALL_EDITORS_CLOSED, [&](wxCommandEvent& event) {
event.Skip();
this->SetEditor(NULL);
});
EventNotifier::Get()->Unbind(wxEVT_ACTIVE_EDITOR_CHANGED, [&](wxCommandEvent& event) {
event.Skip();
// See if we got a new editor
IEditor* editor = clGetManager()->GetActiveEditor();
if(editor) {
this->SetEditor(editor->GetCtrl());
return;
}
SetEditor(NULL);
});
}
bool clPluginsFindBar::Show(bool show)
{
if(!m_sci && show) {
return false;
}
return DoShow(show, wxEmptyString);
}
#define SHOW_STATUS_MESSAGES(searchFlags) (true)
bool clPluginsFindBar::DoSearch(size_t searchFlags)
{
return Search(m_sci, m_textCtrlFind->GetValue(), searchFlags, this);
}
void clPluginsFindBar::OnHide(wxCommandEvent& e)
{
// Kill any "...continued from start" statusbar message
clGetManager()->GetStatusBar()->SetMessage(wxEmptyString);
// Clear all
Show(false);
e.Skip();
}
#define UPDATE_FIND_HISTORY() \
if(!m_textCtrlFind->GetValue().IsEmpty()) { \
m_searchHistory.Add(m_textCtrlFind->GetValue()); \
clConfig::Get().SetQuickFindSearchItems(m_searchHistory.GetItems()); \
}
void clPluginsFindBar::OnNext(wxCommandEvent& e)
{
wxUnusedVar(e);
UPDATE_FIND_HISTORY();
size_t flags = kSearchForward;
m_onNextPrev = true;
DoSearch(flags);
m_onNextPrev = false;
}
void clPluginsFindBar::OnPrev(wxCommandEvent& e)
{
wxUnusedVar(e);
UPDATE_FIND_HISTORY();
size_t flags = 0;
m_onNextPrev = true;
DoSearch(flags);
m_onNextPrev = false;
}
void clPluginsFindBar::OnText(wxCommandEvent& e)
{
e.Skip();
if(!m_replaceInSelection && !m_disableTextUpdateEvent) {
CallAfter(&clPluginsFindBar::DoSearchCB, kSearchForward);
}
}
void clPluginsFindBar::OnKeyDown(wxKeyEvent& e)
{
switch(e.GetKeyCode()) {
case WXK_DOWN: {
// DoArrowDown(m_searchHistory, m_textCtrlFind);
break;
}
case WXK_UP: {
// DoArrowUp(m_searchHistory, m_textCtrlFind);
break;
}
case WXK_ESCAPE: {
wxCommandEvent dummy;
OnHide(dummy);
DoHighlightMatches(false);
break;
}
default: {
e.Skip();
break;
}
}
}
void clPluginsFindBar::OnReplaceKeyDown(wxKeyEvent& e)
{
switch(e.GetKeyCode()) {
case WXK_DOWN: {
// DoArrowDown(m_replaceHistory, m_textCtrlReplace);
break;
}
case WXK_UP: {
// DoArrowUp(m_replaceHistory, m_textCtrlReplace);
break;
}
case WXK_ESCAPE: {
wxCommandEvent dummy;
OnHide(dummy);
DoHighlightMatches(false);
break;
}
default: {
e.Skip();
break;
}
}
}
void clPluginsFindBar::OnEnter(wxCommandEvent& e)
{
wxUnusedVar(e);
if(!m_textCtrlFind->GetValue().IsEmpty()) {
m_searchHistory.Add(m_textCtrlFind->GetValue());
clConfig::Get().SetQuickFindSearchItems(m_searchHistory.GetItems());
}
bool shift = wxGetKeyState(WXK_SHIFT);
if(shift) {
OnPrev(e);
} else {
OnNext(e);
}
// Without this call, the caret is placed at the start of the searched
// text, this at least places the caret at the end
CallAfter(&clPluginsFindBar::DoSetCaretAtEndOfText);
}
void clPluginsFindBar::OnReplace(wxCommandEvent& event)
{
DoReplace();
// Trigger another search
DoSearch(kSearchForward);
}
void clPluginsFindBar::DoReplace()
{
if(!m_sci)
return;
wxString findwhat = m_textCtrlFind->GetValue();
if(findwhat.IsEmpty())
return;
UPDATE_FIND_HISTORY();
wxString findWhatSciVersion = findwhat;
DoFixRegexParen(findWhatSciVersion);
// No selection?
if(m_sci->GetSelections() == 0) {
DoSearch(kSearchForward);
return;
}
// No selection?
if(m_sci->GetSelections() != 1) {
DoSearch(kSearchForward);
return;
}
// did we got a match?
if(m_sci->GetSelections() != 1)
return;
int selStart, selEnd;
m_sci->GetSelection(&selStart, &selEnd);
if(selStart == selEnd) {
// not a real selection
DoSearch(kSearchForward);
return;
}
// Ensure that the selection matches our search pattern
size_t searchFlags = DoGetSearchFlags();
if(m_sci->FindText(selStart, selEnd, searchFlags & wxSTC_FIND_REGEXP ? findWhatSciVersion : findwhat,
searchFlags) == wxNOT_FOUND) {
// we got a selection, but it does not match our search
return;
}
wxString selectedText = m_sci->GetTextRange(selStart, selEnd);
#ifndef __WXMAC__
int re_flags = wxRE_ADVANCED;
#else
int re_flags = wxRE_DEFAULT;
#endif
wxString replaceWith = m_textCtrlReplace->GetValue();
if(!replaceWith.IsEmpty()) {
m_replaceHistory.Add(replaceWith);
clConfig::Get().SetQuickFindReplaceItems(m_replaceHistory.GetItems());
}
size_t replacementLen = replaceWith.length();
if(searchFlags & wxSTC_FIND_REGEXP) {
// Regular expresson search
if(!(searchFlags & wxSTC_FIND_MATCHCASE)) {
re_flags |= wxRE_ICASE;
}
wxRegEx re(findwhat, re_flags);
if(re.IsValid() && re.Matches(selectedText)) {
re.Replace(&selectedText, replaceWith);
// Keep the replacement length
replacementLen = selectedText.length();
// update the view
m_sci->Replace(selStart, selEnd, selectedText);
} else {
return;
}
} else {
// Normal search and replace
m_sci->Replace(selStart, selEnd, replaceWith);
}
// Clear the selection
m_sci->ClearSelections();
m_sci->SetCurrentPos(selStart + replacementLen);
}
void clPluginsFindBar::OnReplaceEnter(wxCommandEvent& e)
{
wxUnusedVar(e);
wxCommandEvent evt(wxEVT_COMMAND_TOOL_CLICKED, ID_TOOL_REPLACE);
GetEventHandler()->AddPendingEvent(evt);
}
void clPluginsFindBar::SetEditor(wxStyledTextCtrl* sci)
{
m_sci = sci;
if(!m_sci) {
DoShow(false, "");
return;
}
}
int clPluginsFindBar::GetCloseButtonId() { return ID_TOOL_CLOSE; }
bool clPluginsFindBar::Show(const wxString& findWhat, bool showReplace)
{
// Same as Show() but set the 'findWhat' field with findWhat
// and show/hide the 'Replace' section depending on the bool
if(!m_sci)
return false;
return DoShow(true, findWhat, showReplace);
}
bool clPluginsFindBar::DoShow(bool s, const wxString& findWhat, bool showReplace)
{
#ifdef __WXMSW__
wxWindowUpdateLocker locker(this);
#endif
bool res = wxPanel::Show(s);
if(s && m_sci) {
// Delete the indicators
m_sci->SetIndicatorCurrent(1);
m_sci->IndicatorClearRange(0, m_sci->GetLength());
if(EditorConfigST::Get()->GetOptions()->GetClearHighlitWordsOnFind()) {
m_sci->SetIndicatorCurrent(MARKER_FIND_BAR_WORD_HIGHLIGHT);
m_sci->IndicatorClearRange(0, m_sci->GetLength());
}
}
if(s) {
// Show or Hide the 'Replace' section as requested
wxSizer* flexgridsizer = m_textCtrlFind->GetContainingSizer();
if(flexgridsizer) {
if(showReplace) {
flexgridsizer->ShowItems(true);
} else {
for(size_t n = 4; n < 7; ++n) {
flexgridsizer->Hide(n);
}
}
}
}
if(res) {
GetParent()->GetSizer()->Layout();
}
m_replaceInSelection = !findWhat.IsEmpty() && findWhat.Contains("\n");
if(!m_sci) {
// nothing to do
} else if(!s) {
// hiding
DoHighlightMatches(false);
m_sci->SetFocus();
} else if(!findWhat.IsEmpty()) {
if(findWhat.Contains("\n")) {
// Multiline selection
// enable the 'Replace in Selection'
m_textCtrlFind->ChangeValue("");
m_textCtrlFind->SetFocus();
} else {
m_textCtrlFind->ChangeValue(findWhat);
m_textCtrlFind->SelectAll();
m_textCtrlFind->SetFocus();
if(m_highlightMatches) {
if(!(m_searchFlags & wxSTC_FIND_REGEXP) || m_textCtrlFind->GetValue().Length() > 2) {
DoHighlightMatches(true);
}
}
PostCommandEvent(this, m_textCtrlFind);
}
} else {
if(m_sci->GetSelections() > 1) {}
wxString findWhat = DoGetSelectedText().BeforeFirst(wxT('\n'));
if(!findWhat.IsEmpty()) {
m_textCtrlFind->ChangeValue(findWhat);
}
m_textCtrlFind->SelectAll();
m_textCtrlFind->SetFocus();
if(m_highlightMatches) {
if(!(m_searchFlags & wxSTC_FIND_REGEXP) || m_textCtrlFind->GetValue().Length() > 2) {
DoHighlightMatches(true);
}
}
PostCommandEvent(this, m_textCtrlFind);
}
return res;
}
void clPluginsFindBar::OnFindNextCaret(wxCommandEvent& e)
{
CHECK_FOCUS_WIN(e);
wxString selection(DoGetSelectedText());
if(selection.IsEmpty()) {
// select the word
long pos = m_sci->GetCurrentPos();
long start = m_sci->WordStartPosition(pos, true);
long end = m_sci->WordEndPosition(pos, true);
selection = m_sci->GetTextRange(start, end);
if(selection.IsEmpty() == false)
m_sci->SetCurrentPos(start);
}
if(selection.IsEmpty())
return;
m_textCtrlFind->ChangeValue(selection);
DoSearch(kSearchForward);
}
void clPluginsFindBar::OnFindPreviousCaret(wxCommandEvent& e)
{
CHECK_FOCUS_WIN(e);
wxString selection(DoGetSelectedText());
if(selection.IsEmpty()) {
// select the word
long pos = m_sci->GetCurrentPos();
long start = m_sci->WordStartPosition(pos, true);
long end = m_sci->WordEndPosition(pos, true);
selection = m_sci->GetTextRange(start, end);
if(selection.IsEmpty() == false)
m_sci->SetCurrentPos(start);
}
if(selection.IsEmpty())
return;
m_textCtrlFind->ChangeValue(selection);
DoSearch(0);
}
void clPluginsFindBar::DoSelectAll(bool addMarkers)
{
if(!m_sci || m_sci->GetLength() == 0 || m_textCtrlFind->GetValue().IsEmpty())
return;
clGetManager()->SetStatusMessage(wxEmptyString);
if(addMarkers) {
m_sci->SetIndicatorCurrent(MARKER_FIND_BAR_WORD_HIGHLIGHT);
m_sci->IndicatorClearRange(0, m_sci->GetLength());
}
wxString find = m_textCtrlFind->GetValue();
int flags = DoGetSearchFlags();
// Since scintilla uses a non POSIX way of handling the regex paren
// fix them
if(flags & wxSTC_FIND_REGEXP) {
DoFixRegexParen(find);
}
// Ensure that we have at least one match before we continue
if(m_sci->FindText(0, m_sci->GetLastPosition(), find, flags) == wxNOT_FOUND) {
clGetManager()->SetStatusMessage(_("No match found"), 1);
return;
}
// We got at least one match
m_sci->SetCurrentPos(0);
m_sci->SetSelectionEnd(0);
m_sci->SetSelectionStart(0);
m_sci->ClearSelections();
m_sci->SearchAnchor();
std::vector<std::pair<int, int>> matches; // pair of matches selStart+selEnd
int pos = m_sci->SearchNext(flags, find);
while(pos != wxNOT_FOUND) {
std::pair<int, int> match;
m_sci->GetSelection(&match.first, &match.second);
if(match.first == match.second) {
clGetManager()->SetStatusMessage(_("No match found"), 1);
return;
}
m_sci->SetCurrentPos(match.second);
m_sci->SetSelectionStart(match.second);
m_sci->SetSelectionEnd(match.second);
m_sci->SearchAnchor();
pos = m_sci->SearchNext(flags, find);
matches.push_back(match);
}
if(matches.empty()) {
clGetManager()->SetStatusMessage(_("No match found"), 1);
return;
}
// add selections
m_sci->ClearSelections();
for(size_t i = 0; i < matches.size(); ++i) {
if(i == 0) {
m_sci->SetSelection(matches.at(i).first, matches.at(i).second);
m_sci->SetMainSelection(0);
DoEnsureLineIsVisible(m_sci, m_sci->LineFromPosition(matches.at(0).first));
} else {
m_sci->AddSelection(matches.at(i).first, matches.at(i).second);
}
}
Show(false);
wxString message;
message << _("Found and selected ") << matches.size() << _(" matches");
clGetManager()->SetStatusMessage(message, 2);
m_sci->SetMainSelection(0);
}
void clPluginsFindBar::DoHighlightMatches(bool checked)
{
if(checked && !m_textCtrlFind->GetValue().IsEmpty()) {
int flags = DoGetSearchFlags();
wxString findwhat = m_textCtrlFind->GetValue();
if(!m_sci || m_sci->GetLength() == 0 || findwhat.IsEmpty())
return;
// Do we have at least one match?
if(m_sci->FindText(0, m_sci->GetLastPosition(), findwhat, flags) == wxNOT_FOUND)
return;
m_sci->ClearSelections();
m_sci->SetCurrentPos(0);
m_sci->SetSelectionEnd(0);
m_sci->SetSelectionStart(0);
m_sci->MarkerDeleteAll(MARKER_FIND_BAR_WORD_HIGHLIGHT);
m_sci->SetIndicatorCurrent(MARKER_FIND_BAR_WORD_HIGHLIGHT);
m_sci->IndicatorClearRange(0, m_sci->GetLength());
int found = 0;
while(true) {
m_sci->SearchAnchor();
if(m_sci->SearchNext(flags, findwhat) != wxNOT_FOUND) {
int selStart, selEnd;
m_sci->GetSelection(&selStart, &selEnd);
m_sci->SetIndicatorCurrent(MARKER_FIND_BAR_WORD_HIGHLIGHT);
m_sci->IndicatorFillRange(selStart, selEnd - selStart);
m_sci->MarkerAdd(m_sci->LineFromPosition(selStart), smt_find_bookmark);
// Clear the selection so the next 'SearchNext' will search forward
m_sci->SetCurrentPos(selEnd);
m_sci->SetSelectionEnd(selEnd);
m_sci->SetSelectionStart(selEnd);
found++;
} else {
break;
}
}
wxString matches;
if(found) {
matches << found << " " << (found > 1 ? _("results") : _("result"));
} else {
matches << _("No matches found");
}
m_matchesFound->SetLabel(matches);
} else {
m_sci->MarkerDeleteAll(MARKER_FIND_BAR_WORD_HIGHLIGHT);
IEditor::List_t editors;
clGetManager()->GetAllEditors(editors);
std::for_each(editors.begin(), editors.end(), [&](IEditor* pEditor) {
pEditor->GetCtrl()->MarkerDeleteAll(smt_find_bookmark);
pEditor->GetCtrl()->SetIndicatorCurrent(MARKER_FIND_BAR_WORD_HIGHLIGHT);
pEditor->GetCtrl()->IndicatorClearRange(0, pEditor->GetCtrl()->GetLength());
});
m_matchesFound->SetLabel("");
}
}
void clPluginsFindBar::OnReceivingFocus(wxFocusEvent& event)
{
event.Skip();
if((event.GetEventObject() == m_textCtrlFind) || (event.GetEventObject() == m_textCtrlReplace)) {
PostCommandEvent(this, wxStaticCast(event.GetEventObject(), wxWindow));
}
}
void clPluginsFindBar::OnQuickFindCommandEvent(wxCommandEvent& event)
{
if(event.GetInt() > 0) {
// We need to delay further, or focus might be set too soon
event.SetInt(event.GetInt() - 1);
wxPostEvent(this, event);
}
if(event.GetEventObject() == m_textCtrlFind) {
m_textCtrlFind->SetFocus();
m_textCtrlFind->SelectAll();
} else if(event.GetEventObject() == m_textCtrlReplace) {
m_textCtrlReplace->SetFocus();
m_textCtrlReplace->SelectAll();
}
}
void clPluginsFindBar::OnReleaseEditor(clFindEvent& e)
{
wxStyledTextCtrl* win = e.GetCtrl();
if(win && win == m_sci) {
m_sci = NULL;
Show(false);
}
}
wxStyledTextCtrl* clPluginsFindBar::DoCheckPlugins()
{
// Let the plugins a chance to provide their own window
clFindEvent evt(wxEVT_FINDBAR_ABOUT_TO_SHOW);
EventNotifier::Get()->ProcessEvent(evt);
return evt.GetCtrl();
}
bool clPluginsFindBar::ShowForPlugins()
{
m_sci = DoCheckPlugins();
if(!m_sci) {
return DoShow(false, "");
} else {
return DoShow(true, "");
}
}
wxString clPluginsFindBar::DoGetSelectedText()
{
if(!m_sci) {
return wxEmptyString;
}
if(m_sci->GetSelections() > 1) {
for(int i = 0; i < m_sci->GetSelections(); ++i) {
int selStart = m_sci->GetSelectionNStart(i);
int selEnd = m_sci->GetSelectionNEnd(i);
if(selEnd > selStart) {
return m_sci->GetTextRange(selStart, selEnd);
}
}
return wxEmptyString;
} else {
return m_sci->GetSelectedText();
}
}
void clPluginsFindBar::OnButtonNext(wxCommandEvent& e) { OnNext(e); }
void clPluginsFindBar::OnButtonPrev(wxCommandEvent& e) { OnPrev(e); }
size_t clPluginsFindBar::DoGetSearchFlags() const { return m_searchFlags; }
void clPluginsFindBar::OnFindAll(wxCommandEvent& e) { DoSelectAll(true); }
void clPluginsFindBar::OnButtonReplace(wxCommandEvent& e) { OnReplace(e); }
void clPluginsFindBar::OnFindMouseWheel(wxMouseEvent& e)
{
// Do nothing and disable the mouse wheel
// by not calling 'skip'
wxUnusedVar(e);
}
void clPluginsFindBar::DoEnsureLineIsVisible(wxStyledTextCtrl* sci, int line)
{
if(line == wxNOT_FOUND) {
line = sci->LineFromPosition(sci->GetSelectionStart());
}
int linesOnScreen = sci->LinesOnScreen();
if(!((line > sci->GetFirstVisibleLine()) && (line < (sci->GetFirstVisibleLine() + linesOnScreen)))) {
// To place our line in the middle, the first visible line should be
// the: line - (linesOnScreen / 2)
int firstVisibleLine = line - (linesOnScreen / 2);
if(firstVisibleLine < 0) {
firstVisibleLine = 0;
}
sci->SetFirstVisibleLine(firstVisibleLine);
}
sci->EnsureVisible(line);
sci->ScrollToColumn(0);
int xScrollPosBefore = sci->GetScrollPos(wxHORIZONTAL);
sci->EnsureCaretVisible();
int xScrollPosAfter = sci->GetScrollPos(wxHORIZONTAL);
if(xScrollPosBefore != xScrollPosAfter) {
// EnsureCaretVisible scrolled the page
// scroll it a bit more
int scrollToPos = sci->GetSelectionStart();
if(scrollToPos != wxNOT_FOUND) {
sci->ScrollToColumn(sci->GetColumn(scrollToPos));
}
}
}
void clPluginsFindBar::DoFixRegexParen(wxString& findwhat)
{
// Scintilla's REGEX group markers are \( and \)
// while wxRegEx is usig bare ( and ) and the escaped version for
// non regex manner
findwhat.Replace("\\(", "/<!@#$");
findwhat.Replace("\\)", "/>!@#$");
findwhat.Replace("(", "<!@#$");
findwhat.Replace(")", ">!@#$");
findwhat.Replace("/<!@#$", "(");
findwhat.Replace("/>!@#$", ")");
findwhat.Replace("<!@#$", "\\(");
findwhat.Replace(">!@#$", "\\)");
}
void clPluginsFindBar::DoSetCaretAtEndOfText() { m_textCtrlFind->SetInsertionPointEnd(); }
void clPluginsFindBar::OnReplaceAll(wxCommandEvent& e)
{
wxUnusedVar(e);
DoReplaceAll(m_replaceInSelection);
}
void clPluginsFindBar::DoReplaceAll(bool selectionOnly)
{
if(!selectionOnly) {
m_sci->BeginUndoAction();
m_sci->SetSelection(0, 0);
m_sci->SetCurrentPos(0); // Start the search from the start
size_t replaced(0);
while(DoSearch(DoGetSearchFlags() | kDisableDisplayErrorMessages | kBreakWhenWrapSearch | kSearchForward)) {
DoReplace();
++replaced;
}
wxString message;
if(replaced) {
message << _("Found and replaced ") << replaced << _(" matches");
} else {
message << _("No matches found");
}
clGetManager()->SetStatusMessage(message, 5);
m_sci->EndUndoAction();
m_sci->ClearSelections();
} else {
if(!m_sci || m_sci->GetLength() == 0 || m_textCtrlFind->GetValue().IsEmpty())
return;
UPDATE_FIND_HISTORY();
clGetManager()->SetStatusMessage(wxEmptyString);
wxString findwhat = m_textCtrlFind->GetValue();
int searchFlags = DoGetSearchFlags();
// Since scintilla uses a non POSIX way of handling the regex paren
// fix them
if(searchFlags & wxSTC_FIND_REGEXP) {
DoFixRegexParen(findwhat);
}
int from, to;
if(selectionOnly && m_sci->GetSelectedText().IsEmpty())
return;
if(selectionOnly) {
m_sci->GetSelection(&from, &to);
} else {
from = 0;
to = m_sci->GetLastPosition();
}
// Ensure that we have at least one match before we continue
if(m_sci->FindText(from, to, findwhat, searchFlags) == wxNOT_FOUND) {
clGetManager()->SetStatusMessage(_("No match found"), 2);
return;
}
int curpos = m_sci->GetCurrentPos();
// We got at least one match
m_sci->SetCurrentPos(0);
m_sci->SetSelectionEnd(0);
m_sci->SetSelectionStart(0);
m_sci->ClearSelections();
m_sci->SearchAnchor();
#ifndef __WXMAC__
int re_flags = wxRE_ADVANCED;
#else
int re_flags = wxRE_DEFAULT;
#endif
wxString replaceWith = m_textCtrlReplace->GetValue();
if(!replaceWith.IsEmpty()) {
m_replaceHistory.Add(replaceWith);
clConfig::Get().SetQuickFindReplaceItems(m_replaceHistory.GetItems());
}
m_sci->BeginUndoAction();
int pos = m_sci->SearchNext(searchFlags, findwhat);
size_t matchesCount = 0;
while(pos != wxNOT_FOUND) {
int selStart, selEnd, newpos;
size_t replacementLen = replaceWith.length();
m_sci->GetSelection(&selStart, &selEnd);
if(!selectionOnly || ((pos >= from) && (pos < to))) {
wxString selectedText = m_sci->GetSelectedText();
if(searchFlags & wxSTC_FIND_REGEXP) {
// Regular expresson search
if(!(searchFlags & wxSTC_FIND_MATCHCASE)) {
re_flags |= wxRE_ICASE;
}
wxRegEx re(findwhat, re_flags);
if(re.IsValid() && re.Matches(selectedText)) {
re.Replace(&selectedText, replaceWith);
// Keep the replacement length
replacementLen = selectedText.length();
// update the view
m_sci->Replace(selStart, selEnd, selectedText);
} else {
return;
}
} else {
// Normal search and replace
m_sci->Replace(selStart, selEnd, replaceWith);
}
newpos = selStart + replacementLen;
// Extend the range (or shrink it) depending on the replacement
if(selectionOnly) {
int matchFoundLen = selEnd - selStart;
to += (replacementLen - matchFoundLen);
}
} else {
// the match is not in the selection range
newpos = pos + replacementLen;
if(newpos <= pos) {
newpos = pos + 1; // make sure we dont hang
}
// Move to the next match
m_sci->SetCurrentPos(newpos);
m_sci->SetSelectionStart(newpos);
m_sci->SetSelectionEnd(newpos);
m_sci->SearchAnchor();
pos = m_sci->SearchNext(searchFlags, findwhat);
continue;
}
// Move to the next match
m_sci->SetCurrentPos(newpos);
m_sci->SetSelectionStart(newpos);
m_sci->SetSelectionEnd(newpos);
m_sci->SearchAnchor();
pos = m_sci->SearchNext(searchFlags, findwhat);
++matchesCount;
}
m_sci->EndUndoAction();
if(!matchesCount) {
clGetManager()->SetStatusMessage(_("No match found"), 2);
return;
}
// add selections
m_sci->ClearSelections();
m_sci->SetSelectionStart(curpos);
m_sci->SetSelectionEnd(curpos);
m_sci->SetCurrentPos(curpos);
DoEnsureLineIsVisible(m_sci, m_sci->LineFromPosition(curpos));
wxString message;
message << _("Found and replaced ") << matchesCount << _(" matches");
clGetManager()->SetStatusMessage(message, 5);
// If needed, restore the selection
if(selectionOnly) {
m_sci->SetCurrentPos(from);
m_sci->SetSelectionStart(from);
m_sci->SetSelectionEnd(to);
}
}
}
void clPluginsFindBar::OnFind(wxCommandEvent& event)
{
wxUnusedVar(event);
if(!EditorConfigST::Get()->GetOptions()->GetDontOverrideSearchStringWithSelection()) {
// Highlighted text takes precedence over the current search string
// if(!IsShown()) {
wxString selectedText = DoGetSelectedText();
if(selectedText.IsEmpty() == false) {
m_textCtrlFind->ChangeValue(selectedText);
m_textCtrlFind->SelectAll();
}
// }
}
DoSearch(kSearchForward);
}
void clPluginsFindBar::OnFindPrev(wxCommandEvent& event)
{
if(!EditorConfigST::Get()->GetOptions()->GetDontOverrideSearchStringWithSelection()) {
wxString selectedText = DoGetSelectedText();
if(selectedText.IsEmpty() == false) {
m_textCtrlFind->ChangeValue(selectedText);
m_textCtrlFind->SelectAll();
}
}
DoSearch(0);
}
void clPluginsFindBar::OnReplaceTextEnter(wxCommandEvent& event) {}
void clPluginsFindBar::OnReplaceTextUpdated(wxCommandEvent& event) {}
void clPluginsFindBar::OnFindAllUI(wxUpdateUIEvent& event) { event.Enable(!m_textCtrlFind->IsEmpty()); }
void clPluginsFindBar::OnFindPrevUI(wxUpdateUIEvent& event) { event.Enable(!m_textCtrlFind->IsEmpty()); }
void clPluginsFindBar::OnFindUI(wxUpdateUIEvent& event) { event.Enable(!m_textCtrlFind->IsEmpty()); }
void clPluginsFindBar::OnReplaceAllUI(wxUpdateUIEvent& event) { event.Enable(!m_textCtrlFind->IsEmpty()); }
void clPluginsFindBar::OnReplaceUI(wxUpdateUIEvent& event)
{
event.Enable(!m_textCtrlFind->IsEmpty() && !m_replaceInSelection);
}
void clPluginsFindBar::DoArrowDown(clTerminalHistory& history, wxTextCtrl* ctrl)
{
const wxString& str = history.ArrowDown();
if(!str.IsEmpty()) {
ctrl->SelectAll();
long from, to;
ctrl->GetSelection(&from, &to);
ctrl->Replace(from, to, str);
ctrl->SelectNone();
ctrl->SetInsertionPoint(ctrl->GetLastPosition());
}
}
void clPluginsFindBar::DoArrowUp(clTerminalHistory& history, wxTextCtrl* ctrl)
{
const wxString& str = history.ArrowUp();
if(!str.IsEmpty()) {
ctrl->SelectAll();
long from, to;
ctrl->GetSelection(&from, &to);
ctrl->Replace(from, to, str);
ctrl->SelectNone();
ctrl->SetInsertionPoint(ctrl->GetLastPosition());
}
}
void clPluginsFindBar::OnButtonKeyDown(wxKeyEvent& event)
{
switch(event.GetKeyCode()) {
case WXK_ESCAPE: {
wxCommandEvent dummy;
OnHide(dummy);
DoHighlightMatches(false);
break;
}
default: {
event.Skip();
break;
}
}
}
bool clPluginsFindBar::Search(wxStyledTextCtrl* ctrl, const wxString& find_what, size_t search_flags,
clPluginsFindBar* This)
{
wxString findwhat = find_what;
if(findwhat.IsEmpty() && This) {
findwhat = This->m_textCtrlFind->GetValue();
}
if(!ctrl || ctrl->GetLength() == 0 || findwhat.IsEmpty())
return false;
clGetManager()->SetStatusMessage(wxEmptyString);
if(This) {
This->m_matchesFound->SetLabel("");
}
if(This && (This->m_textCtrlFind->GetValue() != findwhat)) {
This->m_textCtrlFind->ChangeValue(findwhat);
}
// Clear all search markers if desired
if(EditorConfigST::Get()->GetOptions()->GetClearHighlitWordsOnFind()) {
ctrl->SetIndicatorCurrent(MARKER_FIND_BAR_WORD_HIGHLIGHT);
ctrl->IndicatorClearRange(0, ctrl->GetLength());
}
wxString find = findwhat;
bool fwd = search_flags & kSearchForward;
int flags = 0;
if(This) {
flags = This->DoGetSearchFlags();
}
// Since scintilla uses a non POSIX way of handling the paren
// fix them
if((flags & wxSTC_FIND_REGEXP) && This) {
This->DoFixRegexParen(find);
}
int curpos = ctrl->GetCurrentPos();
int start = wxNOT_FOUND;
int end = wxNOT_FOUND;
ctrl->GetSelection(&start, &end);
if((end != wxNOT_FOUND) && fwd) {
if(ctrl->FindText(start, end, find, flags) != wxNOT_FOUND) {
// Incase we searching forward and the current selection matches the search string
// Clear the selection and set the caret position to the end of the selection
ctrl->SetCurrentPos(end);
ctrl->SetSelectionEnd(end);
ctrl->SetSelectionStart(end);
}
}
int pos = wxNOT_FOUND;
if(fwd) {
ctrl->SearchAnchor();
pos = ctrl->SearchNext(flags, find);
if(pos == wxNOT_FOUND) {
clGetManager()->SetStatusMessage(_("Wrapped past end of file"), 1);
if(search_flags & kBreakWhenWrapSearch) {
// Stop searching
return false;
}
ctrl->SetCurrentPos(0);
ctrl->SetSelectionEnd(0);
ctrl->SetSelectionStart(0);
ctrl->SearchAnchor();
pos = ctrl->SearchNext(flags, find);
}
} else {
ctrl->SearchAnchor();
pos = ctrl->SearchPrev(flags, find);
if(pos == wxNOT_FOUND) {
clGetManager()->SetStatusMessage(_("Wrapped past end of file"), 1);
if(search_flags & kBreakWhenWrapSearch) {
// Stop searching
return false;
}
int lastPos = ctrl->GetLastPosition();
ctrl->SetCurrentPos(lastPos);
ctrl->SetSelectionEnd(lastPos);
ctrl->SetSelectionStart(lastPos);
ctrl->SearchAnchor();
pos = ctrl->SearchPrev(flags, find);
}
}
if(pos == wxNOT_FOUND) {
// Restore the caret position
ctrl->SetCurrentPos(curpos);
ctrl->ClearSelections();
if(This) {
This->DoHighlightMatches(false);
This->m_matchesFound->SetLabel(_("No matches found"));
}
return false;
}
DoEnsureLineIsVisible(ctrl);
if(This && This->m_highlightMatches && !This->m_onNextPrev && (pos != wxNOT_FOUND)) {
// Fix issue when regex is enabled hanging the editor if too few chars
if((This->m_searchFlags & wxSTC_FIND_REGEXP) && findwhat.Length() < 3) {
return false;
} else if(This) {
This->DoHighlightMatches(true);
}
}
int selStart, selEnd;
ctrl->GetSelection(&selStart, &selEnd);
return (selEnd > selStart);
}
void clPluginsFindBar::OnPaint(wxPaintEvent& e)
{
wxAutoBufferedPaintDC dc(this);
dc.SetBrush(clSystemSettings::GetDefaultPanelColour());
dc.SetPen(clSystemSettings::GetDefaultPanelColour());
dc.DrawRectangle(GetClientRect());
}
bool clPluginsFindBar::HasFocus() const
{
wxWindow* win = wxWindow::FindFocus();
return win == m_textCtrlFind || win == m_buttonFind || win == m_buttonFindPrev || win == m_buttonFindAll ||
win == m_textCtrlReplace || win == m_buttonReplace || win == m_buttonReplaceAll;
}
|