Exemplo n.º 1
0
class VimCommands(MappingRule):

    extras = [
        Dictation('text'),
        IntegerRef("n", 1, 1000),
        IntegerRef("line", 1, 10000),
    ]

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

    mapping = {
        # Basic modes
        "insert mode": Key("i"),
        "command mode": Key("escape"),
        "save file": Key("colon, w, enter"),
        "quit": Key("colon, q"),

        # Navigation
        "up [<n>]": Key("k:%(n)d"),
        "down [<n>]": Key("j:%(n)d"),
        "left [<n>]": Key("h:%(n)d"),
        "right [<n>]": Key("l:%(n)d"),
        "go [<line>]": Key("colon") + Text("%(line)s\n"),

        # Basic commands
        "delete line": Key("d,d"),
        "undo": Key("u"),
        "word [<n>]": Key("w:%(n)d"),
        "back [<n>]": Key("b:%(n)d"),
        "change word": Key("c,w"),
    }
Exemplo n.º 2
0
class StaticRule(MappingRule):

    mapping = {
        "zoom in [<n>]": Key("c-equals:%(n)d"),
        "zoom out [<n>]": Key("c-hyphen:%(n)d"),
        "zoom [one] hundred": Key("c-1"),
        "zoom [whole | full] page": Key("c-2"),
        "zoom [page] width": Key("c-3"),
        "find <text>": Key("c-f") + Text("%(text)s") + Key("f3"),
        "find next": Key("f3"),
        "go to page <int>": Key("c-g") + Text("%(int)d\n"),
        "print file": Key("c-p"),
        "print setup": Key("a-f, r"),
        "reading mode": Key("c-H"),
        "previous page": Key("c-pgup"),
        # awkward method of switching between bookmark view and reading
        # pane. creates new bookmark, delete it,then can navigate to
        # bookmark.when wanting to return to Reading window, create and/or
        # focuses start tab. Then switch to tab next (assume is only one tab
        # open)
        "navigation window": Key("c-b, enter, del"),
        "reading window": Key("ca-s/20:2/20"),
        "close navigation window": Key("f4"),
        'next': Key("c-tab"),
        'previous': Key("cs-tab"),
        'close': Key('c-w'),
    }
    extras = [
        IntegerRef("n", 1, 10),
        IntegerRef("int", 1, 10000),
        Dictation("text"),
    ]
    defaults = {
        "n": 1,
    }
Exemplo n.º 3
0
class CommandRule(MappingRule):

    mapping  = {
                "zoom in [<n>]":            Key("c-equals:%(n)d"),
                "zoom out [<n>]":           Key("c-hyphen:%(n)d"),
                "zoom [one] hundred":       Key("c-1"),
                "zoom [whole | full] page": Key("c-2"),
                "zoom [page] width":        Key("c-3"),

                "find <text>":              Key("c-f") + Text("%(text)s")
           	                                 + Key("f3"),
                "find next":                Key("f3"),

                "[go to] page <int>":       Key("cs-n") + Text("%(int)d\n"),

                "print file":               Key("c-p"),
                "print setup":              Key("a-f, r"),
               }
    extras   = [
                IntegerRef("n", 1, 10),
                IntegerRef("int", 1, 10000),
                Dictation("text"),
               ]
    defaults = {
                "n": 1,
               }
Exemplo n.º 4
0
class GridControlRule(MappingRule):

    mapping = {
        "[<pre>] <color> <n> [<action>]":
        R(Function(send_input), rdescript="Rainbow Grid: Action"),
        "exit":
        R(Function(kill), rdescript="Exit Rainbow Grid"),
    }
    extras = [
        IntegerRef("pre", 0, 9),
        Choice(
            "color", {
                "red": 0,
                "(orange | tan | brown)": 1,
                "yellow": 2,
                "green": 3,
                "blue": 4,
                "purple": 5
            }),
        Choice("action", {
            "kick": 0,
            "psychic": 1,
        }),
        IntegerRef("n", 0, 100),
    ]
    defaults = {
        "pre": 0,
        "action": -1,
    }
Exemplo n.º 5
0
class CommandRule(MappingRule):

    mapping = {
        "next tab [<n>]":
        R(Key("c-pgdown") * Repeat(extra="n"),
          rdescript="Notepad++: Next Tab"),
        "prior tab [<n>]":
        R(Key("c-pgup") * Repeat(extra="n"), rdescript="Notepad++: Prior Tab"),
        "close tab [<n>]":
        R(Key("c-w") * Repeat(extra="n"), rdescript="Notepad++: Close Tab"),
        "stylize <n2>":
        R(Mouse("right") + Key("down:6/5, right") +
          (Key("down") * Repeat(extra="n2")) + Key("enter"),
          rdescript="Notepad++: Stylize"),
        "remove style":
        R(Mouse("right") + Key("down:6/5, right/5, down:5/5, enter"),
          rdescript="Notepad++: Remove Style"),
        "preview in browser":
        R(Key("cas-r"), rdescript="Notepad++: Preview In Browser"),
        # requires function list plug-in:
        "function list":
        R(Key("cas-l"), rdescript="Notepad++: Function List"),
    }
    extras = [
        Dictation("text"),
        IntegerRef("n", 1, 100),
        IntegerRef("n2", 1, 10),
    ]
    defaults = {"n": 1}
Exemplo n.º 6
0
class MappingCountRule(MappingRule):
    exported = False
    extras = [
        NoCompile(Optional(Integer(min=0, max=99), default=1), name='nn'),
        IntegerRef(min=1, max=10, name='n'),
        IntegerRef(min=1, max=100, name='bign'),
        DictateWords('text')
    ]
    defaults = {'n': 1, 'nn': 1, 'text': '', 'bign': 1}
Exemplo n.º 7
0
class TexmakerRule(MergeRule):
    pronunciation = "texmaker"

    mapping = {
        # file
        "new [file]": Key("c-n"),
        "open": Key("c-o"),
        "open recent": Key("a-f, down:3, right"),
        "close": Key("c-w"),
        "exit": Key("c-q"),
        "restore previous session": Key("cs-f8"),

        # edit
        "[go to] line <m>": Key("c-g") + Text("%(m)s") + Key("enter"),
        "comment": Key("c-t"),
        "uncomment": Key("c-u"),
        "indent": Key("c-rangle"),
        "(outdent | unindent)": Key("c-langle"),
        "find [<text>]": Key("c-f/5") + Text("%(text)s"),
        "find next [<n>]": Key("c-m") * Repeat(extra="n"),
        "replace": Key("c-r"),
        "check spelling": Key("cs-f7"),
        "refresh structure": Key("cs-f1"),

        # tools
        # if you have f1 set to turn on/off microphone, you will need to reset the Texmaker shortcut
        "quick build": Key("f1"),
        # "LaTeX": Key("f2"), # not sure what this does so I'm going to comment it out
        "view DVI": Key("f3"),
        "DVI to postscript": Key("f4"),
        "view postscript": Key("f5"),
        "PDF latex": Key("f6"),
        "view PDF": Key("f7"),
        "postscript to PDF": Key("f8"),
        "DVI to PDF": Key("f9"),
        "view log": Key("f10"),
        "bibtech": Key("f11"),
        "make index": Key("f12"),

        # view
        # Texmaker doesn't seem to have tabs unless I'm missing something
        "next (document | dock) [<n>]": Key("a-pgdown") * Repeat(extra='n'),
        "(previous | prior)  (document | dock)":
        Key("a-pgup") * Repeat(extra='n'),
        "full-screen": Key("cs-f11"),
        "switch pane":
        Key("c-space"),  # switch between editor and embedded viewer
    }

    extras = [
        Dictation("text"),
        IntegerRef("n", 1, 10),
        IntegerRef("m", 1, 1000),
    ]

    defaults = {}
Exemplo n.º 8
0
class KeystrokeRule(MappingRule):
    exported = False
    mapping = grammarCfg.cmd.map
    extras = [
        IntegerRef("n", 1, 1000),
        IntegerRef("m", 1, 1000),
        Dictation("text"),
        Dictation("text2"),
    ]
    defaults = {
        "n": 1,
    }
class NewAlphabetRule(MappingRule):
    exported = False
    mapping = {
        "Alpha [<n>]": Key("a:%(n)d"),
        "Bravo [<n>]": Key("b:%(n)d"),
        "Charlie [<n>]": Key("c:%(n)d"),
        "Delta [<n>]": Key("d:%(n)d"),
        "Echo [<n>]": Key("e:%(n)d"),
        "Foxtrot [<n>]": Key("f:%(n)d"),
        "Golf [<n>]": Key("g:%(n)d"),
        "Hotel [<n>]": Key("h:%(n)d"),
        "Ice [<n>]": Key("i:%(n)d"),
        "Juneau [<n>]": Key("j:%(n)d"),
        "Kilo [<n>]": Key("k:%(n)d"),
        "Lima [<n>]": Key("l:%(n)d"),
        "Monty [<n>]": Key("m:%(n)d"),
        "Ninja [<n>]": Key("n:%(n)d"),
        "Oscar [<n>]": Key("o:%(n)d"),
        "Papa [<n>]": Key("p:%(n)d"),
        "Quinn [<n>]": Key("q:%(n)d"),
        "Robin [<n>]": Key("r:%(n)d"),
        "Soda [<n>]": Key("s:%(n)d"),
        "Tango [<n>]": Key("t:%(n)d"),
        "Usurp [<n>]": Key("u:%(n)d"),
        "Victor [<n>]": Key("v:%(n)d"),
        "Whiskey [<n>]": Key("w:%(n)d"),
        "X-ray [<n>]": Key("x:%(n)d"),
        "Yankee [<n>]": Key("y:%(n)d"),
        "Zulu [<n>]": Key("z:%(n)d"),
    }
    extras = [IntegerRef("n", 1, 100),]
    defaults = {"n": 1,}
Exemplo n.º 10
0
class CommandRule(MappingRule):
    mapping = mapping

    extras = [Dictation("text"), IntegerRef("n", 1, 50000)]
    defaults = {
        "n": 1,
    }
Exemplo n.º 11
0
class CommandRule(MappingRule):
    mapping = {
        # Search.
        "replace": Key("c-h"),
        "show find": Key("c-f"),
        "find <text>": Key("c-f/25") + Text("%(text)s"),
        "find next [<n>]": Key("c-g:%(n)d"),
        "find (prev | previous) [<n>]": Key("s-f3:%(n)d"),
        "find (prev | previous)": Key("cs-g"),
        "note find": Key("c-q"),
        "note find <text>": Key("c-q/25") + Text("%(text)s"),

        # Window handling.
        # "new tab": Key("c-n"),
        # "next tab [<t>]": Key("c-tab:%(t)d"),
        # "preev tab [<t>]": Key("cs-tab:%(t)d"),
        # "close tab": Key("c-w"),
        # "(full-screen | full screen)": Key("f11"),
    }
    extras = [
        Integer("t", 1, 50),
        Dictation("text"),
        IntegerRef("n", 1, 50000),
    ]
    defaults = {
        "t": 1,
    }
Exemplo n.º 12
0
class VisualStudioGlobalRule(MappingRule):
    mapping = {
        'save all': Key('cs-s'),
        "go to definition": Key("f12"),
        '(show|find) [all] (usages|references)': Key("a-f7"),
        'peek definition': Key('a-f12'),
        '(show params|param info)': Key('cs-space'),
        '(show type|quick info)': visual_studio_action('Quick Info'),
        'show (type|class) (view|hierarchy)': Key('cs-c'),
        'show call hierarchy': Key('ca-k'),
        '(format|reformat) [document]': visual_studio_action('Reformat Document'),
        '(format|reformat) selection': visual_studio_action('Reformat Selection'),
        '[toggle] [line] comment': visual_studio_action('Toggle Line Comment'),
        '[toggle] block comment': visual_studio_action('Toggle Block Comment'),
        'suggest': Key('c-dot'),
        '(cell|select) [<n>]': Function(execute_select, offset=1),
        'show error': visual_studio_action('Quick Info'),
        'rename': visual_studio_action('Rename'),
        'extract variable': Key('c-dot'),
        'close tab': Key('c-f4'),
        'git commit': Key('c-0,g'),
        'next diff': Key('c-f8'),
        'previous diff': Key('cs-f8'),

    }
    extras = [
        IntegerRef('n', 1, 10, default=1),
        LetterRef('letter'),
    ]
Exemplo n.º 13
0
class InsertRules(MappingRule):
    mapping = {
        "[<n>] up": Key("up:%(n)d"),
        "[<n>] down": Key("down:%(n)d"),
        "[<n>] left": Key("left:%(n)d"),
        "[<n>] right": Key("right:%(n)d"),
        "slap": Key("enter"),
        "(scratch|delete)": Key("c-w"),
        "tab": Key("tab"),
        "backspace": Key("backspace"),
        "(scratch|delete) line": Key("c-u"),
        "<text>": Text("%(text)s"),
        "insert breakpoint": Text('import pdb; pdb.set_trace()'),

        # ctrlp commands
        "open tabulator": Key('c-t'),
        "open vertical split": Key('c-v'),
        "open horizontal split": Key('c-x'),
        "switch buffer": Key('c-b'),
        "switch file": Key('c-f'),

        # formatting
        'snake <dictation>': snake_case,
        'snake function <dictation>': snake_case_function,
        'camel <dictation>': camel_case,
        'camel rest <dictation>': camel_case_rest,
        'upper <dictation>': upper,
        'one word <dictation>': one_word,
    }
    extras = [
        Dictation('text'),
        Dictation('dictation'),
        IntegerRef("n", 1, 100),
    ]
Exemplo n.º 14
0
class CommandRule(MappingRule):

    mapping = {
        "quickfix":                 R(Key("a-enter"), rdescript="JetBrains: Quick Fix"),
        "duplicate":                R(Key("c-d"), rdescript="JetBrains: Duplicate"),
        "auto complete":            R(Key("cs-a"), rdescript="JetBrains: Auto Complete"),
        "format code":              R(Key("ca-l"), rdescript="JetBrains: Format Code"),
        "show doc":                 R(Key("c-q"), rdescript="JetBrains: Show Documentation"),
        "show param":               R(Key("c-p"), rdescript="JetBrains: Show Parameters"),
        "Jen method":               R(Key("a-insert"), rdescript="JetBrains: Generated Method"),
        "jump to source":           R(Key("f4"), rdescript="JetBrains: Jump To Source"),
        "delete line":              R(Key("c-y"), rdescript="JetBrains: Delete Line"),
        "search symbol":            R(Key("cas-n"), rdescript="JetBrains: Search Symbol"),
        "build":                    R(Key("c-f9"), rdescript="JetBrains: Build"),
        "build and run":            R(Key("s-f10"), rdescript="JetBrains: Build And Run"),
        "next tab":                 R(Key("a-right"), rdescript="JetBrains: Next Tab"),
        "previous tab":             R(Key("a-left"), rdescript="JetBrains: Previous Tab"),
        
        "comment line":             R(Key("c-slash"), rdescript="JetBrains: Comment Line"), 
        "uncomment line":           R(Key("cs-slash"), rdescript="JetBrains: Uncomment Line"), 
        "select ex":                R(Key("c-w"), rdescript="JetBrains: untitled command"), 
        "select ex down":           R(Key("cs-w"), rdescript="JetBrains: entitled command"),
        "search everywhere":        R(Key("shift, shift"), rdescript="JetBrains: Search Everywhere"),
        "find in current":          R(Key("cs-f"), rdescript="JetBrains: Find In Current"),
        }
    extras = [
              Dictation("text"),
              Dictation("mim"),
              IntegerRef("n", 1, 1000),
              
             ]
    defaults = {"n": 1, "mim":""}
Exemplo n.º 15
0
class UnimpairedRule(MappingRule):
    mapping = {
        "edit <dir>": Key("%(dir)s, c"),
        "space <dir>": Key("%(dir)s, space"),
        "file <dir>": Key("%(dir)s, f"),
        "(lint | lock) <dir>": Key("%(dir)s, l"),
        "(quick | bug) <dir>": Key("%(dir)s, q"),

        # Ack puts search results in quickfixlist, so it should follow search
        "big <ack>": Key("%(ack)s, q"),
    }
    extras = [
        IntegerRef("n", 1, 10),
        Choice("dir", {
            "up": "lbracket",
            "down": "rbracket",
        }),
        Choice("ack", {
            "pecks": "lbracket",
            "next": "rbracket",
        })
    ]
    defaults = {
        'n': 1,
    }
Exemplo n.º 16
0
class PycharmGlobalRule(MappingRule):
    mapping = {
        'save all': Key('c-s'),
        "go to definition": Key("c-b"),
        '(show|find) usages': Key("a-f7"),
        'highlight usages': Key("cs-f7"),
        'peek definition': Key('cs-i'),
        '(show|peek) docs': Key('c-q'),
        '(show params|param info)': Key('c-p'),
        'show type': Key('cs-p'),
        'show type hierarchy': Key('c-h'),
        'show call hierarchy': Key('ca-h'),
        "reformat": Key('ca-l'),
        "reformat line": Key('escape,V,ca-l,escape'),
        'comment': Key('c-slash'),
        'suggest': Key('a-enter'),
        '(cell|select) [<n>]': Function(execute_select, offset=1),
        'show error': Key('c-f1'),
        'run program': Key('s-f10'),
        'run dot dot dot': Key('as-f10'),
        'execute selection [in console]': Key('as-e'),
        'kill program': Key('c-f2'),
        'debug program': Key('s-f9'),
        'debug dot dot dot': Key('as-f9'),
        'toggle breakpoint': Key('c-f8'),
        'step out': Key('s-f8'),
        'step over': Key('f8'),
        'step into': Key('f7'),
        'resume program': Key('f9'),
        'rename': Key('s-f6'),
        'extract variable': Mimic('kay') + Mimic('insert') + Key('ca-v'),
        'new (file|dot dot dot)': Key('a-f/20,a-insert'),
        'panel <n>': Key('a-%(n)d'),
        'close tab': Key('c-f4'),
        'close (all but this|others)': pycharm_action('close others'),
        'close left': pycharm_action('close all to the left'),
        'close right': pycharm_action('close all to the right'),
        'unsplit': pycharm_action('unsplit'),
        'git commit': Key('c-k'),
        'git pull': Key('a-s/20,a-u'),
        'git push': Key('cs-k'),
        'show diff': Key('c-d'),
        'next diff': Key('f7'),
        'next section': Key('tab'),
        'previous section': Key('s-tab'),
        'previous diff': Key('s-f7'),
        'compare next file': Key('a-right'),
        'compare previous file': Key('a-left'),
        'menu <letter>': Key('a-%(letter)s'),
        'hide menu': Key('s-escape'),
        'fold all': Key('cs-npsub'),
        '(expand|unfold) all': Key('cs-npadd'),
        'fold': Key('c-npsub'),
        '(expand|unfold)': Key('c-npadd'),
        'open file': Key('a-n/10,f'),
    }
    extras = [
        IntegerRef('n', 1, 10, default=1),
        LetterRef('letter'),
    ]
Exemplo n.º 17
0
class ExampleRule(MappingRule):
    mapping = {
        # Recognise 'hello' followed by arbitrary dictation.
        # This mapping cannot be matched using Pocket Sphinx because the
        # engine's support for dictation has been temporarily disabled.
        "hello <dictation>": Function(print_, dict(dictation="x")),

        # You still can use Mimic or engine.mimic() to match dictation.
        "say hello world": Mimic("hello", "WORLD"),

        # Update and recognise from a dragonfly list.
        "update list": Function(update_list),
        "<lst>": Function(print_, dict(lst="x")),

        # Command to type numbers, e.g. 'type one two three'.
        "type <numbers>": Function(type_numbers),

        # Write transcript files used for training models.
        "(make|write) transcripts": Function(write_transcripts),
    }

    extras = [
        Dictation("dictation"),
        ListRef("lst", lst),
        Repetition(IntegerRef("n", 1, 20), min=1, max=16, name="numbers"),
    ]
Exemplo n.º 18
0
class LetterRule(MappingRule):
    mapping = {
        "<letter>": Key("%(letter)s"),

        # jedi
        "complete": Key('c-p'),
        "[<n>] up": Key("up:%(n)d"),
        "[<n>] down": Key("down:%(n)d"),
        "[<n>] left": Key("left:%(n)d"),
        "[<n>] right": Key("right:%(n)d"),
        # "slap": Key("enter"),

        # "[<n>] (scratch|delete)": Key("c-w:%(n)d"),
        # "[<n>] slap": Key("enter:%(n)d"),
        # "[<n>] tab": Key("tab:%(n)d"),
        # "[<n>] backspace": Key("backspace:%(n)d"),
        # "(scratch|delete) line": Key("c-u"),

        # "<text>": Text("%(text)s"),
    }
    extras = [
        letterChoice("letter"),
        IntegerRef("n", 1, 100),
        # Dictation('text')
    ]
Exemplo n.º 19
0
class CommandRule(MappingRule):
    mapping = {
        #"[go to | show] project window": Key("a-1"),

        # Search.
        "replace": Key("c-h"),
        "show find": Key("c-f"),
        "find <text>": Key("c-f/25") + Text("%(text)s"),
        # "find next": Key("f3"),
        # "find (prev | previous)": Key("s-f3"),
        "find in files": Key("cs-f"),

        # Code.
        "[shoreline | show] line <w> [<x>] [<y>] [<z>]": Key("c-g/25") + Function(printNumber)+ Key("enter"),
        "show white space": Key("cs-w"),
        
        # Window handling.
        "new tab": Key("c-n"),
        "next tab [<t>]": Key("c-tab:%(t)d"),
        "(preev | previous) tab [<t>]": Key("cs-tab:%(t)d"),
        "close tab": Key("c-w"),
        "(full-screen | full screen)": Key("f11"),
    }
    extras = [
        Integer("t", 1, 50),
        Dictation("text"),
        IntegerRef("n", 1, 50000),
        Integer("w", 0, 10),
        Integer("x", 0, 10),
        Integer("y", 0, 10),
        Integer("z", 0, 10)
    ]
    defaults = {
        "t": 1,
    }
class ScratchRule(CompoundRule):
    context = enabled_context
    spec = "(scratch | scratch that [<n> times])"
    extras = [IntegerRef("n", 1, 20, default=1)]

    def _process_recognition(self, node, extras):
        self.grammar.do_scratch_n_times(extras["n"])
Exemplo n.º 21
0
def test_global_extras():
    Breathe.add_global_extras(Dictation("text"))
    assert len(Breathe.global_extras) == 1
    assert "text" in Breathe.global_extras
    Breathe.add_global_extras([Choice("abc", {"def": "ghi"})])
    # Check that this is overridden
    Breathe.add_global_extras(IntegerRef("n", 1, 2, 1))
Exemplo n.º 22
0
class ExModeCommands(MappingRule):
    mapping = {
        "read": Text("r "),
        "(write|save) file": Text("w "),
        "quit": Text("q "),
        "turbo quit": Text("q! "),
        "write and quit": Text("wq "),
        "edit": Text("e "),
        "tab edit": Text("tabe "),
        "set number": Text("set number "),
        "set relative number": Text("set relativenumber "),
        "set ignore case": Text("set ignorecase "),
        "set no ignore case": Text("set noignorecase "),
        "set file format UNIX": Text("set fileformat=unix "),
        "set file format DOS": Text("set fileformat=dos "),
        "set file type Python": Text("set filetype=python"),
        "set file type tex": Text("set filetype=tex"),
        "P. W. D.": Text("pwd "),
        "help": Text("help"),
        "substitute": Text("s/"),
        "up": Key("up"),
        "down": Key("down"),
        "[<n>] left": Key("left:%(n)d"),
        "[<n>] right": Key("right:%(n)d"),
    }
    extras = [
        Dictation("text"),
        IntegerRef("n", 1, 50),
    ]
    defaults = {
        "n": 1,
    }
Exemplo n.º 23
0
class KeystrokeRule(MappingRule):
    exported = False
    mapping = grammarCfg.cmd.map
    extras = [
        IntegerRef("n", 1, 100),
        IntegerRef("m", 0, 100),
        Dictation("text"),
        Dictation("text2"),
        Choice("formatType", formatMap),
        Choice("abbreviation", abbreviationMap),
        Choice("reservedWord", reservedWord),
    ]
    defaults = {
        "n": 1,
        "m": 0,
    }
Exemplo n.º 24
0
class Editing(MappingRule):
    mapping = {
        "undo": Key("u"),
        "redo": Key("c-r"),
        "(yank | copy | why | Y)": Key("y"),
        "(paste | pea | pee | P)": Key("p"),
        "(ex | x)": Key("x"),
        "(delete | D | dee)": Key("d"),
        "repeat [<n> times]": Text("%(n)d."),
        "[<n>] tilda": Text("%(n)d~"),
        "replace [with] <letter>": Text("r(letter)%s"),
        "find and replace <replace_text>": Key("colon, percent, s, slash") +
        Text("%(replace_text)s/"),
        "with <replace_text>": Text("%(replace_text)s/gc"),
        "yes": Key("y"),
        "no": Key("n"),
        "all": Key("a"),
        "(q | cancel)": Key("q"),
    }

    extras = [
        Dictation("replace_text"),
        Dictation("letter"),
        IntegerRef("n", 1, 900),
    ]

    defaults = {
        "n": 1,
    }
Exemplo n.º 25
0
class Movement(MappingRule):
    mapping = {
        "[<n>] (down | jay | J)": Text("%(n)dj"),
        "[<n>] (up | kay | K)": Text("%(n)dk"),
        "[<n>] (left | h)": Text("%(n)dh"),
        "[<n>] (right | el | l)": Text("%(n)dl"),

        "[<n>] (word | dub | W)": Text("%(n)dw"),
        "[<n>] big (word | dub | W)": Text("%(n)dW"),

        "[<n>] (bee | B | be)": Text("%(n)db"),
        "[<n>] big (bee | B | be)": Text("%(n)dB"),

        "dollar": Key("$"),
        "carrot": Key("^"),

        "page down": Key('c-d'),
        "page up": Key('c-u'),

        "go left window": Key('c-w, h'),
        "go right window": Key('c-w, l'),
        "go next window": Key('c-w, w'),
        "go previous window": Key('c-w, p'),

        "go next tab": Key('c-w, t'),
        "go previous tab": Key('c-w, T'),
    }

    extras = [
        IntegerRef("n", 1, 900),
    ]

    defaults = {
        "n": 1,
    }
Exemplo n.º 26
0
class core(MergeRule):
    non = coreNon

    pronunciation = CORE["pronunciation"]

    mapping = {
        "[<big>] <letter>":
        Function(alphabet),
        CORE["numbers_prefix"] + " <numbers>":
        Text("%(numbers)s"),
        "<punctuation>":
        Key("%(punctuation)s"),
        "(<direction> | <modifier> [<direction>]) [(<n50> | <extreme>)]":
        Function(navigation.text_nav),
        "<repeatable_key> [<n>]":
        Key("%(repeatable_key)s") * Repeat(extra="n"),
        "<non_repeatable_key>":
        Key("%(non_repeatable_key)s"),
        CORE["dictation_prefix"] + " <text>":
        Function(lambda text: Text(str(text).lower()).execute()),
        "shift click":
        Key("shift:down") + Mouse("left") + Key("shift:up"),
    }

    extras = [
        Dictation("text"),
        IntegerRef("n", 1, 10),
        IntegerRef("n50", 1, 50),
        IntegerRefMF("numbers", 0, CORE["numbers_max"]),
        Choice("big", {CORE["capitals_prefix"]: True}),
        Choice("letter", CORE[_LETTERS]),
        Choice("punctuation", CORE["punctuation"]),
        Choice("repeatable_key", CORE["repeatable_keys"]),
        Choice("non_repeatable_key", CORE["non_repeatable_keys"]),
        Choice("direction", CORE[_DIRECTIONS]),
        Choice("modifier", CORE["modifiers"]),
        Choice("extreme", {CORE["extreme"]: True}),
    ]

    defaults = {
        "big": False,
        "extreme": False,
        "n": 1,
        "n50": 1,
        "direction": "left",
        "modifier": "",
    }
Exemplo n.º 27
0
class CommandRule(MappingRule):

    mapping = {
        "initialize repository":       Text( "git init" )+Key("enter"),
        "add":              R(Key("g, i, t, space, a, d, d, space, dot, enter"), rdescript="GIT: Add All"),
        "status":           R(Key( "g, i, t, space, s, t, a, t, u, s, enter" ), rdescript="GIT: Status"),
        "commit":           R(Key( "g, i, t, space, c, o, m, m, i, t, space, minus, a, m, space, apostrophe, apostrophe, left"), rdescript="GIT: Commit"),
        "bug fix commit <n>":    R(Mimic("commit")+Text("fixes #%(n)d ")+Key("backspace"), rdescript="GIT: Bug Fix Commit"),
        "reference commit <n>":  R(Mimic("commit")+Text("refs #%(n)d ")+Key("backspace"), rdescript="GIT: Reference Commit"),
        "checkout":         R(Text( "git checkout " ), rdescript="GIT: Check Out"),
        "merge":            R(Text( "git merge " ), rdescript="GIT: Merge"),
        "merge tool":       R(Text( "git mergetool")+Key("enter"), rdescript="GIT: Merge Tool"),
        "fetch":            R(Text( "git fetch" )+Key("enter"), rdescript="GIT: Fetch"),
        
        
        "(get push | push)":R(Text( "git push" )+Key("enter"), rdescript="GIT: Push"),
        "pull":             R(Text( "git pull" )+Key("enter"), rdescript="GIT: Pull"),
        "CD up":            R(Text( "cd .." )+Key("enter"), rdescript="GIT: Up Directory"),
        "CD":               R(Text( "cd " ), rdescript="GIT: Navigate Directory"),
        "list":             R(Text( "ls" )+Key("enter"), rdescript="GIT: List"),
        "make directory":   R(Text( "mkdir " ), rdescript="GIT: Make Directory"),
        
        
        
        "undo [last] commit":       R(Text("git reset --soft HEAD~1")+Key("enter"), rdescript="GIT: Undo Commit"),
        "undo changes":             R(Text("git reset --hard")+Key("enter"), rdescript="GIT: Undo Since Last Commit"),
        "stop tracking [file]":     R(Text("git rm --cached FILENAME"), rdescript="GIT: Stop Tracking"),
        "preview remove untracked": R(Text("git clean -nd")+Key("enter"), rdescript="GIT: Preview Remove Untracked"),
        "remove untracked":         R(Text("git clean -fd")+Key("enter"), rdescript="GIT: Remove Untracked"),
        
        "visualize":        R(Text("gitk")+Key("enter"), rdescript="GIT: gitk"),
        "visualize file":   R(Text("gitk -- PATH"), rdescript="GIT: gitk Single File"),
        "visualize all":    R(Text("gitk --all")+Key("enter"), rdescript="GIT: gitk All Branches"),
        
        "exit":             R(Text( "exit" )+Key("enter"), rdescript="GIT: Exit"),
        
        
        
        "stash":            R(Text("git stash")+Key("enter"), rdescript="GIT: Stash"),
        "stash apply [<n>]":R(Text("git stash apply")+Function(apply), rdescript="GIT: Stash Apply"),
        "stash list":       R(Text("git stash list")+Key("enter"), rdescript="GIT: Stash List"),
        "stash branch":     R(Text("git stash branch NAME"), rdescript="GIT: Stash Branch"),

        "cherry pick":      R(Text("git cherry-pick "), rdescript="GIT: Cherry Pick"),
        "abort cherry pick":R(Text("git cherry-pick --abort"), rdescript="GIT: Abort Cherry Pick"),
        
        "GUI | gooey":      R(Text("git gui")+Key("enter"), rdescript="GIT: gui"),
        "blame":            R(Text("git blame PATH -L FIRSTLINE,LASTLINE"), rdescript="GIT: Blame"),
        "gooey blame":      R(Text("git gui blame PATH"), rdescript="GIT: GUI Blame"),
        
        "search recursive": R(Text("grep -rinH \"PATTERN\" *"), rdescript="GREP: Search Recursive"),
        "search recursive count": R(Text("grep -rinH \"PATTERN\" * | wc -l"), rdescript="GREP: Search Recursive Count"),
        "search recursive filetype": R(Text("find . -name \"*.java\" -exec grep -rinH \"PATTERN\" {} \\;"), rdescript="GREP: Search Recursive Filetype"),
        "to file":          R(Text(" > FILENAME"), rdescript="Bash: To File"),
        }
    extras = [
              IntegerRef("n", 1, 10000),
             ]
    defaults ={"n": 0}
Exemplo n.º 28
0
class sn_mathematics(MergeRule):
    non = sn_mathematicsNon
    mwith = CORE["pronunciation"]
    mcontext = AppContext(executable="scientific notebook")
    pronunciation = BINDINGS["pronunciation"]

    nested = sn_nested

    mapping = {
        BINDINGS["symbol_prefix"] + " <symbol>":
        Function(texchar),
        #
        BINDINGS["greek_prefix"] + " [<big>] <greek_letter>":
        Function(greek),
        BINDINGS["accent_prefix"] + " <accent>":
        Key("%(accent)s"),
        BINDINGS["unit_prefix"] + " <units>":
        Function(lambda units: execution.alternating_command(units)),
        "<misc_sn_keys>":
        Key("%(misc_sn_keys)s"),
        "<misc_sn_text>":
        Text("%(misc_sn_text)s"),
        "matrix <rows> by <cols>":
        Function(matrix),
        "<numbers> <denominator>":
        Key("c-f") + Text("%(numbers)s") + Key("down") +
        Text("%(denominator)s") + Key("right"),
    }

    extras = [
        IntegerRef("rows", 1, BINDINGS["max_matrix_size"]),
        IntegerRef("cols", 1, BINDINGS["max_matrix_size"]),
        IntegerRef("numbers", 0, CORE["numbers_max"]),
        Choice("big", {CORE["capitals_prefix"]: True}),
        Choice("greek_letter", BINDINGS["greek_letters"]),
        Choice("units", BINDINGS["units"]),
        Choice("symbol", BINDINGS["tex_symbols"]),
        Choice("accent", BINDINGS["accents"]),
        Choice("misc_sn_keys", BINDINGS["misc_sn_keys"]),
        Choice("misc_sn_text", BINDINGS["misc_sn_text"]),
        Choice("denominator", BINDINGS["denominators"]),
    ]

    defaults = {
        "big": False,
    }
Exemplo n.º 29
0
class CommandModeCommands(MappingRule):
    mapping = {
        "read": Text("r "),
        "help": Text("help "),
        "file glob": Text("*/**"),  # see `starstar`

        # Ex mode commands (see :exu for complete list):
        "X delete": Key("d"),
        "X append": Key("a"),
        "X change": Key("c"),
        "X insert": Key("i"),
        "X join": Key("j"),
        "X copy": Key("c, o"),
        "X move": Key("m"),
        "X put": Key("p"),
        "X yank": Key("y"),
        "X sub": Text("s/"),

        # Basic readline:
        "go start": Key("home"),
        "go end": Key("end"),

        # languages
        "python": Text('python'),
        "up": Key("up"),
        "down": Key("down"),
        "[<n>] left": Key("left:%(n)d"),
        "[<n>] right": Key("right:%(n)d"),
        "[<n>] word left": Key("s-left:%(n)d"),
        "[<n>] word right": Key("s-right:%(n)d"),
        "scratch": Key("c-w"),
        "scratch all": Key("c-u"),

        # Pasting info in:
        "paste sys": Key("c-r, asterisk"),
        "paste file": Key("c-r, percent"),
        "paste search": Key("c-r, slash"),
        "paste word": Key("c-r, c-w"),  # 'iw' under cursor
        "paste big word": Key("c-r, c-a"),  # 'iW' under cursor
        "paste selection": Key("c-y"),  # modeless selection
        "shift left": Key("c-t"),
        "shift right": Key("c-d"),

        # Completion:
        "[<n>] match down": Key("c-n"),
        "[<n>] match up": Key("c-p"),

        # TODO: Ranges
        "range all": Key("home, percent, end"),
    }
    extras = [
        letterChoice("letter"),
        Dictation("text"),
        IntegerRef("n", 1, 50),
    ]
    defaults = {
        "n": 1,
    }
Exemplo n.º 30
0
class MainRule(MappingRule):

    mapping = {
        # it is this section that you want to fiddle around with if you're new: mapping, extras, and defaults

        # in the next line, there are two things to observe:
        # the first is the use of parentheses and the pipe symbol (|)
        # --this lets me use either "lock dragon" or "deactivate" to trigger that command.
        # The next is the playback action, which lets me tell Dragon to simulate me speaking some words.
        '(lock Dragon | deactivate)':
        Playback([(["go", "to", "sleep"], 0.0)]),

        # Here I'm using BringApp-- this is the same as typing what goes in between the parentheses
        # into the Windows command prompt, without the quotes and commas, like:
        # explorer C:\NatLink\NatLink\MacroSystem
        # -- (which would open Windows Explorer at the specified location). Anything you can do with the command line can be done this way
        # IMPORTANT: If you don't have Dragonfly  6.6  or later, lines 40 and 46  will cause this file to crash and should be commented out
        "open natlink folder":
        BringApp("explorer", "C:\NatLink\NatLink\MacroSystem"),

        # here I'm using the Key action to press some keys -- see the documentation here: http://dragonfly.readthedocs.org/en/latest/actions.html?highlight=key#module-dragonfly.actions.action_key
        "remax":
        Key("a-space/10,r/10,a-space/10,x"),

        # here I'm chaining a bunch of different actions together to do a complex task
        "(show | open) documentation":
        BringApp(
            'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe')
        + WaitWindow(executable="chrome.exe") + Key('c-t') +
        WaitWindow(title="New Tab") +
        Text('http://dragonfly.readthedocs.org/en/latest') + Key('enter'),

        # here I'm just saying one word to trigger some other words
        "hotel":
        Text("hotels are not cheap"),

        # If you need to do more complicated tasks, or use external resources, a function might be what you need.
        # note that here, I'm using extras: "n" and "text"
        # The angle brackets <> meaning I'm using an extra, and the square brackets [] mean that I don't have to speak that word, it's optional.
        # Advice: if you use an optional extra, like I am with "text", you should set a default value  in the defaults section down below.
        # To trigger the following command, you would have to say the word "function" followed by a number between 1 and 1000.
        '[use] function <n> [<text>]':
        Function(my_function, extra={'n', 'text'}),
    }
    extras = [
        IntegerRef("n", 1, 1000),
        Dictation("text"),
        Choice("choice", {
            "alarm": "alarm",
            "custom grid": "CustomGrid",
            "element": "e"
        }),
    ]
    defaults = {
        "n": 1,
        "text": "",
    }