summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpazz <patricktotzke@gmail.com>2011-07-22 20:02:32 +0100
committerpazz <patricktotzke@gmail.com>2011-07-22 20:02:32 +0100
commitf51175abbf0ef78209d6525c031a42d0ac706967 (patch)
treec8de9eb0ce79e1b3ec554c17ae47484240e14ec0
parent3575347978d060f0baa1369dc12496473f0c37cc (diff)
start with first completion when selecting account
-rw-r--r--alot/commands.py5
-rw-r--r--alot/ui.py4
-rw-r--r--alot/widgets.py5
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
diff --git a/alot/ui.py b/alot/ui.py
index a61c07d5..8bd198ad 100644
--- a/alot/ui.py
+++ b/alot/ui.py
@@ -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]