Skip to content

Commit

Permalink
final msw fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
antonvw committed Apr 8, 2018
1 parent 162a4fc commit 28682f3
Show file tree
Hide file tree
Showing 17 changed files with 73 additions and 60 deletions.
37 changes: 17 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ one of these applications, being a full featured source code text editor.

- [doctest lib](https://github.com/onqtam/doctest)

- [easylogging++ lib](https://github.com/muflihun/easyloggingpp)
- [easylogging++ lib](https://github.com/muflihun/easyloggingpp)

- [eval lib](https://github.com/r-lyeh/eval)

- [fsm lib](https://github.com/eglimi/cppfsm)
- [fsm lib](https://github.com/eglimi/cppfsm)

- [OTL database lib](http://otl.sourceforge.net/)

Expand All @@ -37,14 +37,16 @@ one of these applications, being a full featured source code text editor.
## Building wxWidgets

- under windows:
-- using Microsoft Visual Studio 2017 in build/msw:
`nmake /f makefile.vc` or
`nmake /f makefile.vc BUILD=release`
-- using mingw in build/msw:
`make -f makefile.gcc`
-- using cygwin 1.7.9:
in buildmsw (created):
`../configure --with-msw --disable-shared && make`
-- using Microsoft Visual Studio 2017:
`git clone --recursive`
`mkdir build`
`cd build`

(or make a `debug` directory and use `-DCMAKE_BUILD_TYPE=Debug`)

`cmake.exe -DwxBUILD_SHARED=OFF -DCMAKE_BUILD_TYPE=Release ..`
`nmake`
copy generated lib\vc_lib to wxWidgets\lib

- under Linux g++ 7.1.1:
install gtk:
Expand All @@ -61,17 +63,14 @@ one of these applications, being a full featured source code text editor.
see g++

- under MacOS:
`brew install wxwidgets`
`brew install xcode`
`brew install wxwidgets`
`brew install xcode`

## Building wxExtension

- clone with submodules:
`git clone --recursive`

- start with:
`mkdir build`
`cd build`
- `git clone --recursive`
`mkdir build`
`cd build`

- under windows:
-- using Visual Studio:
Expand All @@ -81,8 +80,6 @@ one of these applications, being a full featured source code text editor.
`cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release ..`
`mingw32-make`

(or make a `debug` directory and use `-DCMAKE_BUILD_TYPE=Debug`)

- under Linux or MacOS:
`cmake ..`
`make`
Expand Down
2 changes: 1 addition & 1 deletion extension/easyloggingpp
11 changes: 7 additions & 4 deletions extension/include/shunting-yard/eval.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ struct evaluator {
{
bool operator() (const std::string &lhs, const std::string &rhs) const
{
if (equal(lhs.begin(), lhs.end(), rhs.begin())) // lhs is prefix of rhs
if (equal(lhs.begin(), lhs.end(), rhs.begin(), rhs.end())) // lhs is prefix of rhs
return false;
else if (equal(rhs.begin(), rhs.end(), lhs.begin())) // rhs is prefix of lhs
else if (equal(rhs.begin(), rhs.end(), lhs.begin(), lhs.begin())) // rhs is prefix of lhs
return true;
else
return lhs < rhs;
Expand Down Expand Up @@ -205,8 +205,11 @@ struct evaluator {
for (; it2 != in.cend() && numbers.find(*it2) != std::string::npos; ++it2); // TODO: find_first_not_of
if (it2 != it)
{
if (lasttok.first == ")" || (opers.find(lasttok.first) == opers.end() && funcs.find(lasttok.first) != funcs.end()) || lasttok.second == -1)
throw parse_error("Missing operator", i);
if (!lasttok.first.empty())
{
if (lasttok.first == ")" || (opers.find(lasttok.first) == opers.end() && funcs.find(lasttok.first) != funcs.end()) || lasttok.second == -1)
throw parse_error("Missing operator", i);
}

out.push_back(lasttok = token_t(std::string(it, it2), -1));
it = it2;
Expand Down
14 changes: 9 additions & 5 deletions extension/include/wx/extension/frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Name: frame.h
// Purpose: Declaration of wxExFrame class
// Author: Anton van Wezenbeek
// Copyright: (c) 2017 Anton van Wezenbeek
// Copyright: (c) 2018 Anton van Wezenbeek
////////////////////////////////////////////////////////////////////////////////

#pragma once
Expand Down Expand Up @@ -118,6 +118,9 @@ class WXDLLIMPEXP_BASE wxExFrame : public wxFrame

/// Updates the specified statusbar pane with values from specified stc.
static bool UpdateStatusBar(wxExSTC* stc, const std::string& pane);

/// Are we closing?
static bool IsClosing() {return m_IsClosing;};
#endif // wxUSE_STATUSBAR
protected:
#if wxUSE_STATUSBAR
Expand All @@ -130,10 +133,11 @@ class WXDLLIMPEXP_BASE wxExFrame : public wxFrame
static wxExStatusBar* m_StatusBar;
#endif
private:
wxWindow* m_FindFocus = nullptr;
wxFindReplaceDialog* m_FindReplaceDialog = nullptr;
wxMenuBar* m_MenuBar = nullptr;
static bool m_IsClosing;

bool m_IsCommand = false;
bool m_IsCommand {false};
wxWindow* m_FindFocus {nullptr};
wxFindReplaceDialog* m_FindReplaceDialog {nullptr};
wxMenuBar* m_MenuBar {nullptr};
};
#endif // wxUSE_GUI
4 changes: 2 additions & 2 deletions extension/sample/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
// Name: app.cpp
// Purpose: Implementation of sample classes for wxExtension
// Author: Anton van Wezenbeek
// Copyright: (c) 2017 Anton van Wezenbeek
// Copyright: (c) 2018 Anton van Wezenbeek
////////////////////////////////////////////////////////////////////////////////

#include <chrono>
#include <numeric>
#include <functional>
#include <easylogging++.h>
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
Expand All @@ -25,6 +24,7 @@
#include <wx/extension/util.h>
#include <wx/extension/vcs.h>
#include <wx/extension/version.h>
#include <easylogging++.h>
#include "app.h"
#ifndef __WXMSW__
#include "app.xpm"
Expand Down
4 changes: 2 additions & 2 deletions extension/sample/report/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
// Name: app.cpp
// Purpose: Implementation of sample classes for wxExRep
// Author: Anton van Wezenbeek
// Copyright: (c) 2017 Anton van Wezenbeek
// Copyright: (c) 2018 Anton van Wezenbeek
////////////////////////////////////////////////////////////////////////////////

#include <easylogging++.h>
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
Expand All @@ -20,6 +19,7 @@
#include <wx/extension/report/dir.h>
#include <wx/extension/report/dirctrl.h>
#include <wx/extension/report/listview.h>
#include <easylogging++.h>
#include "app.h"
#ifndef __WXMSW__
#include "app.xpm"
Expand Down
2 changes: 2 additions & 0 deletions extension/src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,12 @@ bool wxExApp::OnInit()

START_EASYLOGGINGPP(argc_elp, argv_elp);

#ifndef __WXMSW__
for (int i = 0; i < argc_elp; i++)
{
free(argv_elp[i]);
}
#endif

VLOG(1)
<< "started: "
Expand Down
14 changes: 11 additions & 3 deletions extension/src/frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@
wxExStatusBar* wxExFrame::m_StatusBar = nullptr;
#endif

bool wxExFrame::m_IsClosing = false;

#if wxUSE_DRAG_AND_DROP
class FileDropTarget : public wxFileDropTarget
{
Expand Down Expand Up @@ -209,6 +211,10 @@ wxExFrame::wxExFrame(const wxExWindowData& data)
Bind(wxEVT_UPDATE_UI, [=](wxUpdateUIEvent& event) {
(GetMenuBar() != nullptr ? event.Check(GetMenuBar()->IsShown()): event.Check(false));},
ID_VIEW_MENUBAR);

Bind(wxEVT_CLOSE_WINDOW, [=](wxCloseEvent& event) {
m_IsClosing = true;
event.Skip(); });
}

wxExFrame::~wxExFrame()
Expand Down Expand Up @@ -359,12 +365,14 @@ void wxExFrame::StatusBarClicked(const std::string& pane)

bool wxExFrame::StatusText(const std::string& text, const std::string& pane)
{
return (m_StatusBar == nullptr ? false: m_StatusBar->SetStatusText(text, pane));
return (m_IsClosing || m_StatusBar == nullptr ?
false:
m_StatusBar->SetStatusText(text, pane));
}

bool wxExFrame::UpdateStatusBar(const wxListView* lv)
{
if (lv->IsShown())
if (!m_IsClosing && lv->IsShown())
{
const std::string text = std::to_string(lv->GetItemCount()) +
(lv->GetSelectedItemCount() > 0 ? "," + std::to_string(lv->GetSelectedItemCount()):
Expand All @@ -379,7 +387,7 @@ bool wxExFrame::UpdateStatusBar(const wxListView* lv)
// Do not make it const, too many const_casts needed,
bool wxExFrame::UpdateStatusBar(wxExSTC* stc, const std::string& pane)
{
if (stc == nullptr)
if (stc == nullptr || m_IsClosing)
{
return false;
}
Expand Down
17 changes: 10 additions & 7 deletions extension/src/lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ bool wxExLexer::AddKeywords(const std::string& value, int setno)
bool wxExLexer::Apply() const
{
if (m_STC == nullptr) return false;

m_STC->ClearDocumentStyle();

for (const auto& it : m_Properties)
{
it.ApplyReset(m_STC);
Expand All @@ -152,15 +152,20 @@ bool wxExLexer::Apply() const
{
m_STC->SetKeyWords(k.first, wxExGetStringSet(k.second));
}

wxExLexers::Get()->Apply(m_STC);

for (const auto& p : m_Properties) p.Apply(m_STC);
for (const auto& s : m_Styles) s.Apply(m_STC);
}

// And finally colour the entire document.
m_STC->Colourise(0, m_STC->GetLength() - 1);
const auto length = m_STC->GetLength();

if (length > 0)
{
m_STC->Colourise(0, length - 1);
}

return true;
}
Expand Down Expand Up @@ -365,8 +370,6 @@ const std::string wxExLexer::MakeSingleLineComment(
return out;
}



void wxExLexer::Reset()
{
m_CommentBegin.clear();
Expand Down
4 changes: 2 additions & 2 deletions extension/src/stc-bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ void wxExSTC::BindAll()
base10_val = std::stol(word);
base10_ok = (base10_val != 0);
}
catch (std::exception& e)
catch (std::exception&)
{
base10_ok = false;
}
Expand All @@ -509,7 +509,7 @@ void wxExSTC::BindAll()
{
base16_val = std::stol(word, nullptr, 16);
}
catch (std::exception& e)
catch (std::exception&)
{
base16_ok = false;
}
Expand Down
2 changes: 1 addition & 1 deletion extension/tclap
Submodule tclap updated from 1e1cc4 to 4970b7
2 changes: 1 addition & 1 deletion extension/test/doctest
2 changes: 1 addition & 1 deletion syncped/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// Copyright: (c) 2018 Anton van Wezenbeek
////////////////////////////////////////////////////////////////////////////////

#include <easylogging++.h>
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
Expand All @@ -15,6 +14,7 @@
#include <wx/extension/tostring.h>
#include <wx/extension/util.h>
#include <wx/extension/version.h>
#include <easylogging++.h>
#include "app.h"
#include "frame.h"

Expand Down
9 changes: 4 additions & 5 deletions syncped/frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ Frame::Frame(App* app)
GetDebug()->Execute(event.GetId() - ID_EDIT_DEBUG_FIRST);}, ID_EDIT_DEBUG_FIRST, ID_EDIT_DEBUG_LAST);

Bind(wxEVT_CLOSE_WINDOW, [=](wxCloseEvent& event) {
m_IsClosing = true;
long count = 0;
for (size_t i = 0; i < m_Editors->GetPageCount(); i++)
{
Expand All @@ -280,7 +279,6 @@ Frame::Frame(App* app)
{
wxLogStatus(_("Process is running"));
}
m_IsClosing = false;
return;
}
}
Expand All @@ -292,8 +290,8 @@ Frame::Frame(App* app)
if (m_App->GetData().Control().Command().empty())
{
wxDELETE(m_Process);
event.Skip();
}
event.Skip();
});

Bind(wxEVT_MENU, [=](wxCommandEvent& event) {
Expand Down Expand Up @@ -916,7 +914,8 @@ void Frame::OnUpdateUI(wxUpdateUIEvent& event)
switch (event.GetId())
{
case wxID_EXECUTE:
event.Enable( !m_Process->GetExecuteCommand().empty() &&
event.Enable( !IsClosing() && m_Process != nullptr &&
!m_Process->GetExecuteCommand().empty() &&
!m_Process->IsRunning());
break;
case wxID_STOP: event.Enable(m_Process->IsRunning()); break;
Expand Down Expand Up @@ -1420,7 +1419,7 @@ void Frame::SyncCloseAll(wxWindowID id)
{
DecoratedFrame::SyncCloseAll(id);

if (m_IsClosing) return;
if (IsClosing()) return;

switch (id)
{
Expand Down
3 changes: 0 additions & 3 deletions syncped/frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ class Frame : public DecoratedFrame
{
public:
explicit Frame(App* app);

bool IsClosing() const {return m_IsClosing;};
protected:
void OnCommand(wxCommandEvent& event);
void OnUpdateUI(wxUpdateUIEvent& event);
Expand Down Expand Up @@ -63,7 +61,6 @@ class Frame : public DecoratedFrame
const wxString m_ProjectWildcard =
_("Project Files") + " (*.prj)|*.prj";

bool m_IsClosing = false;
int m_NewProjectNo = 1, m_SplitId = 1;

wxCheckBox *m_CheckBoxDirCtrl, *m_CheckBoxHistory;
Expand Down
Loading

0 comments on commit 28682f3

Please sign in to comment.