From 376f2b798ae2824fa3fd081c235e1975a1278ab1 Mon Sep 17 00:00:00 2001 From: Eran Ifrah Date: Sun, 22 Jul 2018 20:42:31 +0300 Subject: [PATCH] Fixed: debugger 'Output' tab 'Clear' button does not work --- LiteEditor.workspace | 4 ++-- LiteEditor/LiteEditor.project | 2 +- Plugin/wxterminal.cpp | 42 ++++++++++------------------------- Plugin/wxterminalbase.cpp | 8 ++----- 4 files changed, 17 insertions(+), 39 deletions(-) diff --git a/LiteEditor.workspace b/LiteEditor.workspace index 184c24b4c5..d3713b87b4 100644 --- a/LiteEditor.workspace +++ b/LiteEditor.workspace @@ -137,7 +137,7 @@ - + @@ -372,7 +372,7 @@ - + diff --git a/LiteEditor/LiteEditor.project b/LiteEditor/LiteEditor.project index cc1747a204..0fbcf29235 100644 --- a/LiteEditor/LiteEditor.project +++ b/LiteEditor/LiteEditor.project @@ -2056,7 +2056,7 @@ resources.cpp: resources.xrc - + diff --git a/Plugin/wxterminal.cpp b/Plugin/wxterminal.cpp index efe8162a8d..3fb52e183c 100644 --- a/Plugin/wxterminal.cpp +++ b/Plugin/wxterminal.cpp @@ -125,9 +125,7 @@ void wxTerminal::OnEnter() { if(m_interactive) { wxString lineText = GetCommandText(); - if(lineText.IsEmpty()) { - return; - } + if(lineText.IsEmpty()) { return; } clCommandEvent event(wxEVT_TERMINAL_EXECUTE_COMMAND); event.SetEventObject(this); event.SetString(lineText); @@ -226,7 +224,9 @@ bool wxTerminal::IsRunning() { return m_process != NULL; } void wxTerminal::Clear() { + m_textCtrl->SetReadOnly(false); m_textCtrl->ClearAll(); + m_textCtrl->SetReadOnly(true); CaretToEnd(); } @@ -236,9 +236,7 @@ wxString wxTerminal::StartTTY() m_process = NULL; // Open the master side of a pseudo terminal int master = ::posix_openpt(O_RDWR | O_NOCTTY); - if(master < 0) { - return ""; - } + if(master < 0) { return ""; } // Grant access to the slave pseudo terminal if(::grantpt(master) < 0) { @@ -290,9 +288,7 @@ void wxTerminal::DoFlushOutputBuffer() { if(!m_outputBuffer.IsEmpty()) { CaretToEnd(); - if(!m_outputBuffer.EndsWith("\n")) { - m_outputBuffer << "\n"; - } + if(!m_outputBuffer.EndsWith("\n")) { m_outputBuffer << "\n"; } AddTextRaw(m_outputBuffer); m_outputBuffer.Clear(); } @@ -304,9 +300,7 @@ void wxTerminal::OnCopy(wxCommandEvent& event) event.Skip(); return; } - if(m_textCtrl->CanCopy()) { - m_textCtrl->Copy(); - } + if(m_textCtrl->CanCopy()) { m_textCtrl->Copy(); } } void wxTerminal::OnCut(wxCommandEvent& event) @@ -315,9 +309,7 @@ void wxTerminal::OnCut(wxCommandEvent& event) event.Skip(); return; } - if(m_textCtrl->CanCut()) { - m_textCtrl->Cut(); - } + if(m_textCtrl->CanCut()) { m_textCtrl->Cut(); } } void wxTerminal::OnSelectAll(wxCommandEvent& event) @@ -339,24 +331,18 @@ void wxTerminal::OnDown(wxKeyEvent& event) void wxTerminal::OnLeft(wxKeyEvent& event) { // Don't allow moving LEFT when at the begin of a line - if(m_textCtrl->GetColumn(m_textCtrl->GetCurrentPos()) == 0) { - return; - } + if(m_textCtrl->GetColumn(m_textCtrl->GetCurrentPos()) == 0) { return; } // Right / Left movement is allowed only on the last line int curline = m_textCtrl->GetCurrentLine(); - if(curline == (m_textCtrl->GetLineCount() - 1)) { - event.Skip(); - } + if(curline == (m_textCtrl->GetLineCount() - 1)) { event.Skip(); } } void wxTerminal::OnRight(wxKeyEvent& event) { // Right / Left movement is allowed only on the last line int curline = m_textCtrl->GetCurrentLine(); - if(curline == (m_textCtrl->GetLineCount() - 1)) { - event.Skip(); - } + if(curline == (m_textCtrl->GetLineCount() - 1)) { event.Skip(); } } void wxTerminal::InsertCommandText(const wxString& command) @@ -400,12 +386,8 @@ void wxTerminal::AddTextWithEOL(const wxString& text) { wxString textToAdd = text; textToAdd.Trim().Trim(false); - if(textToAdd.IsEmpty()) { - return; - } - if(!textToAdd.EndsWith("\n")) { - textToAdd << "\n"; - } + if(textToAdd.IsEmpty()) { return; } + if(!textToAdd.EndsWith("\n")) { textToAdd << "\n"; } m_textCtrl->SetReadOnly(false); m_textCtrl->AppendText(textToAdd); m_textCtrl->GotoPos(m_textCtrl->GetLastPosition()); diff --git a/Plugin/wxterminalbase.cpp b/Plugin/wxterminalbase.cpp index 9c6f6fcce5..15dbc34b45 100644 --- a/Plugin/wxterminalbase.cpp +++ b/Plugin/wxterminalbase.cpp @@ -53,9 +53,7 @@ wxTerminalBase::wxTerminalBase(wxWindow* parent, wxWindowID id, const wxPoint& p m_textCtrl->MarkerAdd(0, MARKER_ID); LexerConf::Ptr_t lexer = ColoursAndFontsManager::Get().GetLexer("text"); - if(lexer) { - lexer->Apply(m_textCtrl); - } + if(lexer) { lexer->Apply(m_textCtrl); } mainSizer->Add(m_textCtrl, 1, wxEXPAND, 0); this->SetSizer(mainSizer); this->Layout(); @@ -65,9 +63,7 @@ wxTerminalBase::wxTerminalBase(wxWindow* parent, wxWindowID id, const wxPoint& p m_textCtrl->Bind(wxEVT_KEY_DOWN, &wxTerminalBase::OnKey, this); m_textCtrl->Bind(wxEVT_STC_CHARADDED, &wxTerminalBase::OnCharAdded, this); m_textCtrl->Bind(wxEVT_LEFT_UP, [&](wxMouseEvent& event) { - if(m_textCtrl->GetSelectedText().IsEmpty()) { - this->CallAfter(&wxTerminalBase::CaretToEnd); - } + if(m_textCtrl->GetSelectedText().IsEmpty()) { this->CallAfter(&wxTerminalBase::CaretToEnd); } event.Skip(); }); m_textCtrl->SetReadOnly(true);