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, }
class SSMSRule(MappingRule): mapping = { # There doesn't seem to be a hotkey for sequential tab navigation in SSMS, but something is better than nothing... "next tab [<n>]": R(Key("c-tab")) * Repeat(extra="n"), "prior tab [<n>]": R(Key("cs-tab")) * Repeat(extra="n"), "close tab [<n>]": R(Key("c-f4/20")) * Repeat(extra="n"), "go to line": R(Key("c-g")), "comment line": R(Key("c-k, c-c")), "comment block": R(Key("c-k, c-c")), "(un | on) comment line": R(Key("c-k/50, c-u")), "(un | on) comment block": R(Key("c-k/50, c-u")), "[toggle] full screen": R(Key("sa-enter")), "(set | toggle) bookmark": R(Key("c-k, c-k")), "next bookmark": R(Key("c-k, c-n")), "prior bookmark": R(Key("c-k, c-p")), "[toggle] break point": R(Key("f9")), "step over [<n>]": R(Key("f10/50") * Repeat(extra="n")), "step into": R(Key("f11")), "step out [of]": R(Key("s-f11")), "resume": R(Key("f5")), } extras = [ Dictation("text"), Dictation("mim"), IntegerRefST("n", 1, 1000), ] defaults = {"n": 1, "mim": ""}
class YamlRule(MappingRule): mapping = { specs.SymbolSpecs.SYSOUT: Text("- debug: \n\t\tmsg: "), specs.SymbolSpecs.TO_INTEGER: Text("|int "), specs.SymbolSpecs.TO_FLOAT: Text("|float"), specs.SymbolSpecs.TO_STRING: Text("|str"), specs.SymbolSpecs.GET_LENGTH: Text("|length"), specs.SymbolSpecs.AND: Text(" and "), specs.SymbolSpecs.OR: Text(" or "), specs.SymbolSpecs.NOT: Text(" not "), specs.SymbolSpecs.IMPORT: Text("import_tasks"), specs.SymbolSpecs.NOT_EQUAL_NULL: Text(" is not undefined"), specs.SymbolSpecs.NULL: Text(" is undefined"), specs.SymbolSpecs.TRUE: Text("True"), specs.SymbolSpecs.FALSE: Text("False"), "(started | start it)": Text("- "), "start when": Text("- when: "), "long not": Text(" not "), "it are in": Text(" in "), #supposed to sound like "iter in" # "convert to int": Text("|int "), "[dot] (pie | pi)": Text(".py"), "dot YAML": Text(".yml"), "(create | define) variable": Text("- set_fact:\n\t\t"), "(print | debug) variable": Text("- debug: var="), "(print | debug) message": Text("- debug:\n\t\tmsg: "), "(extract | get) variable": Text("\"{{}}\"") + Key("left:3") } extras = [ Dictation("modifiers"), Dictation("text"), ] defaults = { "modifiers": None, }
class QuickReplaceRule(MappingRule): mapping = { "strip <haystack>": Text(":%%s/%(haystack)s//c") + Key('enter'), "replace <replace>": Text(":%%s//%(replace)s/c") + Key('enter'), "sub <haystack> shark <replace>": Text(":%%s/%(haystack)s/%(replace)s/c") + Key('enter'), # For the confirmation dialog (due to the C flag) "sub (this | it | yes)": Key("y"), "sub (no | not)": Key("y"), "sub all": Key("a"), "sub last": Key("l"), "sub quit": Key("q"), } extras = [ Dictation("haystack"), Dictation("replace"), ]
class SublimeRule(MergeRule): pronunciation = "sublime" mapping = { "go to line": R(Key("c-g"), rdescript="Sublime: Go To Line"), "go to symbol": R(Key("c-r"), rdescript="Sublime: Go To Symbol"), "go to word": R(Key("c-semicolon"), rdescript="Sublime: Go To Word"), "transform upper": R(Key("control:down, k, u, control:up"), rdescript="Sublime: Transform Upper"), "transform lower": R(Key("control:down, k, l, control:up"), rdescript="Sublime: Transform Lower"), "comment line": R(Key("c-slash"), rdescript="Sublime: Comment Line"), "comment block": R(Key("cs-slash"), rdescript="Sublime: Comment Block"), "full screen": R(Key("f11"), rdescript="Sublime: Fullscreen"), "set bookmark": R(Key("c-f2"), rdescript="Sublime: Set Bookmark"), "next bookmark": R(Key("f2"), rdescript="Sublime: Next Bookmark"), "open file": R(Key("c-p"), rdescript="Sublime: Open File"), } extras = [ Dictation("text"), Dictation("mim"), IntegerRefST("n", 1, 1000), ] defaults = {"n": 1, "mim": ""}
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":""}
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), ]
class CustomVSCode(MergeRule): pronunciation = "custom sublime commands" mapping = { # my custom overrides "save file as": R(Key("cs-s"), rdescript="Sublime: Save As"), "grab it": R(Key("c-d"), rdescript="Sublime: Ctrl + d"), "skip it": R(Key("c-k,c-d"), rdescript="Sublime: Ctrl + d, k"), "uppercase": R(Key("csa-u"), rdescript="Sublime: uppercase"), "lowercase": R(Key("csa-l"), rdescript="Sublime: uppercase"), "cue jeep": R(Key("a-up"), rdescript="Sublime: uppercase"), "cue doom": R(Key("a-down"), rdescript="Sublime: uppercase"), "execute": R(Key("s-enter"), rdescript="Sublime: Ctrl + b"), "[go to] group [<n2>]": R(Key("c-%(n2)s"), rdescript="Sublime: Go to Group #"), "spring <n>": R(Key("c-g") + Pause("10") + Text("%(n)s") + Key("enter"), rdescript="Sublime: Go to Line #"), "crew [<text>]": R(Key("c-i") + Pause("10") + Text("%(text)s") + Pause("10") + Key("enter") + Key("escape"), rdescript="Sublime: Get Next"), "trail [<text>]": R(Key("c-u") + Pause("10") + Text("%(text)s") + Pause("10") + Key("enter") + Key("escape"), rdescript="Sublime: Get Next"), "expand|fill quotes": R(Key("cs-space"), rdescript="Atom: Expand Selection to Quotes"), # SymbolSpecs.FUNCTION: R(Text("fu\\") + Key("tab"), rdescript="CustomSublime: Function"), # SymbolSpecs.IF: R(Text("if\\") + Key("tab"), rdescript="ColdFusion: If"), # my custom overrides "double quotes": R(Key("dquote"), rdescript="Quotation Marks"), "Quach it": R(Key("apostrophe"), rdescript="Thin Quotation Marks"), "(cellaring | sell rang) <n> <n3>": R( Key("c-g") + Pause("5") + Text("%(n)s") + Key("enter") + Pause("5") + Key("c-k") + Key("c-space") + Pause("5") + Key("c-g") + Pause("10") + Text("%(n3)s") + Key("enter") + Key("end") + Key("c-k") + Key("c-a")), } extras = [ Dictation("text"), Dictation("mim"), IntegerRefST("n", 1, 1000), IntegerRefST("n2", 1, 9), IntegerRefST("n3", 1, 999), ] defaults = {"n": 1, "mim": "", "text": ""}
class StackTest(MappingRule): '''test battery for the ContextStack''' mapping = { "close last tag": ContextSeeker([ L(S(["cancel"], None), S(["html spoken"], close_last_spoken, use_spoken=True), S(["span", "div"], close_last_rspec, use_rspec=True)) ]), "html": R(Text("<html>"), rspec="html spoken"), "divider": R(Text("<div>"), rspec="div"), "span": R(Text("<span>"), rspec="span"), "backward seeker [<text>]": ContextSeeker([ L(S(["ashes"], Text("ashes1 [%(text)s] ")), S(["bravery"], Text("bravery1 [%(text)s] "))), L(S(["ashes"], Text("ashes2 [%(text)s] ")), S(["bravery"], Text("bravery2 [%(text)s] "))) ]), "forward seeker [<text>]": ContextSeeker(forward=[ L(S(["ashes"], Text("ashes1 [%(text)s] ")), S(["bravery"], Text("bravery1 [%(text)s] "))), L(S(["ashes"], Text("ashes2 [%(text)s] ")), S(["bravery"], Text("bravery2 [%(text)s] "))) ]), "asynchronous test": AsynchronousAction([ L(S(["ashes", "charcoal"], print_time, None), S(["bravery"], Text, "bravery1")) ], time_in_seconds=0.2, repetitions=20, finisher=Text(FINISHER_TEXT), blocking=False), "ashes": RegisteredAction(Text("ashes _ "), rspec="ashes"), "bravery": RegisteredAction(Text("bravery _ "), rspec="bravery"), "charcoal <text> [<n>]": R(Text("charcoal _ %(text)s"), rspec="charcoal"), "test confirm action": ConfirmAction(Key("a"), rdescript="Confirm Action Test", instructions="some words here"), "test box action": BoxAction(lambda data: _abc(data), rdescript="Test Box Action", box_type=settings.QTYPE_DEFAULT, log_failure=True), } extras = [Dictation("text"), Dictation("text2"), IntegerRefST("n", 1, 5)] defaults = {"text": "", "text2": ""}
class FlashDevelopRule(MergeRule): pronunciation = "flash develop" mapping = { "prior tab [<n>]": R(Key("c-pgup"), rdescript="FlashDevelop: Previous Tab") * Repeat(extra="n"), "next tab [<n>]": R(Key("c-pgdown"), rdescript="FlashDevelop: Next Tab") * Repeat(extra="n"), "open resource": R(Key("c-r"), rdescript="FlashDevelop: Open Resource"), "jump to source": R(Key("f4"), rdescript="FlashDevelop: Jump To Source"), "jump away": R(Key("s-f4"), rdescript="FlashDevelop: Jump Away"), "step over [<n>]": R(Key("f10") * Repeat(extra="n"), rdescript="FlashDevelop: Step Over"), "step into": R(Key("f11"), rdescript="FlashDevelop: Step Into"), "step out [of]": R(Key("s-f11"), rdescript="FlashDevelop: Step Out"), "resume": R(Key("a-d, c"), rdescript="FlashDevelop: Resume"), "terminate": R(Key("s-f5"), rdescript="FlashDevelop: Terminate Running Program"), "find everywhere": R(Key("cs-f"), rdescript="FlashDevelop: Search Project"), "refractor symbol": R(Key("a-r, r"), rdescript="FlashDevelop: Re-Factor Symbol"), "symbol next [<n>]": R(Key("f3"), rdescript="FlashDevelop: Symbol Next") * Repeat(extra="n"), "symbol prior [<n>]": R(Key("s-f3"), rdescript="FlashDevelop: Symbol Prior") * Repeat(extra="n"), "format code": R(Key("cs-2"), rdescript="FlashDevelop: Format Code"), "comment line": R(Key("c-q"), rdescript="FlashDevelop: Comment Line"), "clean it": R(Key("s-f8"), rdescript="FlashDevelop: Clean"), "build it": R(Key("f8"), rdescript="FlashDevelop: Build"), "(debug | run) last": R(Key("f5"), rdescript="FlashDevelop: Run"), "split view horizontal": R(Key("cs-enter"), rdescript="FlashDevelop: Split View (H)"), "auto complete": R(Key("cs-1"), rdescript="FlashDevelop: Auto Complete"), } extras = [ Dictation("text"), Dictation("mim"), IntegerRefST("n", 1, 1000), ] defaults = {"n": 1, "mim": ""}
class KDiff3Rule(MappingRule): mapping = { "refresh": R(Key("f5")), } extras = [ Dictation("text"), Dictation("mim"), IntegerRefST("n", 1, 1000), ] defaults = {"n": 1, "mim": ""}
class DragonRule(MergeRule): pronunciation = "dragon" mapping = { '(lock Dragon | deactivate)': R(Playback([(["go", "to", "sleep"], 0.0)]), rdescript="Dragon: Go To Sleep"), '(number|numbers) mode': R(Playback([(["numbers", "mode", "on"], 0.0)]), rdescript="Dragon: Number Mode"), 'spell mode': R(Playback([(["spell", "mode", "on"], 0.0)]), rdescript="Dragon: Spell Mode"), 'dictation mode': R(Playback([(["dictation", "mode", "on"], 0.0)]), rdescript="Dragon: Dictation Mode"), 'normal mode': R(Playback([(["normal", "mode", "on"], 0.0)]), rdescript="Dragon: Normal Mode"), 'command mode': R(Playback([(["command", "mode", "on"], 0.0)]), rdescript="Dragon: Normal Mode"), 'com on': R(Playback([(["command", "mode", "on"], 0.0)]), rdescript="Dragon: Command Mode (On)"), 'com off': R(Playback([(["command", "mode", "off"], 0.0)]), rdescript="Dragon: Command Mode (Off)"), 'scratch': R(Playback([(["scratch", "that"], 0.0)]), rdescript="Dragon: 'Scratch That'"), "reboot dragon": R(Function(utilities.reboot), rdescript="Reboot Dragon Naturallyspeaking"), "fix dragon double": R(Function(fix_dragon_double, nexus=_NEXUS), rdescript="Fix Dragon Double Letter"), "left point": R(Playback([(["MouseGrid"], 0.1), (["four", "four"], 0.1), (["click"], 0.0)]), rdescript="Mouse: Left Point"), "right point": R(Playback([(["MouseGrid"], 0.1), (["six", "six"], 0.1), (["click"], 0.0)]), rdescript="Mouse: Right Point"), "center point": R(Playback([(["MouseGrid"], 0.1), (["click"], 0.0)]), rdescript="Mouse: Center Point"), } extras = [ Dictation("text"), Dictation("mim"), IntegerRefST("n", 1, 1000), ] defaults = {"n": 1, "mim": ""}
class SSMSRule(MergeRule): pronunciation = "custom sequel server management studio" mapping = { # There doesn't seem to be a hotkey for sequential tab navigation in SSMS, but something is better than nothing... "next tab [<n>]": R(Key("c-tab"), rdescript="SSMS: Next Tab")*Repeat(extra="n"), "prior tab [<n>]": R(Key("cs-tab"), rdescript="SSMS: Previous Tab")*Repeat(extra="n"), "close tab [<n>]": R(Key("c-f4/20"), rdescript="SSMS: Close Tab")*Repeat(extra="n"), "go to line": R(Key("c-g"), rdescript="SSMS: Go To Line"), "[go to] line <n>": R(Key("c-g") + Pause("10") + Text("%(n)s") + Key("enter"), rdescript="SSMS: Go to Line #"), "comment line": R(Key("c-k, c-c"), rdescript="SSMS: Comment Selection"), "comment block": R(Key("c-k, c-c"), rdescript="SSMS: Comment Block"), "(un | on) comment line": R(Key("c-k/50, c-u"), rdescript="SSMS: Uncomment Selection"), "(un | on) comment block": R(Key("c-k/50, c-u"), rdescript="SSMS: Uncomment Block"), "[toggle] full screen": R(Key("sa-enter"), rdescript="SSMS: Fullscreen"), "(set | toggle) bookmark": R(Key("c-k, c-k"), rdescript="SSMS: Toggle Bookmark"), "next bookmark": R(Key("c-k, c-n"), rdescript="SSMS: Next Bookmark"), "prior bookmark": R(Key("c-k, c-p"), rdescript="SSMS: Previous Bookmark"), "[toggle] breakpoint": R(Key("f9"), rdescript="SSMS: Breakpoint"), "step over [<n>]": R(Key("f10/50")*Repeat(extra="n"), rdescript="SSMS: Step Over"), "step into": R(Key("f11"), rdescript="SSMS: Step Into"), "step out [of]": R(Key("s-f11"), rdescript="SSMS: Step Out"), "resume": R(Key("f5"), rdescript="SSMS: Resume"), "execute": R(Key("f5"), rdescript="SQL: Count"), "switch focus [<n>]": R(Key("f6"), rdescript="SQL: Switch Focus")*Repeat(extra="n"), "back focus [<n>]": R(Key("s-f6"), rdescript="SQL: Back Focus")*Repeat(extra="n"), } extras = [ Dictation("text"), Dictation("mim"), IntegerRefST("n", 1, 1000), ] defaults = {"n": 1, "mim": ""}
class VisualStudioRule(MergeRule): pronunciation = "visual studio" mapping = { "next tab [<n>]": R(Key("ca-pgdown"), rdescript="Visual Studio: Next Tab") * Repeat(extra="n"), "prior tab [<n>]": R(Key("ca-pgup"), rdescript="Visual Studio: Previous Tab") * Repeat(extra="n"), "close tab [<n>]": R(Key("c-f4/20"), rdescript="Visual Studio: Close Tab") * Repeat(extra="n"), "(list | show) documents": R(Key("a-w, w"), rdescript="Visual Studio: List Documents"), "[focus] document (window | pane)": R(Key("a-w, w, enter"), rdescript="Visual Studio: Focus Document Pane"), "solution explorer": R(Key("ca-l"), rdescript="Visual Studio: Solution Explorer"), "team explorer": R(Key("c-backslash, c-m"), rdescript="Visual Studio: Team Explorer"), "source control explorer": R(Key("c-q") + Text("Source Control Explorer") + Key("enter"), rdescript="Visual Studio: Source Control Explorer"), "quick launch": R(Key("c-q"), rdescript="Visual Studio: Quick Launch"), "go to line": R(Key("c-g"), rdescript="Visual Studio: Go To Line"), "comment line": R(Key("c-k, c-c"), rdescript="Visual Studio: Comment Selection"), "comment block": R(Key("c-k, c-c"), rdescript="Visual Studio: Comment Block"), "(un | on) comment line": R(Key("c-k/50, c-u"), rdescript="Visual Studio: Uncomment Selection"), "(un | on) comment block": R(Key("c-k/50, c-u"), rdescript="Visual Studio: Uncomment Block"), "[toggle] full screen": R(Key("sa-enter"), rdescript="Visual Studio: Fullscreen"), "(set | toggle) bookmark": R(Key("c-k, c-k"), rdescript="Visual Studio: Toggle Bookmark"), "next bookmark": R(Key("c-k, c-n"), rdescript="Visual Studio: Next Bookmark"), "prior bookmark": R(Key("c-k, c-p"), rdescript="Visual Studio: Previous Bookmark"), "collapse to definitions": R(Key("c-m, c-o"), rdescript="Visual Studio: Collapse To Definitions"), "toggle [section] outlining": R(Key("c-m, c-m"), rdescript="Visual Studio: Toggle Section Outlining"), "toggle all outlining": R(Key("c-m, c-l"), rdescript="Visual Studio: Toggle All Outlining"), "[toggle] breakpoint": R(Key("f9"), rdescript="Visual Studio: Breakpoint"), "step over [<n>]": R(Key("f10/50") * Repeat(extra="n"), rdescript="Visual Studio: Step Over"), "step into": R(Key("f11"), rdescript="Visual Studio: Step Into"), "step out [of]": R(Key("s-f11"), rdescript="Visual Studio: Step Out"), "resume": R(Key("f5"), rdescript="Visual Studio: Resume"), "run tests": R(Key("c-r, t"), rdescript="Visual Studio: Run test(s)"), "run all tests": R(Key("c-r, a"), rdescript="Visual Studio: Run all tests"), "build solution": R(Key("cs-b"), rdescript="Visual Studio: Build solution"), "get latest [version]": R(Key("a-f, r, l"), rdescript="Visual Studio: Get Latest"), "(show | view) history": R(Key("a-f, r, h"), rdescript="Visual Studio: Show History"), "compare (files | versions)": R(Key("a-f, r, h"), rdescript="Visual Studio: Compare..."), "undo (checkout | pending changes)": R(Key("a-f, r, u"), rdescript="Visual Studio: Undo Pending Changes"), "[open] [go to] work item": R(Key("a-m, g"), rdescript="Visual Studio: Open Work Item"), "[add] [new] linked work item": R(Key("sa-l"), rdescript="Visual Studio: New Linked Work Item"), } extras = [ Dictation("text"), Dictation("mim"), IntegerRefST("n", 1, 1000), ] defaults = {"n": 1, "mim":""}
class Experimental(MappingRule): mapping = { # experimental/incomplete commands "experiment": Function(experiment), "short talk number <n2>": Text("%(n2)d"), # "dredge [<id> <text>]": Function(dredge), "test dragonfly paste": Paste("some text"), } extras = [Dictation("text"), Dictation("text2"), IntegerRefST("n2", 1, 100)] defaults = {"text": "", "text2": ""}
class ScanLineRule(MappingRule): mapping = { "scan [(second | third | fourth | fifth | sixth)] (<dictation_to_find> | " + character.CHARACTER_ALTERNATIVES + ") [replace] [<replace_with_me>]": Function(lineSearch), } extras = [Dictation("dictation_to_find"), Dictation("replace_with_me"), ] defaults = {"dictation_to_find":"", "replace_with_me":"", }
class FoxitRule(MappingRule): mapping = { "next tab [<n>]": R(Key("c-tab")) * Repeat(extra="n"), "prior tab [<n>]": R(Key("cs-tab")) * Repeat(extra="n"), "close tab [<n>]": R(Key("c-f4/20")) * Repeat(extra="n"), } extras = [ Dictation("text"), Dictation("mim"), IntegerRefST("n", 1, 1000), ] defaults = {"n": 1, "mim": ""}
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 KDiff3Rule(MergeRule): pronunciation = "K diff" mapping = { "refresh": R(Key("f5"), rdescript="Refresh"), } extras = [ Dictation("text"), Dictation("mim"), IntegerRefST("n", 1, 1000), ] defaults = {"n": 1, "mim": ""}
class CustomVSCode(MergeRule): pronunciation = "custom visual studio code" mapping = { "save file as": R(Key("cs-s"), rdescript="VS Code: Save As"), "uppercase": R(Key("csa-u"), rdescript="VS Code: uppercase"), "lowercase": R(Key("csa-l"), rdescript="VS Code: lowercase"), "execute": R(Key("s-enter"), rdescript="VS Code: Ctrl + b"), "[go to] group [<n2>]": R(Key("c-%(n2)s"), rdescript="VS Code: Go to Group #"), "spring <n>": R(Key("c-g") + Pause("10") + Text("%(n)s") + Key("enter"), rdescript="VS Code: Go to Line #"), "crew [<text>]": R(Key("c-f") + Pause("10") + Text("%(text)s") + Pause("10") + Key("escape"), rdescript="VS Code: Get Next"), "trail [<text>]": R(Key("c-f") + Pause("10") + Text("%(text)s") + Pause("10") + Key("s-enter") + Key("escape"), rdescript="VS Code: Get Next"), "expand|fill quotes": R(Key("cs-space"), rdescript="VS Code: Expand Selection to Quotes"), "(cellaring | sell rang) <n> <n3>": R( Key("c-g") + Pause("5") + Text("%(n)s") + Key("enter") + Pause("5") + Key("c-k") + Key("c-b") + Pause("5") + Key("c-g") + Pause("10") + Text("%(n3)s") + Key("enter") + Key("end") + Key("c-k") + Key("c-k")), # The following commands of been enabled via words.txt # If Caster gets rid of transformers, reenable these words # "grab it": # R(Key("c-d"), rdescript="VS Code: Ctrl + d"), # "skip it": # R(Key("c-k,c-d"), rdescript="VS Code: Ctrl + d, k"), # "cue jeep": # R(Key("a-up"), rdescript="VS Code: uppercase"), # "cue doom": # R(Key("a-down"), rdescript="VS Code: uppercase"), } extras = [ Dictation("text"), Dictation("mim"), ShortIntegerRef("n", 1, 1000), ShortIntegerRef("n2", 1, 9), ShortIntegerRef("n3", 1, 999), ] defaults = {"n": 1, "mim": "", "text": ""}
class FlashDevelopRule(MappingRule): mapping = { "prior tab [<n>]": R(Key("c-pgup")) * Repeat(extra="n"), "next tab [<n>]": R(Key("c-pgdown")) * Repeat(extra="n"), "open resource": R(Key("c-r")), "jump to source": R(Key("f4")), "jump away": R(Key("s-f4")), "step over [<n>]": R(Key("f10") * Repeat(extra="n")), "step into": R(Key("f11")), "step out [of]": R(Key("s-f11")), "resume": R(Key("a-d, c")), "terminate": R(Key("s-f5")), "find everywhere": R(Key("cs-f")), "refractor symbol": R(Key("a-r, r")), "symbol next [<n>]": R(Key("f3")) * Repeat(extra="n"), "symbol prior [<n>]": R(Key("s-f3")) * Repeat(extra="n"), "format code": R(Key("cs-2")), "comment line": R(Key("c-q")), "clean it": R(Key("s-f8")), "build it": R(Key("f8")), "(debug | run) last": R(Key("f5")), "split view horizontal": R(Key("cs-enter")), "auto complete": R(Key("cs-1")), "[go to] line <n>": R(Key("c-g") + Pause("50") + Text("%(n)d") + Key("enter")), } extras = [ Dictation("text"), Dictation("mim"), ShortIntegerRef("n", 1, 1000), ] defaults = {"n": 1, "mim": ""}
class Alias(SelfModifyingRule): mapping = {"default command": NullAction()} toml_path = "single_aliases" pronunciation = "alias" extras = [ IntegerRefST("n", 1, 50), Dictation("s"), Dictation("textnv"), ] defaults = { "n": 1, "textnv": "", } def alias(self, spec): spec = str(spec) if spec != "": text = read_highlighted(10) if text != None: self.refresh(spec, str(text)) def vary(self, capitalization, spacing, textnv): textnv2 = textformat.TextFormat.formatted_text(capitalization, spacing, str(textnv)) Text(textnv2).execute() self.refresh(str(textnv), textnv2) def refresh(self, *args): '''args: spec, text''' aliases = utilities.load_toml_file( settings.SETTINGS["paths"]["ALIAS_PATH"]) if not Alias.toml_path in aliases: aliases[Alias.toml_path] = {} if len(args) > 0: aliases[Alias.toml_path][args[0]] = args[1] utilities.save_toml_file(aliases, settings.SETTINGS["paths"]["ALIAS_PATH"]) mapping = {} for spec in aliases[Alias.toml_path]: mapping[spec] = R( Function(context.paste_string_without_altering_clipboard, content=str(aliases[Alias.toml_path][spec]))) # R( # Text(str(aliases[Alias.toml_path][spec])), # rdescript="Alias: " + spec) mapping["alias <s>"] = R(Function(lambda s: self.alias(s)), rdescript="Create Alias") mapping["delete aliases"] = R( Function(lambda: delete_all(self, Alias.toml_path)), rdescript="Delete Aliases") self.reset(mapping)
class FoxitRule(MergeRule): pronunciation = "fox it reader" mapping = { "next tab [<n>]": R(Key("c-tab"), rdescript="Foxit Reader: Next Tab") * Repeat(extra="n"), "prior tab [<n>]": R(Key("cs-tab"), rdescript="Foxit Reader: Previous Tab") * Repeat(extra="n"), "close tab [<n>]": R(Key("c-f4/20"), rdescript="Foxit Reader: Close Tab") * Repeat(extra="n"), } extras = [ Dictation("text"), Dictation("mim"), IntegerRefST("n", 1, 1000), ] defaults = {"n": 1, "mim":""}
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, }
class IdentifierInsertion(CompoundRule): spec = ( '[upper | natural] ( proper | camel | rel-path | abs-path | score | sentence |' 'scope-resolve | jumble | dotword | dashword | natword | snakeword | brooding-narrative) [<dictation>]' ) extras = [Dictation(name='dictation')] def value(self, node): words = node.words() uppercase = words[0] == 'upper' lowercase = words[0] != 'natural' if lowercase: words = [word.lower() for word in words] if uppercase: words = [word.upper() for word in words] words = [word.split('\\', 1)[0].replace('-', '') for word in words] if words[0].lower() in ('upper', 'natural'): del words[0] function = globals()['format_%s' % words[0].lower()] formatted = function(words[1:]) return Text(formatted)
class NPPRule(MappingRule): mapping = { "stylize <n2>": R( Mouse("right") + Key("down:6/5, right") + (Key("down") * Repeat(extra="n2")) + Key("enter")), "remove style": R(Mouse("right") + Key("down:6/5, right/5, down:5/5, enter")), "preview in browser": R(Key("cas-r")), # requires function list plug-in: "function list": R(Key("cas-l")), "open": R(Key("c-o")), "go [to] line <n>": R(Key("c-g/10") + Text("%(n)s") + Key("enter")), } extras = [ Dictation("text"), IntegerRefST("n", 1, 1000), IntegerRefST("n2", 1, 10), ] defaults = {"n": 1}
class FoodGroupRule(CompoundRule): spec = "(I ate <food> <time> | <time> I ate <food>) [and thought it was <opinion>]" time = { "(two days ago | day before yesterday)": 2, "yesterday": 1, "today": 0, } food = { "(a Granny Smith | an) apple": "fruit", "an orange": "fruit", "a hamburger": "meat", "a [juicy] steak": "meat", } extras = [ Choice("time", time), Choice("food", food), Dictation("opinion"), ] def _process_recognition(self, node, extras): days_ago = extras["time"] foodgroup = extras["food"] print "You ate %s %d days ago." % (foodgroup, days_ago) if "opinion" in extras: print "You thought it was %s." % (extras["opinion"])
class BananaRule(CompoundRule): spec = "I like bananas [<text>]" extras = [Dictation("text")] def _process_recognition(self, node, extras): print("I like bananas! (%s)" % extras.get("text", "")) banana_rule.disable() apple_rule.enable()
def _deserialize(self): """ This _deserialize creates mapping which uses the user-made extras. """ self._initialize() self._smr_mapping = { "bring me <program>": R(Function(self._bring_program)), "bring me <website>": R(Function(self._bring_website)), "bring me <folder> [in <app>]": R(Function(self._bring_folder)), "bring me <file>": R(Function(self._bring_file)), "refresh bring me": R(Function(self._load_and_refresh)), "<launch_type> to bring me as <key>": R(Function(self._bring_add)), "to bring me as <key>": R(Function(self._bring_add_auto)), "remove <key> from bring me": R(Function(self._bring_remove)), "restore bring me defaults": R(Function(self._bring_reset_defaults)), } self._smr_extras = [ Choice( "launch_type", { "[current] program": "program", "website": "website", "folder": "folder", "file": "file", }), Choice("app", { "terminal": "terminal", "explorer": "explorer", }), Dictation("key"), ] self._smr_extras.extend(self._rebuild_items()) self._smr_defaults = {"app": None}
class CompoundTestCCR(CompoundRule): spec = "compound testing <text>" extras = [ Integer("t", 1, 50), Dictation("text"), ] defaults = { "t": 1, } def _process_recognition(self, node, extras): print "testing the compound: " + extras["text"] def value(self, node): extras = { "_grammar": self.grammar, "_rule": self, "_node": node, } extras.update(self.defaults) for name, element in self._extras.items(): extra_node = node.get_child_by_name(name, shallow=True) if extra_node: extras[name] = extra_node.value() elif element.has_default(): extras[name] = element.default #extras[name] = element.value() return BoundAction(Function(self._process_recognition), { "node": node, "extras": extras })