Update Config and NWItem class (#1232)
This commit is contained in:
+28
-13
@@ -161,8 +161,10 @@ class Config:
|
|||||||
|
|
||||||
# User-Selected Symbol Settings
|
# User-Selected Symbol Settings
|
||||||
self.fmtApostrophe = nwUnicode.U_RSQUO
|
self.fmtApostrophe = nwUnicode.U_RSQUO
|
||||||
self.fmtSingleQuotes = [nwUnicode.U_LSQUO, nwUnicode.U_RSQUO]
|
self.fmtSQuoteOpen = nwUnicode.U_LSQUO
|
||||||
self.fmtDoubleQuotes = [nwUnicode.U_LDQUO, nwUnicode.U_RDQUO]
|
self.fmtSQuoteClose = nwUnicode.U_RSQUO
|
||||||
|
self.fmtDQuoteOpen = nwUnicode.U_LDQUO
|
||||||
|
self.fmtDQuoteClose = nwUnicode.U_RDQUO
|
||||||
self.fmtPadBefore = ""
|
self.fmtPadBefore = ""
|
||||||
self.fmtPadAfter = ""
|
self.fmtPadAfter = ""
|
||||||
self.fmtPadThin = False
|
self.fmtPadThin = False
|
||||||
@@ -233,9 +235,6 @@ class Config:
|
|||||||
# Packages
|
# Packages
|
||||||
self.hasEnchant = False # The pyenchant package
|
self.hasEnchant = False # The pyenchant package
|
||||||
|
|
||||||
# Recent Cache
|
|
||||||
self.recentProj = {}
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
@@ -570,8 +569,10 @@ class Config:
|
|||||||
self.scrollPastEnd = theConf.rdInt(cnfSec, "scrollpastend", self.scrollPastEnd)
|
self.scrollPastEnd = theConf.rdInt(cnfSec, "scrollpastend", self.scrollPastEnd)
|
||||||
self.autoScroll = theConf.rdBool(cnfSec, "autoscroll", self.autoScroll)
|
self.autoScroll = theConf.rdBool(cnfSec, "autoscroll", self.autoScroll)
|
||||||
self.autoScrollPos = theConf.rdInt(cnfSec, "autoscrollpos", self.autoScrollPos)
|
self.autoScrollPos = theConf.rdInt(cnfSec, "autoscrollpos", self.autoScrollPos)
|
||||||
self.fmtSingleQuotes = theConf.rdStrList(cnfSec, "fmtsinglequote", self.fmtSingleQuotes)
|
self.fmtSQuoteOpen = theConf.rdStr(cnfSec, "fmtsquoteopen", self.fmtSQuoteOpen)
|
||||||
self.fmtDoubleQuotes = theConf.rdStrList(cnfSec, "fmtdoublequote", self.fmtDoubleQuotes)
|
self.fmtSQuoteClose = theConf.rdStr(cnfSec, "fmtsquoteclose", self.fmtSQuoteClose)
|
||||||
|
self.fmtDQuoteOpen = theConf.rdStr(cnfSec, "fmtdquoteopen", self.fmtDQuoteOpen)
|
||||||
|
self.fmtDQuoteClose = theConf.rdStr(cnfSec, "fmtdquoteclose", self.fmtDQuoteClose)
|
||||||
self.fmtPadBefore = theConf.rdStr(cnfSec, "fmtpadbefore", self.fmtPadBefore)
|
self.fmtPadBefore = theConf.rdStr(cnfSec, "fmtpadbefore", self.fmtPadBefore)
|
||||||
self.fmtPadAfter = theConf.rdStr(cnfSec, "fmtpadafter", self.fmtPadAfter)
|
self.fmtPadAfter = theConf.rdStr(cnfSec, "fmtpadafter", self.fmtPadAfter)
|
||||||
self.fmtPadThin = theConf.rdBool(cnfSec, "fmtpadthin", self.fmtPadThin)
|
self.fmtPadThin = theConf.rdBool(cnfSec, "fmtpadthin", self.fmtPadThin)
|
||||||
@@ -604,23 +605,35 @@ class Config:
|
|||||||
self.searchMatchCap = theConf.rdBool(cnfSec, "searchmatchcap", self.searchMatchCap)
|
self.searchMatchCap = theConf.rdBool(cnfSec, "searchmatchcap", self.searchMatchCap)
|
||||||
|
|
||||||
# Deprecated Settings or Locations as of 2.0
|
# Deprecated Settings or Locations as of 2.0
|
||||||
# These will be loaded for a few minor releases until the users have converted them
|
# ToDo: These will be loaded for a few minor releases until the users have converted them
|
||||||
self.guiFont = theConf.rdStr("Main", "guifont", self.guiFont)
|
self.guiFont = theConf.rdStr("Main", "guifont", self.guiFont)
|
||||||
self.guiFontSize = theConf.rdInt("Main", "guifontsize", self.guiFontSize)
|
self.guiFontSize = theConf.rdInt("Main", "guifontsize", self.guiFontSize)
|
||||||
self.guiLocale = theConf.rdStr("Main", "guilang", self.guiLocale)
|
self.guiLocale = theConf.rdStr("Main", "guilang", self.guiLocale)
|
||||||
self._backupPath = theConf.rdPath("Backup", "backuppath", self._backupPath)
|
self._backupPath = theConf.rdPath("Backup", "backuppath", self._backupPath)
|
||||||
self.backupOnClose = theConf.rdBool("Backup", "backuponclose", self.backupOnClose)
|
self.backupOnClose = theConf.rdBool("Backup", "backuponclose", self.backupOnClose)
|
||||||
self.askBeforeBackup = theConf.rdBool("Backup", "askbeforebackup", self.askBeforeBackup)
|
self.askBeforeBackup = theConf.rdBool("Backup", "askbeforebackup", self.askBeforeBackup)
|
||||||
|
fmtSingleQuotes = theConf.rdStrList(cnfSec, "fmtsinglequote", [])
|
||||||
|
fmtDoubleQuotes = theConf.rdStrList(cnfSec, "fmtdoublequote", [])
|
||||||
|
|
||||||
|
if isinstance(fmtSingleQuotes, list) and len(fmtSingleQuotes) == 2:
|
||||||
|
self.fmtSQuoteOpen = fmtSingleQuotes[0]
|
||||||
|
self.fmtSQuoteClose = fmtSingleQuotes[1]
|
||||||
|
if isinstance(fmtDoubleQuotes, list) and len(fmtDoubleQuotes) == 2:
|
||||||
|
self.fmtDQuoteOpen = fmtDoubleQuotes[0]
|
||||||
|
self.fmtDQuoteClose = fmtDoubleQuotes[1]
|
||||||
|
|
||||||
|
# Check Values
|
||||||
|
# ============
|
||||||
|
|
||||||
# Check Certain Values for None
|
# Check Certain Values for None
|
||||||
self.spellLanguage = self._checkNone(self.spellLanguage)
|
self.spellLanguage = self._checkNone(self.spellLanguage)
|
||||||
|
|
||||||
# If we're using straight quotes, disable auto-replace
|
# If we're using straight quotes, disable auto-replace
|
||||||
if self.fmtSingleQuotes == ["'", "'"] and self.doReplaceSQuote:
|
if self.fmtSQuoteOpen == self.fmtSQuoteClose == "'" and self.doReplaceSQuote:
|
||||||
logger.info("Using straight single quotes, so disabling auto-replace")
|
logger.info("Using straight single quotes, so disabling auto-replace")
|
||||||
self.doReplaceSQuote = False
|
self.doReplaceSQuote = False
|
||||||
|
|
||||||
if self.fmtDoubleQuotes == ['"', '"'] and self.doReplaceDQuote:
|
if self.fmtDQuoteOpen == self.fmtDQuoteClose == '"' and self.doReplaceDQuote:
|
||||||
logger.info("Using straight double quotes, so disabling auto-replace")
|
logger.info("Using straight double quotes, so disabling auto-replace")
|
||||||
self.doReplaceDQuote = False
|
self.doReplaceDQuote = False
|
||||||
|
|
||||||
@@ -685,8 +698,10 @@ class Config:
|
|||||||
"scrollpastend": str(self.scrollPastEnd),
|
"scrollpastend": str(self.scrollPastEnd),
|
||||||
"autoscroll": str(self.autoScroll),
|
"autoscroll": str(self.autoScroll),
|
||||||
"autoscrollpos": str(self.autoScrollPos),
|
"autoscrollpos": str(self.autoScrollPos),
|
||||||
"fmtsinglequote": self._packList(self.fmtSingleQuotes),
|
"fmtsquoteopen": str(self.fmtSQuoteOpen),
|
||||||
"fmtdoublequote": self._packList(self.fmtDoubleQuotes),
|
"fmtsquoteclose": str(self.fmtSQuoteClose),
|
||||||
|
"fmtdquoteopen": str(self.fmtDQuoteOpen),
|
||||||
|
"fmtdquoteclose": str(self.fmtDQuoteClose),
|
||||||
"fmtpadbefore": str(self.fmtPadBefore),
|
"fmtpadbefore": str(self.fmtPadBefore),
|
||||||
"fmtpadafter": str(self.fmtPadAfter),
|
"fmtpadafter": str(self.fmtPadAfter),
|
||||||
"fmtpadthin": str(self.fmtPadThin),
|
"fmtpadthin": str(self.fmtPadThin),
|
||||||
|
|||||||
+21
-15
@@ -36,10 +36,16 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class NWItem:
|
class NWItem:
|
||||||
|
|
||||||
def __init__(self, theProject):
|
__slots__ = (
|
||||||
|
"_project", "_name", "_handle", "_parent", "_root", "_order",
|
||||||
|
"_type", "_class", "_layout", "_status", "_import", "_active",
|
||||||
|
"_expanded", "_heading", "_charCount", "_wordCount",
|
||||||
|
"_paraCount", "_cursorPos", "_initCount",
|
||||||
|
)
|
||||||
|
|
||||||
self.theProject = theProject
|
def __init__(self, project):
|
||||||
|
|
||||||
|
self._project = project
|
||||||
self._name = ""
|
self._name = ""
|
||||||
self._handle = None
|
self._handle = None
|
||||||
self._parent = None
|
self._parent = None
|
||||||
@@ -267,11 +273,11 @@ class NWItem:
|
|||||||
the current item based on its class.
|
the current item based on its class.
|
||||||
"""
|
"""
|
||||||
if self.isNovelLike():
|
if self.isNovelLike():
|
||||||
stName = self.theProject.data.itemStatus.name(self._status)
|
stName = self._project.data.itemStatus.name(self._status)
|
||||||
stIcon = self.theProject.data.itemStatus.icon(self._status) if incIcon else None
|
stIcon = self._project.data.itemStatus.icon(self._status) if incIcon else None
|
||||||
else:
|
else:
|
||||||
stName = self.theProject.data.itemImport.name(self._import)
|
stName = self._project.data.itemImport.name(self._import)
|
||||||
stIcon = self.theProject.data.itemImport.icon(self._import) if incIcon else None
|
stIcon = self._project.data.itemImport.icon(self._import) if incIcon else None
|
||||||
return stName, stIcon
|
return stName, stIcon
|
||||||
|
|
||||||
##
|
##
|
||||||
@@ -443,32 +449,32 @@ class NWItem:
|
|||||||
"""Set the item status by looking it up in the valid status
|
"""Set the item status by looking it up in the valid status
|
||||||
items of the current project.
|
items of the current project.
|
||||||
"""
|
"""
|
||||||
self._status = self.theProject.data.itemStatus.check(value)
|
self._status = self._project.data.itemStatus.check(value)
|
||||||
return
|
return
|
||||||
|
|
||||||
def setImport(self, value):
|
def setImport(self, value):
|
||||||
"""Set the item importance by looking it up in the valid import
|
"""Set the item importance by looking it up in the valid import
|
||||||
items of the current project.
|
items of the current project.
|
||||||
"""
|
"""
|
||||||
self._import = self.theProject.data.itemImport.check(value)
|
self._import = self._project.data.itemImport.check(value)
|
||||||
return
|
return
|
||||||
|
|
||||||
def setActive(self, state):
|
def setActive(self, state):
|
||||||
"""Set the export flag.
|
"""Set the active flag.
|
||||||
"""
|
"""
|
||||||
if isinstance(state, str):
|
if isinstance(state, bool):
|
||||||
self._active = (state == str(True))
|
self._active = state
|
||||||
else:
|
else:
|
||||||
self._active = (state is True)
|
self._active = False
|
||||||
return
|
return
|
||||||
|
|
||||||
def setExpanded(self, state):
|
def setExpanded(self, state):
|
||||||
"""Set the expanded status of an item in the project tree.
|
"""Set the expanded status of an item in the project tree.
|
||||||
"""
|
"""
|
||||||
if isinstance(state, str):
|
if isinstance(state, bool):
|
||||||
self._expanded = (state == str(True))
|
self._expanded = state
|
||||||
else:
|
else:
|
||||||
self._expanded = (state is True)
|
self._expanded = False
|
||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|||||||
@@ -1104,7 +1104,7 @@ class GuiPreferencesQuotes(QWidget):
|
|||||||
self.quoteSym["SO"].setReadOnly(True)
|
self.quoteSym["SO"].setReadOnly(True)
|
||||||
self.quoteSym["SO"].setFixedWidth(qWidth)
|
self.quoteSym["SO"].setFixedWidth(qWidth)
|
||||||
self.quoteSym["SO"].setAlignment(Qt.AlignCenter)
|
self.quoteSym["SO"].setAlignment(Qt.AlignCenter)
|
||||||
self.quoteSym["SO"].setText(self.mainConf.fmtSingleQuotes[0])
|
self.quoteSym["SO"].setText(self.mainConf.fmtSQuoteOpen)
|
||||||
self.btnSingleStyleO = QPushButton("...")
|
self.btnSingleStyleO = QPushButton("...")
|
||||||
self.btnSingleStyleO.setMaximumWidth(bWidth)
|
self.btnSingleStyleO.setMaximumWidth(bWidth)
|
||||||
self.btnSingleStyleO.clicked.connect(lambda: self._getQuote("SO"))
|
self.btnSingleStyleO.clicked.connect(lambda: self._getQuote("SO"))
|
||||||
@@ -1120,7 +1120,7 @@ class GuiPreferencesQuotes(QWidget):
|
|||||||
self.quoteSym["SC"].setReadOnly(True)
|
self.quoteSym["SC"].setReadOnly(True)
|
||||||
self.quoteSym["SC"].setFixedWidth(qWidth)
|
self.quoteSym["SC"].setFixedWidth(qWidth)
|
||||||
self.quoteSym["SC"].setAlignment(Qt.AlignCenter)
|
self.quoteSym["SC"].setAlignment(Qt.AlignCenter)
|
||||||
self.quoteSym["SC"].setText(self.mainConf.fmtSingleQuotes[1])
|
self.quoteSym["SC"].setText(self.mainConf.fmtSQuoteClose)
|
||||||
self.btnSingleStyleC = QPushButton("...")
|
self.btnSingleStyleC = QPushButton("...")
|
||||||
self.btnSingleStyleC.setMaximumWidth(bWidth)
|
self.btnSingleStyleC.setMaximumWidth(bWidth)
|
||||||
self.btnSingleStyleC.clicked.connect(lambda: self._getQuote("SC"))
|
self.btnSingleStyleC.clicked.connect(lambda: self._getQuote("SC"))
|
||||||
@@ -1137,7 +1137,7 @@ class GuiPreferencesQuotes(QWidget):
|
|||||||
self.quoteSym["DO"].setReadOnly(True)
|
self.quoteSym["DO"].setReadOnly(True)
|
||||||
self.quoteSym["DO"].setFixedWidth(qWidth)
|
self.quoteSym["DO"].setFixedWidth(qWidth)
|
||||||
self.quoteSym["DO"].setAlignment(Qt.AlignCenter)
|
self.quoteSym["DO"].setAlignment(Qt.AlignCenter)
|
||||||
self.quoteSym["DO"].setText(self.mainConf.fmtDoubleQuotes[0])
|
self.quoteSym["DO"].setText(self.mainConf.fmtDQuoteOpen)
|
||||||
self.btnDoubleStyleO = QPushButton("...")
|
self.btnDoubleStyleO = QPushButton("...")
|
||||||
self.btnDoubleStyleO.setMaximumWidth(bWidth)
|
self.btnDoubleStyleO.setMaximumWidth(bWidth)
|
||||||
self.btnDoubleStyleO.clicked.connect(lambda: self._getQuote("DO"))
|
self.btnDoubleStyleO.clicked.connect(lambda: self._getQuote("DO"))
|
||||||
@@ -1153,7 +1153,7 @@ class GuiPreferencesQuotes(QWidget):
|
|||||||
self.quoteSym["DC"].setReadOnly(True)
|
self.quoteSym["DC"].setReadOnly(True)
|
||||||
self.quoteSym["DC"].setFixedWidth(qWidth)
|
self.quoteSym["DC"].setFixedWidth(qWidth)
|
||||||
self.quoteSym["DC"].setAlignment(Qt.AlignCenter)
|
self.quoteSym["DC"].setAlignment(Qt.AlignCenter)
|
||||||
self.quoteSym["DC"].setText(self.mainConf.fmtDoubleQuotes[1])
|
self.quoteSym["DC"].setText(self.mainConf.fmtDQuoteClose)
|
||||||
self.btnDoubleStyleC = QPushButton("...")
|
self.btnDoubleStyleC = QPushButton("...")
|
||||||
self.btnDoubleStyleC.setMaximumWidth(bWidth)
|
self.btnDoubleStyleC.setMaximumWidth(bWidth)
|
||||||
self.btnDoubleStyleC.clicked.connect(lambda: self._getQuote("DC"))
|
self.btnDoubleStyleC.clicked.connect(lambda: self._getQuote("DC"))
|
||||||
@@ -1170,10 +1170,10 @@ class GuiPreferencesQuotes(QWidget):
|
|||||||
"""Save the values set for this tab.
|
"""Save the values set for this tab.
|
||||||
"""
|
"""
|
||||||
# Quotation Style
|
# Quotation Style
|
||||||
self.mainConf.fmtSingleQuotes[0] = self.quoteSym["SO"].text()
|
self.mainConf.fmtSQuoteOpen = self.quoteSym["SO"].text()
|
||||||
self.mainConf.fmtSingleQuotes[1] = self.quoteSym["SC"].text()
|
self.mainConf.fmtSQuoteClose = self.quoteSym["SC"].text()
|
||||||
self.mainConf.fmtDoubleQuotes[0] = self.quoteSym["DO"].text()
|
self.mainConf.fmtDQuoteOpen = self.quoteSym["DO"].text()
|
||||||
self.mainConf.fmtDoubleQuotes[1] = self.quoteSym["DC"].text()
|
self.mainConf.fmtDQuoteClose = self.quoteSym["DC"].text()
|
||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|||||||
@@ -105,12 +105,18 @@ class GuiDocEditor(QTextEdit):
|
|||||||
self._doReplace = False # Switch to temporarily disable auto-replace
|
self._doReplace = False # Switch to temporarily disable auto-replace
|
||||||
self._queuePos = None # Used for delayed change of cursor position
|
self._queuePos = None # Used for delayed change of cursor position
|
||||||
|
|
||||||
# Typography
|
# Typography Cache
|
||||||
self._typDQOpen = '"'
|
|
||||||
self._typDQClose = '"'
|
|
||||||
self._typSQOpen = "'"
|
|
||||||
self._typSQClose = "'"
|
|
||||||
self._typPadChar = " "
|
self._typPadChar = " "
|
||||||
|
self._typDQuoteO = '"'
|
||||||
|
self._typDQuoteC = '"'
|
||||||
|
self._typSQuoteO = "'"
|
||||||
|
self._typSQuoteC = "'"
|
||||||
|
self._typRepDQuote = False
|
||||||
|
self._typRepSQuote = False
|
||||||
|
self._typRepDash = False
|
||||||
|
self._typRepDots = False
|
||||||
|
self._typPadBefore = ""
|
||||||
|
self._typPadAfter = ""
|
||||||
|
|
||||||
# Core Elements and Signals
|
# Core Elements and Signals
|
||||||
qDoc = self.document()
|
qDoc = self.document()
|
||||||
@@ -242,9 +248,11 @@ class GuiDocEditor(QTextEdit):
|
|||||||
created, and when the user changes the main editor preferences.
|
created, and when the user changes the main editor preferences.
|
||||||
"""
|
"""
|
||||||
# Some Constants
|
# Some Constants
|
||||||
self._nonWord = "\"'"
|
self._nonWord = (
|
||||||
self._nonWord += "".join(self.mainConf.fmtDoubleQuotes)
|
"\"'"
|
||||||
self._nonWord += "".join(self.mainConf.fmtSingleQuotes)
|
f"{self.mainConf.fmtSQuoteOpen}{self.mainConf.fmtSQuoteClose}"
|
||||||
|
f"{self.mainConf.fmtDQuoteOpen}{self.mainConf.fmtDQuoteClose}"
|
||||||
|
)
|
||||||
|
|
||||||
# Typography
|
# Typography
|
||||||
if self.mainConf.fmtPadThin:
|
if self.mainConf.fmtPadThin:
|
||||||
@@ -252,10 +260,16 @@ class GuiDocEditor(QTextEdit):
|
|||||||
else:
|
else:
|
||||||
self._typPadChar = nwUnicode.U_NBSP
|
self._typPadChar = nwUnicode.U_NBSP
|
||||||
|
|
||||||
self._typDQOpen = self.mainConf.fmtDoubleQuotes[0]
|
self._typSQuoteO = self.mainConf.fmtSQuoteOpen
|
||||||
self._typDQClose = self.mainConf.fmtDoubleQuotes[1]
|
self._typSQuoteC = self.mainConf.fmtSQuoteClose
|
||||||
self._typSQOpen = self.mainConf.fmtSingleQuotes[0]
|
self._typDQuoteO = self.mainConf.fmtDQuoteOpen
|
||||||
self._typSQClose = self.mainConf.fmtSingleQuotes[1]
|
self._typDQuoteC = self.mainConf.fmtDQuoteClose
|
||||||
|
self._typRepDQuote = self.mainConf.doReplaceDQuote
|
||||||
|
self._typRepSQuote = self.mainConf.doReplaceSQuote
|
||||||
|
self._typRepDash = self.mainConf.doReplaceDash
|
||||||
|
self._typRepDots = self.mainConf.doReplaceDots
|
||||||
|
self._typPadBefore = self.mainConf.fmtPadBefore
|
||||||
|
self._typPadAfter = self.mainConf.fmtPadAfter
|
||||||
|
|
||||||
# Reload spell check and dictionaries
|
# Reload spell check and dictionaries
|
||||||
self.setDictionaries()
|
self.setDictionaries()
|
||||||
@@ -792,9 +806,9 @@ class GuiDocEditor(QTextEdit):
|
|||||||
elif theAction == nwDocAction.STRIKE:
|
elif theAction == nwDocAction.STRIKE:
|
||||||
self._toggleFormat(2, "~")
|
self._toggleFormat(2, "~")
|
||||||
elif theAction == nwDocAction.S_QUOTE:
|
elif theAction == nwDocAction.S_QUOTE:
|
||||||
self._wrapSelection(self._typSQOpen, self._typSQClose)
|
self._wrapSelection(self._typSQuoteO, self._typSQuoteC)
|
||||||
elif theAction == nwDocAction.D_QUOTE:
|
elif theAction == nwDocAction.D_QUOTE:
|
||||||
self._wrapSelection(self._typDQOpen, self._typDQClose)
|
self._wrapSelection(self._typDQuoteO, self._typDQuoteC)
|
||||||
elif theAction == nwDocAction.SEL_ALL:
|
elif theAction == nwDocAction.SEL_ALL:
|
||||||
self._makeSelection(QTextCursor.Document)
|
self._makeSelection(QTextCursor.Document)
|
||||||
elif theAction == nwDocAction.SEL_PARA:
|
elif theAction == nwDocAction.SEL_PARA:
|
||||||
@@ -816,9 +830,9 @@ class GuiDocEditor(QTextEdit):
|
|||||||
elif theAction == nwDocAction.BLOCK_UNN:
|
elif theAction == nwDocAction.BLOCK_UNN:
|
||||||
self._formatBlock(nwDocAction.BLOCK_UNN)
|
self._formatBlock(nwDocAction.BLOCK_UNN)
|
||||||
elif theAction == nwDocAction.REPL_SNG:
|
elif theAction == nwDocAction.REPL_SNG:
|
||||||
self._replaceQuotes("'", self._typSQOpen, self._typSQClose)
|
self._replaceQuotes("'", self._typSQuoteO, self._typSQuoteC)
|
||||||
elif theAction == nwDocAction.REPL_DBL:
|
elif theAction == nwDocAction.REPL_DBL:
|
||||||
self._replaceQuotes("\"", self._typDQOpen, self._typDQClose)
|
self._replaceQuotes("\"", self._typDQuoteO, self._typDQuoteC)
|
||||||
elif theAction == nwDocAction.RM_BREAKS:
|
elif theAction == nwDocAction.RM_BREAKS:
|
||||||
self._removeInParLineBreaks()
|
self._removeInParLineBreaks()
|
||||||
elif theAction == nwDocAction.ALIGN_L:
|
elif theAction == nwDocAction.ALIGN_L:
|
||||||
@@ -884,13 +898,13 @@ class GuiDocEditor(QTextEdit):
|
|||||||
theText = theInsert
|
theText = theInsert
|
||||||
elif isinstance(theInsert, nwDocInsert):
|
elif isinstance(theInsert, nwDocInsert):
|
||||||
if theInsert == nwDocInsert.QUOTE_LS:
|
if theInsert == nwDocInsert.QUOTE_LS:
|
||||||
theText = self._typSQOpen
|
theText = self._typSQuoteO
|
||||||
elif theInsert == nwDocInsert.QUOTE_RS:
|
elif theInsert == nwDocInsert.QUOTE_RS:
|
||||||
theText = self._typSQClose
|
theText = self._typSQuoteC
|
||||||
elif theInsert == nwDocInsert.QUOTE_LD:
|
elif theInsert == nwDocInsert.QUOTE_LD:
|
||||||
theText = self._typDQOpen
|
theText = self._typDQuoteO
|
||||||
elif theInsert == nwDocInsert.QUOTE_RD:
|
elif theInsert == nwDocInsert.QUOTE_RD:
|
||||||
theText = self._typDQClose
|
theText = self._typDQuoteC
|
||||||
elif theInsert == nwDocInsert.SYNOPSIS:
|
elif theInsert == nwDocInsert.SYNOPSIS:
|
||||||
theText = "% Synopsis: "
|
theText = "% Synopsis: "
|
||||||
newBlock = True
|
newBlock = True
|
||||||
@@ -1965,49 +1979,49 @@ class GuiDocEditor(QTextEdit):
|
|||||||
nDelete = 0
|
nDelete = 0
|
||||||
tInsert = theOne
|
tInsert = theOne
|
||||||
|
|
||||||
if self.mainConf.doReplaceDQuote and theTwo[:1].isspace() and theTwo.endswith('"'):
|
if self._typRepDQuote and theTwo[:1].isspace() and theTwo.endswith('"'):
|
||||||
nDelete = 1
|
nDelete = 1
|
||||||
tInsert = self._typDQOpen
|
tInsert = self._typDQuoteO
|
||||||
|
|
||||||
elif self.mainConf.doReplaceDQuote and theOne == '"':
|
elif self._typRepDQuote and theOne == '"':
|
||||||
nDelete = 1
|
nDelete = 1
|
||||||
if thePos == 1:
|
if thePos == 1:
|
||||||
tInsert = self._typDQOpen
|
tInsert = self._typDQuoteO
|
||||||
elif thePos == 2 and theTwo == '>"':
|
elif thePos == 2 and theTwo == '>"':
|
||||||
tInsert = self._typDQOpen
|
tInsert = self._typDQuoteO
|
||||||
elif thePos == 3 and theThree == '>>"':
|
elif thePos == 3 and theThree == '>>"':
|
||||||
tInsert = self._typDQOpen
|
tInsert = self._typDQuoteO
|
||||||
else:
|
else:
|
||||||
tInsert = self._typDQClose
|
tInsert = self._typDQuoteC
|
||||||
|
|
||||||
elif self.mainConf.doReplaceSQuote and theTwo[:1].isspace() and theTwo.endswith("'"):
|
elif self._typRepSQuote and theTwo[:1].isspace() and theTwo.endswith("'"):
|
||||||
nDelete = 1
|
nDelete = 1
|
||||||
tInsert = self._typSQOpen
|
tInsert = self._typSQuoteO
|
||||||
|
|
||||||
elif self.mainConf.doReplaceSQuote and theOne == "'":
|
elif self._typRepSQuote and theOne == "'":
|
||||||
nDelete = 1
|
nDelete = 1
|
||||||
if thePos == 1:
|
if thePos == 1:
|
||||||
tInsert = self._typSQOpen
|
tInsert = self._typSQuoteO
|
||||||
elif thePos == 2 and theTwo == ">'":
|
elif thePos == 2 and theTwo == ">'":
|
||||||
tInsert = self._typSQOpen
|
tInsert = self._typSQuoteO
|
||||||
elif thePos == 3 and theThree == ">>'":
|
elif thePos == 3 and theThree == ">>'":
|
||||||
tInsert = self._typSQOpen
|
tInsert = self._typSQuoteO
|
||||||
else:
|
else:
|
||||||
tInsert = self._typSQClose
|
tInsert = self._typSQuoteC
|
||||||
|
|
||||||
elif self.mainConf.doReplaceDash and theThree == "---":
|
elif self._typRepDash and theThree == "---":
|
||||||
nDelete = 3
|
nDelete = 3
|
||||||
tInsert = nwUnicode.U_EMDASH
|
tInsert = nwUnicode.U_EMDASH
|
||||||
|
|
||||||
elif self.mainConf.doReplaceDash and theTwo == "--":
|
elif self._typRepDash and theTwo == "--":
|
||||||
nDelete = 2
|
nDelete = 2
|
||||||
tInsert = nwUnicode.U_ENDASH
|
tInsert = nwUnicode.U_ENDASH
|
||||||
|
|
||||||
elif self.mainConf.doReplaceDash and theTwo == nwUnicode.U_ENDASH + "-":
|
elif self._typRepDash and theTwo == nwUnicode.U_ENDASH + "-":
|
||||||
nDelete = 2
|
nDelete = 2
|
||||||
tInsert = nwUnicode.U_EMDASH
|
tInsert = nwUnicode.U_EMDASH
|
||||||
|
|
||||||
elif self.mainConf.doReplaceDots and theThree == "...":
|
elif self._typRepDots and theThree == "...":
|
||||||
nDelete = 3
|
nDelete = 3
|
||||||
tInsert = nwUnicode.U_HELLIP
|
tInsert = nwUnicode.U_HELLIP
|
||||||
|
|
||||||
@@ -2017,7 +2031,7 @@ class GuiDocEditor(QTextEdit):
|
|||||||
tInsert = nwUnicode.U_PSEP
|
tInsert = nwUnicode.U_PSEP
|
||||||
|
|
||||||
tCheck = tInsert
|
tCheck = tInsert
|
||||||
if self.mainConf.fmtPadBefore and tCheck in self.mainConf.fmtPadBefore:
|
if self._typPadBefore and tCheck in self._typPadBefore:
|
||||||
if self._allowSpaceBeforeColon(theText, tCheck):
|
if self._allowSpaceBeforeColon(theText, tCheck):
|
||||||
nDelete = max(nDelete, 1)
|
nDelete = max(nDelete, 1)
|
||||||
chkPos = thePos - nDelete - 1
|
chkPos = thePos - nDelete - 1
|
||||||
@@ -2026,7 +2040,7 @@ class GuiDocEditor(QTextEdit):
|
|||||||
nDelete += 1
|
nDelete += 1
|
||||||
tInsert = self._typPadChar + tInsert
|
tInsert = self._typPadChar + tInsert
|
||||||
|
|
||||||
if self.mainConf.fmtPadAfter and tCheck in self.mainConf.fmtPadAfter:
|
if self._typPadAfter and tCheck in self._typPadAfter:
|
||||||
if self._allowSpaceBeforeColon(theText, tCheck):
|
if self._allowSpaceBeforeColon(theText, tCheck):
|
||||||
nDelete = max(nDelete, 1)
|
nDelete = max(nDelete, 1)
|
||||||
tInsert = tInsert + self._typPadChar
|
tInsert = tInsert + self._typPadChar
|
||||||
|
|||||||
@@ -151,11 +151,13 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
|||||||
|
|
||||||
# Quoted Strings
|
# Quoted Strings
|
||||||
if self.mainConf.highlightQuotes:
|
if self.mainConf.highlightQuotes:
|
||||||
fmtDbl = self.mainConf.fmtDoubleQuotes
|
fmtDblO = self.mainConf.fmtDQuoteOpen
|
||||||
fmtSng = self.mainConf.fmtSingleQuotes
|
fmtDblC = self.mainConf.fmtDQuoteClose
|
||||||
|
fmtSngO = self.mainConf.fmtSQuoteOpen
|
||||||
|
fmtSngC = self.mainConf.fmtSQuoteClose
|
||||||
|
|
||||||
# Straight Quotes
|
# Straight Quotes
|
||||||
if fmtDbl != ["\"", "\""]:
|
if not (fmtDblO == fmtDblC == "\""):
|
||||||
self.hRules.append((
|
self.hRules.append((
|
||||||
"(\\B\")(.*?)(\"\\B)", {
|
"(\\B\")(.*?)(\"\\B)", {
|
||||||
0: self.hStyles["dialogue1"],
|
0: self.hStyles["dialogue1"],
|
||||||
@@ -165,7 +167,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
|||||||
# Double Quotes
|
# Double Quotes
|
||||||
dblEnd = "|$" if self.mainConf.allowOpenDQuote else ""
|
dblEnd = "|$" if self.mainConf.allowOpenDQuote else ""
|
||||||
self.hRules.append((
|
self.hRules.append((
|
||||||
f"(\\B{fmtDbl[0]})(.*?)({fmtDbl[1]}\\B{dblEnd})", {
|
f"(\\B{fmtDblO})(.*?)({fmtDblC}\\B{dblEnd})", {
|
||||||
0: self.hStyles["dialogue2"],
|
0: self.hStyles["dialogue2"],
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
@@ -173,7 +175,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
|||||||
# Single Quotes
|
# Single Quotes
|
||||||
sngEnd = "|$" if self.mainConf.allowOpenSQuote else ""
|
sngEnd = "|$" if self.mainConf.allowOpenSQuote else ""
|
||||||
self.hRules.append((
|
self.hRules.append((
|
||||||
f"(\\B{fmtSng[0]})(.*?)({fmtSng[1]}\\B{sngEnd})", {
|
f"(\\B{fmtSngO})(.*?)({fmtSngC}\\B{sngEnd})", {
|
||||||
0: self.hStyles["dialogue3"],
|
0: self.hStyles["dialogue3"],
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[Meta]
|
[Meta]
|
||||||
timestamp = 2022-11-10 11:10:10
|
timestamp = 2022-11-11 12:48:18
|
||||||
|
|
||||||
[Main]
|
[Main]
|
||||||
theme = default
|
theme = default
|
||||||
@@ -46,8 +46,10 @@ repdots = True
|
|||||||
scrollpastend = 25
|
scrollpastend = 25
|
||||||
autoscroll = False
|
autoscroll = False
|
||||||
autoscrollpos = 30
|
autoscrollpos = 30
|
||||||
fmtsinglequote = ‘, ’
|
fmtsquoteopen = ‘
|
||||||
fmtdoublequote = “, ”
|
fmtsquoteclose = ’
|
||||||
|
fmtdquoteopen = “
|
||||||
|
fmtdquoteclose = ”
|
||||||
fmtpadbefore =
|
fmtpadbefore =
|
||||||
fmtpadafter =
|
fmtpadafter =
|
||||||
fmtpadthin = False
|
fmtpadthin = False
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[Meta]
|
[Meta]
|
||||||
timestamp = 2022-11-10 11:10:13
|
timestamp = 2022-11-11 12:48:20
|
||||||
|
|
||||||
[Main]
|
[Main]
|
||||||
theme = default
|
theme = default
|
||||||
@@ -46,8 +46,10 @@ repdots = True
|
|||||||
scrollpastend = 0
|
scrollpastend = 0
|
||||||
autoscroll = True
|
autoscroll = True
|
||||||
autoscrollpos = 30
|
autoscrollpos = 30
|
||||||
fmtsinglequote = ‘, ’
|
fmtsquoteopen = ‘
|
||||||
fmtdoublequote = “, ”
|
fmtsquoteclose = ’
|
||||||
|
fmtdquoteopen = “
|
||||||
|
fmtdquoteclose = ”
|
||||||
fmtpadbefore =
|
fmtpadbefore =
|
||||||
fmtpadafter =
|
fmtpadafter =
|
||||||
fmtpadthin = False
|
fmtpadthin = False
|
||||||
|
|||||||
@@ -141,8 +141,10 @@ def testBaseConfig_InitLoadSave(monkeypatch, fncPath, tstPaths):
|
|||||||
assert newConf.guiSyntax == "bar"
|
assert newConf.guiSyntax == "bar"
|
||||||
|
|
||||||
# Test Correcting Quote Settings
|
# Test Correcting Quote Settings
|
||||||
tstConf.fmtDoubleQuotes = ["\"", "\""]
|
tstConf.fmtDQuoteOpen = "\""
|
||||||
tstConf.fmtSingleQuotes = ["'", "'"]
|
tstConf.fmtDQuoteClose = "\""
|
||||||
|
tstConf.fmtSQuoteOpen = "'"
|
||||||
|
tstConf.fmtSQuoteClose = "'"
|
||||||
tstConf.doReplaceDQuote = True
|
tstConf.doReplaceDQuote = True
|
||||||
tstConf.doReplaceSQuote = True
|
tstConf.doReplaceSQuote = True
|
||||||
assert tstConf.saveConfig() is True
|
assert tstConf.saveConfig() is True
|
||||||
|
|||||||
@@ -133,11 +133,11 @@ def testCoreItem_Setters(mockGUI, mockRnd, fncPath):
|
|||||||
theItem.setExpanded("What?")
|
theItem.setExpanded("What?")
|
||||||
assert theItem.isExpanded is False
|
assert theItem.isExpanded is False
|
||||||
theItem.setExpanded("True")
|
theItem.setExpanded("True")
|
||||||
assert theItem.isExpanded is True
|
assert theItem.isExpanded is False
|
||||||
theItem.setExpanded(True)
|
theItem.setExpanded(True)
|
||||||
assert theItem.isExpanded is True
|
assert theItem.isExpanded is True
|
||||||
|
|
||||||
# Exported
|
# Active
|
||||||
theItem.setActive(8)
|
theItem.setActive(8)
|
||||||
assert theItem.isActive is False
|
assert theItem.isActive is False
|
||||||
theItem.setActive(None)
|
theItem.setActive(None)
|
||||||
@@ -147,7 +147,7 @@ def testCoreItem_Setters(mockGUI, mockRnd, fncPath):
|
|||||||
theItem.setActive("What?")
|
theItem.setActive("What?")
|
||||||
assert theItem.isActive is False
|
assert theItem.isActive is False
|
||||||
theItem.setActive("True")
|
theItem.setActive("True")
|
||||||
assert theItem.isActive is True
|
assert theItem.isActive is False
|
||||||
theItem.setActive(True)
|
theItem.setActive(True)
|
||||||
assert theItem.isActive is True
|
assert theItem.isActive is True
|
||||||
|
|
||||||
|
|||||||
@@ -432,19 +432,19 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
|
|||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
# Insert spaces before and after quotes
|
# Insert spaces before and after quotes
|
||||||
nwGUI.mainConf.fmtPadBefore = "\u201d"
|
nwGUI.docEditor._typPadBefore = "\u201d"
|
||||||
nwGUI.mainConf.fmtPadAfter = "\u201c"
|
nwGUI.docEditor._typPadAfter = "\u201c"
|
||||||
|
|
||||||
for c in "Some \"double quoted text with spaces padded\".":
|
for c in "Some \"double quoted text with spaces padded\".":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
nwGUI.mainConf.fmtPadBefore = ""
|
nwGUI.docEditor._typPadBefore = ""
|
||||||
nwGUI.mainConf.fmtPadAfter = ""
|
nwGUI.docEditor._typPadAfter = ""
|
||||||
|
|
||||||
# Insert spaces before colon, but ignore tags and synopsis
|
# Insert spaces before colon, but ignore tags and synopsis
|
||||||
nwGUI.mainConf.fmtPadBefore = ":"
|
nwGUI.docEditor._typPadBefore = ":"
|
||||||
|
|
||||||
for c in "@object: NoSpaceAdded":
|
for c in "@object: NoSpaceAdded":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
||||||
@@ -466,7 +466,7 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
|
|||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
nwGUI.mainConf.fmtPadBefore = ""
|
nwGUI.docEditor._typPadBefore = ""
|
||||||
|
|
||||||
# Indent and Align
|
# Indent and Align
|
||||||
# ================
|
# ================
|
||||||
|
|||||||
@@ -461,19 +461,19 @@ def testGuiMenu_Insert(qtbot, monkeypatch, nwGUI, fncPath, projPath, mockRnd):
|
|||||||
nwGUI.docEditor.clear()
|
nwGUI.docEditor.clear()
|
||||||
|
|
||||||
nwGUI.mainMenu.aInsQuoteLS.activate(QAction.Trigger)
|
nwGUI.mainMenu.aInsQuoteLS.activate(QAction.Trigger)
|
||||||
assert nwGUI.docEditor.getText() == nwGUI.mainConf.fmtSingleQuotes[0]
|
assert nwGUI.docEditor.getText() == nwGUI.mainConf.fmtSQuoteOpen
|
||||||
nwGUI.docEditor.clear()
|
nwGUI.docEditor.clear()
|
||||||
|
|
||||||
nwGUI.mainMenu.aInsQuoteRS.activate(QAction.Trigger)
|
nwGUI.mainMenu.aInsQuoteRS.activate(QAction.Trigger)
|
||||||
assert nwGUI.docEditor.getText() == nwGUI.mainConf.fmtSingleQuotes[1]
|
assert nwGUI.docEditor.getText() == nwGUI.mainConf.fmtSQuoteClose
|
||||||
nwGUI.docEditor.clear()
|
nwGUI.docEditor.clear()
|
||||||
|
|
||||||
nwGUI.mainMenu.aInsQuoteLD.activate(QAction.Trigger)
|
nwGUI.mainMenu.aInsQuoteLD.activate(QAction.Trigger)
|
||||||
assert nwGUI.docEditor.getText() == nwGUI.mainConf.fmtDoubleQuotes[0]
|
assert nwGUI.docEditor.getText() == nwGUI.mainConf.fmtDQuoteOpen
|
||||||
nwGUI.docEditor.clear()
|
nwGUI.docEditor.clear()
|
||||||
|
|
||||||
nwGUI.mainMenu.aInsQuoteRD.activate(QAction.Trigger)
|
nwGUI.mainMenu.aInsQuoteRD.activate(QAction.Trigger)
|
||||||
assert nwGUI.docEditor.getText() == nwGUI.mainConf.fmtDoubleQuotes[1]
|
assert nwGUI.docEditor.getText() == nwGUI.mainConf.fmtDQuoteClose
|
||||||
nwGUI.docEditor.clear()
|
nwGUI.docEditor.clear()
|
||||||
|
|
||||||
nwGUI.mainMenu.aInsMSApos.activate(QAction.Trigger)
|
nwGUI.mainMenu.aInsMSApos.activate(QAction.Trigger)
|
||||||
|
|||||||
Reference in New Issue
Block a user