33
33
BEGIN_EVENT_TABLE(OutputTabWindow, wxPanel)
34
EVT_MENU(XRCID("scroll_on_output"), OutputTabWindow::OnOutputScrolls)
35
EVT_MENU(XRCID("clear_all_output"), OutputTabWindow::OnClearAll)
36
EVT_MENU(XRCID("word_wrap_output"), OutputTabWindow::OnWordWrap)
37
EVT_MENU(XRCID("collapse_all"), OutputTabWindow::OnCollapseAll)
38
EVT_MENU(XRCID("repeat_output"), OutputTabWindow::OnRepeatOutput)
39
EVT_MENU(wxID_COPY, OutputTabWindow::OnCopy)
41
EVT_UPDATE_UI(XRCID("scroll_on_output"), OutputTabWindow::OnOutputScrollsUI)
42
EVT_UPDATE_UI(XRCID("clear_all_output"), OutputTabWindow::OnClearAllUI)
43
EVT_UPDATE_UI(XRCID("word_wrap_output"), OutputTabWindow::OnWordWrapUI)
44
EVT_UPDATE_UI(XRCID("collapse_all"), OutputTabWindow::OnCollapseAllUI)
45
EVT_UPDATE_UI(XRCID("repeat_output"), OutputTabWindow::OnRepeatOutputUI)
46
EVT_UPDATE_UI(wxID_COPY, OutputTabWindow::OnCopyUI)
48
EVT_SCI_DOUBLECLICK(wxID_ANY, OutputTabWindow::OnMouseDClick)
49
EVT_SCI_HOTSPOT_CLICK(wxID_ANY, OutputTabWindow::OnHotspotClicked)
50
EVT_SCI_MARGINCLICK(wxID_ANY, OutputTabWindow::OnMarginClick)
34
EVT_MENU(XRCID("scroll_on_output"), OutputTabWindow::OnOutputScrolls)
35
EVT_MENU(XRCID("clear_all_output"), OutputTabWindow::OnClearAll)
36
EVT_MENU(XRCID("word_wrap_output"), OutputTabWindow::OnWordWrap)
37
EVT_MENU(XRCID("collapse_all"), OutputTabWindow::OnCollapseAll)
38
EVT_MENU(XRCID("repeat_output"), OutputTabWindow::OnRepeatOutput)
39
EVT_MENU(wxID_COPY, OutputTabWindow::OnCopy)
41
EVT_UPDATE_UI(XRCID("scroll_on_output"), OutputTabWindow::OnOutputScrollsUI)
42
EVT_UPDATE_UI(XRCID("clear_all_output"), OutputTabWindow::OnClearAllUI)
43
EVT_UPDATE_UI(XRCID("word_wrap_output"), OutputTabWindow::OnWordWrapUI)
44
EVT_UPDATE_UI(XRCID("collapse_all"), OutputTabWindow::OnCollapseAllUI)
45
EVT_UPDATE_UI(XRCID("repeat_output"), OutputTabWindow::OnRepeatOutputUI)
46
EVT_UPDATE_UI(wxID_COPY, OutputTabWindow::OnCopyUI)
48
EVT_SCI_DOUBLECLICK(wxID_ANY, OutputTabWindow::OnMouseDClick)
49
EVT_SCI_HOTSPOT_CLICK(wxID_ANY, OutputTabWindow::OnHotspotClicked)
50
EVT_SCI_MARGINCLICK(wxID_ANY, OutputTabWindow::OnMarginClick)
54
54
OutputTabWindow::OutputTabWindow(wxWindow *parent, wxWindowID id, const wxString &name)
59
, m_outputScrolls(true)
59
, m_outputScrolls(true)
62
62
CreateGUIControls();
94
sci->IndicatorSetForeground(1, MakeColourLighter(wxT("GOLD"), facttor));
95
sci->IndicatorSetForeground(2, MakeColourLighter(wxT("RED"), 4));
94
sci->IndicatorSetForeground(1, MakeColourLighter(wxT("GOLD"), facttor));
95
sci->IndicatorSetForeground(2, MakeColourLighter(wxT("RED"), 4));
96
96
sci->IndicatorSetStyle(1, wxSCI_INDIC_ROUNDBOX);
97
97
sci->IndicatorSetStyle(2, wxSCI_INDIC_ROUNDBOX);
98
98
sci->IndicatorSetUnder(1, true);
111
111
sci->SetFoldFlags(16); // mark folded lines with line below
114
sci->SetMarginWidth(4, 16);
115
sci->SetProperty(wxT("fold"), wxT("1"));
116
sci->SetMarginSensitive(4, true);
117
sci->StyleSetForeground(wxSCI_STYLE_DEFAULT, wxT("GREY"));
114
sci->SetMarginWidth(4, 16);
115
sci->SetProperty(wxT("fold"), wxT("1"));
116
sci->SetMarginSensitive(4, true);
117
sci->StyleSetForeground(wxSCI_STYLE_DEFAULT, wxT("GREY"));
120
// current line marker
121
DefineMarker(sci, 0x7, wxSCI_MARK_ARROW, wxColor(0x00, 0x00, 0x00), wxColor(0xff, 0xc8, 0xc8));
120
// current line marker
121
DefineMarker(sci, 0x7, wxSCI_MARK_ARROW, wxColor(0x00, 0x00, 0x00), wxColor(0xff, 0xc8, 0xc8));
123
123
wxColor fore(0xff, 0xff, 0xff);
124
124
wxColor back(0x80, 0x80, 0x80);
130
130
DefineMarker(sci, wxSCI_MARKNUM_FOLDEROPENMID, wxSCI_MARK_ARROWDOWN, fore, back);
131
131
DefineMarker(sci, wxSCI_MARKNUM_FOLDERMIDTAIL, wxSCI_MARK_BACKGROUND, fore, back);
133
sci->SetWrapStartIndent(4);
134
sci->SetWrapVisualFlags(2);
133
sci->SetWrapStartIndent(4);
134
sci->SetWrapVisualFlags(2);
136
sci->SetScrollWidthTracking(true);
136
sci->SetScrollWidthTracking(true);
138
138
sci->SetReadOnly(true);
146
146
//Create the toolbar
147
147
m_tb = new wxToolBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTB_FLAT|wxTB_VERTICAL|wxTB_NODIVIDER);
149
m_tb->AddTool(XRCID("scroll_on_output"),
150
wxT("Scroll on Output"),
151
wxXmlResource::Get()->LoadBitmap(wxT("link_editor")),
152
wxT("Scroll on Output"),
154
m_tb->ToggleTool(XRCID("scroll_on_output"), m_outputScrolls);
149
m_tb->AddTool(XRCID("scroll_on_output"),
150
wxT("Scroll on Output"),
151
wxXmlResource::Get()->LoadBitmap(wxT("link_editor")),
152
wxT("Scroll on Output"),
154
m_tb->ToggleTool(XRCID("scroll_on_output"), m_outputScrolls);
156
156
m_tb->AddTool(XRCID("word_wrap_output"),
158
wxXmlResource::Get()->LoadBitmap(wxT("word_wrap")),
158
wxXmlResource::Get()->LoadBitmap(wxT("word_wrap")),
162
m_tb->AddTool(XRCID("clear_all_output"),
164
wxXmlResource::Get()->LoadBitmap(wxT("document_delete")),
162
m_tb->AddTool(XRCID("clear_all_output"),
164
wxXmlResource::Get()->LoadBitmap(wxT("document_delete")),
167
167
m_tb->AddTool(XRCID("collapse_all"), _("Fold All Results"),
168
168
wxXmlResource::Get()->LoadBitmap(wxT("fold_airplane")),
176
176
mainSizer->Add(m_tb, 0, wxTOP|wxBOTTOM|wxEXPAND, 5);
178
178
m_sci = new wxScintilla(this);
179
InitStyle(m_sci, wxSCI_LEX_CONTAINER, false);
179
InitStyle(m_sci, wxSCI_LEX_CONTAINER, false);
180
180
mainSizer->Add(m_sci, 1, wxEXPAND | wxALL, 1);
182
182
mainSizer->Layout();
185
185
void OutputTabWindow::Clear()
187
m_sci->SetReadOnly(false);
189
m_sci->SetScrollWidth(1);
190
m_sci->SetReadOnly(true);
188
m_sci->SetReadOnly(false);
190
m_sci->SetScrollWidth(1);
191
m_sci->SetReadOnly(true);
193
195
void OutputTabWindow::AppendText(const wxString &text)
195
if (m_autoAppear && m_sci->GetLength() == 0) {
196
ManagerST::Get()->ShowOutputPane(m_name);
199
//----------------------------------------------
201
m_sci->SetReadOnly(false);
203
if (m_outputScrolls) {
204
// the next 4 lines make sure that the caret is at last line
206
m_sci->SetSelectionEnd(m_sci->GetLength());
207
m_sci->SetSelectionStart(m_sci->GetLength());
208
m_sci->SetCurrentPos(m_sci->GetLength());
209
m_sci->EnsureCaretVisible();
213
m_sci->InsertText(m_sci->GetLength(), text );
215
if (m_outputScrolls) {
216
// the next 4 lines make sure that the caret is at last line
218
m_sci->SetSelectionEnd(m_sci->GetLength());
219
m_sci->SetSelectionStart(m_sci->GetLength());
220
m_sci->SetCurrentPos(m_sci->GetLength());
221
m_sci->EnsureCaretVisible();
224
// enable readonly mode
225
m_sci->SetReadOnly(true);
198
if (m_autoAppear && m_sci->GetLength() == 0) {
199
ManagerST::Get()->ShowOutputPane(m_name);
202
//----------------------------------------------
204
m_sci->SetReadOnly(false);
206
if (m_outputScrolls) {
207
// the next 4 lines make sure that the caret is at last line
209
m_sci->SetSelectionEnd(m_sci->GetLength());
210
m_sci->SetSelectionStart(m_sci->GetLength());
211
m_sci->SetCurrentPos(m_sci->GetLength());
212
m_sci->EnsureCaretVisible();
216
m_sci->InsertText(m_sci->GetLength(), text );
218
if (m_outputScrolls) {
219
// the next 4 lines make sure that the caret is at last line
221
m_sci->SetSelectionEnd(m_sci->GetLength());
222
m_sci->SetSelectionStart(m_sci->GetLength());
223
m_sci->SetCurrentPos(m_sci->GetLength());
224
m_sci->EnsureCaretVisible();
227
// enable readonly mode
228
m_sci->SetReadOnly(true);
228
233
void OutputTabWindow::OnOutputScrolls(wxCommandEvent &e)
230
m_outputScrolls = !m_outputScrolls;
235
m_outputScrolls = !m_outputScrolls;
233
238
void OutputTabWindow::OnOutputScrollsUI(wxUpdateUIEvent& e)
238
243
void OutputTabWindow::OnClearAll(wxCommandEvent &e)
243
248
void OutputTabWindow::OnClearAllUI(wxUpdateUIEvent& e)
245
e.Enable(m_sci->GetLength() > 0);
250
e.Enable(m_sci && m_sci->GetLength() > 0);
248
253
void OutputTabWindow::OnWordWrap(wxCommandEvent &e)
250
m_sci->SetWrapMode(m_sci->GetWrapMode() == wxSCI_WRAP_WORD ? wxSCI_WRAP_NONE : wxSCI_WRAP_WORD);
256
m_sci->SetWrapMode(m_sci->GetWrapMode() == wxSCI_WRAP_WORD ? wxSCI_WRAP_NONE : wxSCI_WRAP_WORD);
253
260
void OutputTabWindow::OnWordWrapUI(wxUpdateUIEvent& e)
258
265
void OutputTabWindow::OnCollapseAll(wxCommandEvent& e)
260
268
int maxLine = m_sci->GetLineCount();
261
// do two passes: first see if any folds can be collapsed
262
// if not, then expand instead
264
for (int pass = 0; pass < 2 && !done; pass++) {
265
for (int line = 0; line < maxLine; line++) {
266
if ((m_sci->GetFoldLevel(line) & wxSCI_FOLDLEVELHEADERFLAG) &&
267
m_sci->GetFoldExpanded(line) == !pass) {
268
m_sci->ToggleFold(line);
269
// do two passes: first see if any folds can be collapsed
270
// if not, then expand instead
272
for (int pass = 0; pass < 2 && !done; pass++) {
273
for (int line = 0; line < maxLine; line++) {
274
if ((m_sci->GetFoldLevel(line) & wxSCI_FOLDLEVELHEADERFLAG) &&
275
m_sci->GetFoldExpanded(line) == !pass) {
276
m_sci->ToggleFold(line);
275
284
void OutputTabWindow::OnCollapseAllUI(wxUpdateUIEvent& e)
277
e.Enable(m_sci->GetLength() > 0);
286
e.Enable(m_sci && m_sci->GetLength() > 0);
280
289
void OutputTabWindow::OnRepeatOutput(wxCommandEvent& e)
285
294
void OutputTabWindow::OnRepeatOutputUI(wxUpdateUIEvent& e)
290
299
void OutputTabWindow::OnCopy(wxCommandEvent &e)
295
void OutputTabWindow::OnCopyUI(wxUpdateUIEvent& e)
306
void OutputTabWindow::OnCopyUI(wxUpdateUIEvent& e)
297
e.Enable( m_sci->GetSelectionStart() - m_sci->GetSelectionEnd() != 0 );
308
e.Enable(m_sci && (m_sci->GetSelectionStart() - m_sci->GetSelectionEnd() != 0) );
300
311
void OutputTabWindow::OnMouseDClick(wxScintillaEvent& e)
304
315
void OutputTabWindow::OnHotspotClicked(wxScintillaEvent& e)
309
320
void OutputTabWindow::OnMarginClick(wxScintillaEvent& e)
311
if (e.GetMargin() == 4) {
322
if (m_sci && e.GetMargin() == 4) {
312
323
m_sci->ToggleFold(m_sci->LineFromPosition(e.GetPosition()));