diff --git a/CodeLite/clJoinableThread.h b/CodeLite/clJoinableThread.h index 5de84249e4..799314f57b 100644 --- a/CodeLite/clJoinableThread.h +++ b/CodeLite/clJoinableThread.h @@ -1,9 +1,10 @@ #ifndef CSJOINABLETHREAD_H #define CSJOINABLETHREAD_H -#include "clJoinableThread.h" #include "codelite_exports.h" + #include + class WXDLLIMPEXP_CL clJoinableThread : public wxThread { protected: diff --git a/CodeLite/event_notifier.h b/CodeLite/event_notifier.h index c94c2f33e3..0add93ab96 100644 --- a/CodeLite/event_notifier.h +++ b/CodeLite/event_notifier.h @@ -34,8 +34,6 @@ class WXDLLIMPEXP_CL EventNotifier : public wxEvtHandler { - bool _eventsDiabled; - private: EventNotifier(); virtual ~EventNotifier(); diff --git a/CodeLite/fileutils.h b/CodeLite/fileutils.h index 5e5ac1f9ca..2bf445c5a1 100644 --- a/CodeLite/fileutils.h +++ b/CodeLite/fileutils.h @@ -149,7 +149,7 @@ class WXDLLIMPEXP_CL FileUtils * wxString str = "My String That Requires Tokenize"; * wxString word; // The output * size_t offset = 0; - * while(clNextWord(str, offset, word)) { + * while (NextWord(str, offset, word)) { * // Do something with "word" here * } * @codeend diff --git a/Plugin/clTabRendererMinimal.cpp b/Plugin/clTabRendererMinimal.cpp index a66e614da9..294ce47366 100644 --- a/Plugin/clTabRendererMinimal.cpp +++ b/Plugin/clTabRendererMinimal.cpp @@ -12,12 +12,6 @@ #include #include -#define DRAW_LINE(__p1, __p2) \ - dc.DrawLine(__p1, __p2); \ - dc.DrawLine(__p1, __p2); \ - dc.DrawLine(__p1, __p2); \ - dc.DrawLine(__p1, __p2); - namespace { #ifdef __WXMAC__ diff --git a/Plugin/globals.cpp b/Plugin/globals.cpp index 9d15b750df..316f51da94 100644 --- a/Plugin/globals.cpp +++ b/Plugin/globals.cpp @@ -34,7 +34,6 @@ #include "clGetTextFromUserDialog.h" #include "clTreeCtrl.h" #include "cl_standard_paths.h" -#include "cpp_scanner.h" #include "ctags_manager.h" #include "debugger.h" #include "debuggermanager.h" @@ -124,31 +123,6 @@ void MSWSetWindowDarkTheme(wxWindow* win) static wxString DoExpandAllVariables(const wxString& expression, clCxxWorkspace* workspace, const wxString& projectName, const wxString& confToBuild, const wxString& fileName); -#ifdef __WXMAC__ -#include - -// On Mac we determine the base path using system call -//_NSGetExecutablePath(path, &path_len); -static wxString MacGetInstallPath() -{ - char path[257]; - uint32_t path_len = 256; - _NSGetExecutablePath(path, &path_len); - - // path now contains - // CodeLite.app/Contents/MacOS/ - wxFileName fname(wxString(path, wxConvUTF8)); - - // remove he MacOS part of the exe path - wxString file_name = fname.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR); - wxString rest; - file_name.EndsWith("MacOS/", &rest); - rest.Append("SharedSupport/"); - - return rest; -} -#endif - #if defined(__WXGTK__) #include #include @@ -313,20 +287,6 @@ bool ReadFileWithConversion(const wxString& fileName, wxString& content, wxFontE return !content.IsEmpty(); } -bool RemoveDirectory(const wxString& path) -{ - wxString cmd; - if (wxGetOsVersion() & wxOS_WINDOWS) { - // any of the windows variants - cmd << "rmdir /S /Q " - << "\"" << path << "\""; - } else { - cmd << "\rm -fr " - << "\"" << path << "\""; - } - return wxShell(cmd); -} - bool IsValidCppIndetifier(const wxString& id) { if (id.IsEmpty()) { @@ -357,19 +317,6 @@ long AppendListCtrlRow(wxListCtrl* list) return item; } -bool IsValidCppFile(const wxString& id) -{ - if (id.IsEmpty()) { - return false; - } - - // make sure that rest of the id contains only a-zA-Z0-9_ - if (id.find_first_not_of("_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") != wxString::npos) { - return false; - } - return true; -} - wxString ExpandVariables(const wxString& expression, ProjectPtr proj, IEditor* editor, const wxString& filename) { wxString project_name(proj->GetName()); @@ -552,17 +499,6 @@ wxString DoExpandAllVariables(const wxString& expression, clCxxWorkspace* worksp return output; } -bool WriteFileUTF8(const wxString& fileName, const wxString& content) -{ - wxFFile file(fileName, "w+b"); - if (!file.IsOpened()) { - return false; - } - - // first try the Utf8 - return file.Write(content, wxConvUTF8); -} - bool CompareFileWithString(const wxString& filePath, const wxString& str) { wxString content; @@ -679,22 +615,6 @@ void FillFromSemiColonString(wxArrayString& arr, const wxString& str) arr = StringUtils::BuildArgv(str); } -wxString ArrayToSemiColonString(const wxArrayString& array) -{ - wxString result; - for (size_t i = 0; i < array.GetCount(); i++) { - wxString tmp = NormalizePath(array.Item(i)); - tmp.Trim().Trim(false); - if (tmp.IsEmpty() == false) { - result += NormalizePath(array.Item(i)); - result += ";"; - } - } - return result.BeforeLast(';'); -} - -void StripSemiColons(wxString& str) { str.Replace(";", " "); } - wxString NormalizePath(const wxString& path) { wxString normalized_path(path); @@ -864,85 +784,6 @@ void GetProjectTemplateList(std::list& list) list.sort(ProjListComparator()); } -thread_local std::unordered_set words; - -bool IsCppKeyword(const wxString& word) -{ - if (words.empty()) { - words.insert("auto"); - words.insert("break"); - words.insert("case"); - words.insert("char"); - words.insert("const"); - words.insert("continue"); - words.insert("default"); - words.insert("define"); - words.insert("defined"); - words.insert("do"); - words.insert("double"); - words.insert("elif"); - words.insert("else"); - words.insert("endif"); - words.insert("enum"); - words.insert("error"); - words.insert("extern"); - words.insert("float"); - words.insert("for"); - words.insert("goto"); - words.insert("if"); - words.insert("ifdef"); - words.insert("ifndef"); - words.insert("include"); - words.insert("int"); - words.insert("line"); - words.insert("long"); - words.insert("bool"); - words.insert("pragma"); - words.insert("register"); - words.insert("return"); - words.insert("short"); - words.insert("signed"); - words.insert("sizeof"); - words.insert("static"); - words.insert("struct"); - words.insert("switch"); - words.insert("typedef"); - words.insert("undef"); - words.insert("union"); - words.insert("unsigned"); - words.insert("void"); - words.insert("volatile"); - words.insert("while"); - words.insert("class"); - words.insert("namespace"); - words.insert("delete"); - words.insert("friend"); - words.insert("inline"); - words.insert("new"); - words.insert("operator"); - words.insert("overload"); - words.insert("protected"); - words.insert("private"); - words.insert("public"); - words.insert("this"); - words.insert("virtual"); - words.insert("template"); - words.insert("typename"); - words.insert("dynamic_cast"); - words.insert("static_cast"); - words.insert("const_cast"); - words.insert("reinterpret_cast"); - words.insert("using"); - words.insert("throw"); - words.insert("catch"); - words.insert("nullptr"); - words.insert("noexcept"); - words.insert("override"); - words.insert("constexpr"); - } - return words.count(word) != 0; -} - void MSWSetNativeTheme(wxWindow* win, const wxString& theme) { #if defined(__WXMSW__) && defined(_WIN64) && 0 @@ -1530,177 +1371,6 @@ wxStandardID PromptForYesNoDialogWithCheckbox(const wxString& message, const wxS checkboxInitialValue); } -static wxChar sPreviousChar(wxStyledTextCtrl* ctrl, int pos, int& foundPos, bool wantWhitespace) -{ - wxChar ch = 0; - long curpos = ctrl->PositionBefore(pos); - if (curpos == 0) { - foundPos = curpos; - return ch; - } - - while (true) { - ch = ctrl->GetCharAt(curpos); - if (ch == '\t' || ch == ' ' || ch == '\r' || ch == '\v' || ch == '\n') { - // if the caller is intrested in whitepsaces, - // simply return it - if (wantWhitespace) { - foundPos = curpos; - return ch; - } - - long tmpPos = curpos; - curpos = ctrl->PositionBefore(curpos); - if (curpos == 0 && tmpPos == curpos) { - break; - } - } else { - foundPos = curpos; - return ch; - } - } - foundPos = -1; - return ch; -} - -wxString GetCppExpressionFromPos(long pos, wxStyledTextCtrl* ctrl, bool forCC) -{ - bool cont(true); - int depth(0); - - int position(pos); - int at(position); - bool prevGt(false); - while (cont && depth >= 0) { - wxChar ch = sPreviousChar(ctrl, position, at, true); - position = at; - // Eof? - if (ch == 0) { - at = 0; - break; - } - - // Comment? - int style = ctrl->GetStyleAt(position); - if (style == wxSTC_C_COMMENT || style == wxSTC_C_COMMENTLINE || style == wxSTC_C_COMMENTDOC || - style == wxSTC_C_COMMENTLINEDOC || style == wxSTC_C_COMMENTDOCKEYWORD || - style == wxSTC_C_COMMENTDOCKEYWORDERROR || style == wxSTC_C_STRING || style == wxSTC_C_STRINGEOL || - style == wxSTC_C_CHARACTER) { - continue; - } - - switch (ch) { - case ';': - // dont include this token - at = ctrl->PositionAfter(at); - cont = false; - break; - case '-': - if (prevGt) { - prevGt = false; - // if previous char was '>', we found an arrow so reduce the depth - // which was increased - depth--; - } else { - if (depth <= 0) { - // dont include this token - at = ctrl->PositionAfter(at); - cont = false; - } - } - break; - case ' ': - case '\n': - case '\v': - case '\t': - case '\r': - prevGt = false; - if (depth <= 0) { - cont = false; - break; - } - break; - case '{': - case '=': - prevGt = false; - cont = false; - break; - case '(': - case '[': - depth--; - prevGt = false; - if (depth < 0) { - // dont include this token - at = ctrl->PositionAfter(at); - cont = false; - } - break; - case ',': - case '*': - case '&': - case '!': - case '~': - case '+': - case '^': - case '|': - case '%': - case '?': - prevGt = false; - if (depth <= 0) { - - // dont include this token - at = ctrl->PositionAfter(at); - cont = false; - } - break; - case '>': - prevGt = true; - depth++; - break; - case '<': - prevGt = false; - depth--; - if (depth < 0) { - - // dont include this token - at = ctrl->PositionAfter(at); - cont = false; - } - break; - case ')': - case ']': - prevGt = false; - depth++; - break; - default: - prevGt = false; - break; - } - } - - if (at < 0) { - at = 0; - } - wxString expr = ctrl->GetTextRange(at, pos); - if (!forCC) { - // If we do not require the expression for CodeCompletion - // return the un-touched buffer - return expr; - } - - // remove comments from it - CppScanner sc; - sc.SetText(_C(expr)); - wxString expression; - int type = 0; - while ((type = sc.yylex()) != 0) { - wxString token = _U(sc.YYText()); - expression += token; - expression += " "; - } - return expression; -} - wxString& WrapWithQuotes(wxString& str) { if (!str.empty() && str.Contains(" ") && !str.StartsWith("\"") && !str.EndsWith("\"")) { @@ -1709,12 +1379,6 @@ wxString& WrapWithQuotes(wxString& str) return str; } -wxString& EscapeSpaces(wxString& str) -{ - str.Replace(" ", "\\ "); - return str; -} - bool LoadXmlFile(wxXmlDocument* doc, const wxString& filepath) { wxString content; @@ -1738,18 +1402,6 @@ bool SaveXmlToFile(wxXmlDocument* doc, const wxString& filename) return false; } -wxString MakeCommandRunInBackground(const wxString& cmd) -{ - wxString alteredCommand; -#ifdef __WXMSW__ - alteredCommand << "start /b " << cmd; -#else - // POSIX systems - alteredCommand << cmd << "&"; -#endif - return alteredCommand; -} - void wxPGPropertyBooleanUseCheckbox(wxPropertyGrid* grid) { grid->SetPropertyAttributeAll(wxPG_BOOL_USE_CHECKBOX, true); @@ -1910,8 +1562,6 @@ int clFindMenuItemPosition(wxMenu* menu, int menuItemId) return wxNOT_FOUND; } -bool clNextWord(const wxString& str, size_t& offset, wxString& word) { return FileUtils::NextWord(str, offset, word); } - wxString clJoinLinesWithEOL(const wxArrayString& lines, int eol) { wxString glue = "\n"; @@ -2143,31 +1793,6 @@ bool SetBestFocus(wxWindow* win) return false; } -bool IsWindowParentOf(wxWindow* parent, wxWindow* child) -{ - if (!child) { - return false; - } - - std::vector Q; - Q.push_back(parent); - - while (!Q.empty()) { - auto parent = Q.front(); - Q.erase(Q.begin()); - - if (parent == child) { - return true; - } - - // put its children - for (auto c : parent->GetChildren()) { - Q.push_back(c); - } - } - return false; -} - Notebook* FindNotebookParentOf(wxWindow* child) { if (!child) { diff --git a/Plugin/globals.h b/Plugin/globals.h index 64cd6bda54..e90f4345b9 100644 --- a/Plugin/globals.h +++ b/Plugin/globals.h @@ -137,14 +137,6 @@ WXDLLIMPEXP_SDK long AppendListCtrlRow(wxListCtrl* list); WXDLLIMPEXP_SDK bool ReadFileWithConversion(const wxString& fileName, wxString& content, wxFontEncoding encoding = wxFONTENCODING_DEFAULT, BOM* bom = NULL); -/** - * \brief write file using UTF8 converter - * \param fileName file path - * \param content file's content - * \return true on success, false otherwise - */ -WXDLLIMPEXP_SDK bool WriteFileUTF8(const wxString& fileName, const wxString& content); - /** * \brief compare a file with a wxString using md5 * \param filePath file's full path @@ -153,30 +145,11 @@ WXDLLIMPEXP_SDK bool WriteFileUTF8(const wxString& fileName, const wxString& con */ WXDLLIMPEXP_SDK bool CompareFileWithString(const wxString& filePath, const wxString& str); -/** - * \brief delete directory using shell command - * \param path directory path - * \return true on success, false otherwise - */ -WXDLLIMPEXP_SDK bool RemoveDirectory(const wxString& path); - /** * \brief return true of id is a valid cpp identifier */ WXDLLIMPEXP_SDK bool IsValidCppIndetifier(const wxString& id); -/** - * \brief return true of word is a C++ keyword - * \param word - * \return - */ -WXDLLIMPEXP_SDK bool IsCppKeyword(const wxString& word); - -/** - * \brief return true of id is a valid cpp file - */ -WXDLLIMPEXP_SDK bool IsValidCppFile(const wxString& id); - /** * [DEPRECATED] DONT USE THIS METHOD ANYMORE - USE IMacroManager * Expand variables to their real value, if expanding fails @@ -247,16 +220,6 @@ WXDLLIMPEXP_SDK bool IsFileReadOnly(const wxFileName& filename); */ WXDLLIMPEXP_SDK void FillFromSemiColonString(wxArrayString& arr, const wxString& str); -/** - * \brief return a string semi-colon separated of the given array - */ -WXDLLIMPEXP_SDK wxString ArrayToSemiColonString(const wxArrayString& array); - -/** - * \brief Remove all semi colons of the given string - */ -WXDLLIMPEXP_SDK void StripSemiColons(wxString& str); - /** * \brief Normalize the given path (change all \ by /) */ @@ -404,12 +367,6 @@ WXDLLIMPEXP_SDK wxVariant MakeBitmapIndexText(const wxString& text, int imgIndex */ WXDLLIMPEXP_SDK wxVariant MakeCheckboxVariant(const wxString& label, bool checked, int imgIndex); -/** - * @brief queue a call to a function to be executed on the next event loop - */ -WXDLLIMPEXP_SDK void PostCall(wxObject* instance, clEventFunc_t func, wxClientData* arg); -WXDLLIMPEXP_SDK void PostCall(wxObject* instance, clEventFunc_t func); - /** * @brief split lines (using CR|LF as the separator), taking into considertaion line continuation * @param trim trim the lines with set to true @@ -462,19 +419,6 @@ WXDLLIMPEXP_SDK wxStandardID PromptForYesNoDialogWithCheckbox( */ WXDLLIMPEXP_SDK wxString& WrapWithQuotes(wxString& str); -/** - * @brief wrap string with quotes if needed - */ -WXDLLIMPEXP_SDK wxString& EscapeSpaces(wxString& str); - -/** - * @brief return an expression from a given position. - * e.g. if the caret is on a line: - * variable.m_name.m_value| - * the | represents the cart, this function will return the entire expression: variable.m_name.m_value - */ -WXDLLIMPEXP_SDK wxString GetCppExpressionFromPos(long pos, wxStyledTextCtrl* ctrl, bool forCC); - /** * @brief save an xml document to file */ @@ -499,11 +443,6 @@ WXDLLIMPEXP_SDK bool clIsCygwinEnvironment(); */ WXDLLIMPEXP_SDK bool clIsMSYSEnvironment(); -/** - * @brief change the command so it will run in the background - */ -WXDLLIMPEXP_SDK wxString MakeCommandRunInBackground(const wxString& cmd); - /** * @brief enable use of checkbox for boolean properties */ @@ -596,23 +535,6 @@ WXDLLIMPEXP_SDK bool clFindExecutable(const wxString& name, wxFileName& exepath, */ WXDLLIMPEXP_SDK int clFindMenuItemPosition(wxMenu* menu, int menuItemId); -/** - * @brief an efficient way to tokenize string into words (separated by SPACE and/or TAB) - * @code - * wxString str = "My String That Requires Tokenize"; - * wxString word; // The output - * size_t offset = 0; - * while(clNextWord(str, offset, word)) { - * // Do something with "word" here - * } - * @codeend - * @param str the string to tokenize - * @param offset used internally, allocate one on the stack and initialise it to 0 - * @param word [output] - * @return true if a word was found - */ -WXDLLIMPEXP_SDK bool clNextWord(const wxString& str, size_t& offset, wxString& word); - /** * @brief join strings with "\n" or "\r\n" (depends on eol) * eol can be wxSTC_EOL_CRLF, wxSTC_EOL_LF etc @@ -670,9 +592,6 @@ WXDLLIMPEXP_SDK bool clShowFileTypeSelectionDialog(wxWindow* parent, const wxArr /// Find the best window starting from `win` and give it the focus WXDLLIMPEXP_SDK bool SetBestFocus(wxWindow* win); -/// Check if Window `parent` is the parent (or grand parent, or grand-grand-parent ...) of `child` -WXDLLIMPEXP_SDK bool IsWindowParentOf(wxWindow* parent, wxWindow* child); - /// Find Notebook parent of a `child` WXDLLIMPEXP_SDK Notebook* FindNotebookParentOf(wxWindow* child); diff --git a/wxcrafter/src/xy_pair.cpp b/wxcrafter/src/xy_pair.cpp index f574a67f2b..2586b1e620 100644 --- a/wxcrafter/src/xy_pair.cpp +++ b/wxcrafter/src/xy_pair.cpp @@ -1,18 +1,19 @@ #include "xy_pair.h" + #include "wxgui_helpers.h" -XYPair::XYPair(const wxString& str, int defaultx, int defaulty) - : m_string(str) - , m_x(defaultx) +XYPair::XYPair(wxString str, int defaultx, int defaulty) + : m_x(defaultx) , m_y(defaulty) { - m_string.Trim().Trim(false); - if(m_string.StartsWith(wxT("("))) m_string.Remove(0, 1); + if (str.StartsWith(wxT("("))) + str.Remove(0, 1); - if(m_string.EndsWith(wxT(")"))) m_string.RemoveLast(); + if (str.EndsWith(wxT(")"))) + str.RemoveLast(); - wxString strx = m_string.BeforeFirst(wxT(',')); - wxString stry = m_string.AfterFirst(wxT(',')); + wxString strx = str.BeforeFirst(wxT(',')); + wxString stry = str.AfterFirst(wxT(',')); strx.Trim().Trim(false); stry.Trim().Trim(false); @@ -25,7 +26,6 @@ XYPair::XYPair(int x, int y) : m_x(x) , m_y(y) { - m_string = ToString(false); } XYPair::~XYPair() {} diff --git a/wxcrafter/src/xy_pair.h b/wxcrafter/src/xy_pair.h index c9900d1c7d..65a202da70 100644 --- a/wxcrafter/src/xy_pair.h +++ b/wxcrafter/src/xy_pair.h @@ -6,12 +6,11 @@ class XYPair { protected: - wxString m_string; int m_x; int m_y; public: - XYPair(const wxString& str, int defaultx = -1, int defaulty = -1); + XYPair(wxString str, int defaultx = -1, int defaulty = -1); XYPair(int x, int y); virtual ~XYPair();