Skip to content

Commit

Permalink
Make the editor actually Plain Text (#1521)
Browse files Browse the repository at this point in the history
  • Loading branch information
vkbo authored Sep 6, 2023
2 parents 8275963 + 915b9da commit e08790e
Show file tree
Hide file tree
Showing 12 changed files with 259 additions and 487 deletions.
6 changes: 0 additions & 6 deletions novelwriter/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,10 @@ def __init__(self) -> None:
self.doReplaceDash = True # Replace multiple hyphens with dashes
self.doReplaceDots = True # Replace three dots with ellipsis

self.scrollPastEnd = 25 # Number of lines to scroll past end of document
self.autoScroll = False # Typewriter-like scrolling
self.autoScrollPos = 30 # Start point for typewriter-like scrolling

self.wordCountTimer = 5.0 # Interval for word count update in seconds
self.bigDocLimit = 800 # Size threshold for heavy editor features in kilobytes
self.incNotesWCount = True # The status bar word count includes notes

self.highlightQuotes = True # Highlight text in quotes
Expand Down Expand Up @@ -573,7 +571,6 @@ def loadConfig(self) -> bool:
self.doReplaceDQuote = conf.rdBool(sec, "repdquotes", self.doReplaceDQuote)
self.doReplaceDash = conf.rdBool(sec, "repdash", self.doReplaceDash)
self.doReplaceDots = conf.rdBool(sec, "repdots", self.doReplaceDots)
self.scrollPastEnd = conf.rdInt(sec, "scrollpastend", self.scrollPastEnd)
self.autoScroll = conf.rdBool(sec, "autoscroll", self.autoScroll)
self.autoScrollPos = conf.rdInt(sec, "autoscrollpos", self.autoScrollPos)
self.fmtSQuoteOpen = conf.rdStr(sec, "fmtsquoteopen", self.fmtSQuoteOpen)
Expand All @@ -588,7 +585,6 @@ def loadConfig(self) -> bool:
self.showLineEndings = conf.rdBool(sec, "showlineendings", self.showLineEndings)
self.showMultiSpaces = conf.rdBool(sec, "showmultispaces", self.showMultiSpaces)
self.wordCountTimer = conf.rdFlt(sec, "wordcounttimer", self.wordCountTimer)
self.bigDocLimit = conf.rdInt(sec, "bigdoclimit", self.bigDocLimit)
self.incNotesWCount = conf.rdBool(sec, "incnoteswcount", self.incNotesWCount)
self.showFullPath = conf.rdBool(sec, "showfullpath", self.showFullPath)
self.highlightQuotes = conf.rdBool(sec, "highlightquotes", self.highlightQuotes)
Expand Down Expand Up @@ -697,7 +693,6 @@ def saveConfig(self) -> bool:
"repdquotes": str(self.doReplaceDQuote),
"repdash": str(self.doReplaceDash),
"repdots": str(self.doReplaceDots),
"scrollpastend": str(self.scrollPastEnd),
"autoscroll": str(self.autoScroll),
"autoscrollpos": str(self.autoScrollPos),
"fmtsquoteopen": str(self.fmtSQuoteOpen),
Expand All @@ -712,7 +707,6 @@ def saveConfig(self) -> bool:
"showlineendings": str(self.showLineEndings),
"showmultispaces": str(self.showMultiSpaces),
"wordcounttimer": str(self.wordCountTimer),
"bigdoclimit": str(self.bigDocLimit),
"incnoteswcount": str(self.incNotesWCount),
"showfullpath": str(self.showFullPath),
"highlightquotes": str(self.highlightQuotes),
Expand Down
4 changes: 0 additions & 4 deletions novelwriter/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ class nwConst:
FMT_FSTAMP = "%Y-%m-%d %H.%M.%S" # FileName safe format
FMT_DSTAMP = "%Y-%m-%d" # Date only format

# Various Hard Limits
MAX_DOCSIZE = 5000000 # Maximum size of a single document
MAX_BUILDSIZE = 10000000 # Maximum size of a project build

# URLs
URL_WEB = "https://novelwriter.io"
URL_DOCS = "https://docs.novelwriter.io"
Expand Down
10 changes: 1 addition & 9 deletions novelwriter/core/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

from novelwriter.enum import nwItemLayout
from novelwriter.common import formatTimeStamp, numberToRoman, checkInt
from novelwriter.constants import nwConst, nwHeadFmt, nwRegEx, nwUnicode
from novelwriter.constants import nwHeadFmt, nwRegEx, nwUnicode
from novelwriter.core.project import NWProject

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -349,14 +349,6 @@ def setText(self, tHandle: str, text: str | None = None) -> bool:

self._text = text

docSize = len(self._text)
if docSize > nwConst.MAX_DOCSIZE:
errVal = self.tr("Document '{0}' is too big ({1} MB). Skipping.").format(
self._nwItem.itemName, f"{docSize/1.0e6:.2f}"
)
self._text = "# {0}\n\n{1}\n\n".format(self.tr("ERROR"), errVal)
self._errData.append(errVal)

self._isNone = self._nwItem.itemLayout == nwItemLayout.NO_LAYOUT
self._isNovel = self._nwItem.itemLayout == nwItemLayout.DOCUMENT
self._isNote = self._nwItem.itemLayout == nwItemLayout.NOTE
Expand Down
31 changes: 1 addition & 30 deletions novelwriter/dialogs/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,19 +675,6 @@ def __init__(self, prefsGui):
self.tr("Available languages are determined by your system.")
)

# Big Document Size Limit
self.bigDocLimit = QSpinBox(self)
self.bigDocLimit.setMinimum(10)
self.bigDocLimit.setMaximum(10000)
self.bigDocLimit.setSingleStep(10)
self.bigDocLimit.setValue(CONFIG.bigDocLimit)
self.mainForm.addRow(
self.tr("Big document limit"),
self.bigDocLimit,
self.tr("Full spell checking is disabled above this limit."),
unit=self.tr("kB")
)

# Word Count
# ==========
self.mainForm.addGroupLabel(self.tr("Word Count"))
Expand Down Expand Up @@ -737,19 +724,6 @@ def __init__(self, prefsGui):
# ================
self.mainForm.addGroupLabel(self.tr("Scroll Behaviour"))

# Scroll Past End
self.scrollPastEnd = QSpinBox(self)
self.scrollPastEnd.setMinimum(0)
self.scrollPastEnd.setMaximum(100)
self.scrollPastEnd.setSingleStep(1)
self.scrollPastEnd.setValue(int(CONFIG.scrollPastEnd))
self.mainForm.addRow(
self.tr("Scroll past end of the document"),
self.scrollPastEnd,
self.tr("Set to 0 to disable this feature."),
unit=self.tr("lines")
)

# Typewriter Scrolling
self.autoScroll = NSwitch()
self.autoScroll.setChecked(CONFIG.autoScroll)
Expand All @@ -775,11 +749,9 @@ def __init__(self, prefsGui):
return

def saveValues(self):
"""Save the values set for this tab.
"""
"""Save the values set for this tab."""
# Spell Checking
CONFIG.spellLanguage = self.spellLanguage.currentData()
CONFIG.bigDocLimit = self.bigDocLimit.value()

# Word Count
CONFIG.wordCountTimer = self.wordCountTimer.value()
Expand All @@ -790,7 +762,6 @@ def saveValues(self):
CONFIG.showLineEndings = self.showLineEndings.isChecked()

# Scroll Behaviour
CONFIG.scrollPastEnd = self.scrollPastEnd.value()
CONFIG.autoScroll = self.autoScroll.isChecked()
CONFIG.autoScrollPos = self.autoScrollPos.value()

Expand Down
Loading

0 comments on commit e08790e

Please sign in to comment.