| 1 |
#include "DAPTerminalCtrlView.h" |
| 2 |
|
| 3 |
#include "ColoursAndFontsManager.h" |
| 4 |
#include "StringUtils.h" |
| 5 |
#include "clSystemSettings.h" |
| 6 |
#include "event_notifier.h" |
| 7 |
#include "globals.h" |
| 8 |
#include "macros.h" |
| 9 |
|
| 10 |
#include <wx/arrstr.h> |
| 11 |
#include <wx/tokenzr.h> |
| 12 |
|
| 13 |
DAPTerminalCtrlView::DAPTerminalCtrlView(wxWindow* parent, clModuleLogger& log) |
| 14 |
: wxPanel(parent) |
| 15 |
, LOG(log) |
| 16 |
{ |
| 17 |
SetSizer(new wxBoxSizer(wxVERTICAL)); |
| 18 |
|
| 19 |
m_ctrl = new wxStyledTextCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNO_BORDER); |
| 20 |
GetSizer()->Add(m_ctrl, 1, wxEXPAND); |
| 21 |
ApplyTheme(); |
| 22 |
|
| 23 |
EventNotifier::Get()->Bind(wxEVT_SYS_COLOURS_CHANGED, &DAPTerminalCtrlView::OnThemeChanged, this); |
| 24 |
} |
| 25 |
|
| 26 |
DAPTerminalCtrlView::~DAPTerminalCtrlView() |
| 27 |
{ |
| 28 |
EventNotifier::Get()->Unbind(wxEVT_SYS_COLOURS_CHANGED, &DAPTerminalCtrlView::OnThemeChanged, this); |
| 29 |
} |
| 30 |
|
| 31 |
void DAPTerminalCtrlView::OnThemeChanged(clCommandEvent& event) |
| 32 |
{ |
| 33 |
event.Skip(); |
| 34 |
ApplyTheme(); |
| 35 |
} |
| 36 |
|
| 37 |
void DAPTerminalCtrlView::ApplyTheme() |
| 38 |
{ |
| 39 |
auto lexer = ColoursAndFontsManager::Get().GetLexer("text"); |
| 40 |
lexer->ApplySystemColours(m_ctrl); |
| 41 |
MSWSetWindowDarkTheme(m_ctrl); |
| 42 |
} |
| 43 |
|
| 44 |
void DAPTerminalCtrlView::AppendLine(const wxString& line) { m_ctrl->AppendText(line + "\n"); } |
| 45 |
|
| 46 |
void DAPTerminalCtrlView::ScrollToEnd() |
| 47 |
{ |
| 48 |
int lastPos = m_ctrl->GetLastPosition(); |
| 49 |
m_ctrl->SetCurrentPos(lastPos); |
| 50 |
m_ctrl->SetSelectionStart(lastPos); |
| 51 |
m_ctrl->SetSelectionEnd(lastPos); |
| 52 |
m_ctrl->ScrollToEnd(); |
| 53 |
} |