[education/rkward] /: Add "step into" and "finish current" in debugger window, simplify code.

Thomas Friedrichsmeier null at kde.org
Sat May 14 08:54:41 BST 2022


Git commit 129a61601610d44c2c2af16e103eacaefd0bc339 by Thomas Friedrichsmeier.
Committed on 14/05/2022 at 07:54.
Pushed by tfry into branch 'master'.

Add "step into" and "finish current" in debugger window, simplify code.

M  +2    -3    ChangeLog
M  +22   -45   rkward/windows/rkdebugconsole.cpp
M  +3    -9    rkward/windows/rkdebugconsole.h

https://invent.kde.org/education/rkward/commit/129a61601610d44c2c2af16e103eacaefd0bc339

diff --git a/ChangeLog b/ChangeLog
index 7c6bde6b..d3228980 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,5 @@
-TODOs:
-	- More tolerant handshake on Windows? Simply a matter of allowing more time?
-
+--- Version 0.7.4 - May-30-2022
+- Support "step into" and "finish current" modes in the R debugger window
 - When directly upgrading from very old versions (pre 0.6.3, currently), discard existing config settings
 - Plugin maps with the same id are grouped together, and the most recent version is used, automatically
 - Added functionality to install add-on packages directly from git (formerly available as external plugin rk.gitInstall)
diff --git a/rkward/windows/rkdebugconsole.cpp b/rkward/windows/rkdebugconsole.cpp
index 0bc568ea..15eb9c30 100644
--- a/rkward/windows/rkdebugconsole.cpp
+++ b/rkward/windows/rkdebugconsole.cpp
@@ -1,6 +1,6 @@
 /*
 rkdebugconsole - This file is part of RKWard (https://rkward.kde.org). Created: Wed Oct 19 2011
-SPDX-FileCopyrightText: 2011 by Thomas Friedrichsmeier <thomas.friedrichsmeier at kdemail.net>
+SPDX-FileCopyrightText: 2011-2022 by Thomas Friedrichsmeier <thomas.friedrichsmeier at kdemail.net>
 SPDX-FileContributor: The RKWard Team <rkward-devel at kde.org>
 SPDX-License-Identifier: GPL-2.0-or-later
 */
@@ -41,21 +41,17 @@ RKDebugConsole::RKDebugConsole (QWidget *parent, bool tool_window, const char *n
 
 	QVBoxLayout *button_layout = new QVBoxLayout ();
 	upper_layout->addLayout (button_layout);
-	step_button = new QPushButton (i18n ("Next"), this);
-	connect (step_button, &QPushButton::clicked, this, &RKDebugConsole::stepButtonClicked);
-	button_layout->addWidget (step_button);
-	step_out_button = new QPushButton (i18n ("Step out"), this);
-	connect (step_out_button, &QPushButton::clicked, this, &RKDebugConsole::stepOutButtonClicked);
-	RKCommonFunctions::setTips (i18n ("<p>Continue until the caller of this function is reached (unless another debug statement is hit, earlier)</p>"
-	                                  "<p><b>Note:</b> In some cases, the calling function will never be reached, because the call was the last step in the caller. "
-	                                  "In these cases, the behavior is identical to 'Continue'.</p>"), step_out_button);
-	button_layout->addWidget (step_out_button);
-	continue_button = new QPushButton (i18n ("Continue"), this);
-	connect (continue_button, &QPushButton::clicked, this, &RKDebugConsole::continueButtonClicked);
-	button_layout->addWidget (continue_button);
-	cancel_button = new QPushButton (i18n ("Cancel"), this);
-	connect (cancel_button, &QPushButton::clicked, this, &RKDebugConsole::cancelButtonClicked);
-	button_layout->addWidget (cancel_button);
+	button_layout->addWidget(addButton("n\n", i18n("Next (step over)"), i18n("Evaluate the next statement, stepping over function calls.")));
+	button_layout->addWidget(addButton("s\n", i18n("Next (step into)"), i18n("Evaluate the next statement, stepping into function calls.")));
+	button_layout->addWidget(addButton("browserSetDebug(1)\ncont\n", i18n("Step out"), i18n(
+	        "<p>Continue until the caller of this function is reached (unless another debug statement is hit, earlier)</p>"
+	        "<p><b>Note:</b> In some cases, the calling function will never be reached, because the call was the last step in the caller. "
+	        "In these cases, the behavior is identical to 'Continue'.</p>")
+	));
+	button_layout->addWidget(addButton("f\n", i18n("Finish current"), i18n("Finish current loop or function.")));
+	button_layout->addWidget(addButton("cont\n", i18n("Continue"), i18n("Continue evaluation.")));
+	button_layout->addStretch ();
+	button_layout->addWidget(addButton("Q\n", i18n("Cancel"), i18n("Exit debugger and return to top-level statement.")));
 	button_layout->addStretch ();
 
 	QHBoxLayout *lower_layout = new QHBoxLayout ();
@@ -82,6 +78,14 @@ RKDebugConsole::~RKDebugConsole () {
 	RK_TRACE (APP);
 }
 
+QPushButton* RKDebugConsole::addButton(const QString& command, const QString& text, const QString& tip) {
+	QPushButton *button = new QPushButton(text);
+	connect(button, &QPushButton::clicked, this, [this, command]() { this->sendReply(command); } );
+	buttons.append(button);
+	RKCommonFunctions::setTips(tip, button);
+	return button;
+}
+
 void RKDebugConsole::newDebugState () {
 	RK_TRACE (APP);
 
@@ -107,11 +111,8 @@ void RKDebugConsole::newDebugState () {
 		activate (true);
 	}
 
-	setEnabled (true);
-	step_button->setEnabled (enable);
-	step_out_button->setEnabled (enable);
-	continue_button->setEnabled (enable);
-	cancel_button->setEnabled (enable);
+	setEnabled(true);
+	for (int i = 0; i < buttons.size(); ++i) buttons[i]->setEnabled(enable);
 }
 
 void RKDebugConsole::sendReplySlot () {
@@ -123,30 +124,6 @@ void RKDebugConsole::sendReplySlot () {
 	reply_edit->clear ();
 }
 
-void RKDebugConsole::stepOutButtonClicked () {
-	RK_TRACE (APP);
-
-	sendReply ("browserSetDebug(1)\ncont\n");
-}
-
-void RKDebugConsole::stepButtonClicked () {
-	RK_TRACE (APP);
-
-	sendReply ("n\n");
-}
-
-void RKDebugConsole::continueButtonClicked () {
-	RK_TRACE (APP);
-
-	sendReply ("cont\n");
-}
-
-void RKDebugConsole::cancelButtonClicked () {
-	RK_TRACE (APP);
-
-	RKDebugHandler::instance ()->sendCancel ();
-}
-
 void RKDebugConsole::sendReply (const QString &reply) {
 	RK_TRACE (APP);
 
diff --git a/rkward/windows/rkdebugconsole.h b/rkward/windows/rkdebugconsole.h
index 9b8a774d..cce0adbc 100644
--- a/rkward/windows/rkdebugconsole.h
+++ b/rkward/windows/rkdebugconsole.h
@@ -1,6 +1,6 @@
 /*
 rkdebugconsole - This file is part of the RKWard project. Created: Wed Oct 19 2011
-SPDX-FileCopyrightText: 2011 by Thomas Friedrichsmeier <thomas.friedrichsmeier at kdemail.net>
+SPDX-FileCopyrightText: 2011-2022 by Thomas Friedrichsmeier <thomas.friedrichsmeier at kdemail.net>
 SPDX-FileContributor: The RKWard Team <rkward-devel at kde.org>
 SPDX-License-Identifier: GPL-2.0-or-later
 */
@@ -30,21 +30,15 @@ public slots:
 	void newDebugState ();
 private slots:
 	void sendReplySlot ();
-	void stepButtonClicked ();
-	void stepOutButtonClicked ();
-	void continueButtonClicked ();
-	void cancelButtonClicked ();
 private:
+	QPushButton* addButton(const QString &command, const QString &text, const QString &tip);
 	void sendReply (const QString &reply);
 
 	QTextEdit* context_view;
 	KHistoryComboBox* reply_edit;
 	QLabel* prompt_label;
 
-	QPushButton* step_button;
-	QPushButton* step_out_button;
-	QPushButton* continue_button;
-	QPushButton* cancel_button;
+	QList<QPushButton*> buttons;
 
 friend class RKWardMainWindow;
 	static RKDebugConsole *_instance;


More information about the rkward-tracker mailing list