Qt: Rename REPL to Console

This commit is contained in:
Jeffrey Pfau 2016-10-27 10:36:57 -07:00
parent 5406130432
commit 28a64fcbb8
9 changed files with 65 additions and 65 deletions

View File

@ -4,7 +4,7 @@ Features:
- GBA: Better cheat type autodetection - GBA: Better cheat type autodetection
- GB: Tile viewer - GB: Tile viewer
- Sprite viewer - Sprite viewer
- Debugging REPL - Debugging console
Bugfixes: Bugfixes:
- LR35902: Fix core never exiting with certain event patterns - LR35902: Fix core never exiting with certain event patterns
- GB Timer: Improve DIV reset behavior - GB Timer: Improve DIV reset behavior

View File

@ -118,7 +118,7 @@ set(UI_FILES
ArchiveInspector.ui ArchiveInspector.ui
AssetTile.ui AssetTile.ui
CheatsView.ui CheatsView.ui
DebuggerREPL.ui DebuggerConsole.ui
GIFView.ui GIFView.ui
IOViewer.ui IOViewer.ui
LoadSaveState.ui LoadSaveState.ui
@ -181,8 +181,8 @@ endif()
if(USE_DEBUGGERS) if(USE_DEBUGGERS)
list(APPEND SOURCE_FILES list(APPEND SOURCE_FILES
DebuggerController.cpp DebuggerController.cpp
DebuggerREPL.cpp DebuggerConsole.cpp
DebuggerREPLController.cpp) DebuggerConsoleController.cpp)
endif() endif()
if(USE_GDB_STUB) if(USE_GDB_STUB)

View File

@ -3,17 +3,17 @@
* This Source Code Form is subject to the terms of the Mozilla Public * This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "DebuggerREPL.h" #include "DebuggerConsole.h"
#include "DebuggerREPLController.h" #include "DebuggerConsoleController.h"
#include <QScrollBar> #include <QScrollBar>
using namespace QGBA; using namespace QGBA;
DebuggerREPL::DebuggerREPL(DebuggerREPLController* controller, QWidget* parent) DebuggerConsole::DebuggerConsole(DebuggerConsoleController* controller, QWidget* parent)
: QWidget(parent) : QWidget(parent)
, m_replController(controller) , m_consoleController(controller)
{ {
m_ui.setupUi(this); m_ui.setupUi(this);
@ -24,19 +24,19 @@ DebuggerREPL::DebuggerREPL(DebuggerREPLController* controller, QWidget* parent)
controller->attach(); controller->attach();
} }
void DebuggerREPL::log(const QString& line) { void DebuggerConsole::log(const QString& line) {
m_ui.log->moveCursor(QTextCursor::End); m_ui.log->moveCursor(QTextCursor::End);
m_ui.log->insertPlainText(line); m_ui.log->insertPlainText(line);
m_ui.log->verticalScrollBar()->setValue(m_ui.log->verticalScrollBar()->maximum()); m_ui.log->verticalScrollBar()->setValue(m_ui.log->verticalScrollBar()->maximum());
} }
void DebuggerREPL::postLine() { void DebuggerConsole::postLine() {
QString line = m_ui.prompt->text(); QString line = m_ui.prompt->text();
m_ui.prompt->clear(); m_ui.prompt->clear();
if (line.isEmpty()) { if (line.isEmpty()) {
m_replController->enterLine(QString("\n")); m_consoleController->enterLine(QString("\n"));
} else { } else {
log(QString("> %1\n").arg(line)); log(QString("> %1\n").arg(line));
m_replController->enterLine(line); m_consoleController->enterLine(line);
} }
} }

View File

@ -3,29 +3,29 @@
* This Source Code Form is subject to the terms of the Mozilla Public * This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef QGBA_DEBUGGER_REPL #ifndef QGBA_DEBUGGER_CONSOLE
#define QGBA_DEBUGGER_REPL #define QGBA_DEBUGGER_CONSOLE
#include "ui_DebuggerREPL.h" #include "ui_DebuggerConsole.h"
namespace QGBA { namespace QGBA {
class DebuggerREPLController; class DebuggerConsoleController;
class DebuggerREPL : public QWidget { class DebuggerConsole : public QWidget {
Q_OBJECT Q_OBJECT
public: public:
DebuggerREPL(DebuggerREPLController* controller, QWidget* parent = nullptr); DebuggerConsole(DebuggerConsoleController* controller, QWidget* parent = nullptr);
private slots: private slots:
void log(const QString&); void log(const QString&);
void postLine(); void postLine();
private: private:
Ui::DebuggerREPL m_ui; Ui::DebuggerConsole m_ui;
DebuggerREPLController* m_replController; DebuggerConsoleController* m_consoleController;
}; };
} }

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>DebuggerREPL</class> <class>DebuggerConsole</class>
<widget class="QWidget" name="DebuggerREPL"> <widget class="QWidget" name="DebuggerConsole">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>

View File

@ -3,7 +3,7 @@
* This Source Code Form is subject to the terms of the Mozilla Public * This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "DebuggerREPLController.h" #include "DebuggerConsoleController.h"
#include "GameController.h" #include "GameController.h"
@ -15,7 +15,7 @@ extern "C" {
using namespace QGBA; using namespace QGBA;
DebuggerREPLController::DebuggerREPLController(GameController* controller, QObject* parent) DebuggerConsoleController::DebuggerConsoleController(GameController* controller, QObject* parent)
: DebuggerController(controller, &m_cliDebugger.d, parent) : DebuggerController(controller, &m_cliDebugger.d, parent)
{ {
m_backend.d.printf = printf; m_backend.d.printf = printf;
@ -31,7 +31,7 @@ DebuggerREPLController::DebuggerREPLController(GameController* controller, QObje
CLIDebuggerAttachBackend(&m_cliDebugger, &m_backend.d); CLIDebuggerAttachBackend(&m_cliDebugger, &m_backend.d);
} }
void DebuggerREPLController::enterLine(const QString& line) { void DebuggerConsoleController::enterLine(const QString& line) {
QMutexLocker lock(&m_mutex); QMutexLocker lock(&m_mutex);
m_lines.append(line); m_lines.append(line);
if (m_cliDebugger.d.state == DEBUGGER_RUNNING) { if (m_cliDebugger.d.state == DEBUGGER_RUNNING) {
@ -40,33 +40,33 @@ void DebuggerREPLController::enterLine(const QString& line) {
m_cond.wakeOne(); m_cond.wakeOne();
} }
void DebuggerREPLController::attachInternal() { void DebuggerConsoleController::attachInternal() {
mCore* core = m_gameController->thread()->core; mCore* core = m_gameController->thread()->core;
CLIDebuggerAttachSystem(&m_cliDebugger, core->cliDebuggerSystem(core)); CLIDebuggerAttachSystem(&m_cliDebugger, core->cliDebuggerSystem(core));
} }
void DebuggerREPLController::printf(struct CLIDebuggerBackend* be, const char* fmt, ...) { void DebuggerConsoleController::printf(struct CLIDebuggerBackend* be, const char* fmt, ...) {
Backend* replBe = reinterpret_cast<Backend*>(be); Backend* consoleBe = reinterpret_cast<Backend*>(be);
DebuggerREPLController* self = replBe->self; DebuggerConsoleController* self = consoleBe->self;
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
self->log(QString().vsprintf(fmt, args)); self->log(QString().vsprintf(fmt, args));
va_end(args); va_end(args);
} }
void DebuggerREPLController::init(struct CLIDebuggerBackend* be) { void DebuggerConsoleController::init(struct CLIDebuggerBackend* be) {
Backend* replBe = reinterpret_cast<Backend*>(be); Backend* consoleBe = reinterpret_cast<Backend*>(be);
DebuggerREPLController* self = replBe->self; DebuggerConsoleController* self = consoleBe->self;
} }
void DebuggerREPLController::deinit(struct CLIDebuggerBackend* be) { void DebuggerConsoleController::deinit(struct CLIDebuggerBackend* be) {
Backend* replBe = reinterpret_cast<Backend*>(be); Backend* consoleBe = reinterpret_cast<Backend*>(be);
DebuggerREPLController* self = replBe->self; DebuggerConsoleController* self = consoleBe->self;
} }
const char* DebuggerREPLController::readLine(struct CLIDebuggerBackend* be, size_t* len) { const char* DebuggerConsoleController::readLine(struct CLIDebuggerBackend* be, size_t* len) {
Backend* replBe = reinterpret_cast<Backend*>(be); Backend* consoleBe = reinterpret_cast<Backend*>(be);
DebuggerREPLController* self = replBe->self; DebuggerConsoleController* self = consoleBe->self;
GameController::Interrupter interrupter(self->m_gameController, true); GameController::Interrupter interrupter(self->m_gameController, true);
QMutexLocker lock(&self->m_mutex); QMutexLocker lock(&self->m_mutex);
while (self->m_lines.isEmpty()) { while (self->m_lines.isEmpty()) {
@ -78,24 +78,24 @@ const char* DebuggerREPLController::readLine(struct CLIDebuggerBackend* be, size
} }
void DebuggerREPLController::lineAppend(struct CLIDebuggerBackend* be, const char* line) { void DebuggerConsoleController::lineAppend(struct CLIDebuggerBackend* be, const char* line) {
Backend* replBe = reinterpret_cast<Backend*>(be); Backend* consoleBe = reinterpret_cast<Backend*>(be);
DebuggerREPLController* self = replBe->self; DebuggerConsoleController* self = consoleBe->self;
self->lineAppend(QString::fromUtf8(line)); self->lineAppend(QString::fromUtf8(line));
} }
const char* DebuggerREPLController::historyLast(struct CLIDebuggerBackend* be, size_t* len) { const char* DebuggerConsoleController::historyLast(struct CLIDebuggerBackend* be, size_t* len) {
Backend* replBe = reinterpret_cast<Backend*>(be); Backend* consoleBe = reinterpret_cast<Backend*>(be);
DebuggerREPLController* self = replBe->self; DebuggerConsoleController* self = consoleBe->self;
GameController::Interrupter interrupter(self->m_gameController, true); GameController::Interrupter interrupter(self->m_gameController, true);
QMutexLocker lock(&self->m_mutex); QMutexLocker lock(&self->m_mutex);
self->m_last = self->m_history.last().toUtf8(); self->m_last = self->m_history.last().toUtf8();
return self->m_last.constData(); return self->m_last.constData();
} }
void DebuggerREPLController::historyAppend(struct CLIDebuggerBackend* be, const char* line) { void DebuggerConsoleController::historyAppend(struct CLIDebuggerBackend* be, const char* line) {
Backend* replBe = reinterpret_cast<Backend*>(be); Backend* consoleBe = reinterpret_cast<Backend*>(be);
DebuggerREPLController* self = replBe->self; DebuggerConsoleController* self = consoleBe->self;
GameController::Interrupter interrupter(self->m_gameController, true); GameController::Interrupter interrupter(self->m_gameController, true);
QMutexLocker lock(&self->m_mutex); QMutexLocker lock(&self->m_mutex);
self->m_history.append(QString::fromUtf8(line)); self->m_history.append(QString::fromUtf8(line));

View File

@ -3,8 +3,8 @@
* This Source Code Form is subject to the terms of the Mozilla Public * This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef QGBA_DEBUGGER_REPL_CONTROLLER #ifndef QGBA_DEBUGGER_CONSOLE_CONTROLLER
#define QGBA_DEBUGGER_REPL_CONTROLLER #define QGBA_DEBUGGER_CONSOLE_CONTROLLER
#include "DebuggerController.h" #include "DebuggerController.h"
@ -20,11 +20,11 @@ namespace QGBA {
class GameController; class GameController;
class DebuggerREPLController : public DebuggerController { class DebuggerConsoleController : public DebuggerController {
Q_OBJECT Q_OBJECT
public: public:
DebuggerREPLController(GameController* controller, QObject* parent = nullptr); DebuggerConsoleController(GameController* controller, QObject* parent = nullptr);
signals: signals:
void log(const QString&); void log(const QString&);
@ -55,7 +55,7 @@ private:
struct Backend { struct Backend {
CLIDebuggerBackend d; CLIDebuggerBackend d;
DebuggerREPLController* self; DebuggerConsoleController* self;
} m_backend; } m_backend;
}; };

View File

@ -18,8 +18,8 @@
#include "ArchiveInspector.h" #include "ArchiveInspector.h"
#include "CheatsView.h" #include "CheatsView.h"
#include "ConfigController.h" #include "ConfigController.h"
#include "DebuggerREPL.h" #include "DebuggerConsole.h"
#include "DebuggerREPLController.h" #include "DebuggerConsoleController.h"
#include "Display.h" #include "Display.h"
#include "GameController.h" #include "GameController.h"
#include "GBAApp.h" #include "GBAApp.h"
@ -73,7 +73,7 @@ Window::Window(ConfigController* config, int playerId, QWidget* parent)
, m_gdbController(nullptr) , m_gdbController(nullptr)
#endif #endif
#ifdef USE_DEBUGGERS #ifdef USE_DEBUGGERS
, m_repl(nullptr) , m_console(nullptr)
#endif #endif
, m_mruMenu(nullptr) , m_mruMenu(nullptr)
, m_shortcutController(new ShortcutController(this)) , m_shortcutController(new ShortcutController(this))
@ -519,11 +519,11 @@ void Window::gdbOpen() {
#endif #endif
#ifdef USE_DEBUGGERS #ifdef USE_DEBUGGERS
void Window::replOpen() { void Window::consoleOpen() {
if (!m_repl) { if (!m_console) {
m_repl = new DebuggerREPLController(m_controller, this); m_console = new DebuggerConsoleController(m_controller, this);
} }
DebuggerREPL* window = new DebuggerREPL(m_repl); DebuggerConsole* window = new DebuggerConsole(m_console);
openView(window); openView(window);
} }
#endif #endif
@ -1353,9 +1353,9 @@ void Window::setupMenu(QMenuBar* menubar) {
toolsMenu->addSeparator(); toolsMenu->addSeparator();
#ifdef USE_DEBUGGERS #ifdef USE_DEBUGGERS
QAction* replWindow = new QAction(tr("Open debugger REPL..."), toolsMenu); QAction* consoleWindow = new QAction(tr("Open debugger console..."), toolsMenu);
connect(replWindow, SIGNAL(triggered()), this, SLOT(replOpen())); connect(consoleWindow, SIGNAL(triggered()), this, SLOT(consoleOpen()));
addControlledAction(toolsMenu, replWindow, "debuggerWindow"); addControlledAction(toolsMenu, consoleWindow, "debuggerWindow");
#endif #endif
#ifdef USE_GDB_STUB #ifdef USE_GDB_STUB

View File

@ -26,7 +26,7 @@ struct mArguments;
namespace QGBA { namespace QGBA {
class ConfigController; class ConfigController;
class DebuggerREPLController; class DebuggerConsoleController;
class Display; class Display;
class GameController; class GameController;
class GDBController; class GDBController;
@ -82,7 +82,7 @@ public slots:
void openAboutScreen(); void openAboutScreen();
#ifdef USE_DEBUGGERS #ifdef USE_DEBUGGERS
void replOpen(); void consoleOpen();
#endif #endif
#ifdef USE_FFMPEG #ifdef USE_FFMPEG
@ -162,7 +162,7 @@ private:
LogController m_log; LogController m_log;
LogView* m_logView; LogView* m_logView;
#ifdef USE_DEBUGGERS #ifdef USE_DEBUGGERS
DebuggerREPLController* m_repl; DebuggerConsoleController* m_console;
#endif #endif
LoadSaveState* m_stateWindow; LoadSaveState* m_stateWindow;
WindowBackground* m_screenWidget; WindowBackground* m_screenWidget;