From d629ceb3b5ab92faafe8f96387882b7c7e69a5bc Mon Sep 17 00:00:00 2001 From: Glutanimate Date: Sat, 16 Feb 2019 10:26:49 +0100 Subject: [PATCH 1/3] Use system-default fixed font for debug entry and log --- aqt/main.py | 4 ++++ designer/debug.ui | 5 ----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/aqt/main.py b/aqt/main.py index bfac0e9f6..a418d7735 100644 --- a/aqt/main.py +++ b/aqt/main.py @@ -1171,6 +1171,10 @@ will be lost. Continue?""")) d.silentlyClose = True frm = aqt.forms.debug.Ui_Dialog() frm.setupUi(d) + font = QFontDatabase.systemFont(QFontDatabase.FixedFont) + font.setPointSize(frm.text.font().pointSize() + 1) + frm.text.setFont(font) + frm.log.setFont(font) s = self.debugDiagShort = QShortcut(QKeySequence("ctrl+return"), d) s.activated.connect(lambda: self.onDebugRet(frm)) s = self.debugDiagShort = QShortcut( diff --git a/designer/debug.ui b/designer/debug.ui index c8359bcbc..56a6cb44a 100644 --- a/designer/debug.ui +++ b/designer/debug.ui @@ -41,11 +41,6 @@ 8 - - - Courier - - Qt::ClickFocus From 0b2869660e5dee1e55542a654c509e0b4238755f Mon Sep 17 00:00:00 2001 From: Glutanimate Date: Sat, 16 Feb 2019 10:31:35 +0100 Subject: [PATCH 2/3] Add hotkeys to clear debug log and entry (Ctrl+L / Ctrl+Shift+L) --- aqt/main.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/aqt/main.py b/aqt/main.py index a418d7735..4c0b38f4d 100644 --- a/aqt/main.py +++ b/aqt/main.py @@ -1180,6 +1180,10 @@ will be lost. Continue?""")) s = self.debugDiagShort = QShortcut( QKeySequence("ctrl+shift+return"), d) s.activated.connect(lambda: self.onDebugPrint(frm)) + s = self.debugDiagShort = QShortcut(QKeySequence("ctrl+l"), d) + s.activated.connect(frm.log.clear) + s = self.debugDiagShort = QShortcut(QKeySequence("ctrl+shift+l"), d) + s.activated.connect(frm.text.clear) d.show() def _captureOutput(self, on): From fd4b5c11694310197a10c5ad9e351e75d0afc17d Mon Sep 17 00:00:00 2001 From: Glutanimate Date: Sat, 16 Feb 2019 10:57:09 +0100 Subject: [PATCH 3/3] Print-wrap current line rather than the entire field Also: Avoid duplicate wraps, retain cursor position, and preserve undo history. --- aqt/main.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/aqt/main.py b/aqt/main.py index 4c0b38f4d..279e9f1d2 100644 --- a/aqt/main.py +++ b/aqt/main.py @@ -1209,7 +1209,16 @@ will be lost. Continue?""")) return aqt.dialogs._dialogs['Browser'][1].card.__dict__ def onDebugPrint(self, frm): - frm.text.setPlainText("pp(%s)" % frm.text.toPlainText()) + cursor = frm.text.textCursor() + position = cursor.position() + cursor.select(QTextCursor.LineUnderCursor) + line = cursor.selectedText() + pfx, sfx = "pp(", ")" + if not line.startswith(pfx): + line = "{}{}{}".format(pfx, line, sfx) + cursor.insertText(line) + cursor.setPosition(position + len(pfx)) + frm.text.setTextCursor(cursor) self.onDebugRet(frm) def onDebugRet(self, frm):