Commit 4172a791 authored by mathieui's avatar mathieui

Fix #2514 (add a /toggle command)

parent 1f0ff4f0
......@@ -146,6 +146,11 @@ These commands work in *any* tab.
just set the option to true if it’s currently false, and to false if it’s
currently true.
/toggle
**Usage:** ``/toggle <option>``
Toggle an option, shortcut for :term:`/set` <option> toggle.
/move_tab
**Usage:** ``/move_tab <source> <destination>``
......
......@@ -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.
......
......@@ -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"""
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment