Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Move nested thread class to .cpp file.

  • Loading branch information...
commit 26c79fc58b63bbabb3d4c52553095fee157b6a9a 1 parent 1a4a5a6
@adamv adamv authored
View
83 src/FindInProjectDlg.cpp
@@ -22,6 +22,64 @@
#include "WebKitHtmlWnd.h"
#endif
+class SearchThread : public wxThread {
+public:
+ SearchThread();
+ virtual void* Entry();
+ void DeleteThread();
+
+ void StartSearch(const wxString& path, const wxString& pattern, bool matchCase, bool regex);
+ void CancelSearch();
+ bool IsSearching() const {return m_isSearching;};
+ bool LastError() const {return m_lastError;};
+
+ bool GetCurrentPath(wxString& currentPath);
+ bool UpdateOutput(wxString& output);
+
+private:
+ struct FileMatch {
+ unsigned int line;
+ unsigned int column;
+ wxFileOffset start;
+ wxFileOffset end;
+ };
+
+ struct SearchInfo {
+ wxString pattern;
+ wxString patternUpper;
+ wxCharBuffer UTF8buffer;
+ wxCharBuffer UTF8bufferUpper;
+ size_t byte_len;
+ char charmap[256];
+ char lastChar;
+ bool matchCase;
+ pcre* regex;
+ wxString output;
+ };
+
+ void SearchDir(const wxString& path, const SearchInfo& si, ProjectInfoHandler& infoHandler);
+ void DoSearch(const MMapBuffer& buf, const SearchInfo& si, vector<FileMatch>& matches) const;
+ void WriteResult(const MMapBuffer& buf, const wxFileName& filepath, vector<FileMatch>& matches);
+ bool PrepareSearchInfo(SearchInfo& si, const wxString& pattern, bool matchCase, bool regex);
+
+ // Member variables
+ bool m_isSearching;
+ bool m_isWaiting;
+ bool m_stopSearch;
+ wxString m_path;
+ wxString m_pattern;
+ bool m_matchCase;
+ bool m_regex;
+ bool m_lastError;
+ wxString m_currentPath;
+ wxString m_output;
+ wxCriticalSection m_outputCrit;
+
+ wxMutex m_condMutex;
+ wxCondition m_startSearchCond;
+};
+
+
// Ctrl id's
enum {
CTRL_SEARCH,
@@ -165,14 +223,15 @@ void FindInProjectDlg::OnBeforeLoad(IHtmlWndBeforeLoadEvent& event) {
// ---- SearchThread ---------------------------------------------------------------------------------------
-FindInProjectDlg::SearchThread::SearchThread()
-: m_isSearching(false), m_isWaiting(false), m_stopSearch(false), m_lastError(false), m_startSearchCond(m_condMutex) {
+SearchThread::SearchThread():
+ m_isSearching(false), m_isWaiting(false), m_stopSearch(false), m_lastError(false), m_startSearchCond(m_condMutex)
+{
// Create and run the thread
Create();
Run();
}
-void* FindInProjectDlg::SearchThread::Entry() {
+void* SearchThread::Entry() {
while (1) {
// Wait for signal that we should start search
m_isWaiting = true;
@@ -210,7 +269,7 @@ void* FindInProjectDlg::SearchThread::Entry() {
return NULL;
}
-void FindInProjectDlg::SearchThread::DeleteThread() {
+void SearchThread::DeleteThread() {
// We may be waiting for the condition so we cannot just call Delete
m_stopSearch = true;
CancelSearch();
@@ -220,7 +279,7 @@ void FindInProjectDlg::SearchThread::DeleteThread() {
m_startSearchCond.Signal();
}
-void FindInProjectDlg::SearchThread::StartSearch(const wxString& path, const wxString& pattern, bool matchCase, bool regex) {
+void SearchThread::StartSearch(const wxString& path, const wxString& pattern, bool matchCase, bool regex) {
m_path = path;
m_pattern = pattern.c_str(); // wxString is not threadsafe, so we have to force copy
m_matchCase = matchCase;
@@ -232,14 +291,14 @@ void FindInProjectDlg::SearchThread::StartSearch(const wxString& path, const wxS
m_startSearchCond.Signal();
}
-void FindInProjectDlg::SearchThread::CancelSearch() {
+void SearchThread::CancelSearch() {
m_isSearching = false;
// Wait for the search to actually cancel
while (!m_isWaiting) wxSleep(1);
}
-bool FindInProjectDlg::SearchThread::GetCurrentPath(wxString& currentPath) {
+bool SearchThread::GetCurrentPath(wxString& currentPath) {
wxCriticalSectionLocker locker(m_outputCrit);
if (m_currentPath != currentPath) {
@@ -250,7 +309,7 @@ bool FindInProjectDlg::SearchThread::GetCurrentPath(wxString& currentPath) {
return false;
}
-bool FindInProjectDlg::SearchThread::UpdateOutput(wxString& output) {
+bool SearchThread::UpdateOutput(wxString& output) {
wxCriticalSectionLocker locker(m_outputCrit);
if (m_output.length() > output.length()) {
@@ -261,7 +320,7 @@ bool FindInProjectDlg::SearchThread::UpdateOutput(wxString& output) {
return false;
}
-bool FindInProjectDlg::SearchThread::PrepareSearchInfo(SearchInfo& si, const wxString& pattern, bool matchCase, bool regex) {
+bool SearchThread::PrepareSearchInfo(SearchInfo& si, const wxString& pattern, bool matchCase, bool regex) {
si.pattern = pattern;
si.matchCase = matchCase;
si.regex = NULL;
@@ -327,7 +386,7 @@ bool FindInProjectDlg::SearchThread::PrepareSearchInfo(SearchInfo& si, const wxS
return true;
}
-void FindInProjectDlg::SearchThread::SearchDir(const wxString& path, const SearchInfo& si, ProjectInfoHandler& infoHandler) {
+void SearchThread::SearchDir(const wxString& path, const SearchInfo& si, ProjectInfoHandler& infoHandler) {
MMapBuffer buf;
wxFileName filepath;
vector<FileMatch> matches;
@@ -365,7 +424,7 @@ void FindInProjectDlg::SearchThread::SearchDir(const wxString& path, const Searc
}
}
-void FindInProjectDlg::SearchThread::DoSearch(const MMapBuffer& buf, const SearchInfo& si, vector<FileMatch>& matches) const {
+void SearchThread::DoSearch(const MMapBuffer& buf, const SearchInfo& si, vector<FileMatch>& matches) const {
// Ignore binary files (we just check for zero bytes in the first
// 100 bytes of the file)
const wxFileOffset len = buf.Length();
@@ -440,7 +499,7 @@ void FindInProjectDlg::SearchThread::DoSearch(const MMapBuffer& buf, const Searc
}
}
-void FindInProjectDlg::SearchThread::WriteResult(const MMapBuffer& buf, const wxFileName& filepath, vector<FileMatch>& matches) {
+void SearchThread::WriteResult(const MMapBuffer& buf, const wxFileName& filepath, vector<FileMatch>& matches) {
if (matches.empty()) return;
// Header
View
59 src/FindInProjectDlg.h
@@ -35,6 +35,7 @@ class MMapBuffer;
class ProjectInfoHandler;
class wxFileName;
class ProjectInfoHandler;
+class SearchThread;
class FindInProjectDlg : public wxDialog {
public:
@@ -44,64 +45,6 @@ class FindInProjectDlg : public wxDialog {
void SetPattern(const wxString& pattern);
private:
-
- class SearchThread : public wxThread {
- public:
- SearchThread();
- virtual void* Entry();
- void DeleteThread();
-
- void StartSearch(const wxString& path, const wxString& pattern, bool matchCase, bool regex);
- void CancelSearch();
- bool IsSearching() const {return m_isSearching;};
- bool LastError() const {return m_lastError;};
-
- bool GetCurrentPath(wxString& currentPath);
- bool UpdateOutput(wxString& output);
-
- private:
- struct FileMatch {
- unsigned int line;
- unsigned int column;
- wxFileOffset start;
- wxFileOffset end;
- };
-
- struct SearchInfo {
- wxString pattern;
- wxString patternUpper;
- wxCharBuffer UTF8buffer;
- wxCharBuffer UTF8bufferUpper;
- size_t byte_len;
- char charmap[256];
- char lastChar;
- bool matchCase;
- pcre* regex;
- wxString output;
- };
-
- void SearchDir(const wxString& path, const SearchInfo& si, ProjectInfoHandler& infoHandler);
- void DoSearch(const MMapBuffer& buf, const SearchInfo& si, vector<FileMatch>& matches) const;
- void WriteResult(const MMapBuffer& buf, const wxFileName& filepath, vector<FileMatch>& matches);
- bool PrepareSearchInfo(SearchInfo& si, const wxString& pattern, bool matchCase, bool regex);
-
- // Member variables
- bool m_isSearching;
- bool m_isWaiting;
- bool m_stopSearch;
- wxString m_path;
- wxString m_pattern;
- bool m_matchCase;
- bool m_regex;
- bool m_lastError;
- wxString m_currentPath;
- wxString m_output;
- wxCriticalSection m_outputCrit;
-
- wxMutex m_condMutex;
- wxCondition m_startSearchCond;
- };
-
// Event handlers
void OnSearch(wxCommandEvent& event);
void OnIdle(wxIdleEvent& event);
View
0  testfiles/dragcommand/empty_file.txt
No changes.
View
19 testfiles/projects/exclude_txt/.eprj
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+ <dict>
+ <key>filters</key>
+ <dict>
+ <key>excludeDirs</key>
+ <array />
+ <key>excludeFiles</key>
+ <array>
+ <string>*.txt</string>
+ </array>
+ <key>includeDirs</key>
+ <array />
+ <key>includeFiles</key>
+ <array />
+ </dict>
+ </dict>
+</plist>
View
2  testfiles/projects/exclude_txt/readme.otherfile
@@ -0,0 +1,2 @@
+This file will not show up in the e project pane, as this folder
+has a project which filters on "*.txt".
View
1  testfiles/projects/exclude_txt/readme.txt
@@ -0,0 +1 @@
+There is a project in this folder that only displays .txt files.
View
2  testfiles/projects/exclude_txt/subfolder/readme.otherfile
@@ -0,0 +1,2 @@
+This file will not show up in the e project pane, as this folder
+has a project which filters on "*.txt".
View
1  testfiles/projects/exclude_txt/subfolder/readme.txt
@@ -0,0 +1 @@
+There is a project in this folder that only displays .txt files.
View
19 testfiles/projects/only_txt/.eprj
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+ <dict>
+ <key>filters</key>
+ <dict>
+ <key>excludeDirs</key>
+ <array />
+ <key>excludeFiles</key>
+ <array />
+ <key>includeDirs</key>
+ <array />
+ <key>includeFiles</key>
+ <array>
+ <string>*.txt</string>
+ </array>
+ </dict>
+ </dict>
+</plist>
View
2  testfiles/projects/only_txt/readme.otherfile
@@ -0,0 +1,2 @@
+This file will not show up in the e project pane, as this folder
+has a project which filters on "*.txt".
View
1  testfiles/projects/only_txt/readme.txt
@@ -0,0 +1 @@
+There is a project in this folder that only displays .txt files.
View
1  testfiles/readme.txt
@@ -0,0 +1 @@
+These folders contain files for (manually) testing e builds.
View
3  todo.txt
@@ -1,3 +0,0 @@
-To-do:
-* Linux builds.
-* Unit/regression test suites.
View
44 windows-notes.txt
@@ -1,44 +0,0 @@
-= Introduction =
-
-This document describes how to build e & its dependencies.
-
-To build e you will need:
-
-* A copy of Visual C++ 2008
-** You can get the free express edition at http://www.microsoft.com/express/vc/
-** Full Visual Studio versions also work fine.
-** Make sure you have VS2008 SP1 and any applicable Vista-related hot-fixes.
-
-* A set of GNU tools for Windows (including bash, patch, wget, etc.)
-** Cygwin is used by e itself to provide Unix support, but has issues on
- 64-bit versions of Windows.
-** If you're building from source on Windows, you're probably using MSysGit
-** Either of these packages will provide GNU tools, but will have different issues
- and workarounds. See `externals/readme.txt` for more information.
-
-
-= Building the Dependencies =
-
-e's dependencies are:
-* wxWidgets
-* Metakit
-* PCRE
-* libcurl
-* libtommath
-* libtomcrypt
-* TinyXML
-
-
-To download, patch and compile these dependencies:
-* Run "get_externals_win.sh" in a bash shell (Cygwin or MSysGit)
-* Run "build_externals_win.cmd" in a VS2008 Command Prompt.
-
-Later versions of these projects may work with e, but have not been tested.
-Consult the "get_externals_win.sh" script to see what the expected versions are.
-
-
-= Building e Itself =
-
-* After building all the dependencies, open "e.sln" and build the Debug target.
-* The newly build "e" will use configuration in the registry from an installed
- license or trial version.
Please sign in to comment.
Something went wrong with that request. Please try again.