1
// =============================================================================
3
// --- kvi_codetester.cpp ---
5
// This file is part of the KVIrc IRC client distribution
6
// Copyright (C) 1999-2000 Szymon Stefanek (stefanek@tin.it)
7
// Copyright (C) 1999-2000 Till Busch (buti@geocities.com)
9
// This program is FREE software. You can redistribute it and/or
10
// modify it under the terms of the GNU General Public License
11
// as published by the Free Software Foundation; either version 2
12
// of the License, or (at your opinion) any later version.
14
// This program is distributed in the HOPE that it will be USEFUL,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
// See the GNU General Public License for more details.
19
// You should have received a copy of the GNU General Public License
20
// along with this program. If not, write to the Free Software Foundation,
21
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
// =============================================================================
25
#define _KVI_DEBUG_CHECK_RANGE_
26
#define _KVI_DEBUG_CLASS_NAME_ "KviCodeTester"
31
#include "kvi_codetester.h"
32
#include "kvi_console.h"
33
#include "kvi_frame.h"
34
#include "kvi_label.h"
35
#include "kvi_lineedit.h"
36
#include "kvi_locale.h"
37
#include "kvi_pushbutton.h"
38
#include "kvi_script_editor.h"
39
#include "kvi_string.h"
40
#include "kvi_userparser.h"
41
#include "kvi_window.h"
43
// TODO: Totally missing quick help!
45
KviStr g_szLastCodeTesterBuffer = "";
48
@quickhelp: KviCodeTester
49
@widget: Script tester
50
This tab allows you to test multiline code.<br>
51
Since the commandline widget does not allow multiline code to be executed,
52
you can enter it here and click "Execute".<br>
53
You can specify a window for the command to be executed in.<br>
54
If you do not specify a window, or if the target window does not exist,
55
the command buffer will be executed in the first session's Console.<br>
56
If you still do not understand what this tab does, type in the editor:<br>
58
<a href="echo.kvihelp">echo</a> "Hello in <a href="s_window.kvihelp">$window</a>!"
60
click "Execute" and watch the Console window.<br>
67
* This widget allows testing of the script code
70
KviCodeTester::KviCodeTester(QWidget *parent, const char *name)
71
: QWidget(parent, name)
73
QGridLayout *g = new QGridLayout(this, 2, 3, 4, 2);
75
m_pCodeEditor = new KviScriptEditor(this);
76
g->addMultiCellWidget(m_pCodeEditor, 0, 0, 0, 2);
77
m_pCodeEditor->setText(g_szLastCodeTesterBuffer.ptr());
78
KviPushButton *pb = new KviPushButton(_i18n_("E&xecute"), this);
79
g->addWidget(pb, 1, 2);
80
KviLabel *lb = new KviLabel(_i18n_("Window:"), this);
81
g->addWidget(lb, 1, 0);
82
m_pWindowNameEdit = new KviLineEdit(this);
83
g->addWidget(m_pWindowNameEdit, 1, 1);
84
g->setColStretch(1, 1);
85
g->setRowStretch(0, 1);
86
connect(pb, SIGNAL(clicked()), this, SLOT(test()));
89
KviCodeTester::~KviCodeTester()
94
void KviCodeTester::test()
96
KviStr tmp = m_pCodeEditor->text();
98
KviStr szWnd = m_pWindowNameEdit->text();
100
KviFrame *theFrame = 0;
101
if( szWnd.hasData() ) {
102
for( KviFrame *f = g_pApp->m_pFrameList->first(); f; f = g_pApp->m_pFrameList->next() ) {
103
wnd = f->findWindow(szWnd.ptr());
111
theFrame = g_pApp->m_pFrameList->first();
112
wnd = theFrame->m_pConsole;
115
theFrame->m_pUserParser->parseCommand(tmp.ptr(), wnd);
118
#include "m_kvi_codetester.moc"