Simplify some config types by using valid_values.

This commit is contained in:
Florian Bruhin 2014-11-30 22:16:31 +01:00
parent c986bde170
commit d558155620
2 changed files with 222 additions and 23 deletions

View File

@ -218,12 +218,23 @@ General/miscellaneous options.
=== ignore-case === ignore-case
Whether to find text on a page case-insensitively. Whether to find text on a page case-insensitively.
Valid values:
* +true+: Search case-insensitively
* +false+: Search case-sensitively
* +smart+: Search case-sensitively if there are capital chars
Default: +pass:[smart]+ Default: +pass:[smart]+
[[general-wrap-search]] [[general-wrap-search]]
=== wrap-search === wrap-search
Whether to wrap finding text to the top when arriving at the end. Whether to wrap finding text to the top when arriving at the end.
Valid values:
* +true+
* +false+
Default: +pass:[true]+ Default: +pass:[true]+
[[general-startpage]] [[general-startpage]]
@ -248,6 +259,11 @@ Default: +pass:[naive]+
=== auto-save-config === auto-save-config
Whether to save the config automatically on quit. Whether to save the config automatically on quit.
Valid values:
* +true+
* +false+
Default: +pass:[true]+ Default: +pass:[true]+
[[general-editor]] [[general-editor]]
@ -268,6 +284,11 @@ Default: +pass:[utf-8]+
=== private-browsing === private-browsing
Do not record visited pages in the history or store web page icons. Do not record visited pages in the history or store web page icons.
Valid values:
* +true+
* +false+
Default: +pass:[false]+ Default: +pass:[false]+
[[general-developer-extras]] [[general-developer-extras]]
@ -276,12 +297,22 @@ Enable extra tools for Web developers.
This needs to be enabled for `:inspector` to work and also adds an _Inspect_ entry to the context menu. This needs to be enabled for `:inspector` to work and also adds an _Inspect_ entry to the context menu.
Valid values:
* +true+
* +false+
Default: +pass:[false]+ Default: +pass:[false]+
[[general-print-element-backgrounds]] [[general-print-element-backgrounds]]
=== print-element-backgrounds === print-element-backgrounds
Whether the background color and images are also drawn when the page is printed. Whether the background color and images are also drawn when the page is printed.
Valid values:
* +true+
* +false+
Default: +pass:[true]+ Default: +pass:[true]+
[[general-xss-auditing]] [[general-xss-auditing]]
@ -290,12 +321,22 @@ Whether load requests should be monitored for cross-site scripting attempts.
Suspicious scripts will be blocked and reported in the inspector's JavaScript console. Enabling this feature might have an impact on performance. Suspicious scripts will be blocked and reported in the inspector's JavaScript console. Enabling this feature might have an impact on performance.
Valid values:
* +true+
* +false+
Default: +pass:[false]+ Default: +pass:[false]+
[[general-site-specific-quirks]] [[general-site-specific-quirks]]
=== site-specific-quirks === site-specific-quirks
Enable workarounds for broken sites. Enable workarounds for broken sites.
Valid values:
* +true+
* +false+
Default: +pass:[true]+ Default: +pass:[true]+
[[general-default-encoding]] [[general-default-encoding]]
@ -355,12 +396,22 @@ Default: +pass:[never]+
=== display-statusbar-messages === display-statusbar-messages
Whether to display javascript statusbar messages. Whether to display javascript statusbar messages.
Valid values:
* +true+
* +false+
Default: +pass:[false]+ Default: +pass:[false]+
[[ui-zoom-text-only]] [[ui-zoom-text-only]]
=== zoom-text-only === zoom-text-only
Whether the zoom factor on a frame applies only to the text or to all content. Whether the zoom factor on a frame applies only to the text or to all content.
Valid values:
* +true+
* +false+
Default: +pass:[false]+ Default: +pass:[false]+
[[ui-frame-flattening]] [[ui-frame-flattening]]
@ -369,6 +420,11 @@ Whether to expand each subframe to its contents.
This will flatten all the frames to become one scrollable page. This will flatten all the frames to become one scrollable page.
Valid values:
* +true+
* +false+
Default: +pass:[false]+ Default: +pass:[false]+
[[ui-user-stylesheet]] [[ui-user-stylesheet]]
@ -390,6 +446,11 @@ Settings related to the network.
=== do-not-track === do-not-track
Value to send in the `DNT` header. Value to send in the `DNT` header.
Valid values:
* +true+
* +false+
Default: +pass:[true]+ Default: +pass:[true]+
[[network-accept-language]] [[network-accept-language]]
@ -421,12 +482,23 @@ Default: +pass:[system]+
=== ssl-strict === ssl-strict
Whether to validate SSL handshakes. Whether to validate SSL handshakes.
Valid values:
* +true+
* +false+
* +ask+
Default: +pass:[ask]+ Default: +pass:[ask]+
[[network-dns-prefetch]] [[network-dns-prefetch]]
=== dns-prefetch === dns-prefetch
Whether to try to pre-fetch DNS entries to speed up browsing. Whether to try to pre-fetch DNS entries to speed up browsing.
Valid values:
* +true+
* +false+
Default: +pass:[true]+ Default: +pass:[true]+
== completion == completion
@ -436,6 +508,11 @@ Options related to completion and command history.
=== show === show
Whether to show the autocompletion window. Whether to show the autocompletion window.
Valid values:
* +true+
* +false+
Default: +pass:[true]+ Default: +pass:[true]+
[[completion-height]] [[completion-height]]
@ -456,12 +533,22 @@ Default: +pass:[100]+
=== quick-complete === quick-complete
Whether to move on to the next part when there's only one possible completion left. Whether to move on to the next part when there's only one possible completion left.
Valid values:
* +true+
* +false+
Default: +pass:[true]+ Default: +pass:[true]+
[[completion-shrink]] [[completion-shrink]]
=== shrink === shrink
Whether to shrink the completion to be smaller than the configured size if there are no scrollbars. Whether to shrink the completion to be smaller than the configured size if there are no scrollbars.
Valid values:
* +true+
* +false+
Default: +pass:[false]+ Default: +pass:[false]+
== input == input
@ -477,18 +564,33 @@ Default: +pass:[500]+
=== insert-mode-on-plugins === insert-mode-on-plugins
Whether to switch to insert mode when clicking flash and other plugins. Whether to switch to insert mode when clicking flash and other plugins.
Valid values:
* +true+
* +false+
Default: +pass:[false]+ Default: +pass:[false]+
[[input-auto-leave-insert-mode]] [[input-auto-leave-insert-mode]]
=== auto-leave-insert-mode === auto-leave-insert-mode
Whether to leave insert mode if a non-editable element is clicked. Whether to leave insert mode if a non-editable element is clicked.
Valid values:
* +true+
* +false+
Default: +pass:[true]+ Default: +pass:[true]+
[[input-auto-insert-mode]] [[input-auto-insert-mode]]
=== auto-insert-mode === auto-insert-mode
Whether to automatically enter insert mode if an editable element is focused after page load. Whether to automatically enter insert mode if an editable element is focused after page load.
Valid values:
* +true+
* +false+
Default: +pass:[false]+ Default: +pass:[false]+
[[input-forward-unbound-keys]] [[input-forward-unbound-keys]]
@ -509,12 +611,22 @@ Enables or disables the Spatial Navigation feature
Spatial navigation consists in the ability to navigate between focusable elements in a Web page, such as hyperlinks and form controls, by using Left, Right, Up and Down arrow keys. For example, if a user presses the Right key, heuristics determine whether there is an element he might be trying to reach towards the right and which element he probably wants. Spatial navigation consists in the ability to navigate between focusable elements in a Web page, such as hyperlinks and form controls, by using Left, Right, Up and Down arrow keys. For example, if a user presses the Right key, heuristics determine whether there is an element he might be trying to reach towards the right and which element he probably wants.
Valid values:
* +true+
* +false+
Default: +pass:[false]+ Default: +pass:[false]+
[[input-links-included-in-focus-chain]] [[input-links-included-in-focus-chain]]
=== links-included-in-focus-chain === links-included-in-focus-chain
Whether hyperlinks should be included in the keyboard focus chain. Whether hyperlinks should be included in the keyboard focus chain.
Valid values:
* +true+
* +false+
Default: +pass:[true]+ Default: +pass:[true]+
== tabs == tabs
@ -524,6 +636,11 @@ Configuration of the tab bar.
=== background-tabs === background-tabs
Whether to open new tabs (middleclick/ctrl+click) in background. Whether to open new tabs (middleclick/ctrl+click) in background.
Valid values:
* +true+
* +false+
Default: +pass:[false]+ Default: +pass:[false]+
[[tabs-select-on-remove]] [[tabs-select-on-remove]]
@ -580,18 +697,33 @@ Default: +pass:[ignore]+
=== auto-hide === auto-hide
Hide the tabbar if only one tab is open. Hide the tabbar if only one tab is open.
Valid values:
* +true+
* +false+
Default: +pass:[false]+ Default: +pass:[false]+
[[tabs-wrap]] [[tabs-wrap]]
=== wrap === wrap
Whether to wrap when changing tabs. Whether to wrap when changing tabs.
Valid values:
* +true+
* +false+
Default: +pass:[true]+ Default: +pass:[true]+
[[tabs-movable]] [[tabs-movable]]
=== movable === movable
Whether tabs should be movable. Whether tabs should be movable.
Valid values:
* +true+
* +false+
Default: +pass:[true]+ Default: +pass:[true]+
[[tabs-close-mouse-button]] [[tabs-close-mouse-button]]
@ -623,6 +755,11 @@ Default: +pass:[north]+
=== show-favicons === show-favicons
Whether to show favicons in the tab bar. Whether to show favicons in the tab bar.
Valid values:
* +true+
* +false+
Default: +pass:[true]+ Default: +pass:[true]+
[[tabs-width]] [[tabs-width]]
@ -647,6 +784,11 @@ Default: +pass:[3]+
=== tabs-are-windows === tabs-are-windows
Whether to open windows instead of tabs. Whether to open windows instead of tabs.
Valid values:
* +true+
* +false+
Default: +pass:[false]+ Default: +pass:[false]+
== storage == storage
@ -696,6 +838,11 @@ Default: empty
=== offline-storage-database === offline-storage-database
Whether support for the HTML 5 offline storage feature is enabled. Whether support for the HTML 5 offline storage feature is enabled.
Valid values:
* +true+
* +false+
Default: +pass:[true]+ Default: +pass:[true]+
[[storage-offline-web-application-storage]] [[storage-offline-web-application-storage]]
@ -706,12 +853,22 @@ An application cache acts like an HTTP cache in some sense. For documents that u
The feature is described in details at: http://dev.w3.org/html5/spec/Overview.html#appcache The feature is described in details at: http://dev.w3.org/html5/spec/Overview.html#appcache
Valid values:
* +true+
* +false+
Default: +pass:[true]+ Default: +pass:[true]+
[[storage-local-storage]] [[storage-local-storage]]
=== local-storage === local-storage
Whether support for the HTML 5 local storage feature is enabled. Whether support for the HTML 5 local storage feature is enabled.
Valid values:
* +true+
* +false+
Default: +pass:[true]+ Default: +pass:[true]+
[[storage-cache-size]] [[storage-cache-size]]
@ -727,12 +884,22 @@ Loaded plugins/scripts and allowed actions.
=== allow-images === allow-images
Whether images are automatically loaded in web pages. Whether images are automatically loaded in web pages.
Valid values:
* +true+
* +false+
Default: +pass:[true]+ Default: +pass:[true]+
[[content-allow-javascript]] [[content-allow-javascript]]
=== allow-javascript === allow-javascript
Enables or disables the running of JavaScript programs. Enables or disables the running of JavaScript programs.
Valid values:
* +true+
* +false+
Default: +pass:[true]+ Default: +pass:[true]+
[[content-allow-plugins]] [[content-allow-plugins]]
@ -741,36 +908,66 @@ Enables or disables plugins in Web pages.
Qt plugins with a mimetype such as "application/x-qt-plugin" are not affected by this setting. Qt plugins with a mimetype such as "application/x-qt-plugin" are not affected by this setting.
Valid values:
* +true+
* +false+
Default: +pass:[false]+ Default: +pass:[false]+
[[content-javascript-can-open-windows]] [[content-javascript-can-open-windows]]
=== javascript-can-open-windows === javascript-can-open-windows
Whether JavaScript programs can open new windows. Whether JavaScript programs can open new windows.
Valid values:
* +true+
* +false+
Default: +pass:[false]+ Default: +pass:[false]+
[[content-javascript-can-close-windows]] [[content-javascript-can-close-windows]]
=== javascript-can-close-windows === javascript-can-close-windows
Whether JavaScript programs can close windows. Whether JavaScript programs can close windows.
Valid values:
* +true+
* +false+
Default: +pass:[false]+ Default: +pass:[false]+
[[content-javascript-can-access-clipboard]] [[content-javascript-can-access-clipboard]]
=== javascript-can-access-clipboard === javascript-can-access-clipboard
Whether JavaScript programs can read or write to the clipboard. Whether JavaScript programs can read or write to the clipboard.
Valid values:
* +true+
* +false+
Default: +pass:[false]+ Default: +pass:[false]+
[[content-local-content-can-access-remote-urls]] [[content-local-content-can-access-remote-urls]]
=== local-content-can-access-remote-urls === local-content-can-access-remote-urls
Whether locally loaded documents are allowed to access remote urls. Whether locally loaded documents are allowed to access remote urls.
Valid values:
* +true+
* +false+
Default: +pass:[false]+ Default: +pass:[false]+
[[content-local-content-can-access-file-urls]] [[content-local-content-can-access-file-urls]]
=== local-content-can-access-file-urls === local-content-can-access-file-urls
Whether locally loaded documents are allowed to access other local urls. Whether locally loaded documents are allowed to access other local urls.
Valid values:
* +true+
* +false+
Default: +pass:[true]+ Default: +pass:[true]+
[[content-cookies-accept]] [[content-cookies-accept]]
@ -788,6 +985,11 @@ Default: +pass:[default]+
=== cookies-store === cookies-store
Whether to store cookies. Whether to store cookies.
Valid values:
* +true+
* +false+
Default: +pass:[true]+ Default: +pass:[true]+
[[content-host-block-lists]] [[content-host-block-lists]]
@ -838,12 +1040,22 @@ Default: +pass:[asdfghjkl]+
=== uppercase === uppercase
Make chars in hint strings uppercase. Make chars in hint strings uppercase.
Valid values:
* +true+
* +false+
Default: +pass:[false]+ Default: +pass:[false]+
[[hints-auto-follow]] [[hints-auto-follow]]
=== auto-follow === auto-follow
Whether to auto-follow a hint if there's only one left. Whether to auto-follow a hint if there's only one left.
Valid values:
* +true+
* +false+
Default: +pass:[true]+ Default: +pass:[true]+
[[hints-next-regexes]] [[hints-next-regexes]]

View File

@ -246,6 +246,8 @@ class Bool(BaseType):
_BOOLEAN_STATES = {'1': True, 'yes': True, 'true': True, 'on': True, _BOOLEAN_STATES = {'1': True, 'yes': True, 'true': True, 'on': True,
'0': False, 'no': False, 'false': False, 'off': False} '0': False, 'no': False, 'false': False, 'off': False}
valid_values = ValidValues('true', 'false')
def transform(self, value): def transform(self, value):
if not value: if not value:
return None return None
@ -261,14 +263,13 @@ class Bool(BaseType):
if value.lower() not in Bool._BOOLEAN_STATES: if value.lower() not in Bool._BOOLEAN_STATES:
raise ValidationError(value, "must be a boolean!") raise ValidationError(value, "must be a boolean!")
def complete(self):
return [('true', ''), ('false', '')]
class BoolAsk(Bool): class BoolAsk(Bool):
"""A yes/no/ask question.""" """A yes/no/ask question."""
valid_values = ValidValues('true', 'false', 'ask')
def transform(self, value): def transform(self, value):
if value.lower() == 'ask': if value.lower() == 'ask':
return 'ask' return 'ask'
@ -281,9 +282,6 @@ class BoolAsk(Bool):
else: else:
super().validate(value) super().validate(value)
def complete(self):
return [('true', ''), ('false', ''), ('ask', '')]
class Int(BaseType): class Int(BaseType):
@ -562,11 +560,6 @@ class ColorSystem(BaseType):
('hsl', "Interpolate in the HSL color system.")) ('hsl', "Interpolate in the HSL color system."))
def validate(self, value): def validate(self, value):
if not value:
if self._none_ok:
return
else:
raise ValidationError(value, "may not be empty!")
super().validate(value.lower()) super().validate(value.lower())
def transform(self, value): def transform(self, value):
@ -1137,14 +1130,9 @@ class AutoSearch(BaseType):
def __init__(self, none_ok=False): def __init__(self, none_ok=False):
super().__init__(none_ok) super().__init__(none_ok)
self.booltype = Bool() self.booltype = Bool(none_ok=none_ok)
def validate(self, value): def validate(self, value):
if not value:
if self._none_ok:
return
else:
raise ValidationError(value, "may not be empty!")
if value.lower() in ('naive', 'dns'): if value.lower() in ('naive', 'dns'):
pass pass
else: else:
@ -1290,6 +1278,11 @@ class IgnoreCase(Bool):
"""Whether to ignore case when searching.""" """Whether to ignore case when searching."""
valid_values = ValidValues(('true', "Search case-insensitively"),
('false', "Search case-sensitively"),
('smart', "Search case-sensitively if there "
"are capital chars"))
def transform(self, value): def transform(self, value):
if value.lower() == 'smart': if value.lower() == 'smart':
return 'smart' return 'smart'
@ -1302,12 +1295,6 @@ class IgnoreCase(Bool):
else: else:
super().validate(value) super().validate(value)
def complete(self):
return [('true', 'Search case-insensitively'),
('false', 'Search case-sensitively'),
('smart', 'Search case-sensitively if there are capital '
'chars')]
class NewInstanceOpenTarget(BaseType): class NewInstanceOpenTarget(BaseType):