Ejemplo n.º 1
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.º 2
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.º 3
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.º 4
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.º 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)