Add a setting for cursor width (#2219)
This commit is contained in:
@@ -72,7 +72,7 @@ class Config:
|
|||||||
"mainWinSize", "welcomeWinSize", "prefsWinSize", "mainPanePos", "viewPanePos",
|
"mainWinSize", "welcomeWinSize", "prefsWinSize", "mainPanePos", "viewPanePos",
|
||||||
"outlinePanePos", "autoSaveProj", "autoSaveDoc", "emphLabels", "backupOnClose",
|
"outlinePanePos", "autoSaveProj", "autoSaveDoc", "emphLabels", "backupOnClose",
|
||||||
"askBeforeBackup", "askBeforeExit", "textFont", "textWidth", "textMargin", "tabWidth",
|
"askBeforeBackup", "askBeforeExit", "textFont", "textWidth", "textMargin", "tabWidth",
|
||||||
"focusWidth", "hideFocusFooter", "showFullPath", "autoSelect", "doJustify",
|
"cursorWidth", "focusWidth", "hideFocusFooter", "showFullPath", "autoSelect", "doJustify",
|
||||||
"showTabsNSpaces", "showLineEndings", "showMultiSpaces", "doReplace", "doReplaceSQuote",
|
"showTabsNSpaces", "showLineEndings", "showMultiSpaces", "doReplace", "doReplaceSQuote",
|
||||||
"doReplaceDQuote", "doReplaceDash", "doReplaceDots", "autoScroll", "autoScrollPos",
|
"doReplaceDQuote", "doReplaceDash", "doReplaceDots", "autoScroll", "autoScrollPos",
|
||||||
"scrollPastEnd", "dialogStyle", "allowOpenDial", "dialogLine", "narratorBreak",
|
"scrollPastEnd", "dialogStyle", "allowOpenDial", "dialogLine", "narratorBreak",
|
||||||
@@ -184,6 +184,7 @@ class Config:
|
|||||||
self.textWidth = 700 # Editor text width
|
self.textWidth = 700 # Editor text width
|
||||||
self.textMargin = 40 # Editor/viewer text margin
|
self.textMargin = 40 # Editor/viewer text margin
|
||||||
self.tabWidth = 40 # Editor tabulator width
|
self.tabWidth = 40 # Editor tabulator width
|
||||||
|
self.cursorWidth = 1 # Editor cursor width
|
||||||
|
|
||||||
self.focusWidth = 800 # Focus Mode text width
|
self.focusWidth = 800 # Focus Mode text width
|
||||||
self.hideFocusFooter = False # Hide document footer in Focus Mode
|
self.hideFocusFooter = False # Hide document footer in Focus Mode
|
||||||
@@ -626,6 +627,7 @@ class Config:
|
|||||||
self.textWidth = conf.rdInt(sec, "width", self.textWidth)
|
self.textWidth = conf.rdInt(sec, "width", self.textWidth)
|
||||||
self.textMargin = conf.rdInt(sec, "margin", self.textMargin)
|
self.textMargin = conf.rdInt(sec, "margin", self.textMargin)
|
||||||
self.tabWidth = conf.rdInt(sec, "tabwidth", self.tabWidth)
|
self.tabWidth = conf.rdInt(sec, "tabwidth", self.tabWidth)
|
||||||
|
self.cursorWidth = conf.rdInt(sec, "cursorwidth", self.cursorWidth)
|
||||||
self.focusWidth = conf.rdInt(sec, "focuswidth", self.focusWidth)
|
self.focusWidth = conf.rdInt(sec, "focuswidth", self.focusWidth)
|
||||||
self.hideFocusFooter = conf.rdBool(sec, "hidefocusfooter", self.hideFocusFooter)
|
self.hideFocusFooter = conf.rdBool(sec, "hidefocusfooter", self.hideFocusFooter)
|
||||||
self.doJustify = conf.rdBool(sec, "justify", self.doJustify)
|
self.doJustify = conf.rdBool(sec, "justify", self.doJustify)
|
||||||
@@ -741,6 +743,7 @@ class Config:
|
|||||||
"width": str(self.textWidth),
|
"width": str(self.textWidth),
|
||||||
"margin": str(self.textMargin),
|
"margin": str(self.textMargin),
|
||||||
"tabwidth": str(self.tabWidth),
|
"tabwidth": str(self.tabWidth),
|
||||||
|
"cursorwidth": str(self.cursorWidth),
|
||||||
"focuswidth": str(self.focusWidth),
|
"focuswidth": str(self.focusWidth),
|
||||||
"hidefocusfooter": str(self.hideFocusFooter),
|
"hidefocusfooter": str(self.hideFocusFooter),
|
||||||
"justify": str(self.doJustify),
|
"justify": str(self.doJustify),
|
||||||
|
|||||||
@@ -522,6 +522,18 @@ class GuiPreferences(NDialog):
|
|||||||
self.tr("Apply formatting to word under cursor if no selection is made.")
|
self.tr("Apply formatting to word under cursor if no selection is made.")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Cursor Width
|
||||||
|
self.cursorWidth = NSpinBox(self)
|
||||||
|
self.cursorWidth.setMinimum(1)
|
||||||
|
self.cursorWidth.setMaximum(20)
|
||||||
|
self.cursorWidth.setSingleStep(1)
|
||||||
|
self.cursorWidth.setValue(CONFIG.cursorWidth)
|
||||||
|
self.mainForm.addRow(
|
||||||
|
self.tr("Cursor Width"), self.cursorWidth,
|
||||||
|
self.tr("The width of the editor cursor."),
|
||||||
|
unit=self.tr("px")
|
||||||
|
)
|
||||||
|
|
||||||
# Show Tabs and Spaces
|
# Show Tabs and Spaces
|
||||||
self.showTabsNSpaces = NSwitch(self)
|
self.showTabsNSpaces = NSwitch(self)
|
||||||
self.showTabsNSpaces.setChecked(CONFIG.showTabsNSpaces)
|
self.showTabsNSpaces.setChecked(CONFIG.showTabsNSpaces)
|
||||||
@@ -1010,6 +1022,7 @@ class GuiPreferences(NDialog):
|
|||||||
# Text Editing
|
# Text Editing
|
||||||
CONFIG.spellLanguage = self.spellLanguage.currentData()
|
CONFIG.spellLanguage = self.spellLanguage.currentData()
|
||||||
CONFIG.autoSelect = self.autoSelect.isChecked()
|
CONFIG.autoSelect = self.autoSelect.isChecked()
|
||||||
|
CONFIG.cursorWidth = self.cursorWidth.value()
|
||||||
CONFIG.showTabsNSpaces = self.showTabsNSpaces.isChecked()
|
CONFIG.showTabsNSpaces = self.showTabsNSpaces.isChecked()
|
||||||
CONFIG.showLineEndings = self.showLineEndings.isChecked()
|
CONFIG.showLineEndings = self.showLineEndings.isChecked()
|
||||||
|
|
||||||
|
|||||||
@@ -367,8 +367,9 @@ class GuiDocEditor(QPlainTextEdit):
|
|||||||
else:
|
else:
|
||||||
self.setHorizontalScrollBarPolicy(QtScrollAsNeeded)
|
self.setHorizontalScrollBarPolicy(QtScrollAsNeeded)
|
||||||
|
|
||||||
# Refresh the tab stops
|
# Refresh sizes
|
||||||
self.setTabStopDistance(CONFIG.tabWidth)
|
self.setTabStopDistance(CONFIG.tabWidth)
|
||||||
|
self.setCursorWidth(CONFIG.cursorWidth)
|
||||||
|
|
||||||
# If we have a document open, we should refresh it in case the
|
# If we have a document open, we should refresh it in case the
|
||||||
# font changed, otherwise we just clear the editor entirely,
|
# font changed, otherwise we just clear the editor entirely,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[Meta]
|
[Meta]
|
||||||
timestamp = 2025-01-29 11:56:34
|
timestamp = 2025-02-06 11:05:16
|
||||||
|
|
||||||
[Main]
|
[Main]
|
||||||
font =
|
font =
|
||||||
@@ -36,6 +36,7 @@ textfont =
|
|||||||
width = 700
|
width = 700
|
||||||
margin = 40
|
margin = 40
|
||||||
tabwidth = 40
|
tabwidth = 40
|
||||||
|
cursorwidth = 1
|
||||||
focuswidth = 800
|
focuswidth = 800
|
||||||
hidefocusfooter = False
|
hidefocusfooter = False
|
||||||
justify = False
|
justify = False
|
||||||
|
|||||||
@@ -242,11 +242,13 @@ def testDlgPreferences_Settings(qtbot, monkeypatch, nwGUI, fncPath, tstPaths):
|
|||||||
# Text Editing
|
# Text Editing
|
||||||
prefs.spellLanguage.setCurrentIndex(prefs.spellLanguage.findData("de"))
|
prefs.spellLanguage.setCurrentIndex(prefs.spellLanguage.findData("de"))
|
||||||
prefs.autoSelect.setChecked(False)
|
prefs.autoSelect.setChecked(False)
|
||||||
|
prefs.cursorWidth.setValue(5)
|
||||||
prefs.showTabsNSpaces.setChecked(True)
|
prefs.showTabsNSpaces.setChecked(True)
|
||||||
prefs.showLineEndings.setChecked(True)
|
prefs.showLineEndings.setChecked(True)
|
||||||
|
|
||||||
assert CONFIG.spellLanguage != "de"
|
assert CONFIG.spellLanguage != "de"
|
||||||
assert CONFIG.autoSelect is True
|
assert CONFIG.autoSelect is True
|
||||||
|
assert CONFIG.cursorWidth == 1
|
||||||
assert CONFIG.showTabsNSpaces is False
|
assert CONFIG.showTabsNSpaces is False
|
||||||
assert CONFIG.showLineEndings is False
|
assert CONFIG.showLineEndings is False
|
||||||
|
|
||||||
@@ -379,6 +381,7 @@ def testDlgPreferences_Settings(qtbot, monkeypatch, nwGUI, fncPath, tstPaths):
|
|||||||
# Text Editing
|
# Text Editing
|
||||||
assert CONFIG.spellLanguage == "de"
|
assert CONFIG.spellLanguage == "de"
|
||||||
assert CONFIG.autoSelect is False
|
assert CONFIG.autoSelect is False
|
||||||
|
assert CONFIG.cursorWidth == 5
|
||||||
assert CONFIG.showTabsNSpaces is True
|
assert CONFIG.showTabsNSpaces is True
|
||||||
assert CONFIG.showLineEndings is True
|
assert CONFIG.showLineEndings is True
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user