diff --git a/src/View/ASubWindow.py b/src/View/ASubWindow.py index 13719d77635b2725fb541c2ad1184a3d72bd6233..478993cf81b6e37fea77e523bc01c56850c7943c 100644 --- a/src/View/ASubWindow.py +++ b/src/View/ASubWindow.py @@ -18,7 +18,7 @@ from PyQt5.QtWidgets import ( QTimeEdit, QSpinBox, QTextEdit, QRadioButton, QComboBox, QFileDialog, QMessageBox, QTableView, QAction, - QDateTimeEdit, QWidget, + QDateTimeEdit, QWidget, QPlainTextEdit, ) from PyQt5.QtCore import ( QTime, QDateTime, @@ -179,6 +179,29 @@ class ASubWindowFeatures(object): """ 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): """Set status of checkbox component diff --git a/src/View/Debug/Window.py b/src/View/Debug/Window.py index c02075a77fe51171f666fb837be3343f7798f592..974eace334a6cbfdb91fc8ca99ac3bdb3aeb2f1d 100644 --- a/src/View/Debug/Window.py +++ b/src/View/Debug/Window.py @@ -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__ diff --git a/src/View/ui/DebugRepl.ui b/src/View/ui/DebugRepl.ui index f889061d8f7ce2be570e174c6d57859a9b908831..03494a0cd53c65e3e1e91c5594af2b1429dcb24b 100644 --- a/src/View/ui/DebugRepl.ui +++ b/src/View/ui/DebugRepl.ui @@ -21,7 +21,7 @@ <item row="1" column="0"> <layout class="QHBoxLayout" name="horizontalLayout"> <item> - <widget class="QLineEdit" name="lineEdit"/> + <widget class="QPlainTextEdit" name="plainTextEdit"/> </item> <item> <widget class="QPushButton" name="pushButton">