Ejemplo n.º 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)
Ejemplo n.º 2
0
    def __init__(self, *args, **kwargs):
        self.mapping = {
            _("a word"): Key("a,w"),
            _("inner word"): Key("i,w"),
            _("a (big|cap) word"): Key("a,s-w"),
            _("inner (big|cap) word"): Key("i,s-w"),
            _("a sentence"): Key("a,s"),
            _("inner sentence"): Key("i,s"),
            _("a paragraph"): Key("a,p"),
            _("inner paragraph"): Key("i,p"),
            _("a bracket block"): Key("a,lbracket"),
            _("inner bracket block"): Key("i,lbracket"),
            _("a paren block"): Key("a,b"),
            _("inner paren block"): Key("i,b"),
            _("an angle block"): Key("a,langle"),
            _("inner angle block"): Key("i,langle"),
            _("a tag block"): Key("a,t"),
            _("inner tag block"): Key("i,t"),
            _("a curly block"): Key("a,s-b"),
            _("inner curly block"): Key("i,s-b"),
            _("a quoted string"): Key("a,dquote"),
            _("inner quoted string"): Key("i,dquote"),
        }

        MappingRule.__init__(self, *args, **kwargs)
Ejemplo n.º 3
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)
Ejemplo n.º 4
0
 def __init__(self, *args, **kwargs):
     self.mapping = {
         _('alpha'): Key('a'),
         _('bravo'): Key('b'),
         _('charlie'): Key('c'),
         _('delta'): Key('d'),
         _('echo'): Key('e'),
         _('foxtrot'): Key('f'),
         _('golf'): Key('g'),
         _('hotel'): Key('h'),
         _('india'): Key('i'),
         _('juliet'): Key('j'),
         _('kilo'): Key('k'),
         _('lima'): Key('l'),
         _('mike'): Key('m'),
         _('november'): Key('n'),
         _('oscar'): Key('o'),
         _('papa'): Key('p'),
         _('quebec'): Key('q'),
         _('romeo'): Key('r'),
         _('sierra'): Key('s'),
         _('tango'): Key('t'),
         _('uniform'): Key('u'),
         _('victor'): Key('v'),
         _('whiskey'): Key('w'),
         _('x-ray'): Key('x'),
         _('yankee'): Key('y'),
         _('zulu'): Key('z')
     }
     for char in string.uppercase:
         self.mapping[char] = Key(char.lower())
     MappingRule.__init__(self, *args, **kwargs)
Ejemplo n.º 5
0
 def __init__(self, *args, **kwargs):
     self.mapping = {
         _("swich user"): Text("su -"),
         _("change directory"): Text("cd "),
         _("foreground"): Text("fg"),
         _("list"): Text("ls"),
         _("list all"): Text("ls -la"),
         _("remove"): Text("rm "),
         _("remove directory"): Text("rm -r "),
         _("make directory"): Text("mkdir "),
         _("move"): Text("mv "),
         _("link"): Text("ln -s "),
         _("screen"): Text("screen"),
         _("attach screen"): Text("screen -x "),
         _("disk usage"): Text("du -c -h -d1"),
         _("disc find"): Text("df -h"),
         _("service"): Text("/etc/rc.d/rc."),
         _("process grep"): Text("pgrep "),
         _("process kill"): Text("pkill -KILL"),
         _("grep"): Text("grep "),
         _("web get"): Text("wget "),
         _("secure copy"): Text("scp "),
         _("secure copy directory"): Text("scp -r "),
         _("copy"): Text("cp"),
         _("copy directory"): Text("cp -r "),
         _("(edit|vim)"): Text("vim "),
         _("touch"): Text("touch "),
         _("python"): Text("python "),
         _("H top"): Text("htop"),
         _("kill"): Text("kill -sKILL "),
         _("alsa mixer"): Text("alsamixer"),
         _("Q jack"): Text("qjackctl"),
         _("Q synth"): Text("qsynth"),
         _("H G status"): Text("hg status"),
         _("H G add"): Text("hg add "),
         _("H G commit"): Text('hg commit -m "'),
         _("H G push"): Text("hg push"),
         _("H G log"): Text("hg log"),
         _("H G diff[erence]"): Text("hg diff"),
         _("H G clone"): Text("hg clone"),
         _("scan [first]"): Text("scan"),
         _("scan second"): Text("scan2"),
         _("git status"): Text("git status"),
         _("git add"): Text("git add "),
         _("git commit"): Text('git commit -m "'),
         _("git push"): Text("git push"),
         _("git log"): Text("git log"),
         _("git diff[erence]"): Text("git diff"),
         _("git clone"): Text("git clone "),
         _("untar"): Text("tar -xvf "),
         _("telegram"): Text("Telegram"),
         _('firefox'): Text('firefox'),
         _('print working directory'): Text('pwd'),
         _('password gorilla'): Text('passwordgorilla')
     }
     MappingRule.__init__(self, *args, **kwargs)
Ejemplo n.º 6
0
 def __init__(self, *args, **kwargs):
     self.mapping = {
         _('zero'): Key('0'),
         _('one'): Key('1'),
         _('two'): Key('2'),
         _('three'): Key('3'),
         _('four'): Key('4'),
         _('five'): Key('5'),
         _('six'): Key('6'),
         _('seven'): Key('7'),
         _('eight'): Key('8'),
         _('nine'): Key('9'),
     }
     MappingRule.__init__(self, *args, **kwargs)
Ejemplo n.º 7
0
 def __init__(self, *args, **kwargs):
     self.mapping = {
         _('(left|open) angle [bracket]'): Key('langle'),
         _('(left|open) [curly] brace'): Key('lbrace'),
         _('(left|open) [square] bracket'): Key('lbracket'),
         _('(left|open) paren'): Key('lparen'),
         _('(right|close) angle [bracket]'): Key('rangle'),
         _('(right|close) [curly] brace'): Key('rbrace'),
         _('(right|close) [square] bracket'): Key('rbracket'),
         _('(right|close) paren'): Key('rparen'),
         _('(ampersand|and)'): Key('ampersand'),
         _('apostrophe'): Key('apostrophe'),
         _('asterisk'): Key('asterisk'),
         _('at'): Key('at'),
         _('backslash'): Key('backslash'),
         _('backtick'): Key('backtick'),
         _('[vertical] bar'): Key('bar'),
         _('caret'): Key('caret'),
         _('colon'): Key('colon'),
         _('comma'): Key('comma'),
         _('dollar [sign]'): Key('dollar'),
         _('(dot|period|full stop)'): Key('dot'),
         _('double quote'): Key('dquote'),
         _('equal[s]'): Key('equal'),
         _('exclamation [point]'): Key('exclamation'),
         _('hash'): Key('hash'),
         _('hyphen'): Key('hyphen'),
         _('percent [sign]'): Key('percent'),
         _('plus [sign]'): Key('plus'),
         _('question[mark]'): Key('question'),
         _('semicolon'): Key('semicolon'),
         _('slash'): Key('slash'),
         _('tilde'): Key('tilde'),
         _('underscore'): Key('underscore'),
         _('space'): Key('space'),
         _('(enter|newline)'): Key('enter'),
         _('tab [key]'): Key('tab'),
     }
     MappingRule.__init__(self, *args, **kwargs)
Ejemplo n.º 8
0
    def __init__(self, *args, **kwargs):
        self.mapping = {
            _("interrupt"):
            Key("c-c"),
            _("display file name"):
            Key("c-g"),
            _("redraw screen"):
            Key("c-l"),
            _("suspend"):
            Key("c-z"),
            _("store and exit"):
            Key("s-z,s-z"),
            _("unsafe exit"):
            Key("s-z,s-q"),
            _("edit alternate"):
            Key("c-caret"),
            _("help"):
            Key("f1"),
            ###########
            #  jumps  #
            ###########
            _("next jumplist"):
            Key("c-i"),
            _("previous jumplist"):
            Key("c-o"),
            _("previous changelist"):
            Key("g,semicolon"),
            _("next changlist"):
            Key("g,comma"),
            ###########
            #  marks  #
            ###########
            _("set mark <char>"):
            Key("m,%(char)s"),
            _("set previous mark"):
            Key("m,apostrophe"),
            _("set (open|left) [square] bracket mark"):
            Key("m,lbracket"),
            _("set (close|right) [square] bracket mark"):
            Key("m,rbracket"),
            _("set (open|left) angle bracket mark"):
            Key("m,langle"),
            _("set (close|right) angle bracket mark"):
            Key("m,rangle"),
            ###############
            #  scrolling  #
            ###############
            _("scroll down half"):
            Key("c-d"),
            _("scroll extra up"):
            Key("c-e"),
            _("scroll forward screen"):
            Key("c-f"),
            _("scroll back screen"):
            Key("c-b"),
            _("scroll down"):
            Key("c-y"),
            _("scroll half up"):
            Key("c-u"),
            ###########
            #  modes  #
            ###########
            _("insert"):
            Key("i"),
            _("insertmode"):
            Key("c-backslash,c-g"),
            _("insert at start of line"):
            Key("s-i"),
            _("insert on newline"):
            Key("o"),
            _("insert on newline before"):
            Key("s-o"),
            _("append"):
            Key("a"),
            _("(cap|big) append"):
            Key("s-a"),
            _("substitute"):
            Key("s"),
            _("replace [mode]"):
            Key("s-r"),
            _("external [mode]"):
            Key("s-q"),
            _("visual"):
            Key("v"),
            _("visual line"):
            Key("s-v"),
            _("visual block"):
            Key("c-v"),
            ######################
            #  undo/redo/repeat  #
            ######################
            _("redo"):
            Key("c-r"),
            _("undo"):
            Key("u"),
            _("undo on line"):
            Key("s-u"),
            _("(repeat|period)"):
            Key("dot"),
            _("(at|repeat register <register>)"):
            Key("at,%(register)s"),
            _("repeat previous register repeat"):
            Key("at,at"),
            _("repeat ex"):
            Key("at,colon"),
            _("(ampersand|repeat [last] (search|replace))"):
            Key("ampersand"),
            _("(semicolon|repeat (find|tag))"):
            Key("semicolon"),
            _("(comma|reverse repeat (find|tag))"):
            Key("comma"),
            _("record <register>"):
            Key("q,%(register)s"),
            _("stop recording"):
            Key("q"),
            _("edit ex"):
            Key("q,colon"),
            _("edit search"):
            Key("q,slash"),
            _("edit backward search"):
            Key("q,question"),
            ##################
            #  text editing  #
            ##################
            _("addition"):
            Key("c-a"),
            _("subtract"):
            Key("c-x"),
            _("indent"):
            Key("c-rbracket"),
            _("join lines"):
            Key("s-j"),
            _("delete char[acter]"):
            Key("x"),
            _("backwards delete char[acter]"):
            Key("s-x"),
            _("replace <char>"):
            Key("r,%(char)s"),
            _("(tilde|switch case)"):
            Key("tilde"),
            ####################
            #  copy and paste  #
            ####################
            _("copy to end of line"):
            Key("s-c"),
            _("paste"):
            Key("p"),
            _("paste before"):
            Key("s-p"),
            _("register <register>"):
            Key("dquote,%(register)s"),
            _("diff get"):
            Key("d,o"),
            _("diff put"):
            Key("d,p"),
            ############
            #  search  #
            ############
            _("lookup keyword"):
            Key("s-k"),
            _("backward next"):
            Key("s-n"),
            _("next"):
            Key("n"),
            _("after <char>"):
            Key("t,%(char)s"),
            _("backward move after <char>"):
            Key("s-t,%(char)s"),
            _("tag older"):
            Key("c-t"),
            _("(hash|backward search)"):
            Key("hash"),
            _("(asterisk|forward search)"):
            Key("asterisk"),
            _("(slash|search)"):
            Key("slash"),
            _("(question [mark]|backward search)"):
            Key("question"),
            ############
            #  window  #
            ############
            _("window increase height"):
            Key("c-w,plus"),
            _("window decrease height"):
            Key("c-w,hyphen"),
            _("window increase width"):
            Key("c-w,rangle"),
            _("window decrease width"):
            Key("c-w,langle"),
            _("window equalise"):
            Key("c-w,equal"),
            _("window move (H|hotel|left)"):
            Key("c-w,s-h"),
            _("window move (J|juliet|down)"):
            Key("c-w,s-j"),
            _("window move (K|kilo|up)"):
            Key("c-w,s-k"),
            _("window move (L|lima|right)"):
            Key("c-w,s-l"),
            _("window preview"):
            Key("c-w,s-p"),
            _("window rotate up"):
            Key("c-w,s-r"),
            _("window move to [new] tab"):
            Key("c-w,s-t"),
            _("window previous"):
            Key("c-w,s-w"),
            _("window split and jump"):
            Key("c-w,rbracket"),
            _("window split and edit alternate"):
            Key("c-w,caret"),
            _("window set height"):
            Key("c-w,underscore"),
            _("window bottom"):
            Key("c-w,b"),
            _("window close"):
            Key("c-w,c"),
            _("window split and jump to definition"):
            Key("c-w,d"),
            _("window split and edit file"):
            Key("c-w,f"),
            _("window split edit file and jump"):
            Key("c-w,s-f"),
            # TODO: add c-w,g,] and c-w,g,}
            _("window tab and edit file"):
            Key("c-w,g,f"),
            _("window tab edit file and jump"):
            Key("c-w,g,s-f"),
            _("window (H|hotel|left)"):
            Key("c-w,h"),
            _("window split and jump to declaration"):
            Key("c-w,i"),
            _("window (J|juliet|down)"):
            Key("c-w,j"),
            _("window (K|kilo|up)"):
            Key("c-w,k"),
            _("window (L|lima|right)"):
            Key("c-w,l"),
            _("window new"):
            Key("c-w,n"),
            _("window only"):
            Key("c-w,o"),
            _("window last"):
            Key("c-w,p"),
            _("window rotate"):
            Key("c-w,r"),
            _("window split [horizontal]"):
            Key("c-w,s"),
            _("window top"):
            Key("c-w,t"),
            _("window split vertical"):
            Key("c-w,v"),
            _("window next"):
            Key("c-w,w"),
            _("window exchange"):
            Key("c-w,x"),
            _("window close preview"):
            Key("c-w,z"),
            _("window width"):
            Key("c-w,bar"),
            _("window tag in preview"):
            Key("c-w,rbrace"),
        }
        self.extras = [
            # TODO: tighten register to [a-zA-Zs-9.%#:-"]
            RuleRef(name='register', rule=AnyCharacter()),
            RuleRef(name='char', rule=AnyCharacter())
        ]

        MappingRule.__init__(self, *args, **kwargs)
Ejemplo n.º 9
0
    def __init__(self, *args, **kwargs):
        self.mapping = {
            ################
            #  left/right  #
            ################
            _("(backward|left)"):
            Key("h"),
            _("(forward|right)"):
            Key("l"),
            _("(zero|first char[acter])"):
            Key("0"),
            _("(caret|first non-blank char[acter])"):
            Key("caret"),
            _("(dollar|last char[acter])"):
            Key("dollar"),
            _("last visible non-blank char[acter]"):
            Key("g,underscore"),
            _("fist visible char[acter]"):
            Key("g,0"),
            _("first visible non-blank char[acter]"):
            Key("g,caret"),
            _("middle of line"):
            Key("g,m"),
            _("last visible char[acter]"):
            Key("g,dollar"),
            _("(pipe|column)"):
            Key("bar"),
            _("find <char>"):
            Key("f,%(char)s"),
            _("backwards find <char>"):
            Key("s-f,%(char)s"),
            #############
            #  up/down  #
            #############
            _("up"):
            Key("k"),
            _("down"):
            Key("j"),
            _("visible up"):
            Key("g,k"),
            _("visible down"):
            Key("g,j"),
            _("(minus|linewise non-blank up)"):
            Key("minus"),
            _("(plus|linewise non-blank down)"):
            Key("plus"),
            _("(underscore|first non-blank line down)"):
            Key("underscore"),
            _("line"):
            Key("s-g"),
            _("end of [last] line"):
            Key("c-end"),
            _("first non-blank char[acter] on line"):
            Key("g,g"),
            _("percent"):
            Key("percent"),
            ##########
            #  word  #
            ##########
            _("word"):
            Key("w"),
            _("(big|cap) word"):
            Key("s-w"),
            _("end"):
            Key("e"),
            _("(big|cap) end"):
            Key("s-e"),
            _("back"):
            Key("b"),
            _("(big|cap) back"):
            Key("s-b"),
            _("backward end"):
            Key("g,e"),
            _("backward (big|cap) end"):
            Key("g,s-e"),
            #################
            #  text object  #
            #################
            _("((open|left) paren|previous sentence)"):
            Key("lparen"),
            _("((close|right) paren|next sentence)"):
            Key("rparen"),
            _("((left|open) curly brace|previous paragraph)"):
            Key("lbrace"),
            _("((right|close) curly brace|next paragraph)"):
            Key("rbrace"),
            _("next section start"):
            Key("rbracket,rbracket"),
            _("next section end"):
            Key("rbracket,lbracket"),
            _("previous section start"):
            Key("lbracket,rbracket"),
            _("previous section end"):
            Key("lbracket,lbracket"),
            ###########
            #  other  #
            ###########
            _("ex"):
            Key("colon"),
            ###########
            #  marks  #
            ###########
            # TODO: tighten char to [a-vA-Z0-9]
            _("mark <char>"):
            Key("backtick,%(char)s"),
            _("mark <char> first non-blank"):
            Key("apostrophe,%(char)s"),
            _("mark <char> [and] keep jumps"):
            Key("g,backtick,%(char)s"),
            _("mark <char> first non-blank [and] keep jumps"):
            Key("g,apostrophe,%(char)s"),
            _("first char[acter] of last (change|yank)"):
            Key("apostrophe,lbracket"),
            _("last char[acter] of last (change|yank)"):
            Key("apostrophe,rbracket"),
            _("start of last selection"):
            Key("apostrophe,langle"),
            _("end of last selection"):
            Key("apostrophe,rangle"),
            _("restore position"):
            Key("apostrophe,apostrophe"),
            _("restore position at last buffer exit"):
            Key("apostrophe,dquote"),
            _("restore position at last insert"):
            Key("apostrophe,caret"),
            _("restore position at last change"):
            Key("apostrophe,dot"),
            _("first non-blank char[acater] of next lowercase mark"):
            Key("rbracket,apostrophe"),
            _("next lowercase mark"):
            Key("rbracket,backtick"),
            _("first non-blank char[acter] of previous lowercase mark"):
            Key("lbracket,apostrophe"),
            _("previous lowercase mark"):
            Key("lbracket,backtick"),
            #####################
            #  various motions  #
            #####################
            _("(percent|match of next item)"):
            Key("percent"),
            _("previous unmatched (open|left) paren"):
            Key("lbracket,lparen"),
            _("previous unmatched (open|left) [curly] brace"):
            Key("lbracket,lbrace"),
            _("next unmatched (close|right) paren"):
            Key("rbracket,rparen"),
            _("next unmatched (close|right) [curly] brace"):
            Key("rbracket,rbrace"),
            _("next start of method"):
            Key("rbracket,m"),
            _("next end of method"):
            Key("rbracket,s-m"),
            _("previous start of method"):
            Key("lbracket,m"),
            _("previous end of method"):
            Key("lbracket,s-m"),
            _("previous unmatched macro"):
            Key("lbracket,hash"),
            _("next unmatched macro"):
            Key("rbracket,hash"),
            _("previous start of comment"):
            Key("lbracket,asterisk"),
            _("next end of comment"):
            Key("rbracket,asterisk"),
            _("line from top"):
            Key("s-h"),
            _("middle [of (window|screen)]"):
            Key("s-m"),
            _("line from bottom"):
            Key("s-l"),
        }
        self.extras = [RuleRef(name='char', rule=AnyCharacter())]

        MappingRule.__init__(self, *args, **kwargs)
Ejemplo n.º 10
0
 def __init__(self, *args, **kwargs):
     self.mapping = {_('[with] X forwarding'): Text('-Y')}
     MappingRule.__init__(self, *args, **kwargs)
Ejemplo n.º 11
0
rules = MappingRule(
    mapping={
        # Miscellaneous.
        "[start|exit] full screen": Key("f11"),
        "search": Key("cs-f"),
        "(toggle|show|hide) (scroll|scrollbar)": Key("cs-s"),

        # Window management.
        "new window": Key("cs-i"),
        "close window": Key("cs-q"),

        # Tab management.
        "new tab": Key("cs-t"),
        "close tab": Key("cs-w"),
        "rename tab": Key("c-r"),
        "[switch to] next tab": Key("c-pgdown"),
        "[switch to] previous tab": Key("c-pgup"),
        "move tab left": Key("cs-pgup"),
        "move tab right": Key("cs-pgdown"),

        # View management.
        "split horizontally": Key("cs-o"),
        "split vertically": Key("cs-e"),
        "close view": Key("cs-w"),
        "[switch to] next view": Key("c-tab"),
        "[switch to] previous view": Key("cs-tab"),
        "[switch to] left view": Key("a-left"),
        "[switch to] right view": Key("a-right"),
        "[switch to] top view": Key("a-up"),
        "[switch to] bottom view": Key("a-down"),
        "clear (view|tab|window|terminal)": Key("cs-g"),
        "resize left [<n>]": Key("cs-left:%(n)d"),
        "resize right [<n>]": Key("cs-right:%(n)d"),
        "resize up [<n>]": Key("cs-up:%(n)d"),
        "resize down [<n>]": Key("cs-down:%(n)d"),

        # Zoom.
        "(zoom|focus|unzoom|unfocus) (view|tab|terminal)": Key("cs-z"),
        "zoom (100 percent|reset|normal)": Key("c-0"),
        "zoom in": Key("c-plus"),
        "zoom out": Key("c-minus"),

        # Cursor grouping.
        "group all": Key("w-g"),
        "ungroup all": Key("ws-g"),
        "group tab": Key("w-t"),
        "ungroup tab": Key("ws-t"),

        # Copy & paste.
        "copy [that]": Key("cs-c"),
        "paste [that]": Key("cs-v"),
        # Commands and keywords:
        "apt cache search": Text("apt-cache search "),
        "apt cache search <text>": Text("apt-cache search %(text)s"),
        "apt cache show": Text("apt-cache show "),
        "apt cache show <text>": Text("apt-get show %(text)s"),
        "apt get install": Text("apt-get install "),
        "apt get install <text>": Text("apt-get install %(text)s"),
        "apt get update": Text("apt-get update") + Key("enter"),
        "sudo apt get install": Text("sudo apt-get install "),
        "sudo apt get install <text>": Text("sudo apt-get install %(text)s"),
        "sudo apt get update": Text("sudo apt-get update") + Key("enter"),
        "background": Text("bg "),
        "(cat|C A T)": Text("cat "),
        "(cat|C A T) <text>": Text("cat %(text)s"),
        "(change (directory|dir)|C D)": Text("cd "),
        "(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"),
        "jobs": Text("jobs "),
        "kill": Text("kill "),
        "kill (hard|[dash]9)": Text("kill -9 "),
        "kill line": Key("c-k"),
        "(link|L N)": Text("ln "),
        "list files": Text("ls -lah") + Key("enter"),
        "list files <text>": Text("ls -lha %(text)s"),
        "list files time sort": Text("ls -laht") + Key("enter"),
        "make (directory|dir)": Text("mkdir "),
        "make (directory|dir) <text>": Text("mkdir %(text)s"),
        "move": Text("mv "),
        "move <text>": Text("mv %(text)s"),
        "paste terminal": Key("cs-v/3"),
        "pipe": Text(" | "),
        "ping": Text("ping "),
        "(print working directory|P W D)": Text("pwd") + Key("enter"),
        "([list] processes [list]|P S)": Text("ps -ef"),
        "(R M|remove file)": Text("rm "),
        "(R M|remove file) <text>": Text("rm %(text)s"),
        "remove (directory|dir|folder|recursive)": Text("rm -rf "),
        "remove (directory|dir|folder|recursive) <text>": Text("rm -rf %(text)s"),  # @IgnorePep8
        "(sed|S E D)": Text("sed "),
        "(secure copy|S C P)": Text("scp "),
        "(secure copy|S C P) <text>": Text("scp %(text)s"),
        "(secure shell|S S H)": Text("ssh "),
        "(secure shell|S S H) <text>": Text("ssh %(text)s"),
        "soft link": Text("ln -s "),
        "soft link <text>": Text("ln -s %(text)s"),
        "sudo": Text("sudo "),
        "(switch user|S U)": Text("su "),
        "(switch user|S U) login": Text("su - "),
        "tail": Text("tail "),
        "tail <text>": Text("tail %(text)s"),
        "tail (F|follow)": Text("tail -f "),
        "tail (F|follow) <text>": Text("tail -f %(text)s"),
        "telnet": Text("telnet "),
        "touch": Text("touch "),
        "touch <text>": Text("touch %(text)s"),
        "vim": Text("vim "),
        "vim <text>": Text("vim %(text)s"),
        "(W C|word count)": Text("wc "),
        "(W C|word count) lines": Text("wc -l "),
        "W get ": Text("wget "),
        "X args": Text("xargs "),
        "X D O tool": Text("xdotool "),
        "X M L lint": Text("xmllint "),
        "X M L lint <text>": Text("xmllint %(text)s"),
        "X M L lint format": Text("xmllint -format "),
        "X M L lint format <text>": Text("xmllint -format %(text)s"),
        "X M L lint schema": Text("xmllint -schema "),
        "X M L lint schema <text>": Text("xmllint -schema %(text)s"),
        "X prop": Text("xprop "),
        "X win info": Text("xwininfo "),
    },


    extras=[IntegerRef('n', 1, 10), Dictation('text')]

)
Ejemplo n.º 12
0
 def _process_recognition(self, value, extras):
     _esc_newline()
     MappingRule._process_recognition(self, value, extras)
Ejemplo n.º 13
0
 def _process_recognition(self, value, extras):
     _esc_insert()
     MappingRule._process_recognition(self, value, extras)
Ejemplo n.º 14
0
    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.
#  This element will match anywhere between 1 and 16 repetitions
#  of the keystroke elements.  Note that we give this element
#  the name 'sequence' so that it can be used as an extra in
#  the rule definition below.
# Note: when processing a recognition, the *value* of this element
#  will be a sequence of the contained elements: a sequence of
#  actions.
sequence = Repetition(single_action, min=1, max=16, name='sequence')

extras = [
Ejemplo n.º 15
0
 def _process_recognition(self, value, extras):
     # press escape before all normal mode commands
     _esc()
     MappingRule._process_recognition(self, value, extras)