Skip to content

Commit

Permalink
Simplified the find-in-files masking event
Browse files Browse the repository at this point in the history
Fixed: codelite_cppcheck is now installed with all its configuration files
  • Loading branch information
eranif committed Jun 3, 2014
1 parent 6857976 commit abbced1
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 63 deletions.
1 change: 1 addition & 0 deletions InnoSetup/codelite_mingw.iss
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Source: "..\Runtime\config\build_settings.xml.default.win"; DestDir: "{app}\conf
Source: "..\Runtime\rc\*"; DestDir: "{app}\rc"; Flags: ignoreversion ; Components: Editor
Source: "..\Runtime\astyle.sample"; DestDir: "{app}"; Flags: ignoreversion ; Components: Editor
Source: "..\Runtime\config\codelite.layout.default"; DestDir: "{app}\config"; DestName: codelite.layout; Flags: ignoreversion ; Components: Editor
Source: "..\sdk\codelite_cppcheck\cfg\*.cfg"; DestDir: "{app}\config\cppcheck"; Flags: ignoreversion ; Components: Editor
Source: "..\Runtime\templates\*"; DestDir: "{app}\templates"; Flags: recursesubdirs ; Components: Editor

; Override with Windows specific files
Expand Down
12 changes: 3 additions & 9 deletions Interfaces/codelite_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,18 +359,12 @@
// the menu
#define wxEVT_CMD_EDITOR_MARGIN_CONTEXT_MENU 3520

// codelite is requesting for the find-in-files file masking.
// Event type: clCommandEvent
// The Find In Files dialog requests an additional file mask
// the format should be:
// *.a;*.b
// and should be placed at:
// event.SetString("*.a;*.b");
// The plugin can also control what codelite will do with its masking by
// setting the event.SetInt() with the following values (the plugin can use
// bitwise OR):
// 0x00000001 -> append the plugins' masking to the default masking
// 0x00000002 -> prepend the plugins' masking to default masking
// 0x00000004 -> replace default masking with the one provided by the plugin
// 0x00000008 -> select the plugin's masking by default
// event.GetStrings().Add("*.a;*.b");
#define wxEVT_CMD_GET_FIND_IN_FILES_MASK 3521

/////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion LiteEditor/LiteEditor.project
Original file line number Diff line number Diff line change
Expand Up @@ -1556,7 +1556,7 @@ resources.cpp: resources.xrc
<Library Value="liblibclang.dll"/>
</Linker>
<ResourceCompiler Options="$(shell wx-config --rcflags)" Required="yes"/>
<General OutputFile="$(IntermediateDirectory)/codelite-dbg.exe" IntermediateDirectory="./Debug" Command=".\codelite-dbg.exe" CommandArguments="-b ." UseSeparateDebugArgs="yes" DebugArguments="-b . --no-plugins" WorkingDirectory="../Runtime" PauseExecWhenProcTerminates="no" IsGUIProgram="no" IsEnabled="yes"/>
<General OutputFile="$(IntermediateDirectory)/codelite-dbg.exe" IntermediateDirectory="./Debug" Command=".\codelite-dbg.exe" CommandArguments="-b ." UseSeparateDebugArgs="yes" DebugArguments="-b . --with-plugins PHP" WorkingDirectory="../Runtime" PauseExecWhenProcTerminates="no" IsGUIProgram="no" IsEnabled="yes"/>
<Environment EnvVarSetName="Default" DbgSetName="">
<![CDATA[PATH=../sdk/clang/lib;$(WXWIN)\lib\gcc_dll;$(PATH)]]>
</Environment>
Expand Down
68 changes: 24 additions & 44 deletions LiteEditor/findinfilesdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,56 +135,30 @@ void FindInFilesDialog::SetRootDir(const wxString &rootDir)
void FindInFilesDialog::DoSetFileMask()
{
// First send an event to the plugins asking for an additional file mask
wxCommandEvent getFileMaskEvent(wxEVT_CMD_GET_FIND_IN_FILES_MASK, GetId());
clCommandEvent getFileMaskEvent(wxEVT_CMD_GET_FIND_IN_FILES_MASK, GetId());
getFileMaskEvent.SetEventObject(this);
getFileMaskEvent.SetInt(0);
getFileMaskEvent.SetString(wxT(""));
EventNotifier::Get()->ProcessEvent(getFileMaskEvent);

// Get the output
wxString pluginMask = getFileMaskEvent.GetString();
int pluginMaskFlags = getFileMaskEvent.GetInt();
wxArrayString fileTypes = m_data.GetFileMask();
size_t insertPos = wxString::npos;

// Incase we got an additional file masking, add it to the default ones
// as instructed by the plugin
if(pluginMask.IsEmpty() == false) {
if(pluginMaskFlags & 0x00000004)
fileTypes.Clear();

if(pluginMaskFlags & 0x00000001) {
int where = fileTypes.Index(pluginMask);
if(where != wxNOT_FOUND)
fileTypes.RemoveAt(where);
insertPos = fileTypes.Add(pluginMask);
}

else if(pluginMaskFlags & 0x00000002) {
int where = fileTypes.Index(pluginMask);
if(where != wxNOT_FOUND)
fileTypes.RemoveAt(where);
fileTypes.Insert(pluginMask, 0);
insertPos = 0;
}
}

if(fileTypes.IsEmpty() == false) {
wxArrayString fileTypes = m_data.GetFileMask();
m_pluginFileMask = getFileMaskEvent.GetStrings();
if( !fileTypes.IsEmpty() ) {

m_fileTypes->Clear();
m_fileTypes->Append(m_pluginFileMask);
m_fileTypes->Append(fileTypes);

int where (wxNOT_FOUND);
if((pluginMaskFlags & 0x00000008) && (insertPos != wxString::npos)) {
where = m_fileTypes->FindString(pluginMask);

int where = wxNOT_FOUND;
if ( !m_pluginFileMask.IsEmpty() ) {
where = 0;
} else {
where = m_fileTypes->FindString(m_data.GetSelectedMask());

if(where == wxNOT_FOUND) {
where = 0;
}
}
if(where == wxNOT_FOUND)
where = 0;

m_fileTypes->SetSelection(where);
m_fileTypes->SetSelection( where );
}
}

Expand Down Expand Up @@ -303,10 +277,16 @@ void FindInFilesDialog::OnClick(wxCommandEvent &event)
value.Trim().Trim(false);

wxArrayString fileMask = m_fileTypes->GetStrings();
if(!value.IsEmpty() && fileMask.Index(value) == wxNOT_FOUND) {
fileMask.Add(value);
wxArrayString fileMaskFiltered;

// Remove the plugins mask before we save it
for(size_t i=0; i<fileMask.GetCount(); ++i) {
if ( m_pluginFileMask.Index(fileMask.Item(i)) == wxNOT_FOUND ) {
// not part of the plugin mask => keep it
fileMaskFiltered.Add( fileMask.Item(i) );
}
}

fileMaskFiltered.swap( fileMask );
m_data.SetSearchScope(m_dirPicker->GetCurrentSelection());

m_data.SetFileMask( fileMask );
Expand Down
2 changes: 2 additions & 0 deletions LiteEditor/findinfilesdlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
class FindInFilesDialog : public FindInFilesDialogBase
{
FindReplaceData m_data;
wxArrayString m_pluginFileMask;

protected:
void DoSearch();
void DoSearchReplace();
Expand Down
12 changes: 12 additions & 0 deletions LiteEditor/findreplacedlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,10 @@ void FindReplaceData::FromJSON(const JSONElement& json)
TruncateArray(m_searchPaths, (size_t)max_value);
TruncateArray(m_replaceString, (size_t)max_value);
TruncateArray(m_findString, (size_t)max_value);

if ( m_fileMask.IsEmpty() ) {
m_fileMask.Add("*.c;*.cpp;*.cxx;*.cc;*.h;*.hpp;*.inc;*.mm;*.m;*.xrc");
}
}

JSONElement FindReplaceData::ToJSON() const
Expand Down Expand Up @@ -570,3 +574,11 @@ wxArrayString FindReplaceData::GetReplaceStringArr() const
}
return replaceArr;
}

FindReplaceData::FindReplaceData()
: clConfigItem("FindReplaceData")
, m_flags(0)
, m_searchScope(1)
{

}
7 changes: 1 addition & 6 deletions LiteEditor/findreplacedlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,7 @@ class FindReplaceData : public clConfigItem
* @return
*/
virtual JSONElement ToJSON() const;

FindReplaceData()
: clConfigItem("FindReplaceData")
, m_flags(0)
, m_searchScope(1)
{}
FindReplaceData();
virtual ~FindReplaceData()
{}

Expand Down
2 changes: 2 additions & 0 deletions Runtime/make_mac_bundle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ mkdir -p ./codelite.app/Contents/SharedSupport/plugins
mkdir -p ./codelite.app/Contents/SharedSupport/plugins/resources/
mkdir -p ./codelite.app/Contents/SharedSupport/debuggers
mkdir -p ./codelite.app/Contents/SharedSupport/config
mkdir -p ./codelite.app/Contents/SharedSupport/config/cppcheck

wx_file_list=`otool -L ../bin/codelite | grep libwx_* | awk '{print $1;}'`

Expand Down Expand Up @@ -209,6 +210,7 @@ cp -pr ../../Runtime/codelite-icons-fresh-farm.zip ./codelite.app/Contents/Share

## copy empty layout file
cp ../../Runtime/config/codelite.layout.default ./codelite.app/Contents/SharedSupport/config/codelite.layout
cp ../../sdk/codelite_cppcheck/cfg/*.cfg ./codelite.app/Contents/SharedSupport/config/cppcheck/
cp ../../Runtime/config/accelerators.conf.default ./codelite.app/Contents/SharedSupport/config/
cp ../../Runtime/config/build_settings.xml.default.mac ./codelite.app/Contents/SharedSupport/config/build_settings.xml.default
cp ../../Runtime/config/plugins.xml.default ./codelite.app/Contents/SharedSupport/config
Expand Down
6 changes: 5 additions & 1 deletion sdk/codelite_cppcheck/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ FILE(GLOB SRCS "cli/*.cpp" "lib/*.cpp" "externals/*/*.cpp")
# CppChecker 1.63 requires files stored in cfg/ at run-time. For some daft reason, it only looks for this by default inside ${BINDIR/},
# which (at least for Linux) is _not_ the correct location. So we have to set an alternative place, and tell it at *compile-time*.
# AFAICT you can't just add an env var at run-time :/
add_definitions(-DCFGDIR=\"${CL_PREFIX}/share/codelite/config/cfg\")
if ( UNIX AND NOT APPLE )
add_definitions(-DCFGDIR=\"${CL_PREFIX}/share/codelite/config/cfg\")
elseif ( APPLE )
add_definitions(-DCFGDIR=\"config/cppcheck\")
endif()

# Define the output
add_executable(codelite_cppcheck ${SRCS})
Expand Down
4 changes: 2 additions & 2 deletions sdk/codelite_cppcheck/codelite_cppcheck.project
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
<Compiler Options="-g" C_Options="-g" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" UseDifferentPCHFlags="no" PCHFlags="">
<IncludePath Value="."/>
<IncludePath Value="externals/tinyxml"/>
<Preprocessor Value="CFGDIR=\&quot;config\&quot;"/>
<Preprocessor Value="CFGDIR=\&quot;config/cppcheck\&quot;"/>
</Compiler>
<Linker Options="" Required="yes"/>
<ResourceCompiler Options="" Required="no"/>
Expand Down Expand Up @@ -186,7 +186,7 @@
<Compiler Options="" C_Options="" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" UseDifferentPCHFlags="no" PCHFlags="">
<IncludePath Value="."/>
<IncludePath Value="externals/tinyxml"/>
<Preprocessor Value="CFGDIR=\&quot;config\&quot;"/>
<Preprocessor Value="CFGDIR=\&quot;config/cppcheck\&quot;"/>
</Compiler>
<Linker Options="-O2" Required="yes"/>
<ResourceCompiler Options="" Required="no"/>
Expand Down

0 comments on commit abbced1

Please sign in to comment.