Skip to content

Commit

Permalink
Restore the find/replace dialog size from previous session
Browse files Browse the repository at this point in the history
Signed-off-by: Eran Ifrah <[email protected]>
  • Loading branch information
eranif committed Dec 21, 2024
1 parent 2942c92 commit a4aa9c1
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 17 deletions.
22 changes: 18 additions & 4 deletions LiteEditor/quickfindbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,15 @@ QuickFindBar::QuickFindBar(wxWindow* parent, wxWindowID id)

// Make sure that the 'Replace' field is selected when we hit TAB while in the 'Find' field
m_textCtrlReplace->MoveAfterInTabOrder(m_textCtrlFind);
GetSizer()->Fit(this);

#if !defined(__WXMAC__)
SetSize(parent->GetSize().GetWidth() / 2, wxNOT_FOUND);
#endif
int w = wxNOT_FOUND;
int h = wxNOT_FOUND;
if (clConfig::Get().Read("FindBar/Width", w) && clConfig::Get().Read("FindBar/Height", h)) {
SetSize(w, h);
SetSizeHints(w, h);
} else {
GetSizer()->Fit(this);
}
Layout();
}

Expand All @@ -222,6 +226,8 @@ QuickFindBar::~QuickFindBar()
// Remember the buttons clicked
clConfig::Get().Write("FindBar/SearchFlags", (int)DoGetSearchFlags());
clConfig::Get().Write("FindBar/HighlightOccurences", m_highlightMatches);
clConfig::Get().Write("FindBar/Width", GetSize().GetWidth());
clConfig::Get().Write("FindBar/Height", GetSize().GetHeight());

wxTheApp->Unbind(wxEVT_MENU, &QuickFindBar::OnFindNextCaret, this, XRCID("find_next_at_caret"));
wxTheApp->Unbind(wxEVT_MENU, &QuickFindBar::OnFindPreviousCaret, this, XRCID("find_previous_at_caret"));
Expand Down Expand Up @@ -788,6 +794,10 @@ void QuickFindBar::DoReplaceAll(bool selectionOnly)

TargetRange QuickFindBar::DoFind(size_t find_flags, const TargetRange& target)
{
if (!m_sci) {
return {};
}

// define the target range
size_t search_options = DoGetSearchFlags();
int target_start = wxNOT_FOUND, target_end = wxNOT_FOUND;
Expand Down Expand Up @@ -1008,6 +1018,10 @@ bool QuickFindBar::IsReplacementRegex() const

TargetRange QuickFindBar::DoFindWithMessage(size_t find_flags, const TargetRange& target)
{
if (!m_sci) {
return {};
}

m_message->SetLabel(wxEmptyString);
auto res = DoFind(find_flags, target);
if (!res.IsOk()) {
Expand Down
12 changes: 3 additions & 9 deletions LiteEditor/quickfindbarbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,14 @@ clFindReplaceDialogBase::clFindReplaceDialogBase(
wxID_ANY,
wxT(""),
wxDefaultPosition,
wxDLG_UNIT(m_mainPanel, wxSize(350, -1)),
wxDLG_UNIT(m_mainPanel, wxSize(400, -1)),
wxTE_PROCESS_ENTER);
m_textCtrlFind->SetFocus();
#if wxVERSION_NUMBER >= 3000
m_textCtrlFind->SetHint(_("Find what..."));
#endif

flexGridSizer107->Add(m_textCtrlFind, 0, wxALL | wxEXPAND | wxALIGN_CENTER_VERTICAL, WXC_FROM_DIP(2));
m_textCtrlFind->SetMinSize(wxSize(350, -1));

m_buttonFind = new clThemedButton(
m_mainPanel, wxID_FIND, _("Find"), wxDefaultPosition, wxDLG_UNIT(m_mainPanel, wxSize(-1, -1)), 0);
Expand All @@ -271,18 +270,13 @@ clFindReplaceDialogBase::clFindReplaceDialogBase(

flexGridSizer107->Add(m_buttonFindAll, 0, wxALL | wxEXPAND, WXC_FROM_DIP(2));

m_textCtrlReplace = new clThemedTextCtrl(m_mainPanel,
wxID_ANY,
wxT(""),
wxDefaultPosition,
wxDLG_UNIT(m_mainPanel, wxSize(350, -1)),
wxTE_PROCESS_ENTER);
m_textCtrlReplace = new clThemedTextCtrl(
m_mainPanel, wxID_ANY, wxT(""), wxDefaultPosition, wxDLG_UNIT(m_mainPanel, wxSize(-1, -1)), wxTE_PROCESS_ENTER);
#if wxVERSION_NUMBER >= 3000
m_textCtrlReplace->SetHint(_("Replace with..."));
#endif

flexGridSizer107->Add(m_textCtrlReplace, 0, wxALL | wxEXPAND | wxALIGN_CENTER_VERTICAL, WXC_FROM_DIP(2));
m_textCtrlReplace->SetMinSize(wxSize(350, -1));

m_buttonReplace = new clThemedButton(
m_mainPanel, wxID_REPLACE, _("Replace"), wxDefaultPosition, wxDLG_UNIT(m_mainPanel, wxSize(-1, -1)), 0);
Expand Down
8 changes: 4 additions & 4 deletions LiteEditor/quickfindbarbase.wxcp
Original file line number Diff line number Diff line change
Expand Up @@ -1157,11 +1157,11 @@
}, {
"type": "string",
"m_label": "Size:",
"m_value": "350,-1"
"m_value": "400,-1"
}, {
"type": "string",
"m_label": "Minimum Size:",
"m_value": "350,-1"
"m_value": "-1,-1"
}, {
"type": "string",
"m_label": "Name:",
Expand Down Expand Up @@ -1584,11 +1584,11 @@
}, {
"type": "string",
"m_label": "Size:",
"m_value": "350,-1"
"m_value": "-1,-1"
}, {
"type": "string",
"m_label": "Minimum Size:",
"m_value": "350,-1"
"m_value": "-1,-1"
}, {
"type": "string",
"m_label": "Name:",
Expand Down
4 changes: 4 additions & 0 deletions Plugin/clThemedTextCtrl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ class WXDLLIMPEXP_SDK clThemedTextCtrl : public clThemedTextCtrlBase
void SetWrapMode(int) {}
wxString GetText() const { return GetValue(); }
void ClearAll() { Clear(); }
#else
// wxSTC does not provide "SetHint", what it does, it sets the text to the hint
// which triggers an event (an unwanted one)
bool SetHint(const wxString&) override { return false; }
#endif

protected:
Expand Down

0 comments on commit a4aa9c1

Please sign in to comment.