Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mavproxy_mode: Allow for mode names to be tab completed #1499

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions MAVProxy/modules/mavproxy_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
class ModeModule(mp_module.MPModule):
def __init__(self, mpstate):
super(ModeModule, self).__init__(mpstate, "mode", public=True)
self.add_command('mode', self.cmd_mode, "mode change", self.available_modes())
self.add_command('mode', self.cmd_mode, "mode change", [
'(MODE)'
])
self.add_command('guided', self.cmd_guided, "fly to a clicked location on map")
self.add_command('confirm', self.cmd_confirm, "confirm a command")
self.add_completion_function('(MODE)', self.complete_available_modes)

def cmd_mode(self, args):
'''set arbitrary mode'''
Expand All @@ -25,7 +28,7 @@ def cmd_mode(self, args):
print('No mode mapping available')
return
if len(args) != 1:
print('Available modes: ', mode_mapping.keys())
print('Available modes: ', ', '.join(self.available_modes()))
return
if args[0].isdigit():
modenum = int(args[0])
Expand All @@ -50,6 +53,9 @@ def cmd_confirm(self, args):
from MAVProxy.modules.lib import mp_menu
mp_menu.MPMenuConfirmDialog(question, callback=self.mpstate.functions.process_stdin, args=command)

def complete_available_modes(self, text):
return self.available_modes()

def available_modes(self):
if self.master is None:
print('No mode mapping available')
Expand Down