+3
-3
@@ -69,7 +69,7 @@ class Config:
|
||||
self.textSize = 12
|
||||
self.textFixedW = True
|
||||
self.textWidth = 600
|
||||
self.textMargin = [40, 40]
|
||||
self.textMargin = 40
|
||||
self.tabWidth = 40
|
||||
self.doJustify = True
|
||||
self.autoSelect = True
|
||||
@@ -165,7 +165,7 @@ class Config:
|
||||
self.textSize = self._parseLine(cnfParse, cnfSec, "textsize", self.CNF_INT, self.textSize)
|
||||
self.textFixedW = self._parseLine(cnfParse, cnfSec, "fixedwidth", self.CNF_BOOL, self.textFixedW)
|
||||
self.textWidth = self._parseLine(cnfParse, cnfSec, "width", self.CNF_INT, self.textWidth)
|
||||
self.textMargin = self._parseLine(cnfParse, cnfSec, "margins", self.CNF_LIST, self.textMargin)
|
||||
self.textMargin = self._parseLine(cnfParse, cnfSec, "margin", self.CNF_INT, self.textMargin)
|
||||
self.tabWidth = self._parseLine(cnfParse, cnfSec, "tabwidth", self.CNF_INT, self.tabWidth)
|
||||
self.doJustify = self._parseLine(cnfParse, cnfSec, "justify", self.CNF_BOOL, self.doJustify)
|
||||
self.autoSelect = self._parseLine(cnfParse, cnfSec, "autoselect", self.CNF_BOOL, self.autoSelect)
|
||||
@@ -220,7 +220,7 @@ class Config:
|
||||
cnfParse.set(cnfSec,"textsize", str(self.textSize))
|
||||
cnfParse.set(cnfSec,"fixedwidth", str(self.textFixedW))
|
||||
cnfParse.set(cnfSec,"width", str(self.textWidth))
|
||||
cnfParse.set(cnfSec,"margins", self._packList(self.textMargin))
|
||||
cnfParse.set(cnfSec,"margin", str(self.textMargin))
|
||||
cnfParse.set(cnfSec,"tabwidth", str(self.tabWidth))
|
||||
cnfParse.set(cnfSec,"justify", str(self.doJustify))
|
||||
cnfParse.set(cnfSec,"autoselect", str(self.autoSelect))
|
||||
|
||||
+84
-83
@@ -260,21 +260,12 @@ class GuiConfigEditEditor(QWidget):
|
||||
else:
|
||||
self.textFlowJustify.setCheckState(Qt.Unchecked)
|
||||
|
||||
self.testFlowAutoSelect = QCheckBox(self)
|
||||
self.testFlowAutoSelect.setToolTip("Auto-select word under cursor when applying formatting.")
|
||||
if self.mainConf.autoSelect:
|
||||
self.testFlowAutoSelect.setCheckState(Qt.Checked)
|
||||
else:
|
||||
self.testFlowAutoSelect.setCheckState(Qt.Unchecked)
|
||||
|
||||
self.textFlowForm.addWidget(QLabel("Fixed Width"), 0, 0)
|
||||
self.textFlowForm.addWidget(self.textFlowFixed, 0, 1)
|
||||
self.textFlowForm.addWidget(self.textFlowWidth, 0, 2)
|
||||
self.textFlowForm.addWidget(QLabel("px"), 0, 3)
|
||||
self.textFlowForm.addWidget(QLabel("Justify Text"), 1, 0)
|
||||
self.textFlowForm.addWidget(self.textFlowJustify, 1, 1)
|
||||
self.textFlowForm.addWidget(QLabel("Auto-Select Text"), 2, 0)
|
||||
self.textFlowForm.addWidget(self.testFlowAutoSelect, 2, 1)
|
||||
self.textFlowForm.setColumnStretch(4, 1)
|
||||
|
||||
# Text Margins
|
||||
@@ -282,17 +273,11 @@ class GuiConfigEditEditor(QWidget):
|
||||
self.textMarginForm = QGridLayout(self)
|
||||
self.textMargin.setLayout(self.textMarginForm)
|
||||
|
||||
self.textMarginHor = QSpinBox(self)
|
||||
self.textMarginHor.setMinimum(0)
|
||||
self.textMarginHor.setMaximum(2000)
|
||||
self.textMarginHor.setSingleStep(1)
|
||||
self.textMarginHor.setValue(self.mainConf.textMargin[0])
|
||||
|
||||
self.textMarginVer = QSpinBox(self)
|
||||
self.textMarginVer.setMinimum(0)
|
||||
self.textMarginVer.setMaximum(2000)
|
||||
self.textMarginVer.setSingleStep(1)
|
||||
self.textMarginVer.setValue(self.mainConf.textMargin[1])
|
||||
self.textMarginDoc = QSpinBox(self)
|
||||
self.textMarginDoc.setMinimum(0)
|
||||
self.textMarginDoc.setMaximum(2000)
|
||||
self.textMarginDoc.setSingleStep(1)
|
||||
self.textMarginDoc.setValue(self.mainConf.textMargin)
|
||||
|
||||
self.textMarginTab = QSpinBox(self)
|
||||
self.textMarginTab.setMinimum(0)
|
||||
@@ -300,22 +285,26 @@ class GuiConfigEditEditor(QWidget):
|
||||
self.textMarginTab.setSingleStep(1)
|
||||
self.textMarginTab.setValue(self.mainConf.tabWidth)
|
||||
|
||||
self.textMarginForm.addWidget(QLabel("Horizontal"), 0, 0)
|
||||
self.textMarginForm.addWidget(self.textMarginHor, 0, 1)
|
||||
self.textMarginForm.addWidget(QLabel("Document"), 0, 0)
|
||||
self.textMarginForm.addWidget(self.textMarginDoc, 0, 1)
|
||||
self.textMarginForm.addWidget(QLabel("px"), 0, 2)
|
||||
self.textMarginForm.addWidget(QLabel("Vertical"), 1, 0)
|
||||
self.textMarginForm.addWidget(self.textMarginVer, 1, 1)
|
||||
self.textMarginForm.addWidget(QLabel("px"), 1, 2)
|
||||
self.textMarginForm.addWidget(QLabel("Tab Width"), 2, 0)
|
||||
self.textMarginForm.addWidget(self.textMarginTab, 2, 1)
|
||||
self.textMarginForm.addWidget(QLabel("px"), 2, 2)
|
||||
self.textMarginForm.setColumnStretch(4, 1)
|
||||
|
||||
# Auto-Replace
|
||||
self.autoReplace = QGroupBox("Auto-Replace", self)
|
||||
# Automatic Features
|
||||
self.autoReplace = QGroupBox("Automatic Features", self)
|
||||
self.autoReplaceForm = QGridLayout(self)
|
||||
self.autoReplace.setLayout(self.autoReplaceForm)
|
||||
|
||||
self.autoSelect = QCheckBox(self)
|
||||
self.autoSelect.setToolTip("Auto-select word under cursor when applying formatting.")
|
||||
if self.mainConf.autoSelect:
|
||||
self.autoSelect.setCheckState(Qt.Checked)
|
||||
else:
|
||||
self.autoSelect.setCheckState(Qt.Unchecked)
|
||||
|
||||
self.autoReplaceMain = QCheckBox(self)
|
||||
self.autoReplaceMain.setToolTip("Auto-replace text as you type.")
|
||||
if self.mainConf.doReplace:
|
||||
@@ -330,18 +319,6 @@ class GuiConfigEditEditor(QWidget):
|
||||
else:
|
||||
self.autoReplaceSQ.setCheckState(Qt.Unchecked)
|
||||
|
||||
self.autoReplaceSStyleO = QLineEdit()
|
||||
self.autoReplaceSStyleO.setMaxLength(1)
|
||||
self.autoReplaceSStyleO.setFixedWidth(30)
|
||||
self.autoReplaceSStyleO.setAlignment(Qt.AlignCenter)
|
||||
self.autoReplaceSStyleO.setText(self.mainConf.fmtSingleQuotes[0])
|
||||
|
||||
self.autoReplaceSStyleC = QLineEdit()
|
||||
self.autoReplaceSStyleC.setMaxLength(1)
|
||||
self.autoReplaceSStyleC.setFixedWidth(30)
|
||||
self.autoReplaceSStyleC.setAlignment(Qt.AlignCenter)
|
||||
self.autoReplaceSStyleC.setText(self.mainConf.fmtSingleQuotes[1])
|
||||
|
||||
self.autoReplaceDQ = QCheckBox(self)
|
||||
self.autoReplaceDQ.setToolTip("Auto-replace double quotes.")
|
||||
if self.mainConf.doReplaceDQuote:
|
||||
@@ -349,18 +326,6 @@ class GuiConfigEditEditor(QWidget):
|
||||
else:
|
||||
self.autoReplaceDQ.setCheckState(Qt.Unchecked)
|
||||
|
||||
self.autoReplaceDStyleO = QLineEdit()
|
||||
self.autoReplaceDStyleO.setMaxLength(1)
|
||||
self.autoReplaceDStyleO.setFixedWidth(30)
|
||||
self.autoReplaceDStyleO.setAlignment(Qt.AlignCenter)
|
||||
self.autoReplaceDStyleO.setText(self.mainConf.fmtDoubleQuotes[0])
|
||||
|
||||
self.autoReplaceDStyleC = QLineEdit()
|
||||
self.autoReplaceDStyleC.setMaxLength(1)
|
||||
self.autoReplaceDStyleC.setFixedWidth(30)
|
||||
self.autoReplaceDStyleC.setAlignment(Qt.AlignCenter)
|
||||
self.autoReplaceDStyleC.setText(self.mainConf.fmtDoubleQuotes[1])
|
||||
|
||||
self.autoReplaceDash = QCheckBox(self)
|
||||
self.autoReplaceDash.setToolTip("Auto-replace double and triple hyphens with short and long dash.")
|
||||
if self.mainConf.doReplaceDash:
|
||||
@@ -375,31 +340,68 @@ class GuiConfigEditEditor(QWidget):
|
||||
else:
|
||||
self.autoReplaceDots.setCheckState(Qt.Unchecked)
|
||||
|
||||
self.autoReplaceForm.addWidget(QLabel("Enable Feature"), 0, 0)
|
||||
self.autoReplaceForm.addWidget(self.autoReplaceMain, 0, 1)
|
||||
self.autoReplaceForm.addWidget(QLabel("Single Quotes"), 1, 0)
|
||||
self.autoReplaceForm.addWidget(self.autoReplaceSQ, 1, 1)
|
||||
self.autoReplaceForm.addWidget(QLabel("Open"), 1, 2)
|
||||
self.autoReplaceForm.addWidget(self.autoReplaceSStyleO, 1, 3)
|
||||
self.autoReplaceForm.addWidget(QLabel("Close"), 1, 4)
|
||||
self.autoReplaceForm.addWidget(self.autoReplaceSStyleC, 1, 5)
|
||||
self.autoReplaceForm.addWidget(QLabel("Double Quotes"), 2, 0)
|
||||
self.autoReplaceForm.addWidget(self.autoReplaceDQ, 2, 1)
|
||||
self.autoReplaceForm.addWidget(QLabel("Open"), 2, 2)
|
||||
self.autoReplaceForm.addWidget(self.autoReplaceDStyleO, 2, 3)
|
||||
self.autoReplaceForm.addWidget(QLabel("Close"), 2, 4)
|
||||
self.autoReplaceForm.addWidget(self.autoReplaceDStyleC, 2, 5)
|
||||
self.autoReplaceForm.addWidget(QLabel("Hyphens with Dash"), 3, 0)
|
||||
self.autoReplaceForm.addWidget(self.autoReplaceDash, 3, 1)
|
||||
self.autoReplaceForm.addWidget(QLabel("Dots with Ellipsis"), 4, 0)
|
||||
self.autoReplaceForm.addWidget(self.autoReplaceDots, 4, 1)
|
||||
self.autoReplaceForm.setColumnStretch(6, 1)
|
||||
self.autoReplaceForm.addWidget(QLabel("Auto-Select Text"), 0, 0)
|
||||
self.autoReplaceForm.addWidget(self.autoSelect, 0, 1)
|
||||
self.autoReplaceForm.addWidget(QLabel("Auto-Replace:"), 1, 0)
|
||||
self.autoReplaceForm.addWidget(self.autoReplaceMain, 1, 1)
|
||||
self.autoReplaceForm.addWidget(QLabel("\u2192 Single Quotes"), 2, 0)
|
||||
self.autoReplaceForm.addWidget(self.autoReplaceSQ, 2, 1)
|
||||
self.autoReplaceForm.addWidget(QLabel("\u2192 Double Quotes"), 3, 0)
|
||||
self.autoReplaceForm.addWidget(self.autoReplaceDQ, 3, 1)
|
||||
self.autoReplaceForm.addWidget(QLabel("\u2192 Hyphens with Dash"), 4, 0)
|
||||
self.autoReplaceForm.addWidget(self.autoReplaceDash, 4, 1)
|
||||
self.autoReplaceForm.addWidget(QLabel("\u2192 Dots with Ellipsis"), 5, 0)
|
||||
self.autoReplaceForm.addWidget(self.autoReplaceDots, 5, 1)
|
||||
self.autoReplaceForm.setColumnStretch(2, 1)
|
||||
|
||||
# Quote Style
|
||||
self.quoteStyle = QGroupBox("Quotation Style", self)
|
||||
self.quoteStyleForm = QGridLayout(self)
|
||||
self.quoteStyle.setLayout(self.quoteStyleForm)
|
||||
|
||||
self.quoteSingleStyleO = QLineEdit()
|
||||
self.quoteSingleStyleO.setMaxLength(1)
|
||||
self.quoteSingleStyleO.setFixedWidth(30)
|
||||
self.quoteSingleStyleO.setAlignment(Qt.AlignCenter)
|
||||
self.quoteSingleStyleO.setText(self.mainConf.fmtSingleQuotes[0])
|
||||
|
||||
self.quoteSingleStyleC = QLineEdit()
|
||||
self.quoteSingleStyleC.setMaxLength(1)
|
||||
self.quoteSingleStyleC.setFixedWidth(30)
|
||||
self.quoteSingleStyleC.setAlignment(Qt.AlignCenter)
|
||||
self.quoteSingleStyleC.setText(self.mainConf.fmtSingleQuotes[1])
|
||||
|
||||
self.quoteDoubleStyleO = QLineEdit()
|
||||
self.quoteDoubleStyleO.setMaxLength(1)
|
||||
self.quoteDoubleStyleO.setFixedWidth(30)
|
||||
self.quoteDoubleStyleO.setAlignment(Qt.AlignCenter)
|
||||
self.quoteDoubleStyleO.setText(self.mainConf.fmtDoubleQuotes[0])
|
||||
|
||||
self.quoteDoubleStyleC = QLineEdit()
|
||||
self.quoteDoubleStyleC.setMaxLength(1)
|
||||
self.quoteDoubleStyleC.setFixedWidth(30)
|
||||
self.quoteDoubleStyleC.setAlignment(Qt.AlignCenter)
|
||||
self.quoteDoubleStyleC.setText(self.mainConf.fmtDoubleQuotes[1])
|
||||
|
||||
self.quoteStyleForm.addWidget(QLabel("Single Quotes"), 0, 0, 1, 3)
|
||||
self.quoteStyleForm.addWidget(QLabel("Open"), 1, 0)
|
||||
self.quoteStyleForm.addWidget(self.quoteSingleStyleO, 1, 1)
|
||||
self.quoteStyleForm.addWidget(QLabel("Close"), 1, 2)
|
||||
self.quoteStyleForm.addWidget(self.quoteSingleStyleC, 1, 3)
|
||||
self.quoteStyleForm.addWidget(QLabel("Double Quotes"), 2, 0, 1, 3)
|
||||
self.quoteStyleForm.addWidget(QLabel("Open"), 3, 0)
|
||||
self.quoteStyleForm.addWidget(self.quoteDoubleStyleO, 3, 1)
|
||||
self.quoteStyleForm.addWidget(QLabel("Close"), 3, 2)
|
||||
self.quoteStyleForm.addWidget(self.quoteDoubleStyleC, 3, 3)
|
||||
self.quoteStyleForm.setColumnStretch(4, 1)
|
||||
self.quoteStyleForm.setRowStretch(4, 1)
|
||||
|
||||
# Assemble
|
||||
self.outerBox.addWidget(self.textStyle, 0, 0, 1, 2)
|
||||
self.outerBox.addWidget(self.textFlow, 1, 0)
|
||||
self.outerBox.addWidget(self.textMargin, 1, 1)
|
||||
self.outerBox.addWidget(self.autoReplace, 2, 0, 1, 2)
|
||||
self.outerBox.addWidget(self.autoReplace, 2, 0)
|
||||
self.outerBox.addWidget(self.quoteStyle, 2, 1)
|
||||
self.outerBox.setColumnStretch(2, 1)
|
||||
self.setLayout(self.outerBox)
|
||||
|
||||
@@ -418,37 +420,36 @@ class GuiConfigEditEditor(QWidget):
|
||||
textWidth = self.textFlowWidth.value()
|
||||
textFixedW = self.textFlowFixed.isChecked()
|
||||
doJustify = self.textFlowJustify.isChecked()
|
||||
autoSelect = self.testFlowAutoSelect.isChecked()
|
||||
|
||||
self.mainConf.textWidth = textWidth
|
||||
self.mainConf.textFixedW = textFixedW
|
||||
self.mainConf.doJustify = doJustify
|
||||
self.mainConf.autoSelect = autoSelect
|
||||
|
||||
textMarginH = self.textMarginHor.value()
|
||||
textMarginV = self.textMarginVer.value()
|
||||
tabWidth = self.textMarginTab.value()
|
||||
textMargin = self.textMarginDoc.value()
|
||||
tabWidth = self.textMarginTab.value()
|
||||
|
||||
self.mainConf.textMargin[0] = textMarginH
|
||||
self.mainConf.textMargin[1] = textMarginV
|
||||
self.mainConf.tabWidth = tabWidth
|
||||
self.mainConf.textMargin = textMargin
|
||||
self.mainConf.tabWidth = tabWidth
|
||||
|
||||
autoSelect = self.autoSelect.isChecked()
|
||||
doReplace = self.autoReplaceMain.isChecked()
|
||||
doReplaceSQuote = self.autoReplaceSQ.isChecked()
|
||||
doReplaceDQuote = self.autoReplaceDQ.isChecked()
|
||||
doReplaceDash = self.autoReplaceDash.isChecked()
|
||||
doReplaceDots = self.autoReplaceDash.isChecked()
|
||||
fmtSingleQuotesO = self.autoReplaceSStyleO.text()
|
||||
fmtSingleQuotesC = self.autoReplaceSStyleC.text()
|
||||
fmtDoubleQuotesO = self.autoReplaceDStyleO.text()
|
||||
fmtDoubleQuotesC = self.autoReplaceDStyleC.text()
|
||||
|
||||
self.mainConf.autoSelect = autoSelect
|
||||
self.mainConf.doReplace = doReplace
|
||||
self.mainConf.doReplaceSQuote = doReplaceSQuote
|
||||
self.mainConf.doReplaceDQuote = doReplaceDQuote
|
||||
self.mainConf.doReplaceDash = doReplaceDash
|
||||
self.mainConf.doReplaceDots = doReplaceDots
|
||||
|
||||
fmtSingleQuotesO = self.quoteSingleStyleO.text()
|
||||
fmtSingleQuotesC = self.quoteSingleStyleC.text()
|
||||
fmtDoubleQuotesO = self.quoteDoubleStyleO.text()
|
||||
fmtDoubleQuotesC = self.quoteDoubleStyleC.text()
|
||||
|
||||
if self._checkQuoteSymbol(fmtSingleQuotesO):
|
||||
self.mainConf.fmtSingleQuotes[0] = fmtSingleQuotesO
|
||||
else:
|
||||
|
||||
+33
-39
@@ -15,7 +15,7 @@ import nw
|
||||
|
||||
from time import time
|
||||
|
||||
from PyQt5.QtCore import Qt, QTimer
|
||||
from PyQt5.QtCore import Qt, QTimer, QSizeF
|
||||
from PyQt5.QtWidgets import QTextEdit, QAction, QMenu, QShortcut
|
||||
from PyQt5.QtGui import QTextCursor, QTextOption, QIcon, QKeySequence, QFont
|
||||
|
||||
@@ -36,13 +36,13 @@ class GuiDocEditor(QTextEdit):
|
||||
logger.debug("Initialising DocEditor ...")
|
||||
|
||||
# Class Variables
|
||||
self.mainConf = nw.CONFIG
|
||||
self.theParent = theParent
|
||||
self.theProject = theProject
|
||||
self.docChanged = False
|
||||
self.spellCheck = False
|
||||
self.theDocument = NWDoc(self.theProject, self.theParent)
|
||||
self.theHandle = None
|
||||
self.mainConf = nw.CONFIG
|
||||
self.theParent = theParent
|
||||
self.theProject = theProject
|
||||
self.docChanged = False
|
||||
self.spellCheck = False
|
||||
self.nwDocument = NWDoc(self.theProject, self.theParent)
|
||||
self.theHandle = None
|
||||
|
||||
# Document Variables
|
||||
self.charCount = 0
|
||||
@@ -57,14 +57,15 @@ class GuiDocEditor(QTextEdit):
|
||||
self.typSQClose = self.mainConf.fmtSingleQuotes[1]
|
||||
|
||||
# Core Elements
|
||||
self.theQDoc = self.document()
|
||||
self.qDocument = self.document()
|
||||
self.qDocument.contentsChange.connect(self._docChange)
|
||||
if self.mainConf.spellTool == "enchant":
|
||||
from nw.tools.spellenchant import NWSpellEnchant
|
||||
self.theDict = NWSpellEnchant()
|
||||
else:
|
||||
self.theDict = NWSpellCheck()
|
||||
|
||||
self.hLight = GuiDocHighlighter(self.theQDoc, self.theParent)
|
||||
self.hLight = GuiDocHighlighter(self.qDocument, self.theParent)
|
||||
self.hLight.setDict(self.theDict)
|
||||
|
||||
# Context Menu
|
||||
@@ -76,9 +77,6 @@ class GuiDocEditor(QTextEdit):
|
||||
self.setMinimumWidth(300)
|
||||
self.setAcceptRichText(False)
|
||||
|
||||
self.theQDoc.setDocumentMargin(0)
|
||||
self.theQDoc.contentsChange.connect(self._docChange)
|
||||
|
||||
# Custom Shortcuts
|
||||
QShortcut(QKeySequence("Ctrl+."), self, context=Qt.WidgetShortcut, activated=self._openSpellContext)
|
||||
|
||||
@@ -100,7 +98,7 @@ class GuiDocEditor(QTextEdit):
|
||||
|
||||
def clearEditor(self):
|
||||
|
||||
self.theDocument.clearDocument()
|
||||
self.nwDocument.clearDocument()
|
||||
self.setReadOnly(True)
|
||||
self.clear()
|
||||
self.wcTimer.stop()
|
||||
@@ -129,19 +127,14 @@ class GuiDocEditor(QTextEdit):
|
||||
theFont = QFont()
|
||||
if self.mainConf.textFont is None:
|
||||
# If none is defined, set the default back to config
|
||||
self.mainConf.textFont = self.theQDoc.defaultFont().family()
|
||||
self.mainConf.textFont = self.qDocument.defaultFont().family()
|
||||
theFont.setFamily(self.mainConf.textFont)
|
||||
theFont.setPointSize(self.mainConf.textSize)
|
||||
self.setFont(theFont)
|
||||
|
||||
# Set text fixed width, or alternatively, just margins
|
||||
if self.mainConf.textFixedW:
|
||||
self.setLineWrapMode(QTextEdit.FixedPixelWidth)
|
||||
self.setLineWrapColumnOrWidth(self.mainConf.textWidth)
|
||||
else:
|
||||
mTB = self.mainConf.textMargin[0]
|
||||
mLR = self.mainConf.textMargin[1]
|
||||
self.setViewportMargins(mLR,mTB,mLR,mTB)
|
||||
self.qDocument.setDocumentMargin(self.mainConf.textMargin)
|
||||
self.changeWidth()
|
||||
|
||||
# Also set the document text options for the document text flow
|
||||
theOpt = QTextOption()
|
||||
@@ -149,7 +142,7 @@ class GuiDocEditor(QTextEdit):
|
||||
theOpt.setTabStopDistance(self.mainConf.tabWidth)
|
||||
if self.mainConf.doJustify:
|
||||
theOpt.setAlignment(Qt.AlignJustify)
|
||||
self.theQDoc.setDefaultTextOption(theOpt)
|
||||
self.qDocument.setDefaultTextOption(theOpt)
|
||||
|
||||
# If we have a document open, we should reload it in case the font changed
|
||||
if self.theHandle is not None:
|
||||
@@ -163,8 +156,8 @@ class GuiDocEditor(QTextEdit):
|
||||
def loadText(self, tHandle):
|
||||
|
||||
self.hLight.setHandle(tHandle)
|
||||
self.setPlainText(self.theDocument.openDocument(tHandle))
|
||||
self.setCursorPosition(self.theDocument.theItem.cursorPos)
|
||||
self.setPlainText(self.nwDocument.openDocument(tHandle))
|
||||
self.setCursorPosition(self.nwDocument.theItem.cursorPos)
|
||||
self.lastEdit = time()
|
||||
self._runCounter()
|
||||
self.wcTimer.start()
|
||||
@@ -176,17 +169,17 @@ class GuiDocEditor(QTextEdit):
|
||||
|
||||
def saveText(self):
|
||||
|
||||
if self.theDocument.theItem is None:
|
||||
if self.nwDocument.theItem is None:
|
||||
return False
|
||||
|
||||
docText = self.getText()
|
||||
cursPos = self.getCursorPosition()
|
||||
theItem = self.theDocument.theItem
|
||||
theItem = self.nwDocument.theItem
|
||||
theItem.setCharCount(self.charCount)
|
||||
theItem.setWordCount(self.wordCount)
|
||||
theItem.setParaCount(self.paraCount)
|
||||
theItem.setCursorPos(cursPos)
|
||||
self.theDocument.saveDocument(docText)
|
||||
self.nwDocument.saveDocument(docText)
|
||||
self.setDocumentChanged(False)
|
||||
|
||||
self.theParent.theIndex.scanText(theItem.itemHandle, docText)
|
||||
@@ -253,15 +246,16 @@ class GuiDocEditor(QTextEdit):
|
||||
sW = vBar.width()
|
||||
else:
|
||||
sW = 0
|
||||
tW = self.width()
|
||||
tM = int((tW - sW - self.mainConf.textWidth)/2)
|
||||
mTB = self.mainConf.textMargin[0]
|
||||
if tM >= 10:
|
||||
self.setViewportMargins(tM,mTB,0,mTB)
|
||||
self.setLineWrapColumnOrWidth(self.mainConf.textWidth)
|
||||
else:
|
||||
self.setViewportMargins(10,mTB,0,mTB)
|
||||
self.setLineWrapColumnOrWidth(tW - sW - 20)
|
||||
tW = self.mainConf.textWidth
|
||||
wW = self.width()
|
||||
tM = int((wW - sW - tW)/2)
|
||||
if tM < 0:
|
||||
tM = 0
|
||||
# print(wW, tW, dW, sW, tM)
|
||||
self.setViewportMargins(tM,0,tM,0)
|
||||
self.qDocument.setTextWidth(tW)
|
||||
else:
|
||||
self.setViewportMargins(0,0,0,0)
|
||||
return
|
||||
|
||||
def docAction(self, theAction):
|
||||
@@ -369,7 +363,7 @@ class GuiDocEditor(QTextEdit):
|
||||
if not self.wcTimer.isActive():
|
||||
self.wcTimer.start()
|
||||
if self.mainConf.doReplace and not self.hasSelection:
|
||||
self._docAutoReplace(self.theQDoc.findBlock(thePos))
|
||||
self._docAutoReplace(self.qDocument.findBlock(thePos))
|
||||
# logger.verbose("Doc change signal took %.3f µs" % ((time()-self.lastEdit)*1e6))
|
||||
return
|
||||
|
||||
@@ -447,7 +441,7 @@ class GuiDocEditor(QTextEdit):
|
||||
"""
|
||||
logger.verbose("Updating word count")
|
||||
|
||||
tHandle = self.theDocument.docHandle
|
||||
tHandle = self.nwDocument.docHandle
|
||||
self.charCount = self.wCounter.charCount
|
||||
self.wordCount = self.wCounter.wordCount
|
||||
self.paraCount = self.wCounter.paraCount
|
||||
|
||||
+1
-1
@@ -111,7 +111,7 @@ class GuiDocViewer(QTextBrowser):
|
||||
theFont.setPointSize(self.mainConf.textSize)
|
||||
self.setFont(theFont)
|
||||
|
||||
self.theQDoc.setDocumentMargin(self.mainConf.textMargin[0])
|
||||
self.theQDoc.setDocumentMargin(self.mainConf.textMargin)
|
||||
theOpt = QTextOption()
|
||||
if self.mainConf.doJustify:
|
||||
theOpt.setAlignment(Qt.AlignJustify)
|
||||
|
||||
+1
-1
@@ -296,8 +296,8 @@ class GuiMain(QMainWindow):
|
||||
if self.hasProject:
|
||||
self.closeDocument()
|
||||
self.docEditor.loadText(tHandle)
|
||||
self.docEditor.changeWidth()
|
||||
self.docEditor.setFocus()
|
||||
self.docEditor.changeWidth()
|
||||
self.theProject.setLastEdited(tHandle)
|
||||
return True
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[Main]
|
||||
timestamp = 2019-06-11 18:39:59
|
||||
timestamp = 2019-06-15 12:26:17
|
||||
theme = default_dark
|
||||
|
||||
[Sizes]
|
||||
@@ -18,7 +18,7 @@ textfont = None
|
||||
textsize = 12
|
||||
fixedwidth = True
|
||||
width = 600
|
||||
margins = 40, 40
|
||||
margin = 40
|
||||
tabwidth = 40
|
||||
justify = True
|
||||
autoselect = True
|
||||
|
||||
Reference in New Issue
Block a user