def load(): """Register grammar.""" global GRAMMAR GRAMMAR = Grammar('command_line_interface') GRAMMAR.add_rule(PasswordRule()) GRAMMAR.load() print 'password grammar: Loaded.'
def load(): """Register grammar.""" global TRUE_VIM_NORMAL_GRAMMAR TRUE_VIM_NORMAL_GRAMMAR = Grammar('true_vim_normal_mode', context=vim_normal_mode()) TRUE_VIM_NORMAL_GRAMMAR.add_rule(TrueVimNormalRepetitionRule()) TRUE_VIM_NORMAL_GRAMMAR.load() print 'vim grammars: Loaded.'
def load(): """Register grammar.""" global GRAMMAR GRAMMAR = Grammar('i3', context=linux()) GRAMMAR.add_rule(OpenProcessRule()) GRAMMAR.add_rule(WorkspaceRules()) GRAMMAR.load() print 'i3 grammar: Loaded.'
def load(): """Register grammar.""" global GRAMMAR GRAMMAR = Grammar('command_line_interface', context=terminal_not_vim()) GRAMMAR.add_rule(SshRule()) GRAMMAR.add_rule(SimpleCommand()) GRAMMAR.add_rule(SudoRule()) GRAMMAR.load() print 'cli grammar: Loaded.'
def load(): """Register grammar.""" global GRAMMAR GRAMMAR = Grammar('global') GRAMMAR.add_rule(BasicKeyboardRule()) GRAMMAR.add_rule(SpellingRule()) GRAMMAR.add_rule(PressRule()) GRAMMAR.add_rule(DictationRule(exported=True)) GRAMMAR.load() print 'global grammar: Loaded.'
if isinstance(proxy_disable_setting, dict): d = {} for k, v in proxy_disable_setting.iteritems(): d[str(k)] = str(v) proxy_disable_context = ProxyAppContext(**d) else: proxy_disable_context = ProxyAppContext( title=str(proxy_disable_setting), match='substring' ) grammar = Grammar('aenea_emacs', context=emacs_context) grammar.add_rule(RepeatRule(extras=extras + [format_rule, Alternative(finishes, name='finish')], name='a')) grammar.add_rule(LiteralRule()) grammar.load() # Unload function which will be called at unload time. def unload(): global grammar aenea.vocabulary.uninhibit_global_dynamic_vocabulary( 'aenea_emacs', MULTIEDIT_TAGS ) for tag in MULTIEDIT_TAGS: aenea.vocabulary.unregister_dynamic_vocabulary(tag) if grammar: grammar.unload() grammar = None
from aenea import Grammar, MappingRule, Integer, Key, Text grammar = Grammar('tmux') LEADER = 'c-b' class Command(MappingRule): mapping = {'switch win [<n>]': Key(LEADER + ', ' + '%(n)s')} extras = [ Integer("n", 0, 10), ] defaults = { "n": 1, } grammar.add_rule(Command()) grammar.load() def unload(): global grammar if grammar: grammar.unload() grammar = None
class RepeatRule(CompoundRule): # 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() grammar = Grammar("Generic edit") grammar.add_rule(RepeatRule()) # Add the top-level rule. grammar.load() # Load the grammar. def unload(): """Unload function which will be called at unload time.""" global grammar if grammar: grammar.unload() grammar = None
def switch_mode(language): clear_mode() language.enable() basics_mapping = { 'lang <language>': Function(switch_mode), 'clear lang': Function(clear_mode), } class Basics(MappingRule): mapping = basics_mapping extras = [Choice("language", language_map)] generic_grammar.add_rule(Basics()) generic_grammar.load() # Start with no modes active for _, grammar in language_map.iteritems(): grammar.load() grammar.disable() def unload(): generic_grammar.unload() for _, grammar in language_map.iteritems(): grammar.unload()
"(refactor|re-factor) copy": Key("f5"), "(refactor|re-factor) safe delete": Key("a-del"), "(refactor|re-factor) extract variable": Key("ca-v"), "(refactor|re-factor) extract constant": Key("ca-c"), "(refactor|re-factor) extract field": Key("ca-f"), "(refactor|re-factor) extract parameter": Key("ca-p"), "(refactor|re-factor) extract method": Key("ca-m"), "(refactor|re-factor) (in line|inline)": Key("ca-n"), # Custom key mappings. "(run SSH session|run SSH console|run remote terminal|run remote console)": Key("a-f11/25, enter"), #debug }) extras = [ Dictation("text"), IntegerRef("n", 1, 50000) ] terminator_grammar.add_rule(jideaRule()) terminator_grammar.load() # Unload function which will be called by natlink at unload time. def unload(): global terminator_grammar if terminator_grammar: terminator_grammar.unload() terminator_grammar = None
# zoom 'zoom in [<n>]': Key('c-plus:%(n)d'), 'zoom out [<n>]': Key('c-minus:%(n)d'), # scroll slow 'slide': Key('c-0'), }) extras = [IntegerRef('n', 1, 100), Dictation('text')] defaults = { 'n': 1, 'text': '' } chromium_context = aenea.AeneaContext( ProxyAppContext(match='regex', title='(?i).*chrome.*'), AppContext(title='chrome') ) chromium_grammar = Grammar('chromium', context=chromium_context) chromium_grammar.add_rule(ChromiumRule()) chromium_grammar.load() def unload(): global chromium_grammar if chromium_grammar: chromium_grammar.unload() chromium_grammar = None
action = Key("escape") action.execute() class MouseCancelRule(MappingRule): mapping = { "cancel": Function(cancelMouseGrid), } contextMini = ProxyAppContext(title="InvisibleWindow - Mini") grammarMini = Grammar('extra symbols mini grammar', context=contextMini) grammarMini.add_rule(ExtraSymbolsMiniGridRule()) grammarMini.add_rule(MouseCancelRule()) grammarMini.add_rule(MouseActionGridRule()) grammarMini.load() contextFull = ProxyAppContext(title="InvisibleWindow - Full") grammarFull = Grammar('extra symbols full grammar', context=contextFull) grammarFull.add_rule(ExtraSymbolsFullGridRule()) grammarFull.add_rule(MouseCancelRule()) grammarFull.add_rule(MouseActionGridRule()) grammarFull.load() def unload(): global grammarMini if grammarMini: grammarMini.unload() grammarMini = None
'reopen [<n>] ( frame | frames )': Key('cs-t:%(n)d'), '[ go to ] frame [<n>]': Key('c-%(n)d'), 'frame left [<n>]': Key('cs-tab:%(n)d'), 'frame right [<n>]': Key('c-tab:%(n)d'), 'search [<text>]': Key('c-k') + Text('%(text)s'), 'find [<text>]': Key('c-f') + Text('%(text)s'), 'history': Key('c-h'), 'reload': Key('c-r'), 'next [<n>]': Key('c-g:%(n)d'), 'previous [<n>]': Key('cs-g:%(n)d'), 'back [<n>]': Key('a-left:%(n)d'), 'forward [<n>]': Key('a-right:%(n)d'), }) extras = [IntegerRef('n', 1, 10), Dictation('text')] defaults = { 'n': 1, 'text': '' } chromium_grammar.add_rule(ChromiumRule()) chromium_grammar.load() def unload(): global chromium_grammar if chromium_grammar: chromium_grammar.unload() chromium_grammar = None