コード例 #1
0
def test_manual_context():
    Breathe.add_commands(CommandContext("test"), {
        "pizza": DoNothing(),
        "curry": DoNothing(),
    })
    # Fails because the rule isn't enabled yet
    with pytest.raises(MimicFailure):
        engine.mimic(["pizza", "pizza"])
    engine.mimic(["enable", "test"])
    engine.mimic(["pizza", "curry", "pizza"])
コード例 #2
0
def test_negated_context():
    Breathe.add_commands(~(CommandContext("america") | AppContext("england")),
                         {
                             "steak": DoNothing(),
                         })
    engine.mimic(["steak"])
    with pytest.raises(MimicFailure):
        engine.mimic(["steak"], executable="england")
    engine.mimic(["enable", "america"])
    with pytest.raises(MimicFailure):
        engine.mimic(["steak"])
コード例 #3
0
def test_global_top_level():
    Breathe.add_commands(
        None,
        {
            "<sequence1> are preferable to <sequence2>": DoNothing()
            + Exec("sequence1")
            + DoNothing()
            + Exec("sequence2")
        },
        extras=[CommandsRef("sequence1"), CommandsRef("sequence2", 3)],
        top_level=True,
    )
コード例 #4
0
def test_top_level_command_failure():
    Breathe.add_commands(
        AppContext("china"),
        {
            "not marked top level <sequence1> and <sequence2> [<n>]": DoNothing()
            + Exec("sequence1")
            + DoNothing()
            + Exec("sequence2")* Repeat("n")
        },
        extras=[CommandsRef("sequence1"), CommandsRef("sequence2", 2), IntegerRef("n", 1, 10, 1)],
        top_level=False,
    )
    assert len(Breathe.top_level_commands) == 2
コード例 #5
0
def test_manual_context_noccr():
    Breathe.add_commands(CommandContext("test") | AppContext("italy"),
                         {"spaghetti": DoNothing()},
                         ccr=False)
    # Loaded rule should be referencing the original
    # "test" context loaded above, which should already be
    # active
    engine.mimic(["spaghetti"])
    engine.mimic(["disable", "test"])
    with pytest.raises(MimicFailure):
        engine.mimic(["spaghetti"])
        engine.mimic(["pizza", "curry"])
    engine.mimic(["spaghetti"], executable="italy")
コード例 #6
0
def test_top_level_command():
    Breathe.add_commands(None, {"orange": DoNothing(), "grapefruit": DoNothing()})
    Breathe.add_commands(
        AppContext("notepad"), {"lemon": DoNothing(), "banana": DoNothing()}
    )
    Breathe.add_commands(
        AppContext("notepad"),
        {
            "fruit from <sequence1> and [<sequence2>] [<n>]": DoNothing()
            + Exec("sequence1")
            + DoNothing()
            + Exec("sequence2")* Repeat("n")
        },
        extras=[CommandsRef("sequence1"), CommandsRef("sequence2", 2), IntegerRef("n", 1, 10, 1)],
        top_level=True,
    )
コード例 #7
0
def test_top_level_command2():
    Breathe.add_commands(
        AppContext(title="chrome"), {"pear": DoNothing(), "grape": DoNothing()}
    )
コード例 #8
0
from breathe import Breathe, CommandContext

context = CommandContext("chrome")

Breathe.add_commands(
    # Commands will be active either when we are editing a python file
    # or after we say "enable python". pass None for the commands to be global.
    # context = AppContext(title=".py") | CommandContext("python"),
    context=AppContext('chrome') | context,
    mapping={
        'page back': Key('a-left'),
        'page forward': Key('a-right'),
        'page reload': Key('cs-r'),
        'search for <text>': Key('a-d/20') + Text('%(text)s'),
        'edit cut': Key('c-x'),
        'edit copy': Key('c-c'),
        'edit paste': Key('c-v'),
        'edit undo': Key('c-z'),
        'tab new': Key('c-t'),
        'tab close': Key('c-w'),
        '[<n>] link next': Key('tab:%(n)d'),
        '[<n>] link previous': Key('s-tab:%(n)d'),
        'link follow': Key('enter'),
        '[<n>] tab right': Key('c-pgdown:%(n)d'),
        '[<n>] tab left': Key('c-pgup:%(n)d'),
    },
    extras=[
        IntegerRef("n", 1, 20, default=1),
        Dictation("text", default=""),
    ])
コード例 #9
0
    "r": "r",
    "t": "t",
    "y": "y",
    "u": "u",
    "i": "i",
}

Breathe.add_commands(
    # Commands will be active either when we are editing a python file
    # or after we say "enable python". pass None for the commands to be global.
    # context = AppContext(title=".py") | CommandContext("python"),
    context=context,
    mapping={
        'grade <n>': Key('%(n)d'),
        'grade <n> correct': Text('%(n)dq'),
        'grade <n> wrong': Text('%(n)dw'),
        'grade <qwerty>': Key('%(qwerty)s'),
        'problem next': Key('.'),
        'problem previous': Key(','),
        'next page': Key('k'),
        'previous page': Key('j'),
        'next ungraded': Key('z'),
        'next exam': Key('right'),
        'previous exam': Key('left'),
    },
    extras=[
        IntegerRef("n", 1, 10, default=1),
        Dictation("text", default=""),
        Choice('qwerty', querty_alphabet),
    ])
コード例 #10
0
Breathe.add_commands(
    # Commands will be active either when we are editing a python file
    # or after we say "enable python". pass None for the commands to be global.
    # context = AppContext(title=".py") | CommandContext("python"),
    context=AppContext('codium') | AppContext('code') | context,
    mapping={
        'file save': Key('c-s'),
        'file open': Key('c-o'),

        '[<n>] edit indent': Key('c-]:%(n)d'),
        '[<n>] edit out dent': Key('c-[:%(n)d'),

        'edit cut': Key('c-x'),
        'edit copy': Key('c-c'),
        'edit paste': Key('c-v'),
        'edit undo': Key('c-z'),

        'edit comment': Key(r'c-slash'),

        'format document': Key('cs-i'),
        'toggle problem view': Key('cs-m'),
        'problem next': Key('F8'),

        '[<n>] tab right': Key('c-pgdown:%(n)d'),
        '[<n>] tab left': Key('c-pgup:%(n)d'),

        '[<n>] move tab right': Key('cs-pgdown:%(n)d'),
        '[<n>] move tab left': Key('cs-pgup:%(n)d'),

        'find <text>': Key('c-f/20') + Text('%(text)s'),
        'match next': Key('enter'),
        'match previous': Key('s-enter'),
        'go to line [<NNN>]': Key('c-g') + Text('%(NNN)d\n'),
    },
    extras = [
        IntegerRef("n", 1, 20, default=1),
        IntegerRef("NNN", 1, 1000, default=1),
        Dictation("text", default=""),
    ]
)