Пример #1
0
 def __init__(self, *args, **kwargs):
     self.spec = _("[<user> at] <server>")
     self.extras = [
         Choice('user', {_("me"): "nihlaeth"}),
         Choice(
             'server', {
                 _("cerridwen"): "cerridwen",
                 _("yemanja"): "yemanja",
                 _("iris"): "iris",
                 _("aine"): "aine",
                 _("dayea"): "dayea",
                 _("brighid"): "brighid",
                 _("freya"): "freya",
                 _("arthemis"): "arthemis",
                 _("morrighan"): "morrighan",
                 _("epona"): "epona",
                 _("athena"): "athena",
                 _("echo"): "echo",
                 _("hera"): "hera",
                 _("hera boot"): "heraboot",
                 _("pele"): "pele",
                 _("eileen"): "eileen",
                 _("inanna"): "inanna.humanity4all.nl",
                 _("anubis"): "anubis.humanity4all.nl",
             })
     ]
     CompoundRule.__init__(self, *args, **kwargs)
Пример #2
0
class Basics(dragonfly.MappingRule):
    mapping = basics_mapping
    extras = [
        Dictation('text'),
        IntegerRef('n', 1, 999),
        IntegerRef('n2', 1, 999),
        Choice("pressKey", pressKeyMap),
        Choice("surroundChar", surroundCharsMap),
    ]
Пример #3
0
class ExtraSymbolsFullGridRule(CompoundRule):
    spec = "<symbol1> [<mouseAction>]"
    extras = [
        Choice("symbol1", charsDict1D_X),
        Choice("mouseAction", mouseActions),
    ]

    def _process_recognition(self, node, extras):
        doRecognitionLevel(node, extras, "Full")
Пример #4
0
class ExtraSymbolsMiniGridRule(CompoundRule):
    spec = "<symbol1> [<symbol2>] [<mouseAction>]"
    extras = [
        Choice("symbol1", charsDict2D_X),
        Choice("symbol2", charsDict2D_Y),
        Choice("mouseAction", mouseActions),
    ]

    def _process_recognition(self, node, extras):
        print u"node", node
        print u"extras", extras
        doRecognitionLevel(node, extras, "Mini")
Пример #5
0
 def __init__(self, *args, **kwargs):
     self.mapping = {
         _('open terminal'): Key('w-t'),
         _('workspace <n>'): Function(go_to_workspace),
         _('move [to] workspace <n>'): Function(move_to_workspace),
         _('window <direction>'): Key('w-%(direction)s'),
         _('move window [to the] <direction>'): Key('sw-%(direction)s'),
         _("fullscreen"): Key("w-f"),
         _("tabbed layout"): Key("w-w"),
         _("tiling layout"): Key("w-e"),
         _("stacking layout"): Key("w-s"),
         _("kill focused window"): Key("ws-q"),
         _("horizontal split"): Key("w-h"),
         _("vertical split"): Key("w-v"),
         _("toggle floating"): Key("ws-space"),
         _("focus floating"): Key("w-space"),
         _("reload i3 config file"): Key("ws-c"),
         _("restart i3 in place"): Key("ws-r"),
         _("I'm really sure I want to exit i3"): Key("ws-e"),
         _("resize mode"): Key("w-r"),
         _("invert screen rotation"): Key("ws-a"),
         _("reset screen rotation"): Key("ws-n"),
         _("(display|show) window info"): Key("ws-t"),
     }
     self.extras = [
         IntegerRef('n', 1, 13),
         Choice(
             'direction', {
                 _('left'): 'left',
                 _('right'): 'right',
                 _('up'): 'up',
                 _('down'): 'down'
             }),
     ]
     MappingRule.__init__(self, *args, **kwargs)
Пример #6
0
class MouseActionGridRule(CompoundRule):
    spec = "<mouseAction>"
    extras = [
        Choice("mouseAction", mouseActions),
    ]

    def _process_recognition(self, node, extras):
        doRecognitionLevel(node, extras, "Action")
Пример #7
0
class KeystrokeRule(MappingRule):
    mapping = mapping
    extras = [
        Integer("n", 1, 100),
        Dictation("text"),
        Dictation("text2"),
        Choice("char", specialCharMap),
        Choice("letters", letterMap),
#        Choice("modifier1", modifierMap),
#        Choice("modifier2", modifierMap),
#        Choice("modifierSingle", singleModifierMap),
#        Choice("pressKey", pressKeyMap),
        Choice("abbreviation", abbreviationMap),
    ]
    defaults = {
        "n": 1,
	"text": "",
    }
Пример #8
0
class MouseButtonRule(CompoundRule):
    spec = "<mouseAction> [<repetitions>]"
    extras = [
        Choice("mouseAction", mouseActions),
        Choice("repetitions", smallNumbers),
    ]
    defaults = {"repetitions": 1}

    def value(self, node):
        # This file is imported by "_all.py" and needs to return something that has an "execute()" function.
        # But remote mouse actions don't have an "execute()" function, and if we directly perform mouse actions here,
        # they will get executed before the rest of the actions.
        # To support our mouse grid modes, we want the mouse action to happen at the end of the sequence, so the
        # user can move the mouse cursor first then click the mouse after the move.
        # So we'll do nothing in "value()", but we'll get "_all.py" to call "possibleMouseAction()" at the end of
        # the sequence.
        #print "MouseButtonRule is saving the words", node.words(), "to check for mouse button actions later."
        #self.words = node.words()
        return Text()
Пример #9
0
class KeystrokeRule(MappingRule):
    exported = False
    mapping = grammarCfg.cmd.map
    extras = [
        IntegerRef("n", 1, 101),
        IntegerRef("num", 0, 101),
        IntegerRef("digit", 0, 10),
        IntegerRef("digit2", 0, 10),
        Dictation("text"),
        #Dictation("text2"),
        Choice("char", specialCharMap),
        Choice("letters", letterMapBothCases),
        #Choice("modifier1", modifierMap),
        #Choice("modifier2", modifierMap),
        #Choice("modifierSingle", singleModifierMap),
        #Choice("windowChars", windowCharMap),
    ]
    defaults = {
        "n": 1,
    }
Пример #10
0
    def __init__(self, *args, **kwargs):
        self.spec = _("<operator> "
                      "(<line>|[to] "
                      "(<motion>|<operatormotion>) "
                      "[<numbers>] "
                      "[<mode> mode])")
        self.extras = [
            Choice(name='operator',
                   choices={
                       _('change'): Key('c'),
                       _('delete'): Key('d'),
                       _('yank'): Key('y'),
                       _('swap case'): Key('g,tilde'),
                       _('make lowercase'): Key('g,u'),
                       _('make uppercase'): Key('g,s-u'),
                       _('filter'): Key('exclamation'),
                       _('C filter'): Key('equal'),
                       _('text formatting'): Key('g,q'),
                       _('rotation 13 encoding'): Key('g,question'),
                       _('shift right'): Key('rangle'),
                       _('shift left'): Key('langle'),
                       _('define fold'): Key('z,f'),
                       _('call function'): 'g,at'
                   }),
            Literal(name='line', text=_('line')),
            Repetition(name='numbers',
                       child=RuleRef(rule=Number()),
                       min=0,
                       max=3),
            RuleRef(name='motion', rule=MotionRule()),
            RuleRef(name='operatormotion', rule=VisualMotionRule()),
            Choice(name='mode',
                   choices={
                       _("character"): Key("v"),
                       _("line"): Key("s-v"),
                       _("block"): Key("c-v"),
                   })
        ]

        CompoundRule.__init__(self, *args, **kwargs)
Пример #11
0
class KeystrokeRule(MappingRule):
    exported = False
    mapping = grammarCfg.cmd.map
    extras = [
        IntegerRef("n", 1, 100),
        Dictation("text"),
        Dictation("text2"),
        Choice("char", specialCharMap),
        Choice("letters", letterMap),
        Choice("modifier1", modifierMap),
        Choice("modifier2", modifierMap),
        Choice("modifierSingle", singleModifierMap),
        Choice("pressKey", pressKeyMap),
        Choice("formatType", formatMap),
        Choice("abbreviation", abbreviationMap),
        Choice("reservedWord", reservedWord),
    ]
    defaults = {
        "n": 1,
    }
Пример #12
0
 def __init__(self, *args, **kwargs):
     # technically we should not accept uppercase chars here
     self.spec = _('press [<modifiers>] <character>')
     self.extras = [
         Repetition(name='modifiers',
                    child=Choice(name='modifier',
                                 choices={
                                     _('control'): 'c',
                                     _('shift'): 's',
                                     _('alt'): 'a',
                                     _('(command|super)'): 'w',
                                 }),
                    min=0,
                    max=4),
         RuleRef(name='character', rule=AnyCharacter())
     ]
     CompoundRule.__init__(self, *args, **kwargs)
Пример #13
0
class KeystrokeRule(MappingRule):
    exported = False
    mapping = grammarCfg.cmd.map
    extras = [
        IntegerRef("n", 1, 100),
        IntegerRef("num", 0, 1000000),
        Dictation("text"),
        Dictation("text2"),
        Choice("char", specialCharMap),
        Choice("letters", letterMap),
        Choice("modifier1", modifierMap),
        Choice("modifier2", modifierMap),
        Choice("modifierSingle", singleModifierMap),
        Choice("pressKey", pressKeyMap),
    ]
    defaults = {
        "n": 1,
    }
Пример #14
0
 def __init__(self,
              name=None,
              spec=None,
              extras=None,
              defaults=None,
              exported=False,
              context=None,
              default_formatting='snake'):
     if exported is not None:
         self.exported = exported
     if self.exported:
         self.spec = "<formatting> <dictation>"
     else:
         self.default_formatting = default_formatting
         self.spec = "[<formatting>] <dictation>"
     self.extras = [
         Choice(
             name='formatting',
             choices={
                 _("snake [case]"): "snake",  # snake_case
                 _("camel [case]"): "camel",  # CamelCase
                 _("mixed [case]"): "mixed",  # mixedCase
                 _("upper[case]"): "upper",  # UPPERCASE_STUFF
                 _("no case"): "nocase",  # lowercase text
                 _("sentence"): "sentence",  # Cap first letter
                 _("dictate"): "raw",  # raw dictation
             }),
         Dictation(name='dictation'),
     ]
     CompoundRule.__init__(self,
                           name=name,
                           spec=spec,
                           extras=extras,
                           defaults=defaults,
                           exported=exported,
                           context=context)
Пример #15
0
class CenterMouseRule(CompoundRule):
    spec = "center [<mouseAction>]"
    extras = [
        Choice("mouseAction", mouseActions),
    ]
    defaults = {
        # Set the default to -1 if you want "center" to just move the cursor,
        # or set it to 1 if you want "center" to perform a left mouse click by default.
        "mouseAction": 1,
    }

    def _process_recognition(self, node, extras):
        mouseAction = extras["mouseAction"]

        print "Centering the mouse."
        try:
            mouseServer.moveToCenter()
        except:
            print "Couldn't access the mouse grid server, is it running?"
            return

        # Possibly press a mouse button action
        action = int(mouseAction)
        if action >= 0:
            repetitions = 1
            # For the special case of moving the mouse wheel,
            # set the repetition to be a large number, so the user doesn't have to keep repeating it so many times.
            # Asking for a repetition of 0 gets mapped to a scroll of 1.
            if action == 4 or action == 5:  # Mouse wheel up & down button codes are 4 and 5.
                repetitions = repetitions * 3 + 1  # Set the amount to scroll

            print "Calling clickMouseGrid(%d) on the server" % (action)
            # Run our aenea plugin script that moves and clicks the mouse in Linux.
            for i in range(repetitions):
                pid = aenea.communications.server.clickMouseGrid(action)
                time.sleep(0.01)
Пример #16
0
    _arrow_fnc_one_line()
    _esc()
    Key('s-4, a, lbrace, enter, rbrace').execute()
    _esc()
    Key('k, s-f, lparen, a').execute()


###

        
extras = [
    Integer("n", 0, 9999),
    Integer("n2", 0, 9999),
    Dictation('text'),
    Dictation('text2'),
    Choice("pressKey", pressKeyMap),
]

defaults = {
    "n": 1,
    "n2": 1,
}

class JavascriptRuleAppend(EscapeInsertRule):
    mapping = { 
        'con <text>': Function(_const_assign),
        'let <text>': Function(_let_assign),
	'air lie': Function(_arrow_fnc_one_line),
	'air': Function(_arrow_fnc),
	'funk [<text>]': Function(_func),
    }
Пример #17
0
class Basics(MappingRule):
    mapping = basics_mapping
    extras = [Choice("language", language_map)]
Пример #18
0
class SQL(dragonfly.MappingRule):
    mapping = sql_mapping
    extras = [Choice(
        'sqlKeyword',
        sql_map,
    )]
Пример #19
0
class NudgeMouseRule(CompoundRule):
    spec = "nudge <direction> [<distance>] [<mouseAction>]"
    extras = [
        Choice("mouseAction", mouseActions),
        Choice("direction", {                       # Allow to say either up or North
            "North":        1,
            "East":         2,
            "South":        3,
            "West":         4,
            "North East":   5,
            "South East":   6,
            "South West":   7,
            "North West":   8,
            "up":         1,
            "right":      2,
            "down":       3,
            "left":       4,
            "up right":   5,
            "down right": 6,
            "down left":  7,
            "up left":    8,
            }),
        Choice("distance", mostNumbers),
    ]
    defaults = {
        "mouseAction": -1,  # Don't click unless they ask for it
    }

    def _process_recognition(self, node, extras):
        direction = extras["direction"]
        mouseAction = extras["mouseAction"]

        # Figure out how much to move by
        distance = 7  # Default distance to nudge by
        try:
            distance = extras["distance"]
        except:
            pass

        print "Nudging the mouse in direction", direction, "by", distance
        try:
            if direction == 1:
                mouseServer.move_mouse_relative(0, -distance)
            elif direction == 2:
                mouseServer.move_mouse_relative(distance, 0)
            elif direction == 3:
                mouseServer.move_mouse_relative(0, distance)
            elif direction == 4:
                mouseServer.move_mouse_relative(-distance, 0)
            elif direction == 5:
                mouseServer.move_mouse_relative(distance, -distance)
            elif direction == 6:
                mouseServer.move_mouse_relative(distance, distance)
            elif direction == 7:
                mouseServer.move_mouse_relative(-distance, distance)
            elif direction == 8:
                mouseServer.move_mouse_relative(-distance, -distance)
        except:
            print "Couldn't access the mouse grid server, is it running?"
            return

        # Possibly press a mouse button action
        button_int = int(mouseAction)
        if button_int >= 0:
            print "Calling clickMouseGrid(%d) on the server" % (button_int)
            # Run our aenea plugin script that moves and clicks the mouse in Linux.
            pid = aenea.communications.server.clickMouseGrid(button_int)