From 646562cdf811016db3745c066d103e68ffb1e4dd Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 26 Jul 2020 14:33:12 +0200 Subject: [PATCH] Rewritten the doc editors insertText function --- nw/gui/doceditor.py | 31 ++++++++++++++++++++++++++++--- nw/guimain.py | 4 ++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index cba62c16..28edba4e 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -52,7 +52,7 @@ from nw.core import NWDoc, NWSpellSimple, countWords from nw.gui.dochighlight import GuiDocHighlighter from nw.common import transferCase from nw.constants import ( - nwAlert, nwUnicode, nwDocAction, nwDocInsert, nwInsertSymbols, nwItemClass + nwAlert, nwUnicode, nwDocAction, nwDocInsert, nwItemClass ) logger = logging.getLogger(__name__) @@ -590,8 +590,33 @@ class GuiDocEditor(QTextEdit): """ if isinstance(theInsert, str): theText = theInsert - elif theInsert in nwInsertSymbols.SYMBOLS: - theText = nwInsertSymbols.SYMBOLS[theInsert] + elif theInsert in nwDocInsert: + if theInsert == nwDocInsert.NO_INSERT: + theText = "", + elif theInsert == nwDocInsert.HARD_BREAK: + theText = " \n", + elif theInsert == nwDocInsert.NB_SPACE: + theText = nwUnicode.U_NBSP, + elif theInsert == nwDocInsert.THIN_SPACE: + theText = nwUnicode.U_THNSP, + elif theInsert == nwDocInsert.THIN_NB_SPACE: + theText = nwUnicode.U_THNBSP, + elif theInsert == nwDocInsert.SHORT_DASH: + theText = nwUnicode.U_ENDASH, + elif theInsert == nwDocInsert.LONG_DASH: + theText = nwUnicode.U_EMDASH, + elif theInsert == nwDocInsert.ELLIPSIS: + theText = nwUnicode.U_HELLIP, + elif theInsert == nwDocInsert.QUOTE_LS: + theText = self.typSQOpen + elif theInsert == nwDocInsert.QUOTE_RS: + theText = self.typSQClose + elif theInsert == nwDocInsert.QUOTE_LD: + theText = self.typDQOpen + elif theInsert == nwDocInsert.QUOTE_RD: + theText = self.typDQClose + else: + return False else: return False theCursor = self.textCursor() diff --git a/nw/guimain.py b/nw/guimain.py index 668ebf9f..f2a4cb3f 100644 --- a/nw/guimain.py +++ b/nw/guimain.py @@ -1004,6 +1004,10 @@ class GuiMain(QMainWindow): self.addAction(self.mainMenu.aInsENDash) self.addAction(self.mainMenu.aInsEMDash) self.addAction(self.mainMenu.aInsEllipsis) + self.addAction(self.mainMenu.aInsQuoteLS) + self.addAction(self.mainMenu.aInsQuoteRS) + self.addAction(self.mainMenu.aInsQuoteLD) + self.addAction(self.mainMenu.aInsQuoteRD) self.addAction(self.mainMenu.aInsHardBreak) self.addAction(self.mainMenu.aInsNBSpace) self.addAction(self.mainMenu.aInsThinSpace)