Commit 17b11b34 authored by Pierre-Antoine Rouby's avatar Pierre-Antoine Rouby
Browse files

Debug: Switch to multiline debug command.

Showing with 37 additions and 10 deletions
+37 -10
...@@ -18,7 +18,7 @@ from PyQt5.QtWidgets import ( ...@@ -18,7 +18,7 @@ from PyQt5.QtWidgets import (
QTimeEdit, QSpinBox, QTextEdit, QTimeEdit, QSpinBox, QTextEdit,
QRadioButton, QComboBox, QFileDialog, QRadioButton, QComboBox, QFileDialog,
QMessageBox, QTableView, QAction, QMessageBox, QTableView, QAction,
QDateTimeEdit, QWidget, QDateTimeEdit, QWidget, QPlainTextEdit,
) )
from PyQt5.QtCore import ( from PyQt5.QtCore import (
QTime, QDateTime, QTime, QDateTime,
...@@ -179,6 +179,29 @@ class ASubWindowFeatures(object): ...@@ -179,6 +179,29 @@ class ASubWindowFeatures(object):
""" """
return self.find(QTextEdit, name).toHtml() return self.find(QTextEdit, name).toHtml()
def set_plaintext_edit_text(self, name:str, text:str):
"""Set text of text edit component
Args:
text_edit: The text edit component name
text: The text
Returns:
Nothing
"""
self.find(QPlainTextEdit, name).setPlainText(text)
def get_plaintext_edit_text(self, name:str):
"""Get text of text edit component
Args:
text_edit: The text edit component name
Returns:
Text
"""
return self.find(QPlainTextEdit, name).toPlainText()
def set_check_box(self, name:str, checked:bool): def set_check_box(self, name:str, checked:bool):
"""Set status of checkbox component """Set status of checkbox component
......
...@@ -51,8 +51,8 @@ class ReplWindow(ASubMainWindow, ListedSubWindow): ...@@ -51,8 +51,8 @@ class ReplWindow(ASubMainWindow, ListedSubWindow):
self.setup_connections() self.setup_connections()
def setup_connections(self): def setup_connections(self):
self._hup_sc = QShortcut(QKeySequence("Up"), self) self._hup_sc = QShortcut(QKeySequence("ctrl+Up"), self)
self._hdown_sc = QShortcut(QKeySequence("Down"), self) self._hdown_sc = QShortcut(QKeySequence("ctrl+Down"), self)
self._hup_sc.activated.connect(self.history_up) self._hup_sc.activated.connect(self.history_up)
self._hdown_sc.activated.connect(self.history_down) self._hdown_sc.activated.connect(self.history_down)
...@@ -61,21 +61,25 @@ class ReplWindow(ASubMainWindow, ListedSubWindow): ...@@ -61,21 +61,25 @@ class ReplWindow(ASubMainWindow, ListedSubWindow):
def history_up(self): def history_up(self):
if self._history_ind < len(self._history): if self._history_ind < len(self._history):
self._history_ind += 1 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): def history_down(self):
if self._history_ind > 0: if self._history_ind > 0:
self._history_ind -= 1 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): def eval_python(self):
code = self.get_line_edit_text("lineEdit") code = self.get_plaintext_edit_text("plainTextEdit")
self._history.append(code) self._history.append(code)
self.set_line_edit_text("lineEdit", "") self.set_plaintext_edit_text("plainTextEdit", "")
self._history_ind = 0 self._history_ind = 0
rich_code = "self.__debug_exec_result__ = " + code rich_code = code.strip().split("\n")
logger.debug(f"{code}") 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: try:
value = exec(rich_code) value = exec(rich_code)
value = self.__debug_exec_result__ value = self.__debug_exec_result__
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<item row="1" column="0"> <item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QLineEdit" name="lineEdit"/> <widget class="QPlainTextEdit" name="plainTextEdit"/>
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton"> <widget class="QPushButton" name="pushButton">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment