Ejemplo n.º 1
0
 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({})
Ejemplo n.º 2
0
grammarCfg.cmd.map = Item(
    {
        ### Navigation ###
        "up [<n>]":
        Key("up:%(n)d"),
        "down [<n>]":
        Key("down:%(n)d"),
        "left [<n>]":
        Key("left:%(n)d"),
        "right [<n>]":
        Key("right:%(n)d"),
        "pinch [<n>]":
        Key("pgup:%(n)d"),
        "page [<n>]":
        Key("pgdown:%(n)d"),
        "left [<n>] (word|words)":
        Key("c-left/3:%(n)d/10"),
        "right [<n>] (word|words)":
        Key("c-right/3:%(n)d/10"),
        "home":
        Key("home"),
        "lend":
        Key("end"),
        "lendit":
        Key("end, comma"),
        "doc home":
        Key("c-home/3"),
        "doc end":
        Key("c-end/3"),

        ### Selections ###
        "grab <n>":
        release + Key("shift:down, right:%(n)d, shift:up"),
        "take <n>":
        release + Key("shift:down, left:%(n)d, shift:up"),
        "take <n> (line|lines)":
        release + Key("end, shift:down, home, up:%(n)d, home, shift:up"),
        "grab <n> (line|lines)":
        release + Key("home, shift:down, down:%(n)d, end, shift:up"),
        "grab <n> (word|words)":
        release + Key("shift:down, c-right:%(n)d, shift:up"),
        "take <n> (word|words)":
        release + Key("shift:down, c-left:%(n)d, shift:up"),
        "(take|grab) word":
        Key("c-left, sc-right"),
        "(take|grab) home":
        release + Key("shift:down, home, shift:up"),
        "(take|grab) end":
        release + Key("shift:down, end, shift:up"),
        "(take|grab) line":
        release + Key("home, s-end"),
        "(take|grab) all":
        release + Key("c-a/3"),

        ### Functional keys ###
        "act":
        Key("escape"),
        "space":
        release + Key("space"),
        "space [<n>]":
        release + Key("space:%(n)d"),
        "drop [<n>]":
        release + Key("enter:%(n)d"),
        "slide [<n>]":
        release + Key("end, enter:%(n)d"),
        "tab [<n>]":
        Key("tab:%(n)d"),

        ### Deletions ###
        "scratch [<n>]":
        release + Key("backspace:%(n)d"),
        "chuck [<n>]":
        Key("del/3:%(n)d"),
        "whack [<n>]":
        Key("shift:down, c-left/3:%(n)d/10, del, shift:up"),
        "bump [<n>]":
        Key("shift:down, c-right/3:%(n)d/10, del, shift:up"),
        "scratch [this] line":
        Key("home, s-end, del"),  # @IgnorePep8
        "chuck [this] line":
        Key("home:2, s-end, backspace:2"),

        ### Common functions ###
        "dump [that]":
        Function(paste_command),
        "nab [that]":
        Function(copy_command),
        "cut [that]":
        release + Key("c-x/3"),
        "undo":
        release + Key("c-z/3"),
        "undo <n> [times]":
        release + Key("c-z/3:%(n)d"),
        "redo":
        release + Key("c-y/3"),
        "redo <n> [times]":
        release + Key("c-y/3:%(n)d"),
        "save":
        release + Key("c-s"),

        ### Modifiers ###
        "app key":
        release + Key("apps/3"),
        "mod key":
        release + Key("win/3"),
        "[(hold|press)] alt":
        Key("alt:down/3"),
        "release alt":
        Key("alt:up"),
        "[(hold|press)] shift":
        Key("shift:down/3"),
        "release shift":
        Key("shift:up"),
        "[(hold|press)] control":
        Key("ctrl:down/3"),
        "release control":
        Key("ctrl:up"),
        "release [all]":
        release,

        ### Closures ###
        "angles":
        Key("langle, rangle, left/3"),
        "squares":
        Key("lbracket, rbracket, left/3"),
        "braces":
        Key("lbrace, rbrace, left/3"),
        "parens":
        Key("lparen, rparen, left/3"),
        "quotes":
        Key("dquote/3, dquote/3, left/3"),
        "single quotes":
        Key("squote, squote, left/3"),

        ### Multiple characters ###
        "double <char>":
        Text("%(char)s%(char)s"),
        "triple <char>":
        Text("%(char)s%(char)s%(char)s"),
        "double escape":
        Key("escape, escape"),  # Exiting menus.

        ### Punctuation and separation
        "colon [<n>]":
        Key("colon/2:%(n)d"),
        "(semi-colon|semicolon) [<n>]":
        Key("semicolon/2:%(n)d"),
        "dit [<n>]":
        Key("comma/2:%(n)d"),
        "drip":
        Key("comma, space"),
        "drip drop":
        Key("comma, enter"),
        "(dot|period) [<n>]":
        Key("dot/2:%(n)d"),
        "(dash|hyphen|minus) [<n>]":
        Key("hyphen/2:%(n)d"),
        "underscore [<n>]":
        Key("underscore/2:%(n)d"),

        # To release keyboard capture by VirtualBox.
        # "press right control": Key("Control_R"),

        ### Formatting ###
        # Formatting <n> words to the left of the cursor.
        "camel <n> [words]":
        Function(camel_case_count),
        "pascal <n> [words]":
        Function(pascal_case_count),
        "snake <n> [words]":
        Function(snake_case_count),
        "squash <n> [words]":
        Function(squash_count),
        "expand <n> [words]":
        Function(expand_count),
        "uppercase <n> [words]":
        Function(uppercase_count),
        "lowercase <n> [words]":
        Function(lowercase_count),
        # Format dictated words. See the formatMap for all available types.
        # Ex: "camel case my new variable" -> "myNewVariable"
        # 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.
        "short <abbreviation>":
        Text("%(abbreviation)s"),

        ### 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

        ### Miscellaneous ###
        # Microphone sleep/cancel started dictation.
        "[<text>] (go to sleep|cancel and sleep) [<text2>]":
        Function(cancel_and_sleep),  # @IgnorePep8
        # Reload Natlink.
        # "reload Natlink": Function(reload_natlink),
        "<number>":
        Text("%(number)s"),
        "<letter>":
        Text("%(letter)s"),
        "<specialChar>":
        Text("%(specialChar)s"),
    },
    namespace={
        "Key": Key,
        "Text": Text,
    })
Ejemplo n.º 3
0
grammarCfg.cmd.map = Item(
    {
        # Navigation keys.
        "up [<n>]": Key("up:%(n)d"),
        "down [<n>]": Key("down:%(n)d"),
        "left [<n>]": Key("left:%(n)d"),
        "right [<n>]": Key("right:%(n)d"),
        "page up [<n>]": Key("pgup:%(n)d"),
        "page down [<n>]": Key("pgdown:%(n)d"),
        #"up <n> (page|pages)": Key("pgup:%(n)d"),
        #"down <n> (page|pages)": Key("pgdown:%(n)d"),
        #"left <n> (word|words)": Key("c-left/3:%(n)d/10"),
        #"right <n> (word|words)": Key("c-right/3:%(n)d/10"),


		# Android emulator, couldn't get own file working
		"emulator back":			Key("c-backspace"),
		"emulator home":			Key("c-h"),
		"emulator overview":		Key("c-o"),
		"emulator left":			Key("c-left"),
		"emulator right":			Key("c-right"),

		"browser address": Key("a-d"),		

        "home": Key("home"),
        "(end|bend|lend|dole)": Key("end"),
        "doc home": Key("c-home/3"),
        "doc end": Key("c-end/3"),
        # Functional keys.
        "space": release + Key("space"),
        "space [<n>]": release + Key("space:%(n)d"),
        "(enter|slap|slop) [<n>]": release + Key("enter:%(n)d"),
        "tab [<n>]": Key("tab:%(n)d"),
		"delete [<n>]":	Key("delete:%(n)d"),
        "delete line": Key("s-delete"),
        #"delete [this] line": Key("home, s-end, del"),  # @IgnorePep8
        "backspace [<n>]": release + Key("backspace:%(n)d"),
        "application key": release + Key("apps/3"),
        "win key": release + Key("win/3"),
        #"paste [that]": Function(paste_command),
        #"copy [that]": Function(copy_command),
        "cut [that]": release + Key("c-x/3"),
        "select all": release + Key("c-a/3"),
        "[(hold|press)] alt": Key("alt:down/3"),
        "release alt": Key("alt:up"),
        "[(hold|press)] shift": Key("shift:down/3"),
        "release shift": Key("shift:up"),
        "[(hold|press)] control": Key("ctrl:down/3"),
        "release control": Key("ctrl:up"),
        "release [all]": release,
        "press key <pressKey>": Key("%(pressKey)s"),
        # Closures.
        "angle brackets": Key("langle, rangle, left/3"),
        "[square] brackets": Key("lbracket, rbracket, left/3"),
        "[curly] braces": Key("lbrace, rbrace, left/3"),
        "(parens|parentheses)": Key("lparen, rparen, left/3"),
        "quotes": Key("dquote/3, dquote/3, left/3"),
        "backticks": Key("backtick:2, left"),
        "single quotes": Key("squote, squote, left/3"),
        # Shorthand multiple characters.
        "double <char>": Text("%(char)s%(char)s"),
        "triple <char>": Text("%(char)s%(char)s%(char)s"),
        #ESCAPE
		"escape": Key("escape"),
		"double escape": Key("escape, escape"),  # Exiting menus.
        # Punctuation and separation characters, for quick editing.
        "colon [<n>]": Key("colon/2:%(n)d"),
        "semi-colon [<n>]": Key("semicolon/2:%(n)d"),
        "comma [<n>]": Key("comma/2:%(n)d"),
        "(dot|period|dit|point)": Key("dot"),  # cannot be followed by a repeat count
        "(dash|hyphen|minus) [<n>]": Key("hyphen/2:%(n)d"),
        "underscore [<n>]": Key("underscore/2:%(n)d"),
        "<letters>": Text("%(letters)s"),
        "<char>": Text("%(char)s"),

        'langle [<n>]': Key('langle:%(n)d'),
        'lace [<n>]':   Key('lbrace:%(n)d'),
        '(lack|lair) [<n>]':   Key('lbracket:%(n)d'),
        #'(laip|len) [<n>]':   Key('lparen:%(n)d'),
        'len [<n>]':    Key('lparen:%(n)d'),
        'rangle [<n>]': Key('rangle:%(n)d'),
        'race [<n>]':   Key('rbrace:%(n)d'),
        '(rack|rare) [<n>]':   Key('rbracket:%(n)d'),
        #'(raip|ren|wren) [<n>]':   Key('rparen:%(n)d'),
        '(ren|wren) [<n>]':   Key('rparen:%(n)d'),

        "act [<n>]": Key("escape:%(n)d"),
        "calm [<n>]": Key("comma:%(n)d"),
        #'into': Key('space,bar,space'),
        'care':        Key('home'),
        '(dole|doll)': Key('end'), #doll|
        'chuck [<n>]':       Key('del:%(n)d'),
        'scratch [<n>]':     Key('backspace:%(n)d'),
        "visual": Key("v"),
        "visual line": Key("s-v"),
        "visual block": Key("c-v"),
        "doc save": Key("c-s"),


        'gope [<n>]':  Key('pgup:%(n)d'),
        #'drop [<n>]':  Key('pgdown:%(n)d'),

        'lope [<n>]':  Key('c-left:%(n)d'),
        '(yope|rope) [<n>]':  Key('c-right:%(n)d'),
        '(hill scratch|hatch) [<n>]': Key('c-backspace:%(n)d'),

        'hexadecimal': Text("0x"),
        'suspend': Key('c-z'),

        'word <text>': Function(handle_word),
        'number <num>': Text("%(num)d"),
        'change <text> to <text2>': Key("home, slash") + Text("%(text)s") + Key("enter, c, e") + Text("%(text2)s") + Key("escape"),

        # 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.
        # "[<text>] (go to sleep|cancel and sleep) [<text2>]": Function(cancel_and_sleep),  # @IgnorePep8
    },
    namespace={
        "Key": Key,
        "Text": Text,
    }
)
Ejemplo n.º 4
0
# pkg_resources.require("dragonfly >= 0.6.5beta1.dev-r76")

import time
from dragonfly import (Grammar, Alternative, RuleRef, DictListRef,
                       Dictation, Compound, Integer, Rule, CompoundRule,
                       DictList, Window, Rectangle, monitors,
                       Config, Section, Item, FocusWindow, ActionError)


# ---------------------------------------------------------------------------
# Set up this module's configuration.

config = Config("Window control")
config.lang = Section("Language section")
config.lang.name_win = Item(
    "name (window | win) <name>",
    doc="Command to give the foreground window a name; must contain the <name> extra.")
config.lang.focus_win = Item(
    "focus <win_selector> | bring <win_selector> to [the] (top | foreground)",
    doc="Command to bring a named window to the foreground.")
config.lang.focus_title = Item(
    "focus title <text>",
    doc="Command to bring a window with the given title to the foreground.")
config.lang.translate_win = Item(
    "place <win_selector> <position> [on <mon_selector>]",
    doc="Command to translate a window.")
config.lang.resize_win = Item(
    "place <win_selector> [from] <position> [to] <position> [on <mon_selector>]",
    doc="Command to move and resize a window.")
config.lang.stretch_win = Item(
    "stretch <win_selector> [to] <position>",
Ejemplo n.º 5
0
"""

from dragonfly import Config, Section, Item, AppContext, Grammar, MappingRule, IntegerRef, Dictation, Choice

from lib.dynamic_aenea import (
    DynamicContext,
    Key,
    Text,
)

from proxy_nicknames import AppContext as NixAppContext

hipchat_config = Config("HipChat")
hipchat_config.usernames = Section("Username Mappings")
hipchat_config.usernames.map = Item({"All": "all", "Here": "here"})

hipchat_config.load()


class NavigationRule(MappingRule):
    mapping = {
        "move up [<n>]":
        Key("cs-tab:%(n)d"),
        "move down [<n>]":
        Key("c-tab:%(n)d"),
        "close tab":
        Key("c-w"),
        "(join room | private message) <room>":
        Key("c-j/25") + Text("%(room)s") + Key("enter"),
        "search [room] history":
Ejemplo n.º 6
0
grammarCfg.cmd.map = Item(
    {
        # Navigation keys.
        "up [<n>]":
        Key("up:%(n)d"),
        "down [<n>]":
        Key("down:%(n)d"),
        "left [<n>]":
        Key("left:%(n)d"),
        "right [<n>]":
        Key("right:%(n)d"),
        "page up [<n>]":
        Key("pgup:%(n)d"),
        "page down [<n>]":
        Key("pgdown:%(n)d"),
        "up <n> (page | pages)":
        Key("pgup:%(n)d"),
        "down <n> (page | pages)":
        Key("pgdown:%(n)d"),
        "left <n> (word | words)":
        Key("c-left:%(n)d"),
        "right <n> (word | words)":
        Key("c-right:%(n)d"),
        "home":
        Key("home"),
        "end":
        Key("end"),
        "doc home":
        Key("c-home/3"),
        "doc end":
        Key("c-end/3"),
        # Functional keys.
        "space":
        release + Key("space"),
        "space [<n>]":
        release + Key("space:%(n)d"),
        "enter [<n>]":
        release + Key("enter:%(n)d"),
        "tab [<n>]":
        Key("tab:%(n)d"),
        "delete [<n>]":
        release + Key("del:%(n)d/5"),
        "delete [<n> | this] (line|lines)":
        release + Key("home, s-down:%(n)d, del"),  # @IgnorePep8
        "backspace [<n>]":
        release + Key("backspace:%(n)d"),
        "application key":
        release + Key("apps/3"),
        "win key":
        release + Key("win/3"),
        "paste [that]":
        release + Key("c-v/3"),
        "copy [that]":
        release + Key("c-c/3"),
        "cut [that]":
        release + Key("c-x/3"),
        "select all":
        release + Key("c-a/3"),
        "undo":
        release + Key("c-z/3"),
        "undo <n> [times]":
        release + Key("c-z/3:%(n)d"),
        "redo":
        release + Key("c-y/3"),
        "redo <n> [times]":
        release + Key("c-y/3:%(n)d"),
        "[(hold|press)] alt":
        Key("alt:down/3"),
        "release alt":
        Key("alt:up"),
        "[(hold|press)] shift":
        Key("shift:down/3"),
        "release shift":
        Key("shift:up"),
        "[(hold|press)] control":
        Key("ctrl:down/3"),
        "release control":
        Key("ctrl:up"),
        "release [all]":
        release,
        # Type written form of "that which would otherwise not be written".
        "say <text>":
        release + Text("%(text)s"),
        #         "mimic <text>": release + Mimic(extra="text"),
        # Shorthand multiple characters.
        "double <char>":
        Text("%(char)s%(char)s"),
        "triple <char>":
        Text("%(char)s%(char)s%(char)s"),
        "double escape":
        Key("escape, escape"),  # Exiting menus.
        # To release keyboard capture by VirtualBox.
        "press right control":
        Key("Control_R"),
        # Formatting.
        "camel case <text>":
        Function(lib.format.camel_case_text),
        "camel case <n> [words]":
        Function(lib.format.camel_case_count),
        "pascal case <text>":
        Function(lib.format.pascal_case_text),
        "pascal case <n> [words]":
        Function(lib.format.pascal_case_count),
        "snake case <text>":
        Function(lib.format.snake_case_text),
        "snake case <n> [words]":
        Function(lib.format.snake_case_count),
        "squash <text>":
        Function(lib.format.squash_text),
        "squash <n> [words]":
        Function(lib.format.squash_count),
        "expand <n> [words]":
        Function(lib.format.expand_count),
        "uppercase <text>":
        Function(lib.format.uppercase_text),
        "uppercase <n> [words]":
        Function(lib.format.uppercase_count),
        "lowercase <text>":
        Function(lib.format.lowercase_text),
        "lowercase <n> [words]":
        Function(lib.format.lowercase_count),
        # 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
        # Canceling of started sentence.
        # Useful for canceling what inconsiderate loud mouths have started.
        "<text> cancel dictation":
        Function(cancel_dictation),
        "<text> cancel dictation <text2>":
        Function(cancel_dictation),
        "[<text>] cancel and sleep":
        Function(cancel_and_sleep),
        "[<text>] cancel and sleep [<text2>]":
        Function(cancel_and_sleep),
        # Reload Natlink.
        "reload Natlink":
        Function(reload_natlink),
    },
    namespace={
        "Key": Key,
        "Text": Text,
    })
Ejemplo n.º 7
0
#  * http://msdn.microsoft.com/en-us/library/ff184607.aspx
#  * http://dragonfly-modules.googlecode.com/svn-history/r50/trunk/command-modules/documentation/mod-_outlook.html
#

from dragonfly import(Config, Section, Item,
                      Grammar, ConnectionGrammar, AppContext,
                      MappingRule, CompoundRule,
                      Key, Integer, IntegerRef,
                      DictList, DictListRef)
import tempfile
import os
import os.path

config = Config('Microsoft Outlook control')
config.lang = Section('Language section')
config.lang.go_to_folder = Item('folder <folder>')
config.lang.move_to_folder = Item('move to <folder>')
config.lang.sync_folders = Item('refresh folders')
config.load()

def collection_iter(collection):
    for index in xrange(1, collection.Count + 1):
        yield collection.Item(index)

class OutlookControlGrammar(ConnectionGrammar):
    def __init__(self):
        self.folders = DictList("folders")
        super(OutlookControlGrammar,self).__init__(
            name="Microsoft Outlook control",
            context=AppContext(executable="outlook"),
            app_name="Outlook.Application"
Ejemplo n.º 8
0
config.cmd.map = Item({
    "cap deploy [with] migrations to <text>":
    Text("SKIP_ASSETS=true RUBBER_ENV=") +
    Function(lib.format.lowercase_text) + Text(" cap deploy:migrations"),
    "cap deploy [with] migrations to <text> with filter":
    Text("SKIP_ASSETS=true RUBBER_ENV=") +
    Function(lib.format.lowercase_text) +
    Text(" cap deploy:migrations FILTER="),
    "cap deploy [with] migrations to <text> with filter roles":
    Text("SKIP_ASSETS=true RUBBER_ENV=") +
    Function(lib.format.lowercase_text) +
    Text(" cap deploy:migrations FILTER_ROLES="),
    "cap deploy [with] migrations to <text> with assets":
    Text("RUBBER_ENV=") + Function(lib.format.lowercase_text) +
    Text(" cap deploy:migrations"),
    "cap deploy [with] migrations to <text> with assets with filter":
    Text("RUBBER_ENV=") + Function(lib.format.lowercase_text) +
    Text(" cap deploy:migrations FILTER="),
    "cap deploy [with] migrations to <text> with assets with filter roles":
    Text("RUBBER_ENV=") + Function(lib.format.lowercase_text) +
    Text(" cap deploy:migrations FILTER_ROLES="),
    "cap deploy to <text>":
    Text("SKIP_ASSETS=true RUBBER_ENV=") +
    Function(lib.format.lowercase_text) + Text(" cap deploy"),
    "cap deploy to <text> with filter":
    Text("SKIP_ASSETS=true RUBBER_ENV=") +
    Function(lib.format.lowercase_text) + Text(" cap deploy FILTER="),
    "cap deploy to <text> with filter roles":
    Text("SKIP_ASSETS=true RUBBER_ENV=") +
    Function(lib.format.lowercase_text) + Text(" cap deploy FILTER_ROLES="),
    "cap deploy to <text> with assets":
    Text("RUBBER_ENV=") + Function(lib.format.lowercase_text) +
    Text(" cap deploy"),
    "cap deploy to <text> with assets with filter":
    Text("RUBBER_ENV=") + Function(lib.format.lowercase_text) +
    Text(" cap deploy FILTER="),
    "cap deploy to <text> with assets with filter roles":
    Text("RUBBER_ENV=") + Function(lib.format.lowercase_text) +
    Text(" cap deploy FILTER_ROLES="),
    "cap invoke to <text>":
    Text("RUBBER_ENV=") + Function(lib.format.lowercase_text) +
    Text(" cap invoke COMMAND=\"\"") + Key("left:1"),
    "cap invoke to <text> with filter":
    Text("RUBBER_ENV=") + Function(lib.format.lowercase_text) +
    Text(" cap invoke COMMAND=\"\" FILTER="),
    "cap invoke to <text> with filter roles":
    Text("RUBBER_ENV=") + Function(lib.format.lowercase_text) +
    Text(" cap invoke COMMAND=\"\" FILTER_ROLES="),
    "cap rubber reboot <text>":
    Text("RUBBER_ENV=") + Function(lib.format.lowercase_text) +
    Text(" cap rubber:reboot ALIAS=") + Function(lib.format.lowercase_text),
    "cap rubber bootstrap <text>":
    Text("RUBBER_ENV=") + Function(lib.format.lowercase_text) +
    Text(" cap rubber:bootstrap FILTER=") +
    Function(lib.format.lowercase_text),
    "cap rubber set up security groups <text>":
    Text("RUBBER_ENV=") + Function(lib.format.lowercase_text) +
    Text(" cap rubber:setup_security_groups FILTER=") +
    Function(lib.format.lowercase_text),
    "cap rubber set up local aliases <text>":
    Text("RUBBER_ENV=") + Function(lib.format.lowercase_text) +
    Text(" cap rubber:setup_local_aliases"),
    "cap rubber set up remote aliases <text>":
    Text("RUBBER_ENV=") + Function(lib.format.lowercase_text) +
    Text(" cap rubber:setup_remote_aliases"),
    "cap rubber set up D N S aliases <text>":
    Text("RUBBER_ENV=") + Function(lib.format.lowercase_text) +
    Text(" cap rubber:setup_dns_aliases"),
    "cap rubber add role to <text>":
    Text("RUBBER_ENV=") + Function(lib.format.lowercase_text) +
    Text(" cap rubber:roles:add ROLES= ALIAS=") +
    Function(lib.format.lowercase_text),
    "cap rubber create staging <text>":
    Text("RUBBER_ENV=") + Function(lib.format.lowercase_text) +
    Text(" cap rubber:create_staging"),
    "cap rubber destroy staging <text>":
    Text("RUBBER_ENV=") + Function(lib.format.lowercase_text) +
    Text(" cap rubber:destroy_staging"),
    "cap rubber monit start":
    Text("cap rubber:monit:start RUBBER_ENV="),
    "cap rubber monit stop":
    Text("cap rubber:monit:stop RUBBER_ENV="),
    "cap rubber (postgres|PostgreSQL) start":
    Text("cap rubber:postgresql:start RUBBER_ENV="),
    "cap rubber (postgres|PostgreSQL) stop":
    Text("cap rubber:postgresql:stop RUBBER_ENV="),
})
Ejemplo n.º 9
0
grammarCfg.cmd.map = Item(
    {
        # navigation
        # next/prev brace
        # next/prev matching selection
        "down [<n>]": Key("down:%(n)d"),
        "down block": Key("c-rbracket"),
        "down method [<n>]": Key("a-down:%(n)d"),
        "down page [<n>]": Key("pgdown:%(n)d"),

        "doc end": Key("c-end"),
        "doc start": Key("c-home"),

        "go to column <n>": Key("c-g/25") + Text(":%(n)d") + Key("enter"),
        "go to declaration": Key("c-b"),
        "go to implemetation": Key("sc-b"),
        "go to line <n>": Key("c-g/25") + Text("%(n)d") + Key("enter"),
        "go to line <n> column <m>": Key("c-g/25") + Text("%(n)d:%(m)d") + Key("enter"),

        "left [<n>]": Key("left:%(n)d"),
        "left <n> (word|words)": Key("c-left:%(n)d"),

        "line end": Key("end"),
        "line start": Key("home"),

        "matching brace": Key("cs-m"),

        "next error": Key("f2"),
        "next position": Key("ca-right"),
        "previous error": Key("s-f2"),
        "previous position": Key("ca-left"),

        "right [<n>]": Key("right:%(n)d"),
        "right word [<n>]": Key("c-right:%(n)d"),

        "up [<n>]": Key("up:%(n)d"),
        "up block": Key("c-lbracket"),
        "up method [<n>]": Key("a-up:%(n)d"),
        "up page [<n>]": Key("pgup:%(n)d"),
        "up word [<n>]": Key("c-left:%(n)d"),

        # Searching
        "find in file": Key("c-f"),
        "find in path": Key("cs-f"),
        "find usage": Key("a-f7"),
        "find next": Key("f3"),
        "find previous": Key("s-f3"),
        "find word": Key("c-f3"),

        "replace in file": Key("c-r"),
        "replace in pat": Key("sc-r"),
        "select word <n>": Key("c-w:%(n)d"),

        # function keys
        "F one": Key("f1"),
        "F two": Key("f2"),
        "F three": Key("f3"),
        "F four": Key("f4"),
        "F five": Key("f5"),
        "F six": Key("f6"),
        "F Seven": Key("f7"),
        "F eight": Key("f8"),
        "F nine": Key("f9"),
        "F ten": Key("f10"),
        "F eleven": Key("f11"),
        "F 12": Key("f12"),

        # letters
        "(A|alpha)": Text("a"),
        "(B|bravo) ": Text("b"),
        "(C|charlie) ": Text("c"),
        "(D|delta) ": Text("d"),
        "(E|echo) ": Text("e"),
        "(F|foxtrot) ": Text("f"),
        "(G|golf) ": Text("g"),
        "(H|hotel) ": Text("h"),
        "(I|india|indigo) ": Text("i"),
        "(J|juliet) ": Text("j"),
        "(K|kilo) ": Text("k"),
        "(L|lima) ": Text("l"),
        "(M|mike) ": Text("m"),
        "(N|november) ": Text("n"),
        "(O|oscar) ": Text("o"),
        "(P|papa|poppa) ": Text("p"),
        "(Q|quebec|quiche) ": Text("q"),
        "(R|romeo) ": Text("r"),
        "(S|sierra) ": Text("s"),
        "(T|tango) ": Text("t"),
        "(U|uniform) ": Text("u"),
        "(V|victor) ": Text("v"),
        "(W|whiskey) ": Text("w"),
        "(X|x-ray) ": Text("x"),
        "(Y|yankee) ": Text("y"),
        "(Z|zulu) ": Text("z"),

        # Typescript keywords, defined as commands so case etc is correct
        "abstract": Text("abstract "),
        "as": Text("as "),
        "async": Text("async "),
        "await": Text("await "),
        "break": Text("break") + Key("enter"),
        "case": Text("case :") + Key("left"),
        "catch": Text("catch(err) {") + Key("enter"),
        "class <text>": Text("class ") + Function(lib.format.pascal_case_text) + Text(" {") + Key("enter"),
        "const <text>": Text("const ") + Function(lib.format.camel_case_text),
        "constructor": Text("constructor () {") + Key("left:3"),
        "continue": Text("continue") + Key("enter"),
        "declare": Text("declare "),
        "default": Text("default "),
        "delete <text>": Text("delete ") + Function(lib.format.camel_case_text),
        "do": Text("do "),
        "else": Text(" else {") + Key("enter"),
        "enum <text>": Text("enum ") + Function(lib.format.pascal_case_text) + Text(" {") + Key("enter"),
        "export": Text("export "),
        "extends <text>": Text("extends ") + Function(lib.format.pascal_case_text),
        "false": Text("false"),
        "finally": Text("finally {") + Key("enter"),
        "for of <text>": Text("for (const elem of ") + Function(lib.format.pascal_case_text) + Text("){"),
        "for in <text>": Text("for (const key of ") + Function(lib.format.pascal_case_text) + Text("){"),
        "function <text>": Text("function ") + Function(lib.format.pascal_case_text) + Text("() {") + Key("enter") + Key("cs-m") + Key("left:2"),
        "from": Text("from ''") + Key("left"),
        "get <text>": Text("get ") + Function(lib.format.camel_case_text) + Text("() {") + Key("enter") + Text("return "),
        "if": Text("if () {") + Key("enter") + Key("cs-m") + Key("left"),
        "implements <text>": Text("implements ") + Function(lib.format.pascal_case_text),
        "import": Text("import "),
        "in": Text("in "),
        "interface <text>": Text("interface ") + Function(lib.format.pascal_case_text) + Text(" {") + Key("enter"),
        "instance of": Text("instanceof "),
        "let <text>": Text("let ") + Function(lib.format.camel_case_text),
        "new": Text("new "),
        "null": Text("null "),
        "package": Text("package "),
        "private <text>": Text("private ") + Function(lib.format.camel_case_text),
        "protected": Text("protected "),
        "public": Text("public "),
        "read only": Text("readonly "),
        "return": Text("return "),
        "set <text>": Text("set ") + Function(lib.format.camel_case_text) + Text("() {") + Key("enter") + Key("cs-m") + Key("left:2"),
        "static": Text("static "),
        "super": Text("super("),
        "switch": Text("switch () {") + Key("enter") + Text("case :") + Key("enter") + Text("break") + Key("cs-m") + Key("left:2"),
        "this": Text("this"),
        "true": Text("true"),
        "try": Text("try {") + Key("enter") + Key("down:2") + Text("catch (err) {") + Key("enter") + Key("cs-m") + Key("up"),
        "type": Text("type "),
        "type of": Text("typeof"),
        "undefined": Text("undefined"),
        "void": Text("void"),
        "while": Text("while () {") + Key("enter") + Key("cs-m") + Key("left:2"),

        # common  methods
        "log": Text("console.log(\""),

        # common types
        "any": Text("any"),
        "boolean": Text("boolean"),
        "map": Text("Map"),
        "number": Text("number"),
        "new map": Text("Map<>(") + Key("left:2"),
        "string": Text("string"),

        # symbols, puncuation etc
        "bar": Text(" | "),
        "equal to": Text(" === "),
        "equals": Text(" = "),
        "greater than": Text(" > "),
        "greater than or equal 2": Text(" >= "),
        "less than": Text(" < "),
        "less than or equal 2": Text(" <= "),
        "not equal to": Text(" !== "),
        "angle bracket": Key("langle"),
        "close angle bracket": Key("rangle"),
        "square bracket": Text("["),
        "close square bracket": Text("]"),
        "brace": Key("lbrace"),
        "close brace": Key("rbrace"),
        "paren": Key("lparen"),
        "close paren": Key("rparen"),
        "quote": Key("dquote"),
        "single quote": Key("squote"),
        "colon [<n>]": Key("colon:%(n)d"),
        "semi-colon [<n>]": Key("semicolon:%(n)d"),
        "comma [<n>]": Key("comma:%(n)d"),
        "dot [<n>]": Key("dot:%(n)d"),
        "(dash|hyphen|minus) [<n>]": Key("hyphen:%(n)d"),
        "underscore [<n>]": Key("underscore:%(n)d"),
        "plus": Text(" + "),
        "bang": Text("!"),
        "at": Text("@"),

        # Formatting <n> words to the left of the cursor.
        "camel case <n>": Function(lib.format.camel_case_count),
        "camel case <text>": Function(lib.format.camel_case_text),
        "pascal case <n>": Function(lib.format.pascal_case_count),
        "pascal case <text>": Function(lib.format.pascal_case_text),
        "snake case <n>": Function(lib.format.snake_case_count),
        "snake case <text>": Function(lib.format.snake_case_text),
        "squash <n>": Function(lib.format.squash_count),
        "expand <n>": Function(lib.format.expand_count),
        "uppercase <n>": Function(lib.format.uppercase_count),
        "uppercase <text>": Function(lib.format.uppercase_text),
        "lowercase <n>": Function(lib.format.lowercase_count),
        "lowercase <text>": Function(lib.format.lowercase_text),
        # Format dictated words. See the formatMap for all available types.
        # Ex: "camel case my new variable" -> "myNewVariable"
        # Ex: "snake case my new variable" -> "my_new_variable"
        # Ex: "uppercase squash my new hyphen variable" -> "MYNEW-VARIABLE"
        # "<formatType> <text>": Function(lib.format.format_text),

        # editing
        # For writing words that would otherwise be characters or commands.
        # Ex: "period", tab", "left", "right", "home", select word
        "cut": Key("c-x"),
        "dictate <text>": Text("%(text)s"),
        "duplicate line": Key("c-d"),
        "escape": Key("escape"),
        "format": Key("csa-p"),
        "paste": Key("c-v"),
        "save": Key("c-s"),
        "undo": Key("c-z"),
    },
    namespace={
        "Key": Key,
        "Text": Text,
    }
)
Ejemplo n.º 10
0
"""

import pkg_resources
pkg_resources.require("dragonfly >= 0.6.5beta1.dev-r76")

from dragonfly import (Grammar, AppContext, MappingRule, Key,
                       Config, Section, Item)


#---------------------------------------------------------------------------
# Initialize this module's configuration.

config = Config("Audacity control")

config.lang                    = Section("Language section")
config.lang.new_project        = Item("[start] new project", doc="Spec starts a new project.")
config.lang.open_project       = Item("open project", doc="Spec opens an existing project.")
config.lang.close_project      = Item("close [this] project", doc="Spec closes currently open project.")
config.lang.save_project       = Item("save [this] project", doc="Spec saves currently open project.")
config.lang.selection_tool     = Item("[open] selection tool", doc="Spec opens the selection tool.")
config.lang.envelope_tool      = Item("[open] envelope tool", doc="Spec opens the envelope tool.")
config.lang.edit_tool          = Item("[open] edit tool", doc="Spec opens the edit tool.")
config.lang.zoom_tool          = Item("[open] zoom tool", doc="Spec opens the zoom tool.")
config.lang.timeshift_tool     = Item("[open] timeshift tool", doc="Spec opens the timeshift tool.")
config.lang.multi_tool         = Item("[open] multi tool", doc="Spec opens the multitool.")
config.lang.next_toolbar_tool  = Item("[move to | go to] next tool", doc="Spec move to the next tool in toolbar.")
config.lang.previous_toolbar_tool = Item("[move to | go to] previous tool", doc="Spec move to the previous tool in toolbar.")
config.lang.silence            = Item("[insert | create] silence", doc="Spec insert silence at current position.")
config.lang.duplicate          = Item("[make] duplicate", doc="Spec makes duplicate.")
config.lang.find_zero_crossings= Item("[find | search] zero crossings", doc="Spec finds zero crossings.")
config.lang.play_stop          = Item("[start | stop] playing", doc="Spec starts or stops playback.")
Ejemplo n.º 11
0
from dragonfly import Function, MappingRule, Text, Dictation, Config, Section, Item, Key

config = Config("format functions")
config.cmd = Section("Command section")
config.cmd.map = Item(
    {},
    namespace={
        "Key": Key,
        "Text": Text,
    }
)
namespace = config.load()


#---------------------------------------------------------------------------
# Here we prepare the list of formatting functions from the config file.

# Retrieve text-formatting functions from this module's config file. Each of these functions must have a name that starts with "format_".
format_functions = {}
if namespace:
    for name, function in namespace.items():
        if name.startswith("format_") and callable(function):
            spoken_form = function.__doc__.strip()

            # We wrap generation of the Function action in a function so that its *function* variable will be local.  Otherwise it
            #  would change during the next iteration of the namespace loop.
            def wrap_function(function):
                def _function(dictation):
                    formatted_text = function(dictation)
                    Text(formatted_text).execute()
Ejemplo n.º 12
0
#---------------------------------------------------------------------------
# Set up this module's configuration.

config = Config("bring me")
config.targets         = Section("Targets section")
config.targets.mapping = Item(
                              default={
							           "less compiler": open("C:\svn\guesscommerceredesignclean\Websites\GuessInc.Web.Frontend\Content\Guess\LessCompiler.bat"),
                                       "Google": website("http://www.google.com"),
                                       "dev": website("https://dev.plus3.ws"),
                                       "development": ssh("development"),
                                       "Trello": website("http://www.trello.com"),
                                       "Gmail": website("http://mail.google.com"),
                                       "hacker news": website("http://news.ycombinator.com"),
                                       "Reddit": website("http://www.reddit.com"),
                                      },
                              doc="Mapping of spoken targets to bringable targets.",
                              namespace={
                                         "website":  website,
                                         "open":     open,
                                         "folder":   folder,
                                         "ssh":      ssh,
                                        },
                             )
config.lang            = Section("Language section")
config.lang.bring_me   = Item("bring me <target>",
                              doc="Command to bring a target;"
                                  " must contain the <target> extra.")
config.lang.paste_me   = Item("paste me <target>",
                              doc="Command to paste the location of a target;"
Ejemplo n.º 13
0
import os.path
import subprocess
import os
import win32gui
import urllib
#from subprocess import Popen

from dragonfly import (Grammar, ConnectionGrammar, AppContext, CompoundRule,
                       Choice, Window, Config, Section, Item)

#---------------------------------------------------------------------------
# Set up this module's configuration.

config = Config("TortoiseSVN")
config.tortoisesvn = Section("TortoiseSVN configuration")
config.tortoisesvn.path = Item(
    r'C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe')
config.tortoisesvn.command = Item("(tortoise | subversion) <command>")
config.tortoisesvn.global_command = Item(
    "(tortoise | subversion) <command> <predef>")
config.tortoisesvn.actions = Item(
    {
        "add": "add",
        "checkout": "checkout",
        "commit": "commit",
        "revert": "revert",
        "merge": "merge",
        "delete": "delete",
        "diff": "diff",
        "log": "log",
        "import": "import",
        "update": "update",
Ejemplo n.º 14
0
pkg_resources.require("dragonfly >= 0.6.5beta1.dev-r76")

import os.path
from win32com.client  import Dispatch
from pywintypes       import com_error

from dragonfly import (ConnectionGrammar, AppContext, DictListRef,
                       CompoundRule, DictList, Config, Section, Item)


#---------------------------------------------------------------------------
# Set up this module's configuration.

config = Config("Microsoft Word styles control")
config.lang                = Section("Language section")
config.lang.set_style      = Item("set style <style>", doc="Spec for setting a style; must contain the <style> extra.")
config.lang.update_styles  = Item("(update | synchronize) styles", doc="Spec for updating style list.")
#config.generate_config_file()
config.load()


#---------------------------------------------------------------------------
# StyleRule which keeps track of and can set available styles.

class StyleRule(CompoundRule):

    spec   = config.lang.set_style
    styles = DictList("styles")
    extras = [DictListRef("style", styles)]

    def _process_recognition(self, node, extras):
Ejemplo n.º 15
0
try:
    import pkg_resources
    pkg_resources.require("dragonfly >= 0.6.5beta1.dev-r76")
except ImportError:
    pass

from dragonfly import (Grammar, AppContext, MappingRule, Dictation,
                       Key, Text, Config, Section, Item, IntegerRef)


#---------------------------------------------------------------------------
# Set up this module's configuration.

config                             = Config("Foxit reader control")
config.lang                        = Section("Language section")
config.lang.new_win                = Item("new (window | win)")
#config.generate_config_file()
config.load()


#---------------------------------------------------------------------------
# Create the main command rule.

class CommandRule(MappingRule):

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

pkg_resources.require("dragonfly >= 0.6.5beta1.dev-r76")

import ctypes
import natlink
from dragonfly import (Grammar, CompoundRule, Config, Section, Item)

#---------------------------------------------------------------------------
# Set up this module's configuration.

config = Config("lock screen")
config.lang = Section("Language section")
config.lang.lock_screen = Item("lock screen now now",
                               doc="Command to lock the screen;"
                               " also puts the microphone to sleep.")
config.load()

#---------------------------------------------------------------------------
# Lock screen rule.


class LockRule(CompoundRule):

    spec = config.lang.lock_screen

    def _process_recognition(self, node, extras):
        self._log.debug("%s: locking screen." % self)

        # Put the microphone to sleep.
Ejemplo n.º 17
0
grammarCfg.cmd.map = Item(
    {
        # Navigation keys.
        "up [<n>]":
        Key("up:%(n)d"),
        "up [<n>] slow":
        Key("up/15:%(n)d"),
        "down [<n>]":
        Key("down:%(n)d"),
        "down [<n>] slow":
        Key("down/15:%(n)d"),
        "left [<n>]":
        Key("left:%(n)d"),
        "left [<n>] slow":
        Key("left/15:%(n)d"),
        "right [<n>]":
        Key("right:%(n)d"),
        "right [<n>] slow":
        Key("right/15:%(n)d"),
        "page up [<n>]":
        Key("pgup:%(n)d"),
        "page down [<n>]":
        Key("pgdown:%(n)d"),
        "up <n> (page|pages)":
        Key("pgup:%(n)d"),
        "down <n> (page|pages)":
        Key("pgdown:%(n)d"),
        "left <n> (word|words)":
        Key("c-left/3:%(n)d/10"),
        "right <n> (word|words)":
        Key("c-right/3:%(n)d/10"),
        "home":
        Key("home"),
        "end":
        Key("end"),
        "doc home":
        Key("c-home/3"),
        "doc end":
        Key("c-end/3"),
        # Functional keys.
        "space":
        release + Key("space"),
        "space [<n>]":
        release + Key("space:%(n)d"),
        "enter [<n>]":
        release + Key("enter:%(n)d"),
        "tab [<n>]":
        Key("tab:%(n)d"),
        "delete [<n>]":
        Key("del/3:%(n)d"),
        "delete [this] line":
        Key("home, s-end, del"),  # @IgnorePep8
        "backspace [<n>]":
        release + Key("backspace:%(n)d"),
        "application key":
        release + Key("apps/3"),
        "win key":
        release + Key("win/3"),
        "paste [that]":
        Function(paste_command),
        "copy [that]":
        Function(copy_command),
        "cut [that]":
        release + Key("c-x/3"),
        "select all":
        release + Key("c-a/3"),
        "undo":
        release + Key("c-z/3"),
        "undo <n> [times]":
        release + Key("c-z/3:%(n)d"),
        "redo":
        release + Key("c-y/3"),
        "redo <n> [times]":
        release + Key("c-y/3:%(n)d"),
        "[(hold|press)] alt":
        Key("alt:down/3"),
        "release alt":
        Key("alt:up"),
        "[(hold|press)] shift":
        Key("shift:down/3"),
        "release shift":
        Key("shift:up"),
        "[(hold|press)] control":
        Key("ctrl:down/3"),
        "release control":
        Key("ctrl:up"),
        "release [all]":
        release,
        # Closures.
        "angle brackets":
        Key("langle, rangle, left/3"),
        "brackets":
        Key("lbracket, rbracket, left/3"),
        "braces":
        Key("lbrace, rbrace, left/3"),
        "parens":
        Key("lparen, rparen, left/3"),
        "quotes":
        Key("dquote/3, dquote/3, left/3"),
        "single quotes":
        Key("squote, squote, left/3"),
        # Shorthand multiple characters.
        "double <char>":
        Text("%(char)s%(char)s"),
        "triple <char>":
        Text("%(char)s%(char)s%(char)s"),
        "double escape":
        Key("escape, escape"),  # Exiting menus.
        # Punctuation and separation characters, for quick editing.
        "colon [<n>]":
        Key("colon/2:%(n)d"),
        "semi-colon [<n>]":
        Key("semicolon/2:%(n)d"),
        "comma [<n>]":
        Key("comma/2:%(n)d"),
        "(dot|period) [<n>]":
        Key("dot/2:%(n)d"),
        "(dash|hyphen|minus) [<n>]":
        Key("hyphen/2:%(n)d"),
        "underscore [<n>]":
        Key("underscore/2:%(n)d"),
        # To release keyboard capture by VirtualBox.
        "press right control":
        Key("Control_R"),
        # Formatting <n> words to the left of the cursor.
        "camel case <n> [words]":
        Function(camel_case_count),
        "pascal case <n> [words]":
        Function(pascal_case_count),
        "snake case <n> [words]":
        Function(snake_case_count),
        "squash <n> [words]":
        Function(squash_count),
        "expand <n> [words]":
        Function(expand_count),
        "uppercase <n> [words]":
        Function(uppercase_count),
        "lowercase <n> [words]":
        Function(lowercase_count),
        # Format dictated words. See the formatMap for all available types.
        # Ex: "camel case my new variable" -> "myNewVariable"
        # 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.
        "abbreviate <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.
        "[<text>] (go to sleep|cancel and sleep) [<text2>]":
        Function(cancel_and_sleep),  # @IgnorePep8
        # Reload Natlink.
        "reload Natlink":
        Function(reload_natlink),
    },
    namespace={
        "Key": Key,
        "Text": Text,
    })
Ejemplo n.º 18
0
from lib import sound
from natlink import setMicState
import natlinkstatus

import time
import subprocess

#---------------------------------------------------------------------------
# Set up this module's configuration.

config = Config("config manager")
#config                   = Config("dragonfly tools") # I like to keep those names consistent with the .py module file names
config.lang = Section("Language section")

config.lang.list_configs = Item("list configs", doc="Command to ...")
config.lang.edit_config = Item("edit <config> (config | configuration)",
                               doc="Command to ...")

config.lang.list_modules = Item("list modules", doc="Command to ...")
config.lang.edit_module = Item("edit <module> (module|mod)",
                               doc="Command to ...")

config.lang.show_dragonfly_version = Item("show dragonfly version",
                                          doc="Command to ...")
config.lang.update_dragonfly = Item("update dragonfly version",
                                    doc="Command to ...")
config.lang.reload_natlink = Item("reload natlink", doc="Command to ...")

config.lang.show_natlink_messages_window = Item(
    "show (natlink|messages) [window]", doc="Command to ...")
Ejemplo n.º 19
0
from dragonfly import (Grammar, CompoundRule, Config, Section, Item)

import natlink

config = Config("snore")
config.lang = Section("Language section")
config.lang.snore = Item("snore", doc="Put the microphone to sleep")


class SnoreRule(CompoundRule):

    spec = config.lang.snore

    def _process_recognition(self, node, extras):
        self._log.debug("sleepy mic")
        natlink.setMicState("sleeping")


grammar = Grammar("snore")
grammar.add_rule(SnoreRule())
grammar.load()


def unload():
    global grammar
    if grammar: grammar.unload()
    grammar = None
Ejemplo n.º 20
0
from dragonfly import MappingRule, Function, Config, Section, Item


def printTango():
    print "tango"


def printUniform():
    print "uniform"


config = Config("test map")
config.cmd = Section("Command section")
config.cmd.map = Item(
    # Here we define the *default* command map.  If you would like to modify it to your personal taste, please *do not* make changes
    #  here.  Instead change the *config file* called "_multiedit.txt".  If it exists, the map there will replace this one.
    {
        "print tango": Function(printTango),
        "print uniform": Function(printUniform),
    },
    doc=
    "Default window names. Maps spoken-forms to {executable name, title, executable path} dict."
)
config.load()


class TangoMap(MappingRule):
    mapping = config.cmd.map
Ejemplo n.º 21
0
"""

# import logging
from dragonfly.windows.clipboard import Clipboard
from dragonfly import Config, Section, Item, Grammar, CompoundRule, Key
from supporting import utils

# rule_log = logging.getLogger("rule")

# ---------------------------------------------------------------------------
# Set up this module's configuration.

config = Config("Text Manipulation")
config.tweak = Section("Tweak section")
config.tweak.upper = Item("upper that", doc="Command to convert the selected text to uppercase.")
config.tweak.lower = Item("lower that", doc="Command to convert the selected text to lower case.")
# config.generate_config_file()
config.load()

# ===========================================================================
# Create this module's main grammar object.

text_manipulation_grammar = Grammar("text manipulation")


class UpperRule(CompoundRule):
    spec = config.tweak.upper

    def _process_recognition(self, node, extras):
        copy_modify_paste(lambda s: s.upper())
Ejemplo n.º 22
0
config.cmd.map = Item({
    "cd (mogo test|mogotest)":
    Text("cd ~/dev/workspaces/mogotest") + Key("enter"),
    "cd (mogo test|mogotest) remote":
    Text("cd ~/dev/workspaces/mogotest-helix") + Key("enter"),
    "cd ping4":
    Text("cd ~/dev/workspaces/ping4app") + Key("enter"),
    "cd ping4 remote":
    Text("cd ~/ping4-helix") + Key("enter"),
    "cd rubber":
    Text("cd ~/dev/workspaces/rubber") + Key("enter"),
    "cd rubber test":
    Text("cd ~/dev/workspaces/rubbertest") + Key("enter"),
    "cd workspaces":
    Text("cd ~/dev/workspaces") + Key("enter"),
    "cd home":
    Text("cd ~") + Key("enter"),
    "cd downloads":
    Text("cd ~/Downloads") + Key("enter"),
    "cd drop box":
    Text("cd ~/Dropbox") + Key("enter"),
    #"cd NatLink": Text("cd C:\NatLink\NatLink\MacroSystem") + Key("enter"),
    "cd NatLink":
    Text("cd /c/NatLink/NatLink/MacroSystem") + Key("enter"),
    "cd rubber Ping4 production":
    Text("cd ~/.rubber_ping4_production") + Key("enter"),
    "cd rubber Ping4 (development|staging)":
    Text("cd ~/.rubber_ping4_dev") + Key("enter"),
    "cd rubber Mogotest":
    Text("cd ~/.ec2_mogotest") + Key("enter"),
    "(edit|vim) rubber secret":
    Text("vim rubber-secret.yml"),
    "(open|start) rails console":
    Text("./script/rails c") + Key("enter"),
    "fix line endings":
    Text("find . -type f -exec dos2unix {} \; && chmod +x script/*") +
    Key("enter"),
    "fix (date|time)":
    Text("ntpd -qg") + Key("enter"),
    "stop torquebox":
    Text("service monit stop && service torquebox stop") + Key("enter"),
    "start torquebox":
    Text("service torquebox start") + Key("enter"),
    "grep torquebox":
    Text("ps aux | grep torque") + Key("enter"),
    "git get":
    Text("git get") + Key("enter"),
    "git put":
    Text("git put") + Key("enter"),
    "find URL group":
    Text("g = UrlGroup.where(uid: '').first") + Key("left:8"),
    "ssh mets":
    Text("ssh mets.ping4central.com") + Key("enter"),
    "ssh Q A gateway":
    Text("ssh qa-gw.ping4inc.com") + Key("enter"),
    "ssh Q A mets":
    Text("ssh qa-mets.ping4inc.com") + Key("enter"),
    "ssh load test gateway":
    Text("ssh loadtest-gw.ping4inc.com") + Key("enter"),
    "ssh load test mets":
    Text("ssh loadtest-mets.ping4inc.com") + Key("enter"),
    "ssh melchior":
    Text("ssh nirvdrum@melchior") + Key("enter"),
    "ssh ping4 (development|V M)":
    Text("ssh development.ping4inc.com") + Key("enter"),
    "ssh Kevin dot mogotest dot com":
    Text("ssh kevin.mogotest.com") + Key("enter"),
    "ssh app (oh|zero) 1":
    Text("ssh app01.mogotest.com") + Key("enter"),
    "ssh app (oh|zero) 2":
    Text("ssh app02.mogotest.com") + Key("enter"),
    "ssh tools":
    Text("ssh tools.mogotest.com") + Key("enter"),
    "ssh Cassandra 1":
    Text("ssh cas1.ping4central.com") + Key("enter"),
    "ssh Cassandra 2":
    Text("ssh cas2.ping4central.com") + Key("enter"),
    "ssh Cassandra 3":
    Text("ssh cas3.ping4central.com") + Key("enter"),
    "ssh Cassandra 4":
    Text("ssh cas4.ping4central.com") + Key("enter"),
    "ssh Cassandra 5":
    Text("ssh cas5.ping4central.com") + Key("enter"),
    "ssh Cassandra 6":
    Text("ssh cas6.ping4central.com") + Key("enter"),
    "ssh Cassandra 7":
    Text("ssh cas7.ping4central.com") + Key("enter"),
    "ssh Cassandra 8":
    Text("ssh cas8.ping4central.com") + Key("enter"),
    "tail app logs":
    Text("cd ~") + Key("enter") + Text("current") + Key("enter") +
    Text("tail -f log/*.log") + Key("enter"),
    "tail (torquebox|torque box) log":
    Text("tail -f /var/log/torquebox/torquebox.log") + Key("enter"),
    "tail development logs":
    Text("tail -f log/development.log") + Key("enter"),
    "tail postgres (log|logs)":
    Text("tail -f /var/log/postgresql/postgresql*.log") + Key("enter"),
    "edit ssh config":
    Text("vim ~/.ssh/config") + Key("enter"),
    "(open|start) program":
    DynamicAction(Key("a-space"), Key("f1")),
    "(open|start) program <text>":
    DynamicAction(Key("a-space"), Key("f1")) + Pause("30") +
    Function(lib.format.lowercase_text),

    # Custom vocabulary.
    "nerve drum":
    Text("nirvdrum"),
    "chat laugh":
    Text("Heh."),
    "J ruby":
    Text("jruby"),
    "you tills":
    Text("utils"),
    "firefox you tills":
    Text("FirefoxUtils"),
    "IE 601":
    Text("ie601"),
    "IE 602":
    Text("ie602"),
    "IE 701":
    Text("ie701"),
    "IE 702":
    Text("ie702"),
    "IE 801":
    Text("ie801"),
    "IE 802":
    Text("ie802"),
    "IE 901":
    Text("ie901"),
    "IE 902":
    Text("ie902"),
    "IE 1001":
    Text("ie1001"),
    "IE 1002":
    Text("ie1002"),
    "ruby version":
    Text("ruby --version") + Key("enter"),
    "change ruby M R I":
    Text("rbenv shell 2.1.1") + Key("enter"),
    "change ruby (jay ruby|jruby)":
    Text("rbenv shell jruby-1.7.10") + Key("enter"),
    "(torque box|TorqueBox) run":
    Text("torquebox run -b 0.0.0.0") + Key("enter"),
    "(torque box|TorqueBox) deploy":
    Text("torquebox deploy") + Key("enter"),
    "vagrant destroy":
    Text("vagrant destroy"),
    "vagrant up":
    Text("vagrant up"),
    "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"),
})
Ejemplo n.º 23
0
    def bring_it(self):
        subprocess.Popen([self.putty_path, "-load", self.target])


#---------------------------------------------------------------------------
# Set up this module's configuration.

config = Config("bring me")
config.targets = Section("Targets section")
config.targets.mapping = Item(
    default={
        "my site": website("http://www.google.com"),
    },
    doc="Mapping of spoken targets to bringable targets.",
    namespace={
        "website": website,
        "open": open,
        "folder": folder,
        "ssh": ssh,
    },
)
config.lang = Section("Language section")
config.lang.bring_me = Item("bring me <target>",
                            doc="Command to bring a target;"
                            " must contain the <target> extra.")
config.lang.paste_me = Item("paste me <target>",
                            doc="Command to paste the location of a target;"
                            " must contain the <target> extra.")
config.load()

#---------------------------------------------------------------------------
Ejemplo n.º 24
0
grammarCfg.cmd.map = Item(
    {
        # Navigation keys.
        "(up|gup|gope) [<n>]":
        Key("up:%(n)d"),
        "(up|gup|gope) [<n>] slow":
        Key("up/15:%(n)d"),
        "(down|gun|gown) [<n>]":
        Key("down:%(n)d"),
        "(down|gun|gown) [<n>] slow":
        Key("down/15:%(n)d"),
        "(left|leaf) [<n>]":
        Key("left:%(n)d"),
        "(left|leaf) [<n>] slow":
        Key("left/15:%(n)d"),
        "(right|Ross) [<n>]":
        Key("right:%(n)d"),
        "(right|Ross) [<n>] slow":
        Key("right/15:%(n)d"),
        "(page up|pope|powp) [<n>]":
        Key("pgup:%(n)d"),
        "(page down|pown|pound) [<n>]":
        Key("pgdown:%(n)d"),  # pown is getting confused with home
        "up <n> (page|pages)":
        Key("pgup:%(n)d"),
        "down <n> (page|pages)":
        Key("pgdown:%(n)d"),
        "left <n> (word|words)":
        Key("c-left/3:%(n)d/10"),
        "right <n> (word|words)":
        Key("c-right/3:%(n)d/10"),
        "home|West":
        Key("home"),
        "end|East":
        Key("end"),
        "doc home|North":
        Key("c-home/3"),
        "doc end|South":
        Key("c-end/3"),
        # Shorthand word jumps and deletes
        "fomble [<n>]":
        Key("c-right/5:%(n)d"),
        "kimble [<n>]":
        Key("c-del/5:%(n)d"),
        "bamble [<n>]":
        Key("c-left/5:%(n)d"),
        "dumbbell [<n>]":
        Key("c-backspace/5:%(n)d"),
        # Functional keys.
        "space|ace|spooce":
        release + Key("space"),
        "(space|ace|spooce) [<n>]":
        release + Key("space:%(n)d"),
        "(enter|slap|loon|shock) [<n>]":
        release + Key("enter:%(n)d"),
        "(tab|tabby|tub|tubby) [<n>]":
        Key("tab:%(n)d"),
        "(delete|chuck) [<n>]":
        Key("del/3:%(n)d"),
        "(delete|chuck) [this] line":
        Key("home, s-end, del"),  # @IgnorePep8
        "(backspace|chook|crack) [<n>]":
        release + Key("backspace:%(n)d"),
        "(application key|context menu)":
        release + Key("apps/3"),
        "win key":
        release + Key("win/3"),
        "paste [that]":
        Function(paste_command),
        "copy [that]":
        Function(copy_command),
        "cut [that]":
        release + Key("c-x/3"),
        "select all":
        release + Key("c-a/3"),
        "undo":
        release + Key("c-z/3"),
        "undo <n> [times]":
        release + Key("c-z/3:%(n)d"),
        "redo":
        release + Key("c-y/3"),
        "redo <n> [times]":
        release + Key("c-y/3:%(n)d"),
        "[(hold|press)] alt":
        Key("alt:down/3"),
        "release alt":
        Key("alt:up"),
        "[(hold|press)] shift":
        Key("shift:down/3"),
        "release shift":
        Key("shift:up"),
        "[(hold|press)] control":
        Key("ctrl:down/3"),
        "release control":
        Key("ctrl:up"),
        "release [all]":
        release,
        # Closures.
        "angle brackets":
        Key("langle, rangle, left/3"),
        "brackets":
        Key("lbracket, rbracket, left/3"),
        "braces":
        Key("lbrace, rbrace, left/3"),
        "parens":
        Key("lparen, rparen, left/3"),
        "quotes":
        Key("dquote/3, dquote/3, left/3"),
        "single quotes":
        Key("squote, squote, left/3"),
        # Shorthand multiple characters.
        "double <char>":
        Text("%(char)s%(char)s"),
        "triple <char>":
        Text("%(char)s%(char)s%(char)s"),
        "double escape":
        Key("escape, escape"),  # Exiting menus.
        # Punctuation and separation characters, for quick editing.
        #"colon [<n>]": Key("colon/2:%(n)d"),
        #"semi-colon [<n>]": Key("semicolon/2:%(n)d"),
        #"comma [<n>]": Key("comma/2:%(n)d"),
        #"(dot|period) [<n>]": Key("dot/2:%(n)d"),
        #"(dash|hyphen|minus) [<n>]": Key("hyphen/2:%(n)d"),
        #"underscore [<n>]": Key("underscore/2:%(n)d"),
        # To release keyboard capture by VirtualBox.
        "press right control":
        Key("Control_R"),
        # Formatting <n> words to the left of the cursor.
        "camel case <n> [words]":
        Function(camel_case_count),
        "pascal case <n> [words]":
        Function(pascal_case_count),
        "snake case <n> [words]":
        Function(snake_case_count),
        "title case <n> [words]":
        Function(title_case_count),
        "squash <n> [words]":
        Function(squash_count),
        "expand <n> [words]":
        Function(expand_count),
        "uppercase <n> [words]":
        Function(uppercase_count),
        "lowercase <n> [words]":
        Function(lowercase_count),
        # Format dictated words. See the formatMap for all available types.
        # Ex: "camel case my new variable" -> "myNewVariable"
        # 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.
        "abbreviate <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.
        "[<text>] (snore|go to sleep|cancel and sleep) [<text2>]":
        Function(cancel_and_sleep),  # @IgnorePep8
        # Reload Natlink.
        # errors and fails on win7_64bit i think because pywin is 32bit
        # Reloading Python subsystem...
        # some error occurred
        # Traceback (most recent call last):
        # File "C:\NatLink\NatLink\MacroSystem\core\natlinkmain.py", line 146, in <module>
        # import natlinkstatus    # for extracting status info (QH)
        # File "C:\NatLink\NatLink\MacroSystem\core\natlinkstatus.py", line 180, in <module>
        # import RegistryDict, natlinkcorefunctions
        # File "C:\NatLink\NatLink\MacroSystem\core\natlinkcorefunctions.py", line 31, in <module>
        # from win32com.shell import shell, shellcon
        # File "C:\Python27\lib\site-packages\win32com\__init__.py", line 82, in <module>
        # SetupEnvironment()
        # File "<string>", line 3, in __init__
        # TypeError: 'NoneType' object is not callable
        "reload Natlink":
        Function(reload_natlink),
    },
    namespace={
        "Key": Key,
        "Text": Text,
    })
Ejemplo n.º 25
0
from dragonfly import Config, Section, Item

config = Config("gvim")

# What words you wish to use to trigger vim's commands
config.cmd = Section("Language")

# What custom settings does your system have?
config.system = Section("System")
config.system.windowSwitchPrefix = Item(
    'c-',  # default: "c-w,",
    doc=
    "What prefix to use when switching windows? Relevant with vim-tmux-navigator (which can make vim windows and tmux panes inter-navigable.)."
)


def get_config():
    return config
Ejemplo n.º 26
0
grammarCfg.cmd.map = Item(
	{
		# Navigation keys.
		"up [<n>]": Key("up:%(n)d"),
		"up [<n>] slow": Key("up/15:%(n)d"),
		"down [<n>]": Key("down:%(n)d"),
		"down [<n>] slow": Key("down/15:%(n)d"),
		"left [<n>]": Key("left:%(n)d"),
		"left [<n>] slow": Key("left/15:%(n)d"),
		"right [<n>]": Key("right:%(n)d"),
		"right [<n>] slow": Key("right/15:%(n)d"),
		"jump up [<n>]": Key("pgup:%(n)d"),
		"jump down [<n>]": Key("pgdown:%(n)d"),
		"up <n> (page|pages)": Key("pgup:%(n)d"),
		"down <n> (page|pages)": Key("pgdown:%(n)d"),
		"left <n> (word|words)": Key("c-left/3:%(n)d/10"),
		"right <n> (word|words)": Key("c-right/3:%(n)d/10"),
		"house": Key("home"),
		"street": Key("end"),
		"doc house": Key("c-home/3"),
		"doc street": Key("c-end/3"),

		"Thomas": Key("a-space"),

		"lamp": Key("c-left"),
		"lamp <n>": Key("control:down/3") + Key("left:%(n)d") + Key("control:up"),

		"ramp": Key("c-right"),
		"ramp <n>": Key("control:down/3") + Key("right:%(n)d") + Key("control:up"),

		"lace": Key("control:down/3") + Key("s-left") + Key("control:up"),
		"lace <n>": Key("control:down/3") + Key("s-left:%(n)d") + Key("control:up"),

		"race": Key("control:down/3") + Key("s-right") + Key("control:up"),
		"race <n>": Key("control:down/3") + Key("s-right:%(n)d") + Key("control:up"),

		"lava": Key("s-home"),
		"raven": Key("s-end"),

		# Functional keys.
		"space": release + Key("space"),
		"space [<n>]": release + Key("space:%(n)d"),
		"slap [<n>]": release + Key("enter:%(n)d"),
		"tab [<n>]": Key("tab:%(n)d"),
		"delete [<n>]": Key("del/3:%(n)d"),
		"daily": Key("home, s-end, del"),  # @IgnorePep8
		"backspace [<n>]": release + Key("backspace:%(n)d"),
		"application key": release + Key("apps/3"),
		"win key": release + Key("win/3"),
		"paste [that]": Function(paste_command),
		"copy [that]": Function(copy_command),
		"cut [that]": release + Key("c-x/3"),
		"select all": release + Key("c-a/3"),
		"icey": release + Key("c-z/3"),
		"icey <n> [times]": release + Key("c-z/3:%(n)d"),
		"redo": release + Key("c-y/3"),
		"redo <n> [times]": release + Key("c-y/3:%(n)d"),
		"[(hold|press)] alt": Key("alt:down/3"),
		"release alt": Key("alt:up"),
		"[(hold|press)] shift": Key("shift:down/3"),
		"release shift": Key("shift:up"),
		"[(hold|press)] control": Key("ctrl:down/3"),
		"release control": Key("ctrl:up"),
		"release [all]": release,
		# Closures.
		"angle kets": Key("langle, rangle, left/3"),
		"brackets": Key("lbracket, rbracket, left/3"),
		"braces": Key("lbrace, rbrace, left/3"),
		"parens": Key("lparen, rparen, left/3"),
		"quotes": Key("dquote/3, dquote/3, left/3"),
		"single quotes": Key("squote, squote, left/3"),
		# Shorthand multiple characters.
		"<char>": Text("%(char)s"),
		"double <char>": Text("%(char)s%(char)s"),
		"triple <char>": Text("%(char)s%(char)s%(char)s"),
		"shark": Key("escape, escape"),  # Exiting menus.
		# Punctuation and separation characters, for quick editing.
		"colon [<n>]": Key("colon/2:%(n)d"),
		"semi-colon [<n>]": Key("semicolon/2:%(n)d"),
		"comma [<n>]": Key("comma/2:%(n)d"),
		"(dot|period) [<n>]": Key("dot/2:%(n)d"),
		"underscore [<n>]": Key("underscore/2:%(n)d"),
		# To release keyboard capture by VirtualBox.
		"press right control": Key("Control_R"),
		# Formatting <n> words to the left of the cursor.
		"camel <n> [words]": Function(camel_case_count),
		"pascal <n> [words]": Function(pascal_case_count),
		"snake <n> [words]": Function(snake_case_count),
		"squash <n> [words]": Function(squash_count),
		"expand <n> [words]": Function(expand_count),
		"uppercase <n> [words]": Function(uppercase_count),
		"lowercase <n> [words]": Function(lowercase_count),
		# Format dictated words. See the formatMap for all available types.
		# Ex: "camel case my new variable" -> "myNewVariable"
		# 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'),
		'pro seven': Key('w-7'),
		'pro eight': Key('w-8'),
		'pro nine': Key('w-9'),
	},
	namespace={
		"Key": Key,
		"Text": Text,
	}
)
Ejemplo n.º 27
0
    import pkg_resources
    pkg_resources.require("dragonfly >= 0.6.5beta1.dev-r81")
except ImportError:
    pass

import os, os.path
from dragonfly import (Grammar, CompoundRule, DictList, DictListRef,
                       MappingRule, Mimic, Key, FocusWindow, Window, Config,
                       Section, Item)

#---------------------------------------------------------------------------
# Set up this module's configuration.

config = Config("config manager")
config.lang = Section("Language section")
config.lang.list_configs = Item("list configs", doc="Command to ...")
config.lang.edit_config = Item("edit <config> (config | configuration)",
                               doc="Command to ...")
config.lang.show_dragonfly_version = Item("show dragonfly version",
                                          doc="Command to ...")
config.lang.update_dragonfly = Item("update dragonfly version",
                                    doc="Command to ...")
config.lang.reload_natlink = Item("reload natlink", doc="Command to ...")
config.load()

#---------------------------------------------------------------------------

config_map = DictList("config_map")

#---------------------------------------------------------------------------
Ejemplo n.º 28
0
grammarCfg.cmd.map = Item(
    {
        # Navigation keys.
        "up [<n>]":
        Key("up:%(n)d"),
        "up [<n>] slow":
        Key("up/15:%(n)d"),
        "down [<n>]":
        Key("down:%(n)d"),
        "down [<n>] slow":
        Key("down/15:%(n)d"),
        "left [<n>]":
        Key("left:%(n)d"),
        "left [<n>] slow":
        Key("left/15:%(n)d"),
        "right [<n>]":
        Key("right:%(n)d"),
        "right [<n>] slow":
        Key("right/15:%(n)d"),
        "page up [<n>]":
        Key("pgup:%(n)d"),
        "page down [<n>]":
        Key("pgdown:%(n)d"),
        "up <n> (page|pages)":
        Key("pgup:%(n)d"),
        "down <n> (page|pages)":
        Key("pgdown:%(n)d"),
        "left <n> (word|words)":
        Key("c-left/3:%(n)d/10"),
        "right <n> (word|words)":
        Key("c-right/3:%(n)d/10"),
        "home|homer":
        Key("home"),
        "end":
        Key("end"),
        "doc home":
        Key("c-home/3"),
        "doc end":
        Key("c-end/3"),
        "doc save":
        Key("c-s"),
        "doc open":
        Key("c-o"),
        "doc save as":
        Key("alt:down/3,f/3,a/3,alt:up/3"),
        "doc close [<n>]":
        Key("c-w:%(n)d"),
        "doc close all":
        Key("cs-w:%(n)d"),
        "doc next [<n>]":
        Key("c-tab:%(n)d"),
        "doc create":
        Key("c-n"),
        "doc new tab":
        Key("c-t"),
        "doc (previous|back) [<n>]":
        Key("cs-tab:%(n)d"),
        "doc (search|find)":
        Key("c-f"),
        "doc print":
        Key("c-p"),
        "doc format":
        Key("a-e, v, a"),
        "doc this year":
        Key("a-d/5, end/5") +
        Text("&tbs=cdr%%3A1%%2Ccd_min%%3A1+Jan+2019%%2Ccd_max%%3A&tbm=",
             pause=0.001) + Key("enter"),
        "zoom in":
        Key("c-plus, c-plus"),
        "zoom out":
        Key("c-minus, c-minus"),
        "zoom reset":
        Key("c-0"),
        "select line [<n>]":
        release + Key("home, home, s-down:%(n)d"),
        "go block start [<n>]":
        Key("sa-[:%(n)d"),
        "show parameters":
        Key("cs-space"),
        "integer":
        Text("int"),
        "variable":
        Text("var"),
        "uno [<n>]":
        Key("f1:%(n)d"),
        "doss [<n>]":
        Key("f2:%(n)d"),
        "trez [<n>]":
        Key("f3:%(n)d"),
        "quatro [<n>]":
        Key("f4:%(n)d"),
        "sinko [<n>]":
        Key("f5:%(n)d"),
        "see ettay [<n>]":
        Key("f7:%(n)d"),
        "occo [<n>]":
        Key("f8:%(n)d"),
        "noo evvay [<n>]":
        Key("f9:%(n)d"),
        "dee ez [<n>]":
        Key("f10:%(n)d"),
        "onsay [<n>]":
        Key("f11:%(n)d"),
        "dossay [<n>]":
        Key("f12:%(n)d"),
        # Functional keys.
        "space":
        release + Key("space"),
        "space [<n>]":
        release + Key("space:%(n)d"),
        "(slap|go) [<n>]":
        release + Key("enter:%(n)d"),
        "tab [<n>]":
        Key("tab:%(n)d"),
        "delete [<n>]":
        Key("del/3:%(n)d"),
        "delete [this] line":
        Key("home, home, s-end, del, del"),  # @IgnorePep8
        "backspace [<n>]":
        release + Key("backspace:%(n)d"),
        "application key":
        release + Key("apps/3"),
        "win key":
        release + Key("win/3"),
        "paste [that]":
        Function(paste_command),
        "copy [that]":
        Function(copy_command),
        "cut [that]":
        release + Key("c-x/3"),
        "select all":
        release + Key("c-a/3"),
        "undo":
        release + Key("c-z/3"),
        "undo <n> [times]":
        release + Key("c-z/3:%(n)d"),
        "redo":
        release + Key("c-y/3"),
        "redo <n> [times]":
        release + Key("c-y/3:%(n)d"),
        "[(hold|press)] (alt|meta)":
        Key("alt:down/3"),
        "release (alt|meta)":
        Key("alt:up"),
        "[(hold|press)] shift":
        Key("shift:down/3"),
        "release shift":
        Key("shift:up"),
        "[(hold|press)] control":
        Key("ctrl:down/3"),
        "release control":
        Key("ctrl:up"),
        "(hold|press) (hyper|windows)":
        Key("win:down/3"),
        "release (hyper|windows)":
        Key("win:up"),
        "[press] (hyper|windows) first":
        Key("win:down/3, 1/3, win:up/3"),
        "[press] (hyper|windows) <m>":
        Key("win:down/3, %(m)d/3, win:up/3"),
        "release [all]":
        release,
        "git commit minus M":
        Text("git commit -m "),
        # Closures.
        "angle brackets":
        Key("langle, rangle, left/3"),
        "brackets":
        Key("lbracket, rbracket, left/3"),
        "braces":
        Key("lbrace, rbrace, left/3"),
        "parens":
        Key("lparen, rparen, left/3"),
        "quotes":
        Key("dquote/3, dquote/3, left/3"),
        "single quotes":
        Key("squote, squote, left/3"),
        # To release keyboard capture by VirtualBox.
        "press right control":
        Key("Control_R"),
        # Formatting <n> words to the left of the cursor.
        "camel case <n> [words]":
        Function(camel_case_count),
        "pascal case <n> [words]":
        Function(pascal_case_count),
        "snake case <n> [words]":
        Function(snake_case_count),
        "squash <n> [words]":
        Function(squash_count),
        "expand <n> [words]":
        Function(expand_count),
        "uppercase <n> [words]":
        Function(uppercase_count),
        "lowercase <n> [words]":
        Function(lowercase_count),
        # Format dictated words. See the formatMap for all available types.
        # Ex: "camel case my new variable" -> "myNewVariable"
        # 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".
        "Simon says <reservedWord>":
        Text("%(reservedWord)s"),
        # Abbreviate words commonly used in programming.
        # Ex: arguments -> args, parameterers -> params.
        "abbreviate <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.
        "[<text>] (go to sleep|cancel and sleep) [<text2>]":
        Function(cancel_and_sleep),  # @IgnorePep8
        # Reload Natlink.
        "reload Natlink":
        Function(reload_natlink),
        # Ego
        "alpha":
        Text("a"),
        "bravo":
        Text("b"),
        "charlie":
        Text("c"),
        "delta":
        Text("d"),
        "echo":
        Text("e"),
        "foxtrot":
        Text("f"),
        "golf":
        Text("g"),
        "hotel":
        Text("h"),
        "(india|indigo)":
        Text("i"),
        "juliet":
        Text("j"),
        "kilo":
        Text("k"),
        "lima":
        Text("l"),
        "mike":
        Text("m"),
        "november":
        Text("n"),
        "oscar":
        Text("o"),
        "(Papa|pappa|pepper|popper)":
        Text("p"),
        "quebec":
        Text("q"),
        "romeo":
        Text("r"),
        "sierra":
        Text("s"),
        "tango":
        Text("t"),
        "uniform":
        Text("u"),
        "victor":
        Text("v"),
        "whiskey":
        Text("w"),
        "x-ray":
        Text("x"),
        "yankee":
        Text("y"),
        "zulu":
        Text("z"),
        "big alpha":
        Text("A"),
        "big bravo":
        Text("B"),
        "big charlie":
        Text("C"),
        "big delta":
        Text("D"),
        "big echo":
        Text("E"),
        "big foxtrot":
        Text("F"),
        "big golf":
        Text("G"),
        "big hotel":
        Text("H"),
        "big india":
        Text("I"),
        "big juliet":
        Text("J"),
        "big kilo":
        Text("K"),
        "big lima":
        Text("L"),
        "big mike":
        Text("M"),
        "big november":
        Text("N"),
        "big oscar":
        Text("O"),
        "big (Papa|pappa|pepper|popper)":
        Text("P"),
        "big quebec":
        Text("Q"),
        "big romeo":
        Text("R"),
        "big sierra":
        Text("S"),
        "big tango":
        Text("T"),
        "big uniform":
        Text("U"),
        "big victor":
        Text("V"),
        "big whiskey":
        Text("W"),
        "big x-ray":
        Text("X"),
        "big yankee":
        Text("Y"),
        "big zulu":
        Text("Z"),
        # Ego
        "quote [<n>]":
        release + Key("dquote:%(n)d"),
        "dot":
        Text("."),
        "backslish":
        Text("\\"),
        "slish":
        Text("/"),
        "lape":
        Text("("),
        "rape":
        Text(")"),
        "lace":
        Text("{"),
        "race":
        Text("}"),
        "(lack|bra)":
        Text("["),
        "(rack|ket)":
        Text("]"),
        "lang":
        Text("<"),
        "rang":
        Text(">"),
        "pipe":
        Text("|"),
        "eke":
        Text("="),
        "bang":
        Text("!"),
        "plus":
        Text("+"),
        "minus":
        Text("-"),
        "mull":
        Text("*"),
        "(underscore|bar) [<n>]":
        Key("underscore/2:%(n)d"),
        "(sem|semi|rock|semicolon)":
        Text(";"),
        "(coal|colon)":
        Text(":"),
        "(comma|cam) [<n>]":
        Key("comma/2:%(n)d"),
        "(dot|period) [<n>]":
        Key("dot/2:%(n)d"),
        "(dash|hyphen) [<n>]":
        Key("hyphen/2:%(n)d"),
        "hash [<n>]":
        Key("hash/2:%(n)d"),
        #"": Text(""),
        # Ego
        "quit [<n>]":
        release + Key("escape:%(n)d"),
        "switch [<n>]":
        release + Key("alt:down/10, tab:%(n)d/10, alt:up"),
        "hut":
        release + Key("alt:down/5, d, alt:up"),
        "context menu":
        release + Key("apps"),
        # Ego
        "hash include stud Io":
        Text("#include <stdio.h>"),
        "hash include stud lib":
        Text("#include <stdlib.h>"),
        "change directory":
        Text("cd "),
        "change directory drive":
        Text("cd /D "),
        "directory list":
        Text("dir "),
        "strike [<n>]":
        release + Key("backspace:%(n)d"),
        "kill [<n>]":
        release + Key("delete:%(n)d"),
        "pig [<n>]":
        release + Key("pgdown:%(n)d"),
        "pug [<n>]":
        release + Key("pgup:%(n)d"),
        "comment":
        Text("// "),
        # Ego
        "dictation on":
        Function(dictation_on),
        "dictation off":
        Function(dictation_off),
        "say <text>":
        Text("%(text)s"),
        # Ego
        "show dragon tip":
        Text(""),
        "move dragon tip":
        Mouse("[15, 8]/200, left:down, [0.66, 0.98], left:up, <-50,0>"),
    },
    namespace={
        "Key": Key,
        "Text": Text,
    })