Exemple #1
0
    def _create_repeat_rule(self, rule):
        ORIGINAL, SEQ, TERMINAL = "original", "caster_base_sequence", "terminal"
        alts = [RuleRef(rule=rule)]  #+[RuleRef(rule=sm) for sm in selfmod]
        single_action = Alternative(alts)
        print(settings.MAGNETO)
        max = settings.MAGNETO["performance"]["max_ccr_repetitions"]
        sequence = Repetition(single_action, min=1, max=max, name=SEQ)
        original = Alternative(alts, name=ORIGINAL)
        terminal = Alternative(alts, name=TERMINAL)

        class RepeatRule(CompoundRule):
            spec = "[<" + ORIGINAL + "> original] [<" + SEQ + ">] [terminal <" + TERMINAL + ">]"
            extras = [sequence, original, terminal]

            def _process_recognition(self, node, extras):
                original = extras[ORIGINAL] if ORIGINAL in extras else None
                sequence = extras[SEQ] if SEQ in extras else None
                terminal = extras[TERMINAL] if TERMINAL in extras else None
                if original is not None: original.execute()
                if sequence is not None:
                    for action in sequence:
                        action.execute()
                if terminal is not None: terminal.execute()

        return RepeatRule(name="Repeater" + MergeRule.get_merge_name())
Exemple #2
0
 def __init__(self, *args, **kwargs):
     self.spec = _("command <command>")
     self.extras = [
         Alternative(name='command',
                     children=(RuleRef(rule=SimpleCommand()), ))
     ]
     CompoundRule.__init__(self, *args, **kwargs)
Exemple #3
0
 def __init__(self, *args, **kwargs):
     self.spec = _('open process [<cmd>]')
     self.extras = [
         Alternative(name='cmd',
                     children=(
                         RuleRef(name='ssh', rule=SshRule()),
                         RuleRef(name='command', rule=Command()),
                     )),
     ]
     CompoundRule.__init__(self, *args, **kwargs)
 def __init__(self, *args, **kwargs):
     self.spec = '<character>'
     self.extras = [
         Alternative(name='character',
                     children=(RuleRef(rule=UppercaseCharacter()),
                               RuleRef(rule=LowercaseCharacter()),
                               RuleRef(rule=Number()),
                               RuleRef(rule=Symbol())))
     ]
     CompoundRule.__init__(self, *args, **kwargs)
Exemple #5
0
    def __init__(self, *args, **kwargs):
        self.spec = _("<cmd>")
        self.extras = [
            Alternative(name='cmd',
                        children=(
                            RuleRef(name='motion_operator',
                                    rule=MotionOperatorRule()),
                            RuleRef(name='motion', rule=MotionRule()),
                            RuleRef(name='normal', rule=VimNormalRule()),
                            RuleRef(name='number', rule=Number()),
                        ))
        ]

        CompoundRule.__init__(self, *args, **kwargs)
Exemple #6
0
        Choice("modifier1", modifierMap),
        Choice("modifier2", modifierMap),
        Choice("modifierSingle", singleModifierMap),
        Choice("pressKey", pressKeyMap),
        Choice("formatType", formatMap),
        Choice("abbreviation", abbreviationMap),
        Choice("reservedWord", reservedWord),
    ]
    defaults = {
        "n": 1,
    }


alternatives = []
alternatives.append(RuleRef(rule=KeystrokeRule()))
single_action = Alternative(alternatives)


sequence = Repetition(single_action, min=1, max=16, name="sequence")


class RepeatRule(CompoundRule):
    # Here we define this rule's spoken-form and special elements.
    spec = "<sequence> [[[and] repeat [that]] <n> times]"
    extras = [
        sequence,  # Sequence of actions defined above.
        IntegerRef("n", 1, 100),  # Times to repeat the sequence.
    ]
    defaults = {
        "n": 1,  # Default repeat count.
    }
Exemple #7
0
        'dynamic multiedit',
        aenea.vocabulary.register_dynamic_vocabulary('multiedit')
        ),
    DictListRef(
        'static multiedit',
        DictList(
            'static multiedit',
            aenea.vocabulary.get_static_vocabulary('multiedit')
            ),
        ),
    RuleRef(rule=DynamicCountRule(name='aoeuazzzxt'), name='aouxxxazsemi'),
    RuleRef(rule=StaticCountRule(name='aioeuazzzxt'), name='aouxxxazsemii'),
    format_rule,
    ]

single_action = Alternative(alternatives)

# Can only be used as the last element
alphabet_mapping = dict((key, Text(value))
                        for (key, value) in aenea.misc.LETTERS.iteritems())
numbers_mapping = dict((key, Text(value))
                        for (key, value) in aenea.misc.DIGITS.iteritems())
alphanumeric_mapping = dict((key, Text(value))
                            for (key, value) in aenea.misc.ALPHANUMERIC.iteritems())

alphabet_rule = Sequence([Literal('letters'), Repetition(RuleRef(name='x', rule=MappingRule(name='t', mapping=alphabet_mapping)), min=1, max=20)])
numbers_rule = Sequence([Literal('digits'), Repetition(RuleRef(name='y', rule=MappingRule(name='u', mapping=numbers_mapping)), min=1, max=20)])
alphanumeric_rule = Sequence([Literal('alphanumeric'), Repetition(RuleRef(name='z', rule=MappingRule(name='v', mapping=alphanumeric_mapping)), min=1, max=20)])
finishes = [alphabet_rule, numbers_rule, alphanumeric_rule]

# Second we create a repetition of keystroke elements.