), # @IgnorePep8 "doctype X strict": Text( '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' ), # @IgnorePep8 # if conditions. }, extras=[ IntegerRef("n", 1, 100), Dictation("text"), Choice("element", htmlElements), Choice("attribute", htmlAttributes), ], defaults={"n": 1}) grammar = Grammar("Html grammar", context=GlobalDynamicContext()) grammar.add_rule(rules) grammar.load() grammar.disable() def dynamic_enable(): global grammar if grammar.enabled: return False else: grammar.enable() return True def dynamic_disable():
# Protocols. "protocol H T T P": Text("http://"), "protocol H T T P S": Text("https://"), "protocol (git|G I T)": Text("git://"), "protocol F T P": Text("ftp://"), "protocol S S H": Text("ssh://"), }, extras=[ IntegerRef("n", 1, 100), Dictation("text"), ], defaults={"n": 1}) terminator_grammar = Grammar("Programming help", context=GlobalDynamicContext()) terminator_grammar.add_rule(series_rule) terminator_grammar.load() # Unload function which will be called at unload time. def unload(): global terminator_grammar if grammar: grammar.unload() grammar = None
# Special access to commands and options. svn + "command <svncmd>": Text("svn %(svncmd)s "), svn + "option <svnopt>": Text(" %(svnopt)s"), }, extras=[ IntegerRef("n", 1, 100), Dictation("text"), Choice("svncmd", svncmd), Choice("svnopt", svnopt), ], defaults={ "n": 1 } ) grammar = Grammar("Subversion commands", context=GlobalDynamicContext()) grammar.add_rule(series_rule) grammar.load() grammar.disable() def dynamic_enable(): global grammar if grammar.enabled: return False else: grammar.enable() return True def dynamic_disable():
Text("git tag -d "), # Special access to commands and options. "git command <gitcmd>": Text("git %(gitcmd)s "), "git option <gitopt>": Text(" %(gitopt)s"), }, extras=[ IntegerRef("n", 1, 100), Dictation("text"), Choice("gitcmd", gitcmd), Choice("gitopt", gitopt), ], defaults={"n": 1}) terminator_grammar = Grammar("Git commands", context=GlobalDynamicContext()) terminator_grammar.add_rule(series_rule) terminator_grammar.load() terminator_grammar.disable() def dynamic_enable(): global terminator_grammar if grammar.enabled: return False else: grammar.enable() return True def dynamic_disable():
IntegerRef("pos4", 1, 10), IntegerRef("pos5", 1, 10), IntegerRef("pos6", 1, 10), IntegerRef("pos7", 1, 10), IntegerRef("pos8", 1, 10), IntegerRef("pos9", 1, 10), Dictation("text"), Choice("action", actions), ], defaults={ "pos1": 1 } ) # Use global context, and activate/deactivate grammar dynamically. grammarNavigation = Grammar("Grid navigation", context=GlobalDynamicContext()) grammarNavigation.add_rule(navigate_rule) # Add the top-level rule. grammarNavigation.load() # Load the grammar. grammarNavigation.disable() def mouse_grid_start(pos1=None, pos2=None, pos3=None, pos4=None, pos5=None, pos6=None, pos7=None, pos8=None, pos9=None, action=None): if should_send_to_aenea(): lib.grid_base_x.set_grammar_reference(grammarNavigation) grammarNavigation.enable() lib.grid_base_x.mouse_grid(pos1, pos2, pos3, pos4, pos5, pos6, pos7, pos8, pos9, action) else: lib.grid_base_win.set_grammar_reference(grammarNavigation) grammarNavigation.enable()
# Here we define this rule's spoken-form and special elements. spec = "<sequence> [[[and] repeat [that]] <n> times]" extras = [ sequence, # Sequence of actions defined above. IntegerRef("n", 1, 100), # Times to repeat the sequence. ] defaults = { "n": 1, # Default repeat count. } def _process_recognition(self, node, extras): # @UnusedVariable sequence = extras["sequence"] # A sequence of actions. count = extras["n"] # An integer repeat count. for i in range(count): # @UnusedVariable for action in sequence: action.execute() release.execute() terminator_grammar = Grammar("Generic edit", context=GlobalDynamicContext()) terminator_grammar.add_rule(RepeatRule()) # Add the top-level rule. terminator_grammar.load() # Load the grammar. def unload(): """Unload function which will be called at unload time.""" global terminator_grammar if grammar: grammar.unload() grammar = None
"true": Text("true"), "try": Text("try {") + Key("enter"), "toString": Text("toString()") + Key("left"), "while": Text("while () {") + Key("left:3"), "while <text>": SCText("while (%(text)s) {") + Key("left:3"), }, extras=[ IntegerRef("n", 1, 100), Dictation("text"), ], defaults={ "n": 1 } ) grammar = Grammar("Java grammar", context=GlobalDynamicContext()) grammar.add_rule(rules) grammar.load() grammar.disable() def dynamic_enable(): global grammar if grammar.enabled: return False else: grammar.enable() return True def dynamic_disable():
Text("bundle exec rake db:migrate:redo") + Key("enter"), "[bundle exec] rake D B test prepare": Text("bundle exec rake db:test:prepare") + Key("enter"), "[bundle exec] rake routes": Text("bundle exec rake routes") + Key("enter"), "start ruby shell": Text("irb") + Key("enter"), }, extras=[ IntegerRef("n", 1, 100), Dictation("text"), Choice("iterator", iterator), ], defaults={"n": 1}) grammar = Grammar("Ruby grammar", context=GlobalDynamicContext()) grammar.add_rule(rules) grammar.load() grammar.disable() def dynamic_enable(): global grammar if grammar.enabled: return False else: grammar.enable() return True def dynamic_disable():
Text(".org"), # Protocols. "protocol H T T P": Text("http://"), "protocol H T T P S": Text("https://"), "protocol (git|G I T)": Text("git://"), "protocol F T P": Text("ftp://"), "protocol S S H": Text("ssh://"), }, extras=[ IntegerRef("n", 1, 100), Dictation("text"), ], defaults={"n": 1}) grammar = Grammar("Programming help", context=GlobalDynamicContext()) grammar.add_rule(series_rule) grammar.load() # Unload function which will be called at unload time. def unload(): global grammar if grammar: grammar.unload() grammar = None
IntegerRef("numeric", 1, 10000), Dictation("text"), Choice("prop", cssProperties), Choice("hex1", hexValue), Choice("hex2", hexValue), Choice("hex3", hexValue), Choice("hex4", hexValue), Choice("hex5", hexValue), Choice("hex6", hexValue), ], defaults={ "n": 0 } ) terminator_grammar = Grammar("Css grammar", context=GlobalDynamicContext()) terminator_grammar.add_rule(rules) terminator_grammar.load() terminator_grammar.disable() def dynamic_enable(): global terminator_grammar if grammar.enabled: return False else: grammar.enable() return True def dynamic_disable():
"vagrant up [with] virtual box": Text("vagrant up --provider=virtualbox"), "vagrant up [with] VMware": Text("vagrant up --provider=vmware_workstation"), "vagrant ssh": Text("vagrant ssh"), }) class MyCommandsRule(MappingRule): mapping = config.cmd.map extras = [ Dictation("text"), ] terminator_grammar = Grammar( "My commands", context=GlobalDynamicContext()) # Create this module's grammar. terminator_grammar.add_rule(MyCommandsRule()) # Add the top-level rule. terminator_grammar.load() # Load the grammar. def unload(): """Unload function which will be called at unload time.""" global terminator_grammar if grammar: grammar.unload() grammar = None
"X M L lint schema": Text("xmllint -schema "), "X M L lint schema <text>": Text("xmllint -schema %(text)s"), "X prop": Text("xprop "), "X win info": Text("xwininfo "), }, extras=[ IntegerRef("n", 1, 100), Dictation("text"), ], defaults={"n": 1}) terminator_grammar = Grammar("Python grammar", context=GlobalDynamicContext()) terminator_grammar.add_rule(rules) terminator_grammar.load() terminator_grammar.disable() def dynamic_enable(): global terminator_grammar if terminator_grammar.enabled: return False else: terminator_grammar.enable() return True def dynamic_disable():
"save as": Key("colon, w, space"), "undo": Function(enable_command_mode) + Key("u"), "yank [(line|lines)]": Key("d, d"), "<text>": Function(illegal_command), }, extras=[ IntegerRef("n", 1, 100), Dictation("text"), ], defaults={"n": 1}) grammarCommand = Grammar("Vim command grammar", context=GlobalDynamicContext()) grammarCommand.add_rule(commandMode) grammarCommand.load() grammarCommand.disable() insertMode = MappingRule( mapping={ # Commands and keywords: "(command mode|press escape)": Function(enable_command_mode), }, extras=[ IntegerRef("n", 1, 100), Dictation("text"), ], defaults={"n": 1})