From 3c21d5986ea44d94c11130b36d69833aadb73941 Mon Sep 17 00:00:00 2001 From: ZDarian Date: Sun, 18 Jan 2015 07:34:33 -0700 Subject: [PATCH] Added toggle ability to :set Append '!' to option name of boolean value to toggle its state. --- qutebrowser/config/config.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py index b12c33dcf..170586090 100644 --- a/qutebrowser/config/config.py +++ b/qutebrowser/config/config.py @@ -499,6 +499,8 @@ class ConfigManager(QObject): If the option name ends with '?', the value of the option is shown instead. + If the option name ends with '!' and it is a boolean value, toggle it. + // Wrapper for self.set() to output exceptions in the status bar. @@ -523,6 +525,13 @@ class ConfigManager(QObject): val = self.get(sectname, optname[:-1], transformed=False) message.info(win_id, "{} {} = {}".format( sectname, optname[:-1], val), immediately=True) + elif optname.endswith('!'): + val = self.get(sectname, optname[:-1]) + layer = 'temp' if temp else 'conf' + if type(val) == type(True): + self.set(layer, sectname, optname[:-1], str(not val)) + else: + raise cmdexc.CommandError("set: Attempted inversion of non-boolean value. Aborting.") else: if value is None: raise cmdexc.CommandError("set: The following arguments "