diff --git a/src/calibre/gui2/tweak_book/__init__.py b/src/calibre/gui2/tweak_book/__init__.py index 0bd840b508..57eead5d0f 100644 --- a/src/calibre/gui2/tweak_book/__init__.py +++ b/src/calibre/gui2/tweak_book/__init__.py @@ -13,6 +13,7 @@ tprefs.defaults['editor_theme'] = None tprefs.defaults['editor_font_family'] = None tprefs.defaults['editor_font_size'] = 12 tprefs.defaults['editor_line_wrap'] = True +tprefs.defaults['editor_tab_stop_width'] = 2 tprefs.defaults['preview_refresh_time'] = 2 tprefs.defaults['choose_tweak_fmt'] = True tprefs.defaults['tweak_fmt_order'] = ['EPUB', 'AZW3'] diff --git a/src/calibre/gui2/tweak_book/editor/text.py b/src/calibre/gui2/tweak_book/editor/text.py index 10eb76883b..1c6f2c1764 100644 --- a/src/calibre/gui2/tweak_book/editor/text.py +++ b/src/calibre/gui2/tweak_book/editor/text.py @@ -87,6 +87,9 @@ class TextEdit(QPlainTextEdit): if theme is None: theme = THEMES[default_theme()] self.apply_theme(theme) + w = self.fontMetrics() + self.space_width = w.width(' ') + self.setTabStopWidth(prefs['editor_tab_stop_width'] * self.space_width) def apply_theme(self, theme): self.theme = theme diff --git a/src/calibre/gui2/tweak_book/preferences.py b/src/calibre/gui2/tweak_book/preferences.py index 38fc66348d..33607f6bfb 100644 --- a/src/calibre/gui2/tweak_book/preferences.py +++ b/src/calibre/gui2/tweak_book/preferences.py @@ -163,6 +163,10 @@ class EditorSettings(BasicSettings): theme = self.choices_widget('editor_theme', choices, 'auto', 'auto') l.addRow(_('&Color scheme:'), theme) + tw = self('editor_tab_stop_width') + tw.setMinimum(2), tw.setSuffix(_(' characters')), tw.setMaximum(20) + l.addRow(_('Width of &tabs:'), tw) + lw = self('editor_line_wrap') lw.setText(_('&Wrap long lines in the editor')) l.addRow(lw)