Edit book: Add a setting to control cursor width under Preferences->Editor settings

This commit is contained in:
Kovid Goyal 2024-04-17 06:34:22 +05:30
parent 4183627a7d
commit 1d73fabf59
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 8 additions and 0 deletions

View File

@ -19,6 +19,7 @@ d['editor_font_family'] = None
d['editor_font_size'] = 12 d['editor_font_size'] = 12
d['editor_line_wrap'] = True d['editor_line_wrap'] = True
d['editor_tab_stop_width'] = 2 d['editor_tab_stop_width'] = 2
d['editor_cursor_width'] = 1
d['editor_show_char_under_cursor'] = True d['editor_show_char_under_cursor'] = True
d['replace_entities_as_typed'] = True d['replace_entities_as_typed'] = True
d['preview_refresh_time'] = 2 d['preview_refresh_time'] = 2

View File

@ -7,6 +7,7 @@ import os
import re import re
import textwrap import textwrap
import unicodedata import unicodedata
from contextlib import suppress
import regex import regex
from qt.core import ( from qt.core import (
@ -229,6 +230,8 @@ class TextEdit(PlainTextEdit):
prefs = prefs or tprefs prefs = prefs or tprefs
self.setAcceptDrops(prefs.get('editor_accepts_drops', True)) self.setAcceptDrops(prefs.get('editor_accepts_drops', True))
self.setLineWrapMode(QPlainTextEdit.LineWrapMode.WidgetWidth if prefs['editor_line_wrap'] else QPlainTextEdit.LineWrapMode.NoWrap) self.setLineWrapMode(QPlainTextEdit.LineWrapMode.WidgetWidth if prefs['editor_line_wrap'] else QPlainTextEdit.LineWrapMode.NoWrap)
with suppress(Exception):
self.setCursorWidth(int(prefs.get('editor_cursor_width', 1)))
theme = get_theme(prefs['editor_theme']) theme = get_theme(prefs['editor_theme'])
self.apply_theme(theme) self.apply_theme(theme)
fm = self.fontMetrics() fm = self.fontMetrics()

View File

@ -197,6 +197,10 @@ class EditorSettings(BasicSettings): # {{{
fs.setMinimum(8), fs.setSuffix(' pt'), fs.setMaximum(50) fs.setMinimum(8), fs.setSuffix(' pt'), fs.setMaximum(50)
l.addRow(_('Editor font &size:'), fs) l.addRow(_('Editor font &size:'), fs)
cs = self('editor_cursor_width')
cs.setMinimum(1), cs.setSuffix(' px'), cs.setMaximum(50)
l.addRow(_('Editor cursor &width:'), cs)
choices = self.theme_choices() choices = self.theme_choices()
theme = self.choices_widget('editor_theme', choices, 'auto', 'auto') theme = self.choices_widget('editor_theme', choices, 'auto', 'auto')
self.custom_theme_button = b = QPushButton(_('Create/edit &custom color schemes')) self.custom_theme_button = b = QPushButton(_('Create/edit &custom color schemes'))