diff options
author | pazz <patricktotzke@gmail.com> | 2011-07-22 20:02:32 +0100 |
---|---|---|
committer | pazz <patricktotzke@gmail.com> | 2011-07-22 20:02:32 +0100 |
commit | f51175abbf0ef78209d6525c031a42d0ac706967 (patch) | |
tree | c8de9eb0ce79e1b3ec554c17ae47484240e14ec0 | |
parent | 3575347978d060f0baa1369dc12496473f0c37cc (diff) |
start with first completion when selecting account
-rw-r--r-- | alot/commands.py | 5 | ||||
-rw-r--r-- | alot/ui.py | 4 | ||||
-rw-r--r-- | alot/widgets.py | 5 |
3 files changed, 8 insertions, 6 deletions
diff --git a/alot/commands.py b/alot/commands.py index 2357db21..6324988a 100644 --- a/alot/commands.py +++ b/alot/commands.py @@ -386,13 +386,12 @@ class ComposeCommand(Command): elif len(accounts) == 1: a = accounts[0] else: - # TODO: completer for accounts cmpl = AccountCompleter() - fromaddress = ui.prompt(prefix='From>',completer=cmpl) + fromaddress = ui.prompt(prefix='From>', completer=cmpl, tab=1) validaddresses = [a.address for a in accounts] + [None] while fromaddress not in validaddresses: ui.notify('couldn\'t find a matching account. (<esc> cancels)') - fromaddress = ui.prompt(prefix='From>',completer=cmpl) + fromaddress = ui.prompt(prefix='From>', completer=cmpl) if not fromaddress: ui.notify('canceled') return @@ -68,11 +68,13 @@ class UI: """ raise urwid.ExitMainLoop() - def prompt(self, prefix='>', text=u'', completer=None): + def prompt(self, prefix='>', text=u'', tab=0, completer=None): self.logger.info('open prompt') leftpart = urwid.Text(prefix, align='left') if completer: editpart = CompleteEdit(completer, edit_text=text) + for i in range(tab): + editpart.keypress((0,), 'tab') else: editpart = urwid.Edit(edit_text=text) both = urwid.Columns( diff --git a/alot/widgets.py b/alot/widgets.py index 78654899..b1d855f1 100644 --- a/alot/widgets.py +++ b/alot/widgets.py @@ -130,13 +130,14 @@ class TagWidget(urwid.Text): class CompleteEdit(urwid.Edit): - def __init__(self, completer, edit_text=u''): + # TODO: defaulttext: visible in darker font, tpe it with tab/enter + def __init__(self, completer, edit_text=u'', **kwargs): self.completer = completer if not isinstance(edit_text, unicode): edit_text = unicode(edit_text, errors='replace') self.start_completion_pos = len(edit_text) self.completion_results = None - urwid.Edit.__init__(self, edit_text=edit_text) + urwid.Edit.__init__(self, edit_text=edit_text, **kwargs) def keypress(self, size, key): cmd = command_map[key] |