Rewritten the doc editors insertText function
This commit is contained in:
+28
-3
@@ -52,7 +52,7 @@ from nw.core import NWDoc, NWSpellSimple, countWords
|
|||||||
from nw.gui.dochighlight import GuiDocHighlighter
|
from nw.gui.dochighlight import GuiDocHighlighter
|
||||||
from nw.common import transferCase
|
from nw.common import transferCase
|
||||||
from nw.constants import (
|
from nw.constants import (
|
||||||
nwAlert, nwUnicode, nwDocAction, nwDocInsert, nwInsertSymbols, nwItemClass
|
nwAlert, nwUnicode, nwDocAction, nwDocInsert, nwItemClass
|
||||||
)
|
)
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -590,8 +590,33 @@ class GuiDocEditor(QTextEdit):
|
|||||||
"""
|
"""
|
||||||
if isinstance(theInsert, str):
|
if isinstance(theInsert, str):
|
||||||
theText = theInsert
|
theText = theInsert
|
||||||
elif theInsert in nwInsertSymbols.SYMBOLS:
|
elif theInsert in nwDocInsert:
|
||||||
theText = nwInsertSymbols.SYMBOLS[theInsert]
|
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:
|
else:
|
||||||
return False
|
return False
|
||||||
theCursor = self.textCursor()
|
theCursor = self.textCursor()
|
||||||
|
|||||||
@@ -1004,6 +1004,10 @@ class GuiMain(QMainWindow):
|
|||||||
self.addAction(self.mainMenu.aInsENDash)
|
self.addAction(self.mainMenu.aInsENDash)
|
||||||
self.addAction(self.mainMenu.aInsEMDash)
|
self.addAction(self.mainMenu.aInsEMDash)
|
||||||
self.addAction(self.mainMenu.aInsEllipsis)
|
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.aInsHardBreak)
|
||||||
self.addAction(self.mainMenu.aInsNBSpace)
|
self.addAction(self.mainMenu.aInsNBSpace)
|
||||||
self.addAction(self.mainMenu.aInsThinSpace)
|
self.addAction(self.mainMenu.aInsThinSpace)
|
||||||
|
|||||||
Reference in New Issue
Block a user