Rewritten the doc editors insertText function

This commit is contained in:
Veronica K. B. Olsen
2020-07-26 14:33:12 +02:00
parent 0d179a6208
commit 646562cdf8
2 changed files with 32 additions and 3 deletions
+28 -3
View File
@@ -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()
+4
View File
@@ -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)