forked from eranif/codelite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTerminalEmulatorUI.cpp
More file actions
67 lines (60 loc) · 1.73 KB
/
TerminalEmulatorUI.cpp
File metadata and controls
67 lines (60 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "TerminalEmulatorUI.h"
#if wxUSE_GUI
TerminalEmulatorUI::TerminalEmulatorUI(wxWindow* parent)
: TerminalEmulatorUIBase(parent)
, m_terminal(NULL)
{
}
void TerminalEmulatorUI::OnSendCommand(wxCommandEvent& event) {}
void TerminalEmulatorUI::SetTerminal(TerminalEmulator* terminal)
{
if (m_terminal) {
DoUnBindTerminal(m_terminal);
}
this->m_terminal = terminal;
if (m_terminal) {
DoBindTerminal(m_terminal);
}
}
void TerminalEmulatorUI::OnProcessExit(clCommandEvent& e)
{
e.Skip();
if (m_terminal) {
DoUnBindTerminal(m_terminal);
m_terminal = NULL;
}
}
void TerminalEmulatorUI::OnProcessOutput(clCommandEvent& e)
{
e.Skip();
m_stc->SetReadOnly(false);
m_stc->AppendText(e.GetString());
m_stc->SetReadOnly(true);
int lastPos = m_stc->GetLastPosition();
m_stc->SetCurrentPos(lastPos);
m_stc->SetSelectionStart(lastPos);
m_stc->SetSelectionEnd(lastPos);
m_stc->ScrollToEnd();
}
void TerminalEmulatorUI::DoBindTerminal(TerminalEmulator* terminal)
{
if (terminal) {
terminal->Bind(wxEVT_TERMINAL_COMMAND_EXIT, &TerminalEmulatorUI::OnProcessExit, this);
terminal->Bind(wxEVT_TERMINAL_COMMAND_OUTPUT, &TerminalEmulatorUI::OnProcessOutput, this);
}
}
void TerminalEmulatorUI::DoUnBindTerminal(TerminalEmulator* terminal)
{
if (terminal) {
terminal->Unbind(wxEVT_TERMINAL_COMMAND_EXIT, &TerminalEmulatorUI::OnProcessExit, this);
terminal->Unbind(wxEVT_TERMINAL_COMMAND_OUTPUT, &TerminalEmulatorUI::OnProcessOutput, this);
}
}
void TerminalEmulatorUI::Clear()
{
m_textCtrl->ChangeValue("");
m_stc->SetReadOnly(false);
m_stc->ClearAll();
m_stc->SetReadOnly(true);
}
#endif // LIBCODELITE_WITH_UI