Debug: Switch to multiline debug command.

This commit is contained in:
Pierre-Antoine Rouby committed 2023-07-07 11:36:21 +02:00
1 parent 609e9d39db
commit 17b11b34a7
3 files changed
+37 -10

No files matched your search

+12 -8
View File
@@ -51,8 +51,8 @@ class ReplWindow(ASubMainWindow, ListedSubWindow):
self.setup_connections()
def setup_connections(self):
self._hup_sc = QShortcut(QKeySequence("Up"), self)
self._hdown_sc = QShortcut(QKeySequence("Down"), self)
self._hup_sc = QShortcut(QKeySequence("ctrl+Up"), self)
self._hdown_sc = QShortcut(QKeySequence("ctrl+Down"), self)
self._hup_sc.activated.connect(self.history_up)
self._hdown_sc.activated.connect(self.history_down)
@@ -61,21 +61,25 @@ class ReplWindow(ASubMainWindow, ListedSubWindow):
def history_up(self):
if self._history_ind < len(self._history):
self._history_ind += 1
self.set_line_edit_text("lineEdit", self._history[-self._history_ind])
self.set_plaintext_edit_text("plainTextEdit", self._history[-self._history_ind])
def history_down(self):
if self._history_ind > 0:
self._history_ind -= 1
self.set_line_edit_text("lineEdit", self._history[-self._history_ind])
self.set_plaintext_edit_text("plainTextEdit", self._history[-self._history_ind])
else:
self.set_plaintext_edit_text("plainTextEdit", "")
def eval_python(self):
code = self.get_line_edit_text("lineEdit")
code = self.get_plaintext_edit_text("plainTextEdit")
self._history.append(code)
self.set_line_edit_text("lineEdit", "")
self.set_plaintext_edit_text("plainTextEdit", "")
self._history_ind = 0
rich_code = "self.__debug_exec_result__ = " + code
logger.debug(f"{code}")
rich_code = code.strip().split("\n")
rich_code[-1] = "self.__debug_exec_result__ = " + rich_code[-1]
rich_code = "\n".join(rich_code)
logger.debug(f"User debug command : {rich_code}")
try:
value = exec(rich_code)
value = self.__debug_exec_result__