Bugfix/improve config output
This commit is contained in:
parent
2a7fca8652
commit
cd29814ef3
@ -119,27 +119,22 @@ class NewConfig:
|
|||||||
('statusbar', opt.StatusbarFont()),
|
('statusbar', opt.StatusbarFont()),
|
||||||
)),
|
)),
|
||||||
])
|
])
|
||||||
self.first_comment = """
|
|
||||||
# vim: ft=dosini
|
|
||||||
|
|
||||||
# Configfile for qutebrowser.
|
self._first_comment = (
|
||||||
#
|
'vim: ft=dosini\n\n'
|
||||||
# This configfile is parsed by python's configparser in extended
|
'Configfile for qutebrowser.\n\n'
|
||||||
# interpolation mode. The format is very INI-like, so there are
|
"This configfile is parsed by python's configparser in extended "
|
||||||
# categories like [general] with "key = value"-pairs.
|
'interpolation mode. The format is very INI-like, so there are '
|
||||||
#
|
'categories like [general] with "key = value"-pairs.\n\n'
|
||||||
# Comments start with ; or # and may only start at the beginning of a
|
"Note that you shouldn't add your own comments, as this file is "
|
||||||
# line.
|
'regenerated every time the config is saved.\n\n'
|
||||||
#
|
'Interpolation looks like ${value} or ${section:value} and '
|
||||||
# Interpolation looks like ${value} or ${section:value} and will be
|
'will be replaced by the respective value.\n\n'
|
||||||
# replaced by the respective value.
|
'This is the default config, so if you want to remove anything '
|
||||||
#
|
'from here (as opposed to change/add), for example a keybinding, '
|
||||||
# This is the default config, so if you want to remove anything from
|
'set it to an empty value.')
|
||||||
# here (as opposed to change/add), for example a keybinding, set it to
|
|
||||||
# an empty value.
|
|
||||||
""".lstrip('\n')
|
|
||||||
|
|
||||||
self.section_desc = {
|
self._section_desc = {
|
||||||
'general': 'General/misc. options',
|
'general': 'General/misc. options',
|
||||||
'tabbar': 'Configuration of the tab bar.',
|
'tabbar': 'Configuration of the tab bar.',
|
||||||
'searchengines': (
|
'searchengines': (
|
||||||
@ -150,7 +145,7 @@ class NewConfig:
|
|||||||
'was entered to be opened. Other search engines can be used '
|
'was entered to be opened. Other search engines can be used '
|
||||||
'via the bang-syntax, e.g. "qutebrowser !google". The string '
|
'via the bang-syntax, e.g. "qutebrowser !google". The string '
|
||||||
'"{}" will be replaced by the search term, use "{{" and "}}" '
|
'"{}" will be replaced by the search term, use "{{" and "}}" '
|
||||||
'for literal {/} signs.')
|
'for literal {/} signs.'),
|
||||||
'keybind': (
|
'keybind': (
|
||||||
'Bindings from a key(chain) to a command. For special keys '
|
'Bindings from a key(chain) to a command. For special keys '
|
||||||
"(can't be part of a keychain), enclose them in @-signs. For "
|
"(can't be part of a keychain), enclose them in @-signs. For "
|
||||||
@ -164,12 +159,12 @@ class NewConfig:
|
|||||||
'is pressed with Shift. For modifier keys (with @ signs), you '
|
'is pressed with Shift. For modifier keys (with @ signs), you '
|
||||||
'need to explicitely add "Shift-" to match a key pressed with '
|
'need to explicitely add "Shift-" to match a key pressed with '
|
||||||
'shift. You can bind multiple commands by separating them '
|
'shift. You can bind multiple commands by separating them '
|
||||||
'with ";;".')
|
'with ";;".'),
|
||||||
'aliases': (
|
'aliases': (
|
||||||
'Here you can add aliases for commands. By default, no '
|
'Here you can add aliases for commands. By default, no '
|
||||||
'aliases are defined. Example which adds a new command :qtb '
|
'aliases are defined. Example which adds a new command :qtb '
|
||||||
'to open qutebrowsers website:\n'
|
'to open qutebrowsers website:\n'
|
||||||
' qtb = open http://www.qutebrowser.org/')
|
' qtb = open http://www.qutebrowser.org/'),
|
||||||
'colors': (
|
'colors': (
|
||||||
'Colors used in the UI. A value can be in one of the '
|
'Colors used in the UI. A value can be in one of the '
|
||||||
'following format:\n'
|
'following format:\n'
|
||||||
@ -183,12 +178,12 @@ class NewConfig:
|
|||||||
' - A gradient as explained at [2] under "Gradient"\n'
|
' - A gradient as explained at [2] under "Gradient"\n'
|
||||||
'[1] http://www.w3.org/TR/SVG/types.html#ColorKeywords\n'
|
'[1] http://www.w3.org/TR/SVG/types.html#ColorKeywords\n'
|
||||||
'[2] http://qt-project.org/doc/qt-4.8/stylesheet-reference'
|
'[2] http://qt-project.org/doc/qt-4.8/stylesheet-reference'
|
||||||
'.html#list-of-property-types')
|
'.html#list-of-property-types'),
|
||||||
'fonts': (
|
'fonts': (
|
||||||
'Fonts used for the UI, with optional style/weight/size.\n'
|
'Fonts used for the UI, with optional style/weight/size.\n'
|
||||||
'Style: normal/italic/oblique\n'
|
'Style: normal/italic/oblique\n'
|
||||||
'Weight: normal, bold, 100..900\n'
|
'Weight: normal, bold, 100..900\n'
|
||||||
'Size: Number + px/pt\n')
|
'Size: Number + px/pt\n'),
|
||||||
}
|
}
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
@ -197,12 +192,22 @@ class NewConfig:
|
|||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
"""Get the whole config as a string."""
|
"""Get the whole config as a string."""
|
||||||
lines = textwrap.dedent(self.first_comment).splitlines()
|
# FIXME empty lines get discared
|
||||||
|
# FIXME we should set subsequent_indent for config options later
|
||||||
|
wrapper = textwrap.TextWrapper(
|
||||||
|
width=72, replace_whitespace=False, break_long_words=False,
|
||||||
|
break_on_hyphens=False, initial_indent='# ',
|
||||||
|
subsequent_indent='# ')
|
||||||
|
lines = []
|
||||||
|
for par in map(wrapper.wrap, self._first_comment.splitlines()):
|
||||||
|
lines += par
|
||||||
for secname, section in self.config.items():
|
for secname, section in self.config.items():
|
||||||
if not section:
|
|
||||||
continue
|
|
||||||
lines.append('\n[{}]'.format(secname))
|
lines.append('\n[{}]'.format(secname))
|
||||||
|
for par in map(wrapper.wrap,
|
||||||
|
self._section_desc[secname].splitlines()):
|
||||||
|
lines += par
|
||||||
for optname, option in section.items():
|
for optname, option in section.items():
|
||||||
|
# FIXME display option comment
|
||||||
lines.append('{} = {}'.format(optname, option))
|
lines.append('{} = {}'.format(optname, option))
|
||||||
return '\n'.join(lines)
|
return '\n'.join(lines)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user