]> git.siccegge.de Git - frida/frida.git/commitdiff
Add basic Backlog to ScriptingDock
authorChristoph Egger <christoph@christoph-egger.org>
Mon, 25 May 2015 09:02:09 +0000 (11:02 +0200)
committerChristoph Egger <christoph@christoph-egger.org>
Mon, 25 May 2015 09:02:09 +0000 (11:02 +0200)
src/gui/widgets/ScriptingDock.cxx

index 0c25b596262bd8160e4bf390c9ca7db2056ba4ef..4ec7f3bd3be451269b6ffefef377df1e7d6ce0bb 100644 (file)
@@ -5,13 +5,32 @@
 
 #include <sstream>
 
+namespace {
+       class ScriptingLineEdit : public QObject, public QLineEdit {
+       public:
+               void keyPressEvent(QKeyEvent* event) {
+                       if (event->key() == Qt::Key_Up) {
+                               setText(backlog);
+                       }
+                       QLineEdit::keyPressEvent(event);
+               }
+
+               void clear() {
+                       backlog = text();
+                       QLineEdit::clear();
+               }
+       private:
+               QString backlog;
+       };
+}
+
 ScriptingDock::ScriptingDock(Interpreter* interpreter, FridaDock* parent)
        : QWidget(parent)
        , logger(log4cxx::Logger::getLogger("gui.ScriptingDock"))
        , interpreter(interpreter) {
        setLayout(layout = new QGridLayout);
        layout->addWidget(browser = new QTextBrowser, 0, 0, 1, 0);
-       layout->addWidget(line = new QLineEdit, 1, 0);
+       layout->addWidget(line = new ScriptingLineEdit, 1, 0);
        layout->addWidget(button = new QPushButton(tr("Evaluate")), 1, 1);
        connect(button, SIGNAL(released()), this, SLOT(doEvaluate()));
        connect(line, SIGNAL(returnPressed()), this, SLOT(doEvaluate()));
@@ -24,7 +43,7 @@ void ScriptingDock::doEvaluate() {
        QString output;
        QString text = line->text();
 
-       line->clear();
+       ((ScriptingLineEdit*)line)->clear();
        LOG4CXX_INFO(logger, "Evaluating String \"" << text.toStdString() << "\"");
        browser->append(QString("> ") + text);