Preference to control tab width in the editor

This commit is contained in:
Kovid Goyal 2013-12-01 16:06:48 +05:30
parent cd01049c6e
commit b91454d454
3 changed files with 8 additions and 0 deletions

View File

@ -13,6 +13,7 @@ tprefs.defaults['editor_theme'] = None
tprefs.defaults['editor_font_family'] = None tprefs.defaults['editor_font_family'] = None
tprefs.defaults['editor_font_size'] = 12 tprefs.defaults['editor_font_size'] = 12
tprefs.defaults['editor_line_wrap'] = True tprefs.defaults['editor_line_wrap'] = True
tprefs.defaults['editor_tab_stop_width'] = 2
tprefs.defaults['preview_refresh_time'] = 2 tprefs.defaults['preview_refresh_time'] = 2
tprefs.defaults['choose_tweak_fmt'] = True tprefs.defaults['choose_tweak_fmt'] = True
tprefs.defaults['tweak_fmt_order'] = ['EPUB', 'AZW3'] tprefs.defaults['tweak_fmt_order'] = ['EPUB', 'AZW3']

View File

@ -87,6 +87,9 @@ class TextEdit(QPlainTextEdit):
if theme is None: if theme is None:
theme = THEMES[default_theme()] theme = THEMES[default_theme()]
self.apply_theme(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): def apply_theme(self, theme):
self.theme = theme self.theme = theme

View File

@ -163,6 +163,10 @@ class EditorSettings(BasicSettings):
theme = self.choices_widget('editor_theme', choices, 'auto', 'auto') theme = self.choices_widget('editor_theme', choices, 'auto', 'auto')
l.addRow(_('&Color scheme:'), theme) 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 = self('editor_line_wrap')
lw.setText(_('&Wrap long lines in the editor')) lw.setText(_('&Wrap long lines in the editor'))
l.addRow(lw) l.addRow(lw)