Пример #1
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)
Пример #2
0
class RubyNewLineRule(EscapeNewLineRule):
    mapping = {
	 'meth [<text>]': Function(_method),
	 'class [<text>] [parent <text2>]': Function(_class),
	 'ins [<text>] [nine <text2>]': Function(_instance),
    }
    extras = extras
    defaults = defaults
Пример #3
0
class RubyRuleAppend(EscapeInsertRule):
    mapping = { 
        'sap': Function(_block_one_line(".map")),
        'map': Function(_block(".map")),
        'funk [<text>]': Function(_call),
        'punk [<text>]': Function(_call_implicit)
    }
    extras = extras
    defaults = defaults
Пример #4
0
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),
    }
    extras = extras
    defaults = defaults
Пример #5
0
    def __init__(self,
                 name=None,
                 mapping=None,
                 extras=None,
                 defaults=None,
                 exported=None,
                 ID=None,
                 composite=None,
                 compatible=None,
                 mcontext=None,
                 mwith=None):

        self.ID = ID if ID is not None else MergeRule._get_next_id()
        self.compatible = {} if compatible is None else compatible
        '''composite is the IDs of the rules which this MergeRule is composed of: '''
        self.composite = composite if composite is not None else set([self.ID])
        self._mcontext = self.__class__.mcontext
        if self._mcontext is None: self._mcontext = mcontext
        self._mwith = self.__class__.mwith
        if self._mwith is None: self._mwith = mwith

        if mapping is not None:
            mapping["display available commands"] = Function(
                lambda: self._display_available_commands())

        MappingRule.__init__(self, name, mapping, extras, defaults, exported)
Пример #6
0
class StartMouseGridRule(MappingRule):
    mapping = {
        # Commands for starting the mouse grid. The grid might only cover part of a large screen,
        # or you might have multiple screens, so we have commands to show grids in multiple locations.
        "sink": Function(showMouseGridY0),  # Slide down or up
        "glide": Function(showMouseGridX0),  # Slide left or right
        "sled": Function(showMouseGridX0),  # Slide to the left screen
        "sliddle": Function(showMouseGridX1),  # Slide to the inner screen
        "slight": Function(showMouseGridX2),  # Slide to the right screen
        "grid": Function(showMouseGridG0),  # 2D grid
        "beam": Function(clickMouseGridG0),  # 2D grid + left mouse click
        "ladder":
        Function(showMouseGridX0Y0
                 ),  # Show a sequence of 2 grids moving in a single direction
    }
Пример #7
0
class FormatRule(EscapeInsertRule):
    mapping = {# Format dictated words
	"snake [<text>]": Function(snake_case_text),
	"since [<text>]": Function(sentence),
	"upper [<text>]": Function(uppercase_text),
	"dashy [<text>]": Function(dash),
	"camel [<text>]": Function(camel_case_text),
	"dotty [<text>]": Function(dot),
	"low [<text>]": Function(lowercase_text)
    }
    defaults = {
        "n": 1,
	"text": "",
    }
    extras = [Dictation("text")]
Пример #8
0
        'gope [<n>]':
        Key('pgup:%(n)d'),
        'drop [<n>]':
        Key('pgdown:%(n)d'),
        'lope [<n>]':
        Key('c-left:%(n)d'),
        '(yope|rope) [<n>]':
        Key('c-right:%(n)d'),
        '(hill scratch|hatch) [<n>]':
        Key('c-backspace:%(n)d'),
        'hexadecimal':
        Text("0x"),
        'suspend':
        Key('c-z'),
        'word <text>':
        Function(handle_word),
        'number <num>':
        Text("%(num)d"),
        'change <text> to <text2>':
        Key("home, slash") + Text("%(text)s") + Key("enter, c, e") +
        Text("%(text2)s") + Key("escape"),

        # Text corrections.
        "(add|fix) missing space":
        Key("c-left/3, space, c-right/3"),
        "(delete|remove) (double|extra) (space|whitespace)":
        Key("c-left/3, backspace, c-right/3"),  # @IgnorePep8
        "(delete|remove) (double|extra) (type|char|character)":
        Key("c-left/3, del, c-right/3"),  # @IgnorePep8
        # Microphone sleep/cancel started dictation.
        "[<text>] (stupefy|go to sleep|cancel and sleep) [<text2>]":
Пример #9
0
class JavascriptNewLineRule(EscapeNewLineRule):
    mapping = {
	 'class [<text>] [parent <text2>]': Function(_class),
    }
    extras = extras
    defaults = defaults
Пример #10
0
 "right <n> (word|words)": Key("c-right/3:%(n)d/10"),
 "home": Key("home"),
 "end": Key("end"),
 "doc home": Key("c-home/3"),
 "doc end": Key("c-end/3"),
 # Functional keys.
 "space": release + Key("space"),
 "space [<n>]": release + Key("space:%(n)d"),
 "enter [<n>]": release + Key("enter:%(n)d"),
 "tab [<n>]": Key("tab:%(n)d"),
 "delete [<n>]": Key("del/3:%(n)d"),
 "delete [this] line": Key("home, s-end, del"),  # @IgnorePep8
 "backspace [<n>]": release + Key("backspace:%(n)d"),
 "application key": release + Key("apps/3"),
 "win key": release + Key("win/3"),
 "paste [that]": Function(paste_command),
 "copy [that]": Function(copy_command),
 "cut [that]": release + Key("c-x/3"),
 "select all": release + Key("c-a/3"),
 "[(hold|press)] alt": Key("alt:down/3"),
 "release alt": Key("alt:up"),
 "[(hold|press)] shift": Key("shift:down/3"),
 "release shift": Key("shift:up"),
 "[(hold|press)] control": Key("ctrl:down/3"),
 "release control": Key("ctrl:up"),
 "release [all]": release,
 # Closures.
 "angle brackets": Key("langle, rangle, left/3"),
 "brackets": Key("lbracket, rbracket, left/3"),
 "braces": Key("lbrace, rbrace, left/3"),
 "parens": Key("lparen, rparen, left/3"),
Пример #11
0
    "javascript": get_javascript_grammar()
}


def clear_mode():
    for _, grammar in language_map.iteritems():
        grammar.disable()


def switch_mode(language):
    clear_mode()
    language.enable()


basics_mapping = {
    'lang <language>': Function(switch_mode),
    'clear lang': Function(clear_mode),
}


class Basics(MappingRule):
    mapping = basics_mapping
    extras = [Choice("language", language_map)]


generic_grammar.add_rule(Basics())
generic_grammar.load()

# Start with no modes active
for _, grammar in language_map.iteritems():
    grammar.load()
class jideaRule(MappingRule):
    mapping = aenea.configuration.make_grammar_commands('jidea', {

        "all actions": Key("cs-a"),
        # Code execution.
        "run app": Key("s-f10"),
        "re-run app": Key("c-f5"),
        "run test": Key("cs-f10"),
        "stop running": Key("c-f2"),

        # Code navigation.
        "navigate to class <text>": Key("c-n") + Pause("30") + Function(format.pascal_case_text) + Pause("30") + Key(
            "enter"),
        "navigate to class chooser <text>": Key("c-n") + Pause("30") + Function(format.pascal_case_text) + Pause("30"),
        "navigate to file <text>": Key("cs-n") + Pause("30") + Function(format.camel_case_text) + Pause("30") + Key(
            "enter"),
        "navigate to file chooser <text>": Key("cs-n") + Pause("30") + Function(format.camel_case_text) + Pause("30"),
        "navigate to symbol <text>": Key("cas-n") + Pause("30") + Function(format.camel_case_text) + Pause("30") + Key(
            "enter"),
        "navigate to symbol chooser <text>": Key("cas-n") + Pause("30") + Function(format.camel_case_text) + Pause(
            "30"),
        "go to declaration": Key("c-b"),
        "go to implementation": Key("ca-b"),
        "go to super": Key("c-u"),
        "go to (class|test)": Key("cs-t"),
        "go back": Key("a-left"),

        # Project settings.
        "go to project window": Key("a-1"),
        "go to module settings": Key("f4"),
        "go to [project] settings": Key("ca-s"),
        "synchronize files": Key("ca-y"),

        # Terminal.
        "run terminal": Key("a-f12"),

        # Search.
        "find in path": Key("cs-f"),
        "find usages": Key("a-f7"),
        "find <text>": Key("c-f") + Text('%(text)s'),
        "replace <text>": Key("c-r") + Text('%(text)s'),

        # Edit.
        "save [file|all]": Key("c-s"),

        # Code.
        "show intentions": Key("a-enter"),
        "accept choice": Key("c-enter"),
        "go to line": Key("c-g"),
        "go to line <n>": Key("c-g/25") + Text("%(n)d") + Key("enter"),
        "[go to] start of line": Key("home"),
        "[go to] end of line": Key("end"),
        "down": Key("down"),

        # Window handling.
        "tab foo": Key("c-tab"),
        "tab bar": Key("cs-tab"),
        "close tab": Key("c-f4"),

        # Version control.
        "show diff": Key("c-d"),

        # Refactoring.
        "(refactor|re-factor) (this|choose)": Key("cas-t"),
        "(refactor|re-factor) rename": Key("s-f6"),
        "(refactor|re-factor) change signature": Key("c-f6"),
        "(refactor|re-factor) move": Key("f6"),
        "(refactor|re-factor) copy": Key("f5"),
        "(refactor|re-factor) safe delete": Key("a-del"),
        "(refactor|re-factor) extract variable": Key("ca-v"),
        "(refactor|re-factor) extract constant": Key("ca-c"),
        "(refactor|re-factor) extract field": Key("ca-f"),
        "(refactor|re-factor) extract parameter": Key("ca-p"),
        "(refactor|re-factor) extract method": Key("ca-m"),
        "(refactor|re-factor) (in line|inline)": Key("ca-n"),

        # Custom key mappings.
        "(run SSH session|run SSH console|run remote terminal|run remote console)": Key("a-f11/25, enter"),

        #debug

    })

    extras = [
        Dictation("text"),
        IntegerRef("n", 1, 50000)
    ]
Пример #13
0
class MouseCancelRule(MappingRule):
    mapping = {
        "cancel":    Function(cancelMouseGrid),
    }
Пример #14
0
 "(change (directory|dir)|C D) <text>": Text("cd %(text)s"),
 "[press] control break": Key("ctrl:down, c/10, ctrl:up"),
 "(copy|C P)": Text("cp "),
 "(copy|C P) recursive": Text("cp -r "),
 "copy terminal": Key("cs-c/3"),
 "(change mode)|C H mod": Text("chmod "),
 "(cron|cron tab|crontab) edit": Text("crontab -e") + Key("enter"),
 "(cron|cron tab|crontab) list": Text("crontab -l") + Key("enter"),
 "(cron|cron tab|crontab) reset": Text("crontab -r"),
 "diff": Text("diff "),
 "(D P K G|D package)": Text("dpkg "),
 "(D P K G|D package) list": Text("dpkg -l "),
 "exit": Text("exit"),
 "foreground": Text("fg "),
 "find process": Text("ps aux | grep -i "),
 "find process <text>": Text("ps aux | grep -i ") + Function(format.snake_case_text),
 "find": Text("find . -name "),
 "find <text>": Text("find . -name %(text)s"),
 "[go to] end of line": Key("c-e"),
 "[go to] start of line": Key("c-a"),
 "grep": Text("grep "),
 "grep invert": Text("grep -v "),
 "grep <text>": Text("grep %(text)s"),
 "grep invert <text>": Text("grep -v %(text)s"),
 "grep recursive": Text("grep -rn ") + Key("dquote/3, dquote/3") + Text(" *") + Key("left/3:3"),  # @IgnorePep8
 "grep recursive <text>": Text("grep -rn ") + Key("dquote/3") + Text("%(text)s") + Key("dquote/3") + Text(
     " *") + Key("left/3:3"),  # @IgnorePep8
 "history": Text("history "),
 "ifconfig": Text("ifconfig "),
 "(iptables|I P tables) list": Text("iptables -L"),
 "(iptables|I P tables) flush": Text("iptables -F"),
Пример #15
0
    #motions 
    'row [<n>]': Text('%(n)sG'),
    'jump': jump,
    'up   [<n>]': Key('k:%(n)d'),
    'down [<n>]': Key('j:%(n)d'),
    'left [<n>]': Key('h:%(n)d'),
    'right [<n>]': Key('l:%(n)d'),
    'jee-jee': Key('g, g'),
    'end-jee': Key('s-g'),

    'rinden [<n>]': Key('%(n), rangle, rangle'),
    'linden [<n>]': Key('%(n), langle, langle'),

    #line stuff
    'boop <n>': Function(goto_line) + Key("s-i"),
    'boop': Key("s-i"),

    'noop <n>': Function(goto_line) + Key("s-a, enter"),
    'noop': Key("s-a, enter"),
    'nope': Key("s-a"),
    'nope <n>': Function(goto_line) + Key("s-a"),
    'nope <n>': Function(goto_line) + Key("s-a"),
 
    'die': Key("d:2"),
    'dino': Key("s-d, a"),
    'diney': Key("0, s-d"),
    'diner <n>': Key("%(n)d, d:2"),
    'die <n>': Function(goto_line) + Key("d:2"),
    'die <n> (thru) <n2>': Function(delete_lines),
    'die till <pressKey>': Key("d, t, %(pressKey)s"),
Пример #16
0
        "visual line": Key("s-v"),
        "visual block": Key("c-v"),
        "doc save": Key("c-s"),
        "arrow": Text("->"),

        'gope [<n>]':  Key('pgup:%(n)d'),
        'drop [<n>]':  Key('pgdown:%(n)d'),

        'lope [<n>]':  Key('c-left:%(n)d'),
        '(yope|rope) [<n>]':  Key('c-right:%(n)d'),
        '(hill scratch|hatch) [<n>]': Key('c-backspace:%(n)d'),

        'hexadecimal': Text("0x"),
        'suspend': Key('c-z'),

        'word <text>': Function(handle_word),
        'number <num>': Text("%(num)d"),
        'change <text> to <text2>': Key("home, slash") + Text("%(text)s") + Key("enter, c, e") + Text("%(text2)s") + Key("escape"),

        # Text corrections.
        "(add|fix) missing space": Key("c-left/3, space, c-right/3"),
        "(delete|remove) (double|extra) (space|whitespace)": Key("c-left/3, backspace, c-right/3"),  # @IgnorePep8
        "(delete|remove) (double|extra) (type|char|character)": Key("c-left/3, del, c-right/3"),  # @IgnorePep8
        # Microphone sleep/cancel started dictation.
        "[<text>] (go to sleep|cancel and sleep) [<text2>]": Function(cancel_and_sleep),  # @IgnorePep8
    },
    namespace={
        "Key": Key,
        "Text": Text,
    }
)