~ubuntu-branches/ubuntu/maverick/codelite/maverick

« back to all changes in this revision

Viewing changes to LiteEditor/outputtabwindow.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2009-04-30 02:46:27 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090430024627-7xp71gerfvw00xtt
Tags: 1.0.2822+dfsg-0ubuntu1
* New upstream release (LP: #369466)
* debian/copyright:
  + Added Files section for sdk/wxpropgrid
  + Made license text RFC compliant (add . for empty lines)
* debian/control:
  + Bump Standards-Version to 3.8.1
* debian/patches/02_fix-desktop.patch,
  + Refreshed to patch cleanly
* debian/*.install,
  debian/codelite.dirs,
  debian/codelite.links,
  debian/patches/03_fix-sh.patch,
  debian/patches/04_change-installpath.patch,
  + Updated for new upstream directory structure
  + Patches dropped, no longer needed.
* debian/patches/03_cstdio-include.patch,
  + Include cstdio for C++ and stdio.h for C, since it seems to be missing
* debian/codelite.menu,
  debian/*.1,
  debian/codelite.manpages:
  + Updated to reflect change in command names
    - CodeLite    => codelite
    - le_exec     => codelite_exec
    - le_dos2unix => codelite_fix_files
    - le_killproc => codelite_kill_children
* debian/README.source,
  debian/rules,
  debian/copyright:
  + Remove sdk/curl from the list of excluded files, since it doesn't exist
    any more

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
 
32
32
 
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)
40
 
 
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)
47
 
 
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)
 
40
 
 
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)
 
47
 
 
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)
51
51
END_EVENT_TABLE()
52
52
 
53
53
 
54
54
OutputTabWindow::OutputTabWindow(wxWindow *parent, wxWindowID id, const wxString &name)
55
 
    : wxPanel(parent, id)
56
 
    , m_name(name)
57
 
    , m_tb(NULL)
58
 
    , m_sci(NULL)
59
 
    , m_outputScrolls(true)
60
 
    , m_autoAppear(true)
 
55
                : wxPanel(parent, id)
 
56
                , m_name(name)
 
57
                , m_tb(NULL)
 
58
                , m_sci(NULL)
 
59
                , m_outputScrolls(true)
 
60
                , m_autoAppear(true)
61
61
{
62
62
        CreateGUIControls();
63
63
}
91
91
#else
92
92
        int facttor = 5;
93
93
#endif
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);
110
110
 
111
111
        sci->SetFoldFlags(16); // mark folded lines with line below
112
112
 
113
 
    if (folding) {
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"));
118
 
    }
 
113
        if (folding) {
 
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"));
 
118
        }
119
119
 
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));
122
122
 
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);
132
132
 
133
 
    sci->SetWrapStartIndent(4);
134
 
    sci->SetWrapVisualFlags(2);
 
133
        sci->SetWrapStartIndent(4);
 
134
        sci->SetWrapVisualFlags(2);
135
135
 
136
 
    sci->SetScrollWidthTracking(true);
 
136
        sci->SetScrollWidthTracking(true);
137
137
 
138
138
        sci->SetReadOnly(true);
139
139
}
146
146
        //Create the toolbar
147
147
        m_tb = new wxToolBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTB_FLAT|wxTB_VERTICAL|wxTB_NODIVIDER);
148
148
 
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"),
153
 
                wxITEM_CHECK);
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"),
 
153
                      wxITEM_CHECK);
 
154
        m_tb->ToggleTool(XRCID("scroll_on_output"), m_outputScrolls);
155
155
 
156
156
        m_tb->AddTool(XRCID("word_wrap_output"),
157
 
                    wxT("Word Wrap"),
158
 
                    wxXmlResource::Get()->LoadBitmap(wxT("word_wrap")),
159
 
                    wxT("Word Wrap"),
160
 
                    wxITEM_CHECK);
 
157
                      wxT("Word Wrap"),
 
158
                      wxXmlResource::Get()->LoadBitmap(wxT("word_wrap")),
 
159
                      wxT("Word Wrap"),
 
160
                      wxITEM_CHECK);
161
161
 
162
 
    m_tb->AddTool(XRCID("clear_all_output"),
163
 
                wxT("Clear All"),
164
 
                wxXmlResource::Get()->LoadBitmap(wxT("document_delete")),
165
 
                wxT("Clear All"));
 
162
        m_tb->AddTool(XRCID("clear_all_output"),
 
163
                      wxT("Clear All"),
 
164
                      wxXmlResource::Get()->LoadBitmap(wxT("document_delete")),
 
165
                      wxT("Clear All"));
166
166
 
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);
177
177
 
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);
181
181
 
182
182
        mainSizer->Layout();
184
184
 
185
185
void OutputTabWindow::Clear()
186
186
{
187
 
        m_sci->SetReadOnly(false);
188
 
        m_sci->ClearAll();
189
 
    m_sci->SetScrollWidth(1);
190
 
        m_sci->SetReadOnly(true);
 
187
        if (m_sci) {
 
188
                m_sci->SetReadOnly(false);
 
189
                m_sci->ClearAll();
 
190
                m_sci->SetScrollWidth(1);
 
191
                m_sci->SetReadOnly(true);
 
192
        }
191
193
}
192
194
 
193
195
void OutputTabWindow::AppendText(const wxString &text)
194
196
{
195
 
    if (m_autoAppear && m_sci->GetLength() == 0) {
196
 
        ManagerST::Get()->ShowOutputPane(m_name);
197
 
    }
198
 
 
199
 
        //----------------------------------------------
200
 
        // enable writing
201
 
        m_sci->SetReadOnly(false);
202
 
 
203
 
    if (m_outputScrolls) {
204
 
        // the next 4 lines make sure that the caret is at last line
205
 
        // and is visible
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();
210
 
    }
211
 
 
212
 
        // add the text
213
 
        m_sci->InsertText(m_sci->GetLength(), text );
214
 
 
215
 
    if (m_outputScrolls) {
216
 
        // the next 4 lines make sure that the caret is at last line
217
 
        // and is visible
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();
222
 
    }
223
 
 
224
 
        // enable readonly mode
225
 
        m_sci->SetReadOnly(true);
 
197
        if (m_sci) {
 
198
                if (m_autoAppear && m_sci->GetLength() == 0) {
 
199
                        ManagerST::Get()->ShowOutputPane(m_name);
 
200
                }
 
201
 
 
202
                //----------------------------------------------
 
203
                // enable writing
 
204
                m_sci->SetReadOnly(false);
 
205
 
 
206
                if (m_outputScrolls) {
 
207
                        // the next 4 lines make sure that the caret is at last line
 
208
                        // and is visible
 
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();
 
213
                }
 
214
 
 
215
                // add the text
 
216
                m_sci->InsertText(m_sci->GetLength(), text );
 
217
 
 
218
                if (m_outputScrolls) {
 
219
                        // the next 4 lines make sure that the caret is at last line
 
220
                        // and is visible
 
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();
 
225
                }
 
226
 
 
227
                // enable readonly mode
 
228
                m_sci->SetReadOnly(true);
 
229
 
 
230
        }
226
231
}
227
232
 
228
233
void OutputTabWindow::OnOutputScrolls(wxCommandEvent &e)
229
234
{
230
 
    m_outputScrolls = !m_outputScrolls;
 
235
        m_outputScrolls = !m_outputScrolls;
231
236
}
232
237
 
233
238
void OutputTabWindow::OnOutputScrollsUI(wxUpdateUIEvent& e)
234
239
{
235
 
    e.Enable(true);
 
240
        e.Enable(true);
236
241
}
237
242
 
238
243
void OutputTabWindow::OnClearAll(wxCommandEvent &e)
242
247
 
243
248
void OutputTabWindow::OnClearAllUI(wxUpdateUIEvent& e)
244
249
{
245
 
    e.Enable(m_sci->GetLength() > 0);
 
250
        e.Enable(m_sci && m_sci->GetLength() > 0);
246
251
}
247
252
 
248
253
void OutputTabWindow::OnWordWrap(wxCommandEvent &e)
249
254
{
250
 
    m_sci->SetWrapMode(m_sci->GetWrapMode() == wxSCI_WRAP_WORD ? wxSCI_WRAP_NONE : wxSCI_WRAP_WORD);
 
255
        if(m_sci) {
 
256
        m_sci->SetWrapMode(m_sci->GetWrapMode() == wxSCI_WRAP_WORD ? wxSCI_WRAP_NONE : wxSCI_WRAP_WORD);
 
257
        }
251
258
}
252
259
 
253
260
void OutputTabWindow::OnWordWrapUI(wxUpdateUIEvent& e)
254
261
{
255
 
    e.Enable(true);
 
262
        e.Enable(true);
256
263
}
257
264
 
258
265
void OutputTabWindow::OnCollapseAll(wxCommandEvent& e)
259
266
{
 
267
        if(m_sci) {
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
263
 
    bool done = false;
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
 
                done = true;
270
 
            }
271
 
        }
272
 
    }
 
269
        // do two passes: first see if any folds can be collapsed
 
270
        // if not, then expand instead
 
271
        bool done = false;
 
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);
 
277
                                done = true;
 
278
                        }
 
279
                }
 
280
        }
 
281
        }
273
282
}
274
283
 
275
284
void OutputTabWindow::OnCollapseAllUI(wxUpdateUIEvent& e)
276
285
{
277
 
    e.Enable(m_sci->GetLength() > 0);
 
286
        e.Enable(m_sci && m_sci->GetLength() > 0);
278
287
}
279
288
 
280
289
void OutputTabWindow::OnRepeatOutput(wxCommandEvent& e)
281
290
{
282
 
    e.Skip();
 
291
        e.Skip();
283
292
}
284
293
 
285
294
void OutputTabWindow::OnRepeatOutputUI(wxUpdateUIEvent& e)
286
295
{
287
 
    e.Enable(false);
 
296
        e.Enable(false);
288
297
}
289
298
 
290
299
void OutputTabWindow::OnCopy(wxCommandEvent &e)
291
300
{
292
 
    m_sci->Copy();
 
301
        if(m_sci) {
 
302
        m_sci->Copy();
 
303
        }
293
304
}
294
305
 
295
 
void OutputTabWindow::OnCopyUI(wxUpdateUIEvent& e)
 
306
void OutputTabWindow::OnCopyUI(wxUpdateUIEvent& e)
296
307
{
297
 
    e.Enable( m_sci->GetSelectionStart() - m_sci->GetSelectionEnd() != 0 );
298
 
}
299
 
 
 
308
        e.Enable(m_sci && (m_sci->GetSelectionStart() - m_sci->GetSelectionEnd() != 0) );
 
309
}
 
310
 
300
311
void OutputTabWindow::OnMouseDClick(wxScintillaEvent& e)
301
312
{
302
313
}
303
314
 
304
315
void OutputTabWindow::OnHotspotClicked(wxScintillaEvent& e)
305
316
{
306
 
    OnMouseDClick(e);
 
317
        OnMouseDClick(e);
307
318
}
308
319
 
309
320
void OutputTabWindow::OnMarginClick(wxScintillaEvent& e)
310
321
{
311
 
        if (e.GetMargin() == 4) {
 
322
        if (m_sci && e.GetMargin() == 4) {
312
323
                m_sci->ToggleFold(m_sci->LineFromPosition(e.GetPosition()));
313
324
        }
314
325
}