Skip to content

Commit

Permalink
Edit book: Add a setting to control cursor width under Preferences->E…
Browse files Browse the repository at this point in the history
…ditor settings
  • Loading branch information
kovidgoyal committed Apr 17, 2024
1 parent 4183627 commit 1d73fab
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/calibre/gui2/tweak_book/__init__.py
Expand Up @@ -19,6 +19,7 @@
d['editor_font_size'] = 12
d['editor_line_wrap'] = True
d['editor_tab_stop_width'] = 2
d['editor_cursor_width'] = 1
d['editor_show_char_under_cursor'] = True
d['replace_entities_as_typed'] = True
d['preview_refresh_time'] = 2
Expand Down
3 changes: 3 additions & 0 deletions src/calibre/gui2/tweak_book/editor/text.py
Expand Up @@ -7,6 +7,7 @@
import re
import textwrap
import unicodedata
from contextlib import suppress

import regex
from qt.core import (
Expand Down Expand Up @@ -229,6 +230,8 @@ def apply_settings(self, prefs=None, dictionaries_changed=False): # {{{
prefs = prefs or tprefs
self.setAcceptDrops(prefs.get('editor_accepts_drops', True))
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'])
self.apply_theme(theme)
fm = self.fontMetrics()
Expand Down
4 changes: 4 additions & 0 deletions src/calibre/gui2/tweak_book/preferences.py
Expand Up @@ -197,6 +197,10 @@ def __init__(self, parent=None):
fs.setMinimum(8), fs.setSuffix(' pt'), fs.setMaximum(50)
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()
theme = self.choices_widget('editor_theme', choices, 'auto', 'auto')
self.custom_theme_button = b = QPushButton(_('Create/edit &custom color schemes'))
Expand Down

0 comments on commit 1d73fab

Please sign in to comment.