コード例 #1
0
def _InitDefaultCompletions(ex, complete_builtin, comp_lookup):
    # register builtins and words
    complete_builtin(['-E', '-A', 'command'])
    # register path completion
    # Add -o filenames?  Or should that be automatic?
    complete_builtin(['-D', '-A', 'file'])

    # TODO: Move this into demo/slow-completion.sh
    if 1:
        # Something for fun, to show off.  Also: test that you don't repeatedly hit
        # the file system / network / coprocess.
        A1 = completion.TestAction(['foo.py', 'foo', 'bar.py'])
        A2 = completion.TestAction(['m%d' % i for i in xrange(5)], delay=0.1)
        C1 = completion.UserSpec([A1, A2], [], [], lambda candidate: True)
        comp_lookup.RegisterName('slowc', {}, C1)
コード例 #2
0
ファイル: completion_test.py プロジェクト: tyxieblub/oil
from core import alloc
from core import completion  # module under test
from core import comp_ui
from core import test_lib
from core import util
from core.meta import runtime_asdl, syntax_asdl

from frontend import parse_lib
from osh import state
from testdata.completion import bash_oracle

assign_op_e = syntax_asdl.assign_op_e
value_e = runtime_asdl.value_e
log = util.log

A1 = completion.TestAction(['foo.py', 'foo', 'bar.py'])
U1 = completion.UserSpec([A1], [], [], lambda candidate: True)

BASE_OPTS = {}

mem = state.Mem('', [], {}, None)

FIRST = completion.TestAction(['grep', 'sed', 'test'])
U2 = completion.UserSpec([FIRST], [], [], lambda candidate: True)


def MockApi(line):
    """Match readline's get_begidx() / get_endidx()."""
    return completion.Api(line=line, begin=0, end=len(line))