Skip to content

Commit

Permalink
Windows: OutputDebugString: only report these messages when the debug…
Browse files Browse the repository at this point in the history
…ger is running or when a program is being executed by CodeLite
  • Loading branch information
eranif committed Feb 20, 2017
1 parent 63b7483 commit 1df2313
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 14 deletions.
1 change: 0 additions & 1 deletion ExternalTools/externaltools.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "cl_command_event.h"

class wxToolBar;
class AsyncExeCmd;

class ExternalToolsPlugin : public IPlugin
{
Expand Down
58 changes: 49 additions & 9 deletions LiteEditor/shelltab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,10 @@ bool ShellTab::DoSendInput(const wxString& line)
void ShellTab::OnProcStarted(wxCommandEvent& e)
{
if(m_cmd && m_cmd->IsBusy()) {
// TODO: log message: already running a process
return;
}
m_cmd = (AsyncExeCmd*)e.GetEventObject();
Clear();
AppendText("\n");
AppendText(e.GetString());
m_input->Clear();
}
Expand Down Expand Up @@ -342,9 +341,16 @@ void DebugTab::OnHoldOpenUpdateUI(wxUpdateUIEvent& e)
}
}

//------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------
// OutputTab class
//------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------

OutputTab::OutputTab(wxWindow* parent, wxWindowID id, const wxString& name)
: ShellTab(parent, id, name)
, m_thread(NULL)
, m_outputDebugStringActive(false)
{
m_inputSizer->Show(false);
GetSizer()->Layout();
Expand All @@ -353,21 +359,55 @@ OutputTab::OutputTab(wxWindow* parent, wxWindowID id, const wxString& name)
m_thread->Start();
#endif
EventNotifier::Get()->Bind(wxEVT_OUTPUT_DEBUG_STRING, &OutputTab::OnOutputDebugString, this);
EventNotifier::Get()->Bind(wxEVT_DEBUG_STARTED, &OutputTab::OnDebugStarted, this);
EventNotifier::Get()->Bind(wxEVT_DEBUG_ENDED, &OutputTab::OnDebugStopped, this);
}

OutputTab::~OutputTab()
OutputTab::~OutputTab()
{
EventNotifier::Get()->Unbind(wxEVT_OUTPUT_DEBUG_STRING, &OutputTab::OnOutputDebugString, this);
EventNotifier::Get()->Unbind(wxEVT_DEBUG_STARTED, &OutputTab::OnDebugStarted, this);
EventNotifier::Get()->Unbind(wxEVT_DEBUG_ENDED, &OutputTab::OnDebugStopped, this);
if(m_thread) {
m_thread->Stop();
wxDELETE(m_thread);
}
}

void OutputTab::OnOutputDebugString(clCommandEvent& event)

void OutputTab::OnOutputDebugString(clCommandEvent& event)
{
event.Skip();
wxString msg;
msg << "[" << event.GetInt() << "] " << event.GetString() << "\n";
AppendText(msg);
}
if(!m_outputDebugStringActive) return;

wxString msg = event.GetString();
msg.Trim().Trim(false);
if(msg.IsEmpty()) return;

wxString formattedMessage;
formattedMessage << "[" << event.GetInt() << "] " << msg << "\n";
AppendText(formattedMessage);
}

void OutputTab::OnDebugStarted(clDebugEvent& event)
{
event.Skip();
m_outputDebugStringActive = true;
}

void OutputTab::OnDebugStopped(clDebugEvent& event)
{
event.Skip();
m_outputDebugStringActive = false;
}

void OutputTab::OnProcStarted(wxCommandEvent& e)
{
ShellTab::OnProcStarted(e);
m_outputDebugStringActive = true;
}

void OutputTab::OnProcEnded(wxCommandEvent& e)
{
ShellTab::OnProcEnded(e);
m_outputDebugStringActive = false;
}
12 changes: 9 additions & 3 deletions LiteEditor/shelltab.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,21 @@ class ShellTab : public OutputTabWindow
class OutputTab : public ShellTab
{
OutputDebugStringThread* m_thread;
bool m_outputDebugStringActive;

public:
OutputTab(wxWindow* parent, wxWindowID id, const wxString& name);
virtual ~OutputTab();
/**
* @brief Windows only. Report a string from a debuggee process which used the "OuptutDebugString" method

/**
* @brief Windows only. Report a string from a debuggee process which used the "OuptutDebugString" method
*/
void OnOutputDebugString(clCommandEvent& event);

void OnDebugStarted(clDebugEvent& event);
void OnDebugStopped(clDebugEvent& event);
virtual void OnProcStarted(wxCommandEvent& e);
virtual void OnProcEnded(wxCommandEvent& e);
};

class DebugTab : public ShellTab
Expand Down
1 change: 0 additions & 1 deletion MemCheck/memcheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
#include "TerminalEmulator.h"
#include "clTabTogglerHelper.h"

class AsyncExeCmd;
class MemCheckOutputView;

class MemCheckPlugin : public IPlugin
Expand Down

0 comments on commit 1df2313

Please sign in to comment.