blob: 6f71459b71b77e0d2b09987d9b47511b141748c0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# Copyright (C) 2011-2019 Patrick Totzke <patricktotzke@gmail.com>
# This file is released under the GNU GPL, version 3 or a later revision.
# For further details see the COPYING file
import logging
from alot import commands
from .completer import Completer
class CommandNameCompleter(Completer):
"""Completes command names."""
def __init__(self, mode):
"""
:param mode: mode identifier
:type mode: str
"""
self.mode = mode
super().__init__()
def complete(self, original, pos):
commandprefix = original[:pos]
logging.debug('original="%s" prefix="%s"', original, commandprefix)
cmdlist = commands.COMMANDS['global'].copy()
cmdlist.update(commands.COMMANDS[self.mode])
matching = [t for t in cmdlist if t.startswith(commandprefix)]
return [(t, len(t)) for t in matching]
|