Skip to content

Commit

Permalink
Find in files: hitting ENTER in any field should trigger the search
Browse files Browse the repository at this point in the history
Tab: when using GenericNoteboko allow to user to remove / set the x button & enable/disable scrolling between tabs using the mouse scroll button
  • Loading branch information
eranif committed Apr 15, 2024
1 parent da96839 commit fa1e97c
Show file tree
Hide file tree
Showing 6 changed files with 2,299 additions and 2,215 deletions.
4 changes: 3 additions & 1 deletion LiteEditor/editorsettingsdockingwidows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

#include "editorsettingsdockingwidows.h"

#include "imanager.h"

EditorSettingsDockingWindows::EditorSettingsDockingWindows(wxWindow* parent, OptionsConfigPtr options)
: OptionsConfigPage(parent, options)
{
Expand Down Expand Up @@ -81,7 +83,7 @@ EditorSettingsDockingWindows::EditorSettingsDockingWindows(wxWindow* parent, Opt
AddProperty(_("Show close button on tabs"), m_options->IsTabHasXButton(), UPDATE_BOOL_CB(SetTabHasXButton));
AddProperty(_("Show file path on tab label"), m_options->IsTabShowPath(), UPDATE_BOOL_CB(SetTabShowPath));

#if 0
#if !MAINBOOK_AUIBOOK
AddProperty(_("Mouse scroll switch bewtween tabs"), m_options->IsMouseScrollSwitchTabs(),
UPDATE_BOOL_CB(SetMouseScrollSwitchTabs));
AddProperty(_("Sort tab file list"), m_options->IsSortTabsDropdownAlphabetically(),
Expand Down
90 changes: 58 additions & 32 deletions LiteEditor/findinfiles_dlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,25 @@
// Declare the bitmap loading function
extern void wxCABC4InitBitmapResources();

static bool bBitmapLoaded = false;
namespace
{
// return the wxBORDER_SIMPLE that matches the current application theme
wxBorder get_border_simple_theme_aware_bit()
{
#if wxVERSION_NUMBER >= 3300 && defined(__WXMSW__)
return wxSystemSettings::GetAppearance().IsDark() ? wxBORDER_SIMPLE : wxBORDER_STATIC;
#else
return wxBORDER_DEFAULT;
#endif
} // DoGetBorderSimpleBit
bool bBitmapLoaded = false;
} // namespace

FindInFilesDialogBase::FindInFilesDialogBase(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos,
const wxSize& size, long style)
: wxDialog(parent, id, title, pos, size, style)
{
if(!bBitmapLoaded) {
if (!bBitmapLoaded) {
// We need to initialise the default bitmap handler
wxXmlResource::Get()->AddHandler(new wxBitmapXmlHandler);
wxCABC4InitBitmapResources();
Expand All @@ -33,12 +45,16 @@ FindInFilesDialogBase::FindInFilesDialogBase(wxWindow* parent, wxWindowID id, co
wxBoxSizer* boxSizer132 = new wxBoxSizer(wxHORIZONTAL);
m_panelMainPanel->SetSizer(boxSizer132);

wxBoxSizer* boxSizer178 = new wxBoxSizer(wxVERTICAL);

boxSizer132->Add(boxSizer178, 1, wxALL | wxEXPAND, WXC_FROM_DIP(5));

wxFlexGridSizer* fgSizer41 = new wxFlexGridSizer(0, 3, 0, 0);
fgSizer41->SetFlexibleDirection(wxBOTH);
fgSizer41->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
fgSizer41->AddGrowableCol(1);

boxSizer132->Add(fgSizer41, 1, wxALL | wxEXPAND, WXC_FROM_DIP(5));
boxSizer178->Add(fgSizer41, 1, wxALL | wxEXPAND, WXC_FROM_DIP(5));

m_staticText1 = new wxStaticText(m_panelMainPanel, wxID_ANY, _("Find :"), wxDefaultPosition,
wxDLG_UNIT(m_panelMainPanel, wxSize(-1, -1)), 0);
Expand Down Expand Up @@ -149,94 +165,98 @@ FindInFilesDialogBase::FindInFilesDialogBase(wxWindow* parent, wxWindowID id, co

wxGridBagSizer* gridBagSizer174 = new wxGridBagSizer(0, 0);

boxSizer7->Add(gridBagSizer174, 0, wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND, WXC_FROM_DIP(5));
boxSizer178->Add(gridBagSizer174, 0, wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND, WXC_FROM_DIP(5));

wxStaticBoxSizer* staticBoxSizer170 =
new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, _("Options:")), wxHORIZONTAL);
new wxStaticBoxSizer(new wxStaticBox(m_panelMainPanel, wxID_ANY, _("Options:")), wxHORIZONTAL);

gridBagSizer174->Add(staticBoxSizer170, wxGBPosition(0, 0), wxGBSpan(1, 2), wxALL | wxEXPAND | wxALIGN_LEFT,
WXC_FROM_DIP(5));

m_matchCase = new wxCheckBox(this, wxID_ANY, _("Case"), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);
m_matchCase = new wxCheckBox(m_panelMainPanel, wxID_ANY, _("Case"), wxDefaultPosition,
wxDLG_UNIT(m_panelMainPanel, wxSize(-1, -1)), 0);
m_matchCase->SetValue(false);
m_matchCase->SetToolTip(_("Toggle case sensitive search"));

staticBoxSizer170->Add(m_matchCase, 0, wxALL | wxEXPAND, WXC_FROM_DIP(5));

m_matchWholeWord =
new wxCheckBox(this, wxID_ANY, _("Word"), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);
m_matchWholeWord = new wxCheckBox(m_panelMainPanel, wxID_ANY, _("Word"), wxDefaultPosition,
wxDLG_UNIT(m_panelMainPanel, wxSize(-1, -1)), 0);
m_matchWholeWord->SetValue(false);
m_matchWholeWord->SetToolTip(_("Toggle whole word search"));

staticBoxSizer170->Add(m_matchWholeWord, 0, wxALL | wxEXPAND, WXC_FROM_DIP(5));

m_regualrExpression =
new wxCheckBox(this, wxID_ANY, _("Regex"), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);
m_regualrExpression = new wxCheckBox(m_panelMainPanel, wxID_ANY, _("Regex"), wxDefaultPosition,
wxDLG_UNIT(m_panelMainPanel, wxSize(-1, -1)), 0);
m_regualrExpression->SetValue(false);
m_regualrExpression->SetToolTip(_("The 'Find What' field is a regular expression"));

staticBoxSizer170->Add(m_regualrExpression, 0, wxALL | wxEXPAND, WXC_FROM_DIP(5));

m_checkBoxPipeForGrep =
new wxCheckBox(this, wxID_ANY, _("Pipe filter"), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);
m_checkBoxPipeForGrep = new wxCheckBox(m_panelMainPanel, wxID_ANY, _("Pipe filter"), wxDefaultPosition,
wxDLG_UNIT(m_panelMainPanel, wxSize(-1, -1)), 0);
m_checkBoxPipeForGrep->SetValue(false);
m_checkBoxPipeForGrep->SetToolTip(
_("Use the pipe character (\"|\") as a special separator for applying additional filters. This has the similar "
"effect as using the \"grep\" command line tool"));

staticBoxSizer170->Add(m_checkBoxPipeForGrep, 0, wxALL, WXC_FROM_DIP(5));

m_checkBoxSaveFilesBeforeSearching =
new wxCheckBox(this, wxID_ANY, _("Save before"), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);
m_checkBoxSaveFilesBeforeSearching = new wxCheckBox(m_panelMainPanel, wxID_ANY, _("Save before"), wxDefaultPosition,
wxDLG_UNIT(m_panelMainPanel, wxSize(-1, -1)), 0);
m_checkBoxSaveFilesBeforeSearching->SetValue(false);
m_checkBoxSaveFilesBeforeSearching->SetToolTip(_("Save any modified files before search starts"));

staticBoxSizer170->Add(m_checkBoxSaveFilesBeforeSearching, 0, wxALL | wxEXPAND, WXC_FROM_DIP(5));

wxStaticBoxSizer* staticBoxSizer175 =
new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, _("File System:")), wxHORIZONTAL);
new wxStaticBoxSizer(new wxStaticBox(m_panelMainPanel, wxID_ANY, _("File System:")), wxHORIZONTAL);

gridBagSizer174->Add(staticBoxSizer175, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALL | wxEXPAND, WXC_FROM_DIP(5));

m_checkBoxFollowSymlinks =
new wxCheckBox(this, wxID_ANY, _("Symlinks"), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);
m_checkBoxFollowSymlinks = new wxCheckBox(m_panelMainPanel, wxID_ANY, _("Symlinks"), wxDefaultPosition,
wxDLG_UNIT(m_panelMainPanel, wxSize(-1, -1)), 0);
m_checkBoxFollowSymlinks->SetValue(false);
m_checkBoxFollowSymlinks->SetToolTip(_("When enabled, follow symbolic links folders"));

staticBoxSizer175->Add(m_checkBoxFollowSymlinks, 0, wxALL | wxEXPAND, WXC_FROM_DIP(5));

m_checkBoxIncludeHiddenFolders =
new wxCheckBox(this, wxID_ANY, _("Hidden folders"), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);
m_checkBoxIncludeHiddenFolders = new wxCheckBox(m_panelMainPanel, wxID_ANY, _("Hidden folders"), wxDefaultPosition,
wxDLG_UNIT(m_panelMainPanel, wxSize(-1, -1)), 0);
m_checkBoxIncludeHiddenFolders->SetValue(false);
m_checkBoxIncludeHiddenFolders->SetToolTip(_("Search in hidden folders"));

staticBoxSizer175->Add(m_checkBoxIncludeHiddenFolders, 0, wxALL, WXC_FROM_DIP(5));

wxStaticBoxSizer* staticBoxSizer171 =
new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, _("Presets:")), wxHORIZONTAL);
new wxStaticBoxSizer(new wxStaticBox(m_panelMainPanel, wxID_ANY, _("Presets:")), wxHORIZONTAL);

gridBagSizer174->Add(staticBoxSizer171, wxGBPosition(1, 1), wxGBSpan(1, 1), wxALL | wxEXPAND, WXC_FROM_DIP(5));

m_checkBoxTODO = new wxCheckBox(this, wxID_ANY, _("TODO"), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);
m_checkBoxTODO = new wxCheckBox(m_panelMainPanel, wxID_ANY, _("TODO"), wxDefaultPosition,
wxDLG_UNIT(m_panelMainPanel, wxSize(-1, -1)), 0);
m_checkBoxTODO->SetValue(false);
m_checkBoxTODO->SetToolTip(_("Search for TODO patterns in the code\nThis options enables regular expression"));

staticBoxSizer171->Add(m_checkBoxTODO, 0, wxALL, WXC_FROM_DIP(5));

m_checkBoxATTN = new wxCheckBox(this, wxID_ANY, _("ATTN"), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);
m_checkBoxATTN = new wxCheckBox(m_panelMainPanel, wxID_ANY, _("ATTN"), wxDefaultPosition,
wxDLG_UNIT(m_panelMainPanel, wxSize(-1, -1)), 0);
m_checkBoxATTN->SetValue(false);
m_checkBoxATTN->SetToolTip(_("Search for ATTN patterns in the code\nThis options enables regular expression"));

staticBoxSizer171->Add(m_checkBoxATTN, 0, wxALL | wxEXPAND, WXC_FROM_DIP(5));

m_checkBoxBUG = new wxCheckBox(this, wxID_ANY, _("BUG"), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);
m_checkBoxBUG = new wxCheckBox(m_panelMainPanel, wxID_ANY, _("BUG"), wxDefaultPosition,
wxDLG_UNIT(m_panelMainPanel, wxSize(-1, -1)), 0);
m_checkBoxBUG->SetValue(false);
m_checkBoxBUG->SetToolTip(_("Search for BUG patterns in the code\nThis options enables regular expression"));

staticBoxSizer171->Add(m_checkBoxBUG, 0, wxALL, WXC_FROM_DIP(5));

m_checkBoxFIXME =
new wxCheckBox(this, wxID_ANY, _("FIXME"), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);
m_checkBoxFIXME = new wxCheckBox(m_panelMainPanel, wxID_ANY, _("FIXME"), wxDefaultPosition,
wxDLG_UNIT(m_panelMainPanel, wxSize(-1, -1)), 0);
m_checkBoxFIXME->SetValue(false);
m_checkBoxFIXME->SetToolTip(_("Search for FIXME patterns in the code\nThis options enables regular expression"));

Expand All @@ -246,15 +266,15 @@ FindInFilesDialogBase::FindInFilesDialogBase(wxWindow* parent, wxWindowID id, co

SetName(wxT("FindInFilesDialogBase"));
SetSize(wxDLG_UNIT(this, wxSize(-1, -1)));
if(GetSizer()) {
if (GetSizer()) {
GetSizer()->Fit(this);
}
if(GetParent()) {
if (GetParent()) {
CentreOnParent(wxBOTH);
} else {
CentreOnScreen(wxBOTH);
}
if(!wxPersistenceManager::Get().Find(this)) {
if (!wxPersistenceManager::Get().Find(this)) {
wxPersistenceManager::Get().RegisterAndRestore(this);
} else {
wxPersistenceManager::Get().Restore(this);
Expand All @@ -266,7 +286,10 @@ FindInFilesDialogBase::FindInFilesDialogBase(wxWindow* parent, wxWindowID id, co
m_replaceString->Bind(wxEVT_COMMAND_TEXT_ENTER, &FindInFilesDialogBase::OnReplaceEnter, this);
m_replaceAll->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &FindInFilesDialogBase::OnReplace, this);
m_replaceAll->Bind(wxEVT_UPDATE_UI, &FindInFilesDialogBase::OnReplaceUI, this);
m_fileTypes->Bind(wxEVT_COMMAND_TEXT_ENTER, &FindInFilesDialogBase::OnFindEnter, this);
m_comboBoxWhere->Bind(wxEVT_COMMAND_TEXT_ENTER, &FindInFilesDialogBase::OnFindEnter, this);
m_btnAddPath->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &FindInFilesDialogBase::OnAddPath, this);
m_comboBoxEncoding->Bind(wxEVT_COMMAND_TEXT_ENTER, &FindInFilesDialogBase::OnFindEnter, this);
m_cancel->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &FindInFilesDialogBase::OnButtonClose, this);
m_regualrExpression->Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &FindInFilesDialogBase::OnRegex, this);
m_checkBoxTODO->Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &FindInFilesDialogBase::OnTODO, this);
Expand All @@ -283,7 +306,10 @@ FindInFilesDialogBase::~FindInFilesDialogBase()
m_replaceString->Unbind(wxEVT_COMMAND_TEXT_ENTER, &FindInFilesDialogBase::OnReplaceEnter, this);
m_replaceAll->Unbind(wxEVT_COMMAND_BUTTON_CLICKED, &FindInFilesDialogBase::OnReplace, this);
m_replaceAll->Unbind(wxEVT_UPDATE_UI, &FindInFilesDialogBase::OnReplaceUI, this);
m_fileTypes->Unbind(wxEVT_COMMAND_TEXT_ENTER, &FindInFilesDialogBase::OnFindEnter, this);
m_comboBoxWhere->Unbind(wxEVT_COMMAND_TEXT_ENTER, &FindInFilesDialogBase::OnFindEnter, this);
m_btnAddPath->Unbind(wxEVT_COMMAND_BUTTON_CLICKED, &FindInFilesDialogBase::OnAddPath, this);
m_comboBoxEncoding->Unbind(wxEVT_COMMAND_TEXT_ENTER, &FindInFilesDialogBase::OnFindEnter, this);
m_cancel->Unbind(wxEVT_COMMAND_BUTTON_CLICKED, &FindInFilesDialogBase::OnButtonClose, this);
m_regualrExpression->Unbind(wxEVT_COMMAND_CHECKBOX_CLICKED, &FindInFilesDialogBase::OnRegex, this);
m_checkBoxTODO->Unbind(wxEVT_COMMAND_CHECKBOX_CLICKED, &FindInFilesDialogBase::OnTODO, this);
Expand All @@ -296,7 +322,7 @@ FindInFilesLocationsDlgBase::FindInFilesLocationsDlgBase(wxWindow* parent, wxWin
const wxPoint& pos, const wxSize& size, long style)
: wxDialog(parent, id, title, pos, size, style)
{
if(!bBitmapLoaded) {
if (!bBitmapLoaded) {
// We need to initialise the default bitmap handler
wxXmlResource::Get()->AddHandler(new wxBitmapXmlHandler);
wxCABC4InitBitmapResources();
Expand Down Expand Up @@ -345,15 +371,15 @@ FindInFilesLocationsDlgBase::FindInFilesLocationsDlgBase(wxWindow* parent, wxWin

SetName(wxT("FindInFilesLocationsDlgBase"));
SetSize(wxDLG_UNIT(this, wxSize(-1, -1)));
if(GetSizer()) {
if (GetSizer()) {
GetSizer()->Fit(this);
}
if(GetParent()) {
if (GetParent()) {
CentreOnParent(wxBOTH);
} else {
CentreOnScreen(wxBOTH);
}
if(!wxPersistenceManager::Get().Find(this)) {
if (!wxPersistenceManager::Get().Find(this)) {
wxPersistenceManager::Get().RegisterAndRestore(this);
} else {
wxPersistenceManager::Get().Restore(this);
Expand Down
2 changes: 1 addition & 1 deletion LiteEditor/findinfiles_dlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ class FindInFilesDialogBase : public wxDialog
wxStaticText* GetStaticText5() { return m_staticText5; }
clThemedComboBox* GetComboBoxEncoding() { return m_comboBoxEncoding; }
wxButton* GetCancel() { return m_cancel; }
wxPanel* GetPanelMainPanel() { return m_panelMainPanel; }
wxCheckBox* GetMatchCase() { return m_matchCase; }
wxCheckBox* GetMatchWholeWord() { return m_matchWholeWord; }
wxCheckBox* GetRegualrExpression() { return m_regualrExpression; }
Expand All @@ -115,6 +114,7 @@ class FindInFilesDialogBase : public wxDialog
wxCheckBox* GetCheckBoxATTN() { return m_checkBoxATTN; }
wxCheckBox* GetCheckBoxBUG() { return m_checkBoxBUG; }
wxCheckBox* GetCheckBoxFIXME() { return m_checkBoxFIXME; }
wxPanel* GetPanelMainPanel() { return m_panelMainPanel; }
FindInFilesDialogBase(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Find In Files"),
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(-1, -1),
long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
Expand Down
4 changes: 2 additions & 2 deletions LiteEditor/findinfiles_dlg_formbuilder_bitmaps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ void wxCABC4InitBitmapResources()
else wxFileSystem::AddHandler(new wxMemoryFSHandlerBase);
}

XRC_ADD_FILE(wxT("XRC_resource/findinfiles_dlg_formbuilder_bitmaps.cpp$C__src_codelite_formbuilder_findinfiles_dlg_formbuilder_bitmaps.xrc"), xml_res_file_0, xml_res_size_0, wxT("text/xml"));
wxXmlResource::Get()->Load(wxT("memory:XRC_resource/findinfiles_dlg_formbuilder_bitmaps.cpp$C__src_codelite_formbuilder_findinfiles_dlg_formbuilder_bitmaps.xrc"));
XRC_ADD_FILE(wxT("XRC_resource/findinfiles_dlg_formbuilder_bitmaps.cpp$C__msys64_home_eran_devl_codelite_formbuilder_findinfiles_dlg_formbuilder_bitmaps.xrc"), xml_res_file_0, xml_res_size_0, wxT("text/xml"));
wxXmlResource::Get()->Load(wxT("memory:XRC_resource/findinfiles_dlg_formbuilder_bitmaps.cpp$C__msys64_home_eran_devl_codelite_formbuilder_findinfiles_dlg_formbuilder_bitmaps.xrc"));
}
6 changes: 6 additions & 0 deletions LiteEditor/mainbook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1573,6 +1573,12 @@ void MainBook::OnSettingsChanged(wxCommandEvent& e)
{
e.Skip();
ApplyTabLabelChanges();

#if !MAINBOOK_AUIBOOK
m_book->EnableStyle(kNotebook_CloseButtonOnActiveTab, EditorConfigST::Get()->GetOptions()->IsTabHasXButton());
m_book->EnableStyle(kNotebook_MouseScrollSwitchTabs,
EditorConfigST::Get()->GetOptions()->IsMouseScrollSwitchTabs());
#endif
}

clEditor* MainBook::OpenFile(const BrowseRecord& rec)
Expand Down

0 comments on commit fa1e97c

Please sign in to comment.