summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2014-04-26 14:27:02 +0200
committermathieui <mathieui@mathieui.net>2014-04-26 14:27:02 +0200
commit4172a79117606ffaf23feba6dc38ced3fa759ea5 (patch)
tree7f417c57a53eb9b366d903175e5122ac742492a8 /src
parent1f0ff4f0c30f5326e1b36ff03ebf83ac85239e89 (diff)
downloadpoezio-4172a79117606ffaf23feba6dc38ced3fa759ea5.tar.gz
poezio-4172a79117606ffaf23feba6dc38ced3fa759ea5.tar.bz2
poezio-4172a79117606ffaf23feba6dc38ced3fa759ea5.tar.xz
poezio-4172a79117606ffaf23feba6dc38ced3fa759ea5.zip
Fix #2514 (add a /toggle command)
Diffstat (limited to 'src')
-rw-r--r--src/core/commands.py9
-rw-r--r--src/core/completions.py4
-rw-r--r--src/core/core.py7
3 files changed, 20 insertions, 0 deletions
diff --git a/src/core/commands.py b/src/core/commands.py
index 0815a80e..1c728283 100644
--- a/src/core/commands.py
+++ b/src/core/commands.py
@@ -620,6 +620,15 @@ def command_set(self, arg):
self.call_for_resize()
self.information(*info)
+def command_toggle(self, arg):
+ """
+ /toggle <option>
+ shortcut for /set <option> toggle
+ """
+ arg = arg.split()
+ if arg and arg[0]:
+ self.command_set('%s toggle' % arg[0])
+
def command_server_cycle(self, arg=''):
"""
Do a /cycle on each room of the given server.
diff --git a/src/core/completions.py b/src/core/completions.py
index 75122885..5387eefd 100644
--- a/src/core/completions.py
+++ b/src/core/completions.py
@@ -351,6 +351,10 @@ def completion_set(self, the_input):
return
return the_input.new_completion(end_list, n, quotify=True)
+def completion_toggle(self, the_input):
+ "Completion for /toggle"
+ return the_input.new_completion(config.options('Poezio'), 1, quotify=False)
+
def completion_bookmark_local(self, the_input):
"""Completion for /bookmark_local"""
diff --git a/src/core/core.py b/src/core/core.py
index 5313e89d..4bb0725b 100644
--- a/src/core/core.py
+++ b/src/core/core.py
@@ -1688,6 +1688,11 @@ class Core(object):
"used as a special value to toggle a boolean option."),
shortdesc=_("Set the value of an option"),
completion=self.completion_set)
+ self.register_command('toggle', self.command_toggle,
+ usage=_('<option>'),
+ desc=_('Shortcut for /set <option> toggle'),
+ shortdesc=_('Toggle an option'),
+ completion=self.completion_toggle)
self.register_command('theme', self.command_theme,
usage=_('[theme name]'),
desc=_("Reload the theme defined in the config file. If theme"
@@ -1866,6 +1871,7 @@ class Core(object):
command_destroy_room = commands.command_destroy_room
command_remove_bookmark = commands.command_remove_bookmark
command_set = commands.command_set
+ command_toggle = commands.command_toggle
command_server_cycle = commands.command_server_cycle
command_last_activity = commands.command_last_activity
command_mood = commands.command_mood
@@ -1904,6 +1910,7 @@ class Core(object):
completion_last_activity = completions.completion_last_activity
completion_server_cycle = completions.completion_server_cycle
completion_set = completions.completion_set
+ completion_toggle = completions.completion_toggle
completion_bookmark_local = completions.completion_bookmark_local