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'), ]
class AlternateKeyMap(MappingRule): mapping = { "wave": Key("shift:up, right"), # "boss": Key("ctrl:down"), # "shun": Key("ctrl:up"), "switch": release + Key("ctrl:down, tab"), "show apps": release + Key("alt:down, tab"), "mimic <text>": release + Mimic(extra="text"), "pop": Key("apps"), # right click "list Windows": Mimic("list", "all", "Windows"), ### programming "short object": Text("obj"), "short string": Text("str"), "jason": Text("json"), ### Dragonfly Commands "add text map": Text("\"\": Text(\"\"),") + Key("left:12"), "add key map": Text("\"\": Key(\"\"),") + Key("left:11"), } extras = [ Integer("n", 1, 50), Integer("tab", 1, 8), Integer("number", 1, 9999), Dictation("text"), ] defaults = { "n": 1, }
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}
def _process_recognition(self, node, extras): dictation = str(extras["text"]).split() # this is the target email subject dictation.insert(0, "click") # this adds the "click" command for Dragon Mimic(*dictation).execute() # expand the list to var args #Pause("10").execute() # doesn"t seem to need this... Mimic("choose", "2").execute()
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"), ]
class MultiMoreKeyMap(MappingRule): mapping = { "wave": Key("shift:up, right"), # "boss": Key("ctrl:down"), # "shun": Key("ctrl:up"), "switch": release + Key("ctrl:down, tab"), "show [all] apps | show [all] Windows": release + Key("alt:down, tab"), "mimic <text>": release + Mimic(extra="text"), "pop": Key("apps"), # right click "focus chrome too": Mimic("focus", "chrome") + Pause("25") + Mimic("focus", "chrome"), # Dragon NaturallySpeaking mimics "list Windows": Mimic("list", "all", "Windows"), "(web search | search web) <text>": Mimic("search", "the", "web", "for", extra="text"), ### programming "short object": Text("obj"), "short string": Text("str"), "jason": Text("json"), ### Dragonfly Commands "add text map": Text("\"\": Text(\"\"),") + Key("left:12"), "add key map": Text("\"\": Key(\"\"),") + Key("left:11"), } extras = [ Integer("n", 1, 50), Integer("tab", 1, 8), Integer("number", 1, 9999), Dictation("text"), ] defaults = { "n": 1, }
def handle_word(text): #words = map(list, text) #print text words = str(text).split() print 'word (', words, ')' if len(words) > 0: Text(words[0]).execute() if len(words) > 1: Mimic(' '.join(words[1:])).execute()
class GmailMappings(MappingRule): mapping = { "Gmail find <text>": Key("slash/25") + Text("%(text)s"), "Gmail undo": Key("z"), "compose": Key("c"), "next mail [<n>]": Key("j:%(n)d"), "(previous | preev) mail [<n>]": Key("k:%(n)d"), "next mess [<n>]": Key("n:%(n)d"), "(previous | preev) mess [<n>]": Key("p:%(n)d"), "(delete | trash)": Key("hash"), "archive": Key("e"), "select [and] archive": Key("x,e"), "line trash [<n>]": Function(lineTrash), "send [and] archive": Mimic("click", "send", "and", "archive"), "send (it | mail)": Key("c-enter"), "reply": Key("r"), "reply [to] all": Key("a"), "forward": Key("f"), "important": Key("s"), # star line item "select [<n>]": Function(select), # navigation "[go to] inbox": Key("g,i"), "[go to] sent mail": Key("g,t"), "[go to] drafts": Key("g,d"), "[go to] label Indeni": Key("g,l/20") + Text("__Indeni") + Key("enter"), # move to folders "move": Key("v"), "move to <text>": Key("x,v/20") + Text("%(text)s") + Key("enter"), "[move] [to] Indeni": Key("x,v/20") + Text("__Indeni") + Key("enter"), "[move] [to] Indeni to do": Key("x,v/20") + Text("__Indeni/todo") + Key("enter"), "[move] [to] receipts": Key("x,v/20") + Text("aa_receipts") + Key("enter"), "[move] [to] asap": Key("x,v/20") + Text("aa_todo/asap") + Key("enter"), "[move] [to] [check back] soon": Key("x,v/20") + Text("aa_todo/check back soon") + Key("enter"), "[move] [to] respond": Key("x,v/20") + Text("aa_todo/respond") + Key("enter"), "[move] [to] someday": Key("x,v/20") + Text("aa_todo/someday") + Key("enter"), "[move] [to] waiting [for response]": Key("x,v/20") + Text("aa_todo/waiting for response") + Key("enter"), "[move] [to] check me out": Key("x,v/20") + Text("check me out") + Key("enter"), "[move] [to] friends": Key("x,v/20") + Text("friends") + Key("enter"), "[move] [to] miscellaneous": Key("x,v/20") + Text("miscellaneous") + Key("enter"), "[move] [to] mom": Key("x,v/20") + Text("mom") + Key("enter"), "[move] [to] notes [to self]": Key("x,v/20") + Text("notes to self") + Key("enter"), "[move] [to] trips": Key("x,v/20") + Text("trips") + Key("enter"), } extras = [ Dictation("text"), Integer("n", 1, 50), ] defaults = { "n": 1, }
def __init__(self, name): Config.__init__(self, name) self.cmd = Section("Language section") self.cmd.map = Item({ "mimic <text>": Mimic(extra="text"), }, namespace={ "Key": Key, "Text": Text, }) self.cmd.extras = Item([Dictation("text")]) self.cmd.defaults = Item({})
class CustomKeysRule(MappingRule): mapping = { "windows": Key('win:down/3, win:up/3'), "caster reboot": Mimic("reboot caster"), "magic":Mouse("left:down/3, left:up/3"), "space bar":Key("space:down/3, space:up/3"), "foot pedal <footPedalMode>":Function(setFootPedalMode), "ecks box controller <onOff>":Function(setControllerMode), "look":Key("f15") # "foot pedal mouse":Function(lambda:writeIni("footMode","mouse")) } extras = [ Choice("footPedalMode",foot_pedal_modes), Choice("onOff",{"on":"on","off":"off"}) ]
class SpellingWindowRule(MappingRule): mapping = { # todo: make these CCR "<first_second_third> word": R(Key("home, c-right:%(first_second_third)d, cs-right"), rdescript="Dragon: select the first second or third etc. word"), "last [word]": R(Key("right, cs-left"), rdescript="Dragon: select the last word"), "second [to] last word": R(Key("right, c-left:1, cs-left"), rdescript="Dragon: select the second to last word"), "<n10>": R(Mimic("choose", extra="n10"), rdescript="Dragon: e.g. instead of having to say 'choose two' you can just say 'two'"), # consider making the above command global so that it works when you say something like # "insert before 'hello'" where there are multiple instances of 'hello' # personally I think it's better just to have the setting where Dragon choose is the closest instance } # see above extras = extras_for_whole_file() defaults = defaults_for_whole_file()
from dragonfly import (Grammar, AppContext, MappingRule, Dictation, Key, Text, Integer, Mimic) context = AppContext(title = "jade") grammar = Grammar("jade", context=context) noSpaceNoCaps = Mimic("\\no-caps-on") + Mimic("\\no-space-on") rules = MappingRule( name = "jade", mapping = { "heading [<n>]": Text("h%(n)d "), "span [<n>]": Text(".span%(n)d"), "paragraph": Text("p ") + noSpaceNoCaps, "link": Text("link") + Key("tab") + noSpaceNoCaps, "attribute": Text("attribute") + Key("tab") + noSpaceNoCaps, "Eckelberry": Text("echo_var") + Key("tab") + noSpaceNoCaps, "row fluid": Text(".row-fluid ") + noSpaceNoCaps, "row": Text(".row") + noSpaceNoCaps, "container": Text(".container") + noSpaceNoCaps, "unordered list": Text("ul") + noSpaceNoCaps, "list item": Text("li") + noSpaceNoCaps, "image": Text("image") + Key("tab") + noSpaceNoCaps, "equal": Text("=") + noSpaceNoCaps, }, extras = [ Dictation("text"), Integer("n", 0, 20000), ], defaults = { "n" : 1 } )
class GitBashRule(MergeRule): pronunciation = "git bash" GIT_ADD_ALL = "g, i, t, space, a, d, d, space, minus, A" GIT_COMMIT = "g, i, t, space, c, o, m, m, i, t, space, minus, m, space, quote, quote, left" mapping = { "(git|get) clone ": Text("git clone "), "(git|get) base": Text("git "), "(git|get) (initialize repository|init)": Text("git init"), "(git|get) add": R(Key("g, i, t, space, a, d, d, space, dot")), "(git|get) add all": R(Key(GIT_ADD_ALL)), "(git|get) commit all": R(Key("%s, ;, space, %s" % (GIT_ADD_ALL, GIT_COMMIT))), "(git|get) status": R(Key("g, i, t, space, s, t, a, t, u, s")), "(git|get) commit": R(Key(GIT_COMMIT)), "(git|get) bug fix commit <n>": R(Mimic("get", "commit") + Text("fixes #%(n)d ") + Key("backspace")), "(git|get) reference commit <n>": R(Mimic("get", "commit") + Text("refs #%(n)d ") + Key("backspace")), "(git|get) checkout": R(Text("git checkout ")), "(git|get) branch": R(Text("git branch ")), "(git|get) reset": R(Text("git reset ")), "(git|get) diff": R(Text("git diff ")), "(git|get) remote": R(Text("git remote ")), "(git|get) merge": R(Text("git merge ")), "(git|get) rebase": R(Text("git rebase ")), "(git|get) merge tool": R(Text("git mergetool")), "(git|get) fetch": R(Text("git fetch ")), "(git|get) push": R(Text("git push ")), "(git|get) pull": R(Text("git pull ")), "CD up": R(Text("cd ..")), "CD": R(Text("cd ")), "make directory": R(Text("mkdir ")), "undo [last] commit | (git|get) reset soft head": R(Text("git reset --soft HEAD~1")), "(undo changes | (git|get) reset hard)": R(Text("git reset --hard")), "stop tracking [file] | (git|get) remove": R(Text("git rm --cached ")), "preview remove untracked | (git|get) clean preview": R(Text("git clean -nd")), "remove untracked | (git|get) clean untracked": R(Text("git clean -fd")), "(git|get) visualize": R(Text("gitk")), "(git|get) visualize file": R(Text("gitk -- PATH")), "(git|get) visualize all": R(Text("gitk --all")), "(git|get) stash": R(Text("git stash")), "(git|get) stash apply [<n>]": R(Text("git stash apply") + Function(_apply)), "(git|get) stash list": R(Text("git stash list")), "(git|get) stash branch": R(Text("git stash branch NAME")), "(git|get) cherry pick": R(Text("git cherry-pick ")), "(git|get) (abort cherry pick | cherry pick abort)": R(Text("git cherry-pick --abort")), "(git|get) (GUI | gooey)": R(Text("git gui")), "(git|get) blame": R(Text("git blame PATH -L FIRSTLINE,LASTLINE")), "(git|get) gooey blame": R(Text("git gui blame PATH")), "search recursive": R(Text("grep -rinH \"PATTERN\" *")), "search recursive count": R(Text("grep -rinH \"PATTERN\" * | wc -l")), "search recursive file type": R(Text("find . -name \"*.java\" -exec grep -rinH \"PATTERN\" {} \\;")), "to file": R(Text(" > FILENAME")), } extras = [ IntegerRefST("n", 1, 10000), ] defaults = {"n": 0}
class CSharp(MergeRule): auto = [".cs", ".cshtml"] pronunciation = "C sharp" mapping = { SymbolSpecs.IF: R(Key("i, f, lparen, rparen, leftbrace, enter,up,left"), rdescript="C#: If"), SymbolSpecs.ELSE: R(Key("e, l, s, e, leftbrace, enter"), rdescript="C#: Else"), # SymbolSpecs.SWITCH: R(Text("switch(){\ncase : break;\ndefault: break;") + Key("up,up,left,left"), rdescript="C#: Switch"), SymbolSpecs.CASE: R(Text("case :") + Key("left"), rdescript="C#: Case"), SymbolSpecs.BREAK: R(Text("break;"), rdescript="C#: Break"), SymbolSpecs.DEFAULT: R(Text("default: "), rdescript="C#: Default"), # SymbolSpecs.DO_LOOP: R(Text("do {}") + Key("left, enter:2"), rdescript="C#: Do Loop"), SymbolSpecs.WHILE_LOOP: R(Text("while ()") + Key("left"), rdescript="C#: While"), SymbolSpecs.FOR_LOOP: R(Text("for (int i=0; i<TOKEN; i++)"), rdescript="C#: For i Loop"), SymbolSpecs.FOR_EACH_LOOP: R(Text("foreach (TOKEN in Collection)"), rdescript="C#: For Each Loop"), # SymbolSpecs.TO_INTEGER: R(Text("Convert.ToInt32()") + Key("left"), rdescript="C#: Convert To Integer"), SymbolSpecs.TO_FLOAT: R(Text("Convert.ToDouble()") + Key("left"), rdescript="C#: Convert To Floating-Point"), SymbolSpecs.TO_STRING: R(Text("Convert.ToString()") + Key("left"), rdescript="C#: Convert To String"), # SymbolSpecs.AND: R(Text("&&"), rdescript="C#: And"), SymbolSpecs.OR: R(Text("||"), rdescript="C#: Or"), SymbolSpecs.NOT: R(Text("!"), rdescript="C# Not"), # SymbolSpecs.SYSOUT: R(Text("Console.WriteLine()") + Key("left"), rdescript="C#: Print"), # SymbolSpecs.FUNCTION: R(Text("TOKEN TOKEN(){}") + Key("left"), rdescript="C#: Function"), SymbolSpecs.CLASS: R(Text("class TOKEN{}") + Key("left"), rdescript="C#: Class"), # SymbolSpecs.COMMENT: R(Text("//"), rdescript="C#: Add Comment"), SymbolSpecs.LONG_COMMENT: R(Text("/**/") + Key("left, left"), rdescript="C#: Long Comment"), # SymbolSpecs.NULL: R(Text("null"), rdescript="C#: Null Value"), # SymbolSpecs.RETURN: R(Text("return"), rdescript="C#: Return"), # SymbolSpecs.TRUE: R(Text("true"), rdescript="C#: True"), SymbolSpecs.FALSE: R(Text("false"), rdescript="C#: False"), # C# specific "using": R(Text("using"), rdescript="C#: Using"), "enum": R(Text("enum TOKEN {}") + Key("left"), rdescript="C#: Enum"), "struct": R(Text("struct TOKEN {}") + Key("left"), rdescript="C#: Struct"), "interface": R(Text("interface TOKEN {}") + Key("left"), rdescript="C#: Struct"), "public": R(Text("public "), rdescript="C#: Public"), "private": R(Text("private "), rdescript="C#: Private"), "static": R(Text("static "), rdescript="C#: Static"), "internal": R(Text("internal "), rdescript="C#: Internal"), "cast integer": R(Text("(int)") + Key("left"), rdescript="C#: Cast Integer"), "cast double": R(Text("(double)") + Key("left"), rdescript="C#: Cast Double"), "constant": R(Text("const"), rdescript="C#: Constant"), "array": R(Mimic("brackets"), rdescript="C#: Array"), "list": R(Text("List<>") + Key("left"), rdescript="C# List"), "var": R(Text("var TOKEN = TOKEN;"), rdescript="C# variable"), "(lambda|goes to)": R(Text("->"), rdescript="C#: lambda"), "new new": R(Text("new "), rdescript="C#: New"), "integer": R(Text("int "), rdescript="C#: Integer"), "double": R(Text("double "), rdescript="C#: Double"), "character": R(Text("char "), rdescript="C#: Character"), "big integer": R(Text("Integer"), rdescript="C#: Big Integer"), "string": R(Text("string "), rdescript="C#: String"), "ternary": R(Text("()?t:f") + (Key("left") * 5), rdescript="C#: Ternary"), } extras = [] defaults = {}
class CPP(MergeRule): auto = [".h", ".cpp"] pronunciation = "C plus plus" mapping = { SymbolSpecs.IF: R(Key("i, f, lparen, rparen, leftbrace, enter,up,left"), rdescript="C++: If"), SymbolSpecs.ELSE: R(Key("e, l, s, e, leftbrace, enter"), rdescript="C++: Else"), # SymbolSpecs.SWITCH: R(Text("switch(){\ncase : break;\ndefault: break;") + Key("up,up,left,left"), rdescript="C++: Switch"), SymbolSpecs.CASE: R(Text("case :") + Key("left"), rdescript="C++: Case"), SymbolSpecs.BREAK: R(Text("break;"), rdescript="C++: Break"), SymbolSpecs.DEFAULT: R(Text("default: "), rdescript="C++: Default"), # SymbolSpecs.DO_LOOP: R(Text("do {}") + Key("left, enter:2"), rdescript="C++: Do Loop"), SymbolSpecs.WHILE_LOOP: R(Text("while ()") + Key("left"), rdescript="C++: While"), SymbolSpecs.FOR_LOOP: R(Text("for (int i=0; i<TOKEN; i++)"), rdescript="C++: For i Loop"), SymbolSpecs.FOR_EACH_LOOP: R(Text("for_each (TOKEN, TOKEN, TOKEN);"), rdescript="C++: For Each Loop"), # SymbolSpecs.TO_INTEGER: R(Text("(int)"), rdescript="C++: Convert To Integer"), SymbolSpecs.TO_FLOAT: R(Text("(double)"), rdescript="C++: Convert To Floating-Point"), SymbolSpecs.TO_STRING: R(Text("std::to_string()") + Key("left"), rdescript="C++: Convert To String"), # SymbolSpecs.AND: R(Text("&&"), rdescript="C++: And"), SymbolSpecs.OR: R(Text("||"), rdescript="C++: Or"), SymbolSpecs.NOT: R(Text("!"), rdescript="Not"), # SymbolSpecs.SYSOUT: R(Text("cout <<"), rdescript="C++: Print"), # SymbolSpecs.IMPORT: R(Text("#include"), rdescript="C++: Import"), # SymbolSpecs.FUNCTION: R(Text("TOKEN TOKEN(){}") + Key("left"), rdescript="C++: Function"), SymbolSpecs.CLASS: R(Text("class TOKEN{}") + Key("left"), rdescript="C++: Class"), # SymbolSpecs.COMMENT: R(Text("//"), rdescript="C++: Add Comment"), SymbolSpecs.LONG_COMMENT: R(Text("/**/") + Key("left, left"), rdescript="C++: Long Comment"), # SymbolSpecs.NULL: R(Text("null"), rdescript="C++: Null Value"), # SymbolSpecs.RETURN: R(Text("return"), rdescript="C++: Return"), # SymbolSpecs.TRUE: R(Text("true"), rdescript="C++: True"), SymbolSpecs.FALSE: R(Text("false"), rdescript="C++: False"), # C++ specific "public": R(Text("public "), rdescript="C++: Public"), "private": R(Text("private "), rdescript="C++: Private"), "static": R(Text("static "), rdescript="C++: Static"), "final": R(Text("final "), rdescript="C++: Final"), "static cast integer": R(Text("static_cast<int>()") + Key("left"), rdescript="C++: Static Cast Integer"), "static cast double": R(Text("static_cast<double>()") + Key("left"), rdescript="C++: Static Cast Double"), "([global] scope | name)": R(Text("::"), rdescript="C++: ::"), "Vic": R(Text("vector"), rdescript="C++: Vector"), "pushback": R(Text("push_back"), rdescript="C++: Pushback"), "standard": R(Text("std"), rdescript="C++: Standard"), "constant": R(Text("const"), rdescript="C++: Constant"), "array": R(Mimic("brackets"), rdescript="C++: Array"), #http://www.learncpp.com/cpp-tutorial/67-introduction-to-pointers/ "(reference to | address of)": R(Text("&"), rdescript="C++: Reference"), "(pointer | D reference)": R(Text("*"), rdescript="C++: Dereference"), "member": R(Text("->"), rdescript="C++: Member"), "new new": R(Text("new "), rdescript="C++: New"), "integer": R(Text("int "), rdescript="C++: Integer"), "double": R(Text("double "), rdescript="C++: Double"), "character": R(Text("char "), rdescript="C++: Character"), "big integer": R(Text("Integer"), rdescript="C++: Big Integer"), "string": R(Text("string "), rdescript="C++: String"), "ternary": R(Text("()?;") + (Key("left") * 3), rdescript="C++: Ternary"), } extras = [] defaults = {} token_set = TokenSet([ "alignas", "alignof", "and", "and_eq", "asm", "auto", "bitand", "bitor", "bool", "break", "case", "catch", "char", "char16_t", "char32_t", "class", "compl", "concept", "const", "constexpr", "const_cast", "continue", "decltype", "default", "delete", "do", "double", "dynamic_cast", "else", "enum", "explicit", "export", "extern", "false", "float", "for", "friend", "goto", "if", "inline", "int", "long", "mutable", "namespace", "new", "noexcept", "not", "not_eq", "nullptr", "operator", "or", "or_eq", "private", "protected", "public", "register", "reinterpret_cast", "requires", "return", "short", "signed", "sizeof", "static", "static_assert", "static_cast", "struct", "switch", "template", "this", "thread_local", "throw", "true", "try", "typedef", "typeid", "typename", "union", "unsigned", "using", "virtual", "void", "volatile", "wchar_t", "while", "xor", "xor_eq" ], "//", ["/*", "*/"])
def start_day(): # Mimic('open', 'dryfly') # Pause('500') Mimic('open', 'pie') Mimic('connect', 'pre')
class CSharp(MergeRule): pronunciation = "C sharp" mapping = { SymbolSpecs.IF: R(Key("i, f, lparen, rparen, leftbrace, enter,up,left")), SymbolSpecs.ELSE: R(Key("e, l, s, e, leftbrace, enter")), # SymbolSpecs.SWITCH: R( Text("switch(){\ncase : break;\ndefault: break;") + Key("up,up,left,left")), SymbolSpecs.CASE: R(Text("case :") + Key("left")), SymbolSpecs.BREAK: R(Text("break;")), SymbolSpecs.DEFAULT: R(Text("default: ")), # SymbolSpecs.DO_LOOP: R(Text("do {}") + Key("left, enter:2")), SymbolSpecs.WHILE_LOOP: R(Text("while ()") + Key("left")), SymbolSpecs.FOR_LOOP: R(Text("for (int i=0; i<TOKEN; i++)")), SymbolSpecs.FOR_EACH_LOOP: R(Text("foreach (TOKEN in Collection)")), # SymbolSpecs.TO_INTEGER: R(Text("Convert.ToInt32()") + Key("left")), SymbolSpecs.TO_FLOAT: R(Text("Convert.ToDouble()") + Key("left")), SymbolSpecs.TO_STRING: R(Text("Convert.ToString()") + Key("left")), # SymbolSpecs.AND: R(Text("&&")), SymbolSpecs.OR: R(Text("||")), SymbolSpecs.NOT: R(Text("!")), # SymbolSpecs.SYSOUT: R(Text("Console.WriteLine()") + Key("left")), # SymbolSpecs.FUNCTION: R(Text("TOKEN TOKEN(){}") + Key("left")), SymbolSpecs.CLASS: R(Text("class TOKEN{}") + Key("left")), # SymbolSpecs.COMMENT: R(Text("//")), SymbolSpecs.LONG_COMMENT: R(Text("/**/") + Key("left, left")), # SymbolSpecs.NULL: R(Text("null")), # SymbolSpecs.RETURN: R(Text("return")), # SymbolSpecs.TRUE: R(Text("true")), SymbolSpecs.FALSE: R(Text("false")), # C# specific "using": R(Text("using")), "enum": R(Text("enum TOKEN {}") + Key("left")), "struct": R(Text("struct TOKEN {}") + Key("left")), "interface": R(Text("interface TOKEN {}") + Key("left")), "public": R(Text("public ")), "private": R(Text("private ")), "static": R(Text("static ")), "internal": R(Text("internal ")), "cast integer": R(Text("(int)") + Key("left")), "cast double": R(Text("(double)") + Key("left")), "constant": R(Text("const")), "array": R(Mimic("brackets")), "list": R(Text("List<>") + Key("left")), "var": R(Text("var TOKEN = TOKEN;")), "(lambda|goes to)": R(Text("=>")), "new new": R(Text("new ")), "integer": R(Text("int ")), "double": R(Text("double ")), "character": R(Text("char ")), "big integer": R(Text("Integer")), "string": R(Text("string ")), "ternary": R(Text("()?t:f") + (Key("left") * 5)), } extras = [] defaults = {}
class DragonRule(MappingRule): mapping = { '(number|numbers) mode': R(Playback([(["numbers", "mode", "on"], 0.0)])), 'spell mode': R(Playback([(["spell", "mode", "on"], 0.0)])), 'dictation mode': R(Playback([(["dictation", "mode", "on"], 0.0)])), 'normal mode': R(Playback([(["normal", "mode", "on"], 0.0)])), '(command mode | command on | com on)': R(Playback([(["command", "mode", "on"], 0.0)])), '(command off | com off)': R(Playback([(["command", "mode", "off"], 0.0)])), "fix dragon double": R(Function(fix_dragon_double)), "left point": R( Playback([(["MouseGrid"], 0.1), (["four", "four"], 0.1), (["click"], 0.0)])), "right point": R( Playback([(["MouseGrid"], 0.1), (["six", "six"], 0.1), (["click"], 0.0)])), "center point": R(Playback([(["MouseGrid"], 0.1), (["click"], 0.0)]), rdescript="Mouse: Center Point"), "show windows": R(Mimic("list", "all", "windows"), rdescript="Dragon: emulate Dragon command for listing windows"), "cory <text>": R(Mimic("correct", extra="text") + WaitWindow(title="spelling window") + Mimic("choose", "one"), rdescript= "Dragon: brings up the correction menu for the phrase spoken in the command and chooses the 1st choice" ), "cory that": R(Mimic("correct", "that") + WaitWindow(title="spelling window") + Mimic("choose", "one"), rdescript= "Dragon: brings up the correction menu for the previously spoken phrase and chooses the first choice" ), "make that <text>": R(Mimic("scratch", "that") + Mimic(extra="text"), rdescript= "Dragon: deletes the dictation generated by the previous utterance and replaces it with what you say next" ), "scratch [<n10>]": R(Playback([(["scratch", "that"], 0.03)]), rdescript="Dragon: delete dictation from previous n utterances") * Repeat(extra="n10"), # Users may want to adjust the wait time on the next few commands "train word": R(Mimic("train", "that") + Pause("75") + Key("a-r/250, s"), rdescript= "Dragon: quickly train word when you have it selected in a Dragon friendly text field" ), "word train": R(Key("c-c/20") + Mimic("edit", "vocabulary") + Key("c-v/5, tab, down, up, a-t/50, enter/50, a-r/250, s/50, escape"), rdescript= "train word quickly once you have it selected in non-full text control application" ), "(add train | train from add word)": R(Key("a-a/2, enter/300, a-s"), rdescript="Dragon: quickly train word from the add word dialogbox"), "(train from vocab | cab train)": R(Key("a-t/50, enter/50, a-r/250, s"), rdescript="Dragon: quickly train word from Vocabulary Editor"), "(train from vocab | cab train)": R(Key("a-t/50, enter/50, a-r/250, s"), rdescript="Dragon: quickly train word from Vocabulary Editor"), "remove from vocab": R(Key("c-c/5") + Mimic("edit", "vocabulary") + Pause("20") + Key("c-v/10, tab, down, up/5, a-d, y, escape/30, right"), rdescript="Dragon: remove selected word from vocabulary"), "(add to vocab | vocab that)": R(Key("c-c/5") + Mimic("add", "word") + Pause("20") + Key("c-v, a-a/2, enter/300, a-s/30, right"), rdescript="Dragon: add selected word to vocabulary and train it"), "recognition history": R(Playback([(["view", "recognition", "history"], 0.03)]), rdescript="Dragon: open Dragon recognition history"), "peak [recognition] history": R(Playback([(["view", "recognition", "history"], 0.03)]) + Pause("300") + Key("escape"), rdescript="Dragon: open Dragon recognition history then close it"), "[dictation] sources": R(Mimic("manage", "dictation", "sources"), rdescript="Dragon: manage dictation sources"), } # see above extras = extras_for_whole_file() defaults = defaults_for_whole_file()
Key("a-tab"), "termi": Key("w-b/10, s-tab/10, enter"), "foxy": Key("w-b/10, s-tab/10, right:1/10, enter"), "foxy reload": Key("w-b/10, s-tab/10, right:1/10, enter/10, f5"), "Jimmy": Key("w-b/10, s-tab/10, right:2/10, enter"), "Heidi": Key("w-b/10, s-tab/10, right:3/10, enter"), "chrome": Key("w-b/10, s-tab/10, right:4/10, enter"), "chrome reload": Key("w-b/10, s-tab/10, right:4/10, enter/10, f5"), "bashing": Key("w-b/10, s-tab/10, right:5/10, enter"), "code mode": Mimic("\\no-caps-on") + Mimic("\\no-space-on"), }) grammar = Grammar("general") grammar.add_rule(rules) grammar.load() def unload(): global grammar if grammar: grammar.unload() grammar = None
"right when": Key("w-right"), "min win": Key("w-down"), "switch apps": Key("alt:down, tab"), "switch app": Key("a-tab/10"), "search tabs": Key("ctrl:down, tab"), "free": Key("alt:up") + Key("shift:up") + Key("ctrl:up"), "folders": Key("w-b/10, s-tab/10, enter"), "foxy": Key("w-b/10, s-tab/10, right:1/10, enter"), "foxy reload": Key("w-b/10, s-tab/10, right:1/10, enter/10, f5"), "Eddie": Key("w-b/10, s-tab/10, right:2/10, enter"), "Heidi": Key("w-b/10, s-tab/10, right:3/10, enter"), "chrome": Key("w-b/10, s-tab/10, right:4/10, enter"), "skype": Key("w-b/10, s-tab/10, right:5/10, enter"), "chrome reload": Key("w-b/10, s-tab/10, right:4/10, enter/10, f5"), "bashing": Key("w-b/10, s-tab/10, right:5/10, enter"), "como": Mimic("\\no-caps-on") + Mimic("\\no-space-on"), "escape": Key('escape'), "switch tab": Key('c-tab'), "new one": Key('c-n'), "kick": Mouse('left'), "rye kick": Mouse('right'), "dee kick": Mouse('left:2'), "block": Key("f6"), "address bar": Key ("a-d"), "logout of computer": Key ("w-l"), "crack": Key("s-f10") + Key("down"), "open file" : Key("c-o"), "logout" : Mimic("press windows ell"), # svn
def _copy_chunk(to, direction): """Copies a section of the current line to the clipboard""" save_clip() Key(to + ", c-c/5").execute() Key(direction).execute() def just(text=""): """Prints a word without calling any functions associated with that word""" Text(re.sub(r'[\W]', '', str(text))).execute() series_rule = SeriesMappingRule( mapping={ "word <text>": Function(just), "drop word": Mimic("delete previous word"), "kill word": Mimic("delete next word"), "skip [<n>]": Function(jump_forward, text=""), "skip <token>": Function(jump_forward), "step [<n>]": Function(jump_backward, text=""), "step <token>": Function(jump_backward), "drop [<n>]": Function(delete_backward), "ditch [<n>]": Function(delete_forward), "select [<n>]": Function(select_forward, text=""), "select next": Function(select_next, text=""), "select <token>": Function(select_forward), "trunk": Key("s-end, delete"), "chop": Key("s-home, delete"), # Belongs in a different module "prog [<n>]": Function(switch_task),
# Ex: "snake case my new variable" -> "my_new_variable" # Ex: "uppercase squash my new hyphen variable" -> "MYNEW-VARIABLE" "<formatType> <text>": Function(format_text), # For writing words that would otherwise be characters or commands. # Ex: "period", tab", "left", "right", "home". "say <reservedWord>": Text("%(reservedWord)s"), # Abbreviate words commonly used in programming. # Ex: arguments -> args, parameters -> params. "squish <abbreviation>": Text("%(abbreviation)s"), # Text corrections. "(add|fix) missing space": Key("c-left/3, space, c-right/3"), "(delete|remove) (double|extra) (space|whitespace)": Key("c-left/3, backspace, c-right/3"), # @IgnorePep8 "(delete|remove) (double|extra) (type|char|character)": Key("c-left/3, del, c-right/3"), # @IgnorePep8 # Microphone sleep/cancel started dictation. "clinkz": Function(reload_rules), # @IgnorePep8 "code mode": Mimic("\\no-caps-on") + Mimic("\\no-space-on"), # create rules "dragon rule": Text('dragonrule') + Key("tab"), "dragon text": Text('dragontext') + Key("tab"), "dragon key": Text('dragonkey') + Key("tab"), "dockmel <text>": Text('.') + Function(camel_case_text), "libra": Text("() {}") + Key('left, enter'), 'pro one': Key('w-1'), 'pro two': Key('w-2'), 'pro three': Key('w-3'), 'pro four': Key('w-4'), 'pro five': Key('w-5'), 'pro six': Key('w-6'),
class CustomGitBashRule(MappingRule): pronunciation = "custom get bash" mapping = { "initialize repository": Text("git init") + Key("enter"), "log": Key("g, i, t, space, l, o, g") + Key("enter"), "Re-base": Key("g, i, t, space, r, e, b, a, s, e, space"), "Re-base interactive": Key("g, i, t, space, r, e, b, a, s, e, space, minus, i, space, H, E, A, D, ~" ), "add": R(Key("g, i, t, space, a, d, d, space, minus, p"), rdescript="GIT: Add All"), "status": R(Key("g, i, t, space, s, t, a, t, u, s, enter"), rdescript="GIT: Status"), "reset": R(Key( "g, i, t, space, r, e, s, e, t, space, minus, minus, s, o, f, t, space, H, E, A, D, ~" ), rdescript="GIT: Reset"), "commit": R(Key( "g, i, t, space, c, o, m, m, i, t, space, minus, 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"), "check out new branch": R(Text("git checkout -b feature/SWOPS-"), rdescript="GIT: Check Out New Branch"), "difference": R(Text("git diff") + Key('enter'), rdescript="GIT: Diff"), "branch": R(Text("git branch") + Key("enter"), rdescript="GIT: Branch"), "remote": R(Text("git remote "), rdescript="GIT: Remote"), "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 "), rdescript="GIT: Push"), "(get push origin | push origin)": R(Text("git push -u origin "), rdescript="GIT: Push Origin"), "pull": R(Text("git pull") + Key("enter"), rdescript="GIT: Pull"), "dirrup": R(Text("cd ../ ; ls;") + Key("enter"), rdescript="GIT: Up Directory"), "list": R(Text("ls "), rdescript="GIT: List"), "list all": R(Text("ls -la "), rdescript="GIT: List all"), "Moved or": # move dir R(Text("mv "), rdescript="GIT: Move"), "make directory": R(Text("mkdir "), rdescript="GIT: Make Directory"), "abort": R(Key("c-c "), rdescript="GIT: Abort"), "undo [last] commit": R(Text("git reset --soft HEAD~1") + Key("enter"), rdescript="GIT: Undo Commit"), "(undo changes | reset hard)": R(Text("git reset --hard") + Key("enter"), rdescript="GIT: Undo or Reset 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 "), 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"), "search": R(Key("c-r"), rdescript="Bash: To File"), # Specific Commands "remove directory [<text>]": R(Text("rm -rf ") + Text("%(text)s"), rdescript="GIT: Navigate To Caster Directory"), "CD [<text>]": R(Text("cd ") + Text("%(text)s") + Text("; ls") + Key("left") + Key("left") + Key("left") + Key("left"), rdescript="GIT: Navigate To Caster Directory"), "CD Castor": R(Text("cd /c/NatLink/NatLink/MacroSystem/caster") + Key("enter"), rdescript="GIT: Navigate To Caster Directory"), "CD custom Castor": R(Text("cd /c/NatLink/NatLink/MacroSystem/caster/user") + Key("enter"), rdescript="GIT: Navigate To Caster Directory"), "checkout develop": R(Text("git checkout develop") + Key("enter"), rdescript="GIT: Check Out"), # "Mungo": # R(Text("mongo "), rdescript="GIT: Check Out"), "Clear": R(Text("clear") + Key("enter"), rdescript="GIT: Check Out"), "Cat": R(Text("cat "), rdescript="GIT: Check Out"), "SSH [<text>]": R(Text("ssh ") + Text("%(text)s"), rdescript="GIT: ssh"), "pseudo": R(Text("sudo "), rdescript="GIT: Check Out"), "apt get install": R(Text("apt-get install "), rdescript="GIT: Check Out"), "next tab": R(Key("c-tab"), rdescript="switch tab"), "pytest": R(Text("pytest -s -vv"), rdescript="run pytest"), "activate environment": R(Text("source .venv/bin/activate") + Key("enter"), rdescript="activate virtual environment"), } extras = [ ShortIntegerRef("n", 1, 10000), Dictation("text"), ] defaults = {"n": 0, "text": ""}
import natlink from dragonfly import (Grammar, AppContext, MappingRule, Dictation, Key, Text, FocusWindow, Function, Mimic, StartApp, IntegerRef) grammar = Grammar("global") def snore(**kw): natlink.setMicState('sleeping') example_rule = MappingRule( name="global", mapping={ 'scratch': Mimic('scratch', 'that'), 'Pick <n>': Key('down/5:%(n)d, enter'), 'Pick Minus <n>': Key('up/5:%(n)d, enter'), 'swap': Key('w-tab/5'), '<n> swap': Key('w-tab/5:%(n)d'), 'swap <text>': FocusWindow(title='%(text)s'), 'win left': Key('w-left'), 'win right': Key('w-right'), 'desk <n>': Key('w-%(n)d'), 'snore': Function(snore), 'Show task [manager]': Key('cs-escape'), # # Words and phrases 'import clarus': Text('import brighttrac2 as clarus'), },
class CPP(MergeRule): pronunciation = "C plus plus" mapping = { SymbolSpecs.IF: R(Key("i, f, lparen, rparen, leftbrace, enter,up,left")), SymbolSpecs.ELSE: R(Key("e, l, s, e, leftbrace, enter")), # SymbolSpecs.SWITCH: R( Text("switch(){\ncase : break;\ndefault: break;") + Key("up,up,left,left")), SymbolSpecs.CASE: R(Text("case :") + Key("left")), SymbolSpecs.BREAK: R(Text("break;")), SymbolSpecs.DEFAULT: R(Text("default: ")), # SymbolSpecs.DO_LOOP: R(Text("do {}") + Key("left, enter:2")), SymbolSpecs.WHILE_LOOP: R(Text("while ()") + Key("left")), SymbolSpecs.FOR_LOOP: R(Text("for (int i=0; i<TOKEN; i++)")), SymbolSpecs.FOR_EACH_LOOP: R(Text("for_each (TOKEN, TOKEN, TOKEN);")), # SymbolSpecs.TO_INTEGER: R(Text("(int)")), SymbolSpecs.TO_FLOAT: R(Text("(double)")), SymbolSpecs.TO_STRING: R(Text("std::to_string()") + Key("left")), # SymbolSpecs.AND: R(Text("&&")), SymbolSpecs.OR: R(Text("||")), SymbolSpecs.NOT: R(Text("!")), # SymbolSpecs.SYSOUT: R(Text("cout <<")), # SymbolSpecs.IMPORT: R(Text("#include")), # SymbolSpecs.FUNCTION: R(Text("TOKEN TOKEN(){}") + Key("left")), SymbolSpecs.CLASS: R(Text("class TOKEN{}") + Key("left")), # SymbolSpecs.COMMENT: R(Text("//")), SymbolSpecs.LONG_COMMENT: R(Text("/**/") + Key("left, left")), # SymbolSpecs.NULL: R(Text("null")), # SymbolSpecs.RETURN: R(Text("return")), # SymbolSpecs.TRUE: R(Text("true")), SymbolSpecs.FALSE: R(Text("false")), # C++ specific "public": R(Text("public ")), "private": R(Text("private ")), "static": R(Text("static ")), "final": R(Text("final ")), "static cast integer": R(Text("static_cast<int>()") + Key("left")), "static cast double": R(Text("static_cast<double>()") + Key("left")), "([global] scope | name)": R(Text("::")), "Vic": R(Text("vector")), "pushback": R(Text("push_back")), "standard": R(Text("std")), "constant": R(Text("const")), "array": R(Mimic("brackets")), #http://www.learncpp.com/cpp-tutorial/67-introduction-to-pointers/ "(reference to | address of)": R(Text("&")), "(pointer | D reference)": R(Text("*")), "member": R(Text("->")), "new new": R(Text("new ")), "integer": R(Text("int ")), "double": R(Text("double ")), "character": R(Text("char ")), "big integer": R(Text("Integer")), "string": R(Text("string ")), "ternary": R(Text("()?;") + (Key("left") * 3)), } extras = [] defaults = {}
class MainRule(MappingRule): mapping = { "snore": Mimic("stop", "listening"), }
from dragonfly import Mimic from caster.asynch.auto_com import language from caster.lib import control, utilities, settings from caster.lib.dfplus.state.short import R _LAST = False _HAS_RUN_FIRST_TIME = False _ON = R(Mimic("command", "mode", "on"), rdescript="Command Mode On") _OFF = R(Mimic("command", "mode", "off"), rdescript="Command Mode Off") if control.nexus().dep.NATLINK: import natlink def toggle(): if control.nexus().dep.NATLINK and natlink.getMicState() != "on": return '''determines whether to toggle and then if so toggles appropriately''' global _LAST, _HAS_RUN_FIRST_TIME, _ON, _OFF should_toggle = False if not _HAS_RUN_FIRST_TIME: should_toggle = True _HAS_RUN_FIRST_TIME = True if not settings.SETTINGS["auto_com"]["change_language_only"]: current_window = utilities.get_active_window_path().split("\\")[-1] should_be_on = current_window in settings.SETTINGS["auto_com"][ "executables"] should_toggle = should_be_on != _LAST
if isinstance(window, str): window = [window] for j, words in enumerate(window): windows_mapping[windows_prefix + " " + words] = Key( "win:down, %d:%d/10, win:up" % (i + 1, j + 1)) windows_prefix_second = "go to" windows_mapping_second = {} for i, window in enumerate(windows): if isinstance(window, str): window = [window] for j, words in enumerate(window): windows_mapping_second[windows_prefix_second + " " + words] = Key( "win:down, %d:%d/10, %d:%d/10, win:up" % (i + 1, j + 1, i + 1, j + 1)) # Work around security restrictions in Windows 8. if platform.release() == "8": swap_action = Mimic("press", "alt", "tab") else: swap_action = Key("alt:down, tab:%(n)d/25, alt:up") final_action_map = utils.combine_maps(windows_mapping, windows_mapping_second, { "swap [<n>]": swap_action, }) final_element_map = {"n": (IntegerRef(None, 1, 5), 1)} final_rule = utils.create_rule("FinalRule", final_action_map, final_element_map)
class KeystrokeRule(MappingRule): release = Key("shift:up, ctrl:up") mapping = { "[<n>] up": Key("up/2:%(n)d"), "[<n>] down": Key("down/2:%(n)d"), "[<n>] left": Key("left/2:%(n)d"), "[<n>] right": Key("right/2:%(n)d"), "[<n>] pop": Key("pgup/2:%(n)d"), "[<n>] pen": Key("pgdown/2:%(n)d"), "<n> up (page | pages)": Key("pgup/2:%(n)d"), "<n> down (page | pages)": Key("pgdown/2:%(n)d"), "<n> left (word | words)": Key("c-left/2:%(n)d"), "<n> right (word | words)": Key("c-right/2:%(n)d"), "home": Key("home"), "end": Key("end"), "doc home": Key("c-home"), "doc end": Key("c-end"), "follow": Key("ctrl:down") + Mouse("left") + Key("ctrl:up"), # "soot": Key("escape"), # "[<n>] joot": release + Key("space/2:%(n)d"), "[<n>] slap": release + Key("enter/2:%(n)d"), "[<n>] tab": Key("tab/2:%(n)d"), "[<n>] dij": release + Key("del/2:%(n)d"), "ditch [<n> | this] (line|lines)": release + Key("home, s-down/2:%(n)d, del"), "[<n>] boot": release + Key("backspace/2:%(n)d"), "pop up": release + Key("apps"), "pinj": release + Key("c-v"), "duplicate <n>": release + Key("c-c, c-v:%(n)d"), "copy": release + Key("c-c"), "thatsy": release + Key("c-c"), "cut": release + Key("c-x"), "select all": release + Key("c-a"), # "[hold] appsj": Key("apps:down"), # "appsup": d Key("apps:up,"), "[hold] shi": Key("shift:down"), "shiffup": Key("shift:up"), "[hold] zoo": Key("ctrl:down"), "contup": Key("ctrl:up"), "[hold] az": Key("alt"), "altup": Key("alt:up"), "release [all]": release, "tux": Key("c-a"), "amplify": Key("c-plus"), # "say <text>": release + Text("%(text)s"), "mimic <text>": release + Mimic(extra="text"), "efyek": Key("f1"), "efdouce": Key("f2"), "efse": Key("f3"), "efchar": Key("f4"), "efpanj": Key("f5"), "efshish": Key("f6"), "efhaf": Key("f7"), "efhash": Key("f8"), "efnoh": Key("f9"), "efdah": Key("f10"), "efyazdah": Key("f11"), "efdavazdah": Key("f12"), "efsizdah": Key("f13"), "efcharda": Key("f14"), "efpoonza": Key("f15"), "inteli jey": Text("intellij") } extras = [ IntegerRef("n", 1, 100), Dictation("text"), Dictation("text2"), ] defaults = { "n": 1, }
class GmailMappings(MappingRule): select_line_open_move = Key("x/30,v/30") mapping = { "Gmail find <text>": Key("slash/25") + Text("%(text)s"), "Gmail undo": Key("z"), "compose": Key("c"), "next mail [<n>]": Key("j:%(n)d"), "(previous | preev) mail [<n>]": Key("k:%(n)d"), "next mess [<n>]": Key("n:%(n)d"), "(previous | preev) mess [<n>]": Key("p:%(n)d"), "(delete | trash)": Key("hash"), "archive": Key("e"), "select [and] archive": Key("x,e"), "line trash [<n>]": Function(lineTrash), "send [and] archive": Mimic("click", "send", "and", "archive"), "send (it | mail)": Key("c-enter"), "reply": Key("r"), "reply [to] all": Key("a"), "forward": Key("f"), "important": Key("s"), # star line item "select [<n>]": Function(select), # navigation "Gmail back": Key("u"), "[go to] inbox": Key("g,i"), "[go to] sent mail": Key("g,t"), "[go to] drafts": Key("g,d"), # move to folders "move": Key("v"), "move to <text>": select_line_open_move + Text("%(text)s") + Key("enter"), #"[go to] label ASAP": Key("g,l/20") + Text("aa_todo/asap") + Key("enter"), "[go to] label asap": Key("g,l/20") + Text("aa_todo/asap") + Key("enter"), "[go to] label check [back] soon": Key("g,l/20") + Text("aa_todo/check back soon") + Key("enter"), "[go to] label respond": Key("g,l/20") + Text("aa_todo/respond") + Key("enter"), "[go to] label someday": Key("g,l/20") + Text("aa_todo/someday") + Key("enter"), "[go to] label waiting [for response]": Key("g,l/20") + Text("aa_todo/waiting for response") + Key("enter"), "[go to] label newsletters": Key("g,l/20") + Text("newsletters") + Key("enter"), "[move] [to] asap": Function(selectAndMove, dest="aa_todo/asap"), "[move] [to] [check back] soon": Function(selectAndMove, dest="aa_todo/check back soon"), "[move] [to] respond": Function(selectAndMove, dest="aa_todo/respond"), "[move] [to] someday": Function(selectAndMove, dest="aa_todo/someday"), "[move] [to] waiting [for response]": Function(selectAndMove, dest="aa_todo/waiting for response"), "move [to] inbox": Function(selectAndMove, dest="inbox"), "[move] [to] receipts": Function(selectAndMove, dest="aa_receipts"), "[move] [to] donations": Function(selectAndMove, dest="aa_receipts/donations"), "[move] [to] expenses": Function(selectAndMove, dest="aa_receipts/expenses"), "[move] [to] check me out": Function(selectAndMove, dest="check me out"), "[move] [to] friends": Function(selectAndMove, dest="friends"), "[move] [to] (health | health medical)": Function(selectAndMove, dest="health medical"), "[move] [to] job search": Function(selectAndMove, dest="aa_job search"), "[move] [to] job alerts": Function(selectAndMove, dest="aa_job search/alerts"), "[move] [to] applied for": Function(selectAndMove, dest="aa_job search/applied for"), "[move] [to] contacts": Function(selectAndMove, dest="aa_job search/contacts"), "[move] [to] Karsa": Function(selectAndMove, dest="Karsa"), "[move] [to] MVNS": Function(selectAndMove, dest="Karsa/MVNS"), "[move] [to] miscellaneous": Function(selectAndMove, dest="miscellaneous"), "[move] [to] mom": Function(selectAndMove, dest="mom"), "[move] [to] notes [to self]": Function(selectAndMove, dest="notes to self"), "[move] [to] trips": Function(selectAndMove, dest="trips"), # "[go to] label Indeni": Key("g,l/20") + Text("__Indeni") + Key("enter"), # "[go to] label Indeni inbox": Key("g,l/20") + Text("__Indeni/_in") + Key("enter"), # "[go to] label Indeni to do": Key("g,l/20") + Text("__Indeni/_todo") + Key("enter"), # # "[move] [to] Indeni": Function(selectAndMove, dest="__Indeni"), # "[move] [to] Indeni inbox": Function(selectAndMove, dest="__Indeni/_in"), # "[move] [to] Indeni to do": Function(selectAndMove, dest="__Indeni/_todo"), # "[move] [to] Indeni waiting": Function(selectAndMove, dest="__Indeni/_waiting"), } extras = [ Dictation("text"), Integer("n", 1, 50), ] defaults = { "n": 1, }