]>
git.siccegge.de Git - frida/frida.git/blob - widgets/ScriptingDock.cxx
1 #include "ScriptingDock.hxx"
2 #include "FridaDock.hxx"
4 #include "bindings/Interpreter.hxx"
9 class ScriptingLineEdit
: public QObject
, public QLineEdit
{
11 void keyPressEvent(QKeyEvent
* event
) {
12 if (event
->key() == Qt::Key_Up
) {
15 QLineEdit::keyPressEvent(event
);
27 ScriptingDock::ScriptingDock(Interpreter
* interpreter
, FridaDock
* parent
)
29 , logger(log4cxx::Logger::getLogger("gui.ScriptingDock"))
30 , interpreter(interpreter
) {
31 setLayout(layout
= new QGridLayout
);
32 layout
->addWidget(browser
= new QTextBrowser
, 0, 0, 1, 0);
33 layout
->addWidget(line
= new ScriptingLineEdit
, 1, 0);
34 layout
->addWidget(button
= new QPushButton(tr("Evaluate")), 1, 1);
35 connect(button
, SIGNAL(released()), this, SLOT(doEvaluate()));
36 connect(line
, SIGNAL(returnPressed()), this, SLOT(doEvaluate()));
40 void ScriptingDock::doEvaluate() {
41 std::stringstream stdout
, stderr
;
44 QString text
= line
->text();
46 ((ScriptingLineEdit
*)line
)->clear();
47 LOG4CXX_INFO(logger
, "Evaluating String \"" << text
.toStdString() << "\"");
48 browser
->append(QString("> ") + text
);
50 interpreter
->evaluate(text
.toStdString(), stdout
, stderr
, result
);
52 output
= stdout
.str().c_str();
53 if (output
.endsWith("\n")) output
.chop(1);
54 if (output
!= "") browser
->append(output
);
56 output
= stderr
.str().c_str();
57 if (output
.endsWith("\n")) output
.chop(1);
58 if (output
!= "") browser
->append(output
);
60 browser
->append(result
.c_str());