コード例 #1
0
class Navigation(MergeRule):
    pronunciation = "navigation"

    mapping = {
        # "periodic" repeats whatever comes next at 1-second intervals until "terminate"
        # or "escape" (or your SymbolSpecs.CANCEL) is spoken or 100 tries occur
        "periodic":
        ContextSeeker(forward=[
            L(
                S(["cancel"], lambda: None),
                S(["*"],
                  lambda fnparams: UntilCancelled(
                      Mimic(*filter(lambda s: s != "periodic", fnparams)), 1).
                  execute(),
                  use_spoken=True))
        ]),
        # VoiceCoder-inspired -- these should be done at the IDE level
        "fill <target>":
        R(Key("escape, escape, end"), show=False) + AsynchronousAction(
            [L(S(["cancel"], Function(context.fill_within_line)))],
            time_in_seconds=0.2,
            repetitions=50),
        "jump in":
        AsynchronousAction(
            [L(S(["cancel"], context.nav, ["right", "(~[~{~<"]))],
            time_in_seconds=0.1,
            repetitions=50),
        "jump out":
        AsynchronousAction(
            [L(S(["cancel"], context.nav, ["right", ")~]~}~>"]))],
            time_in_seconds=0.1,
            repetitions=50),
        "jump back":
        AsynchronousAction(
            [L(S(["cancel"], context.nav, ["left", "(~[~{~<"]))],
            time_in_seconds=0.1,
            repetitions=50),
        "jump back in":
        AsynchronousAction(
            [L(S(["cancel"], context.nav, ["left", "(~[~{~<"]))],
            finisher=Key("right"),
            time_in_seconds=0.1,
            repetitions=50),

        # keyboard shortcuts
        'save':
        R(Key("c-s"), rspec="save"),
        "shift click":
        R(Key("shift:down") + Mouse("left") + Key("shift:up")),
        "stoosh [<nnavi500>]":
        R(Function(navigation.stoosh_keep_clipboard), rspec="stoosh"),
        "cut [<nnavi500>]":
        R(Function(navigation.cut_keep_clipboard), rspec="cut"),
        "spark [<nnavi500>] [(<capitalization> <spacing> | <capitalization> | <spacing>) [(bow|bowel)]]":
        R(Function(navigation.drop_keep_clipboard), rspec="spark"),
        "splat [<splatdir>] [<nnavi10>]":
        R(Key("c-%(splatdir)s"), rspec="splat") * Repeat(extra="nnavi10"),
        SymbolSpecs.CANCEL:
        R(Key("escape"), rspec="cancel"),
        "shackle":
        R(Key("home/5, s-end"), rspec="shackle"),
        "(tell | tau) <semi>":
        R(Function(navigation.next_line), rspec="tell dock"),
        "(hark | heart) <semi>":
        R(Function(navigation.previous_line), rspec="hark dock"),
        "duple [<nnavi50>]":
        R(Function(navigation.duple_keep_clipboard), rspec="duple"),
        "Kraken":
        R(Key("c-space"), rspec="Kraken"),
        "undo [<nnavi10>]":
        R(Key("c-z")) * Repeat(extra="nnavi10"),
        "redo [<nnavi10>]":
        R(
            ContextAction(
                default=Key("c-y") * Repeat(extra="nnavi10"),
                actions=[
                    (AppContext(executable=["rstudio", "foxitreader"]),
                     Key("cs-z") * Repeat(extra="nnavi10")),
                ])),

        # text formatting
        "set [<big>] format (<capitalization> <spacing> | <capitalization> | <spacing>) [(bow|bowel)]":
        R(Function(textformat.set_text_format)),
        "clear castervoice [<big>] formatting":
        R(Function(textformat.clear_text_format)),
        "peek [<big>] format":
        R(Function(textformat.peek_text_format)),
        "(<capitalization> <spacing> | <capitalization> | <spacing>) [(bow|bowel)] <textnv> [brunt]":
        R(Function(textformat.master_format_text)),
        "[<big>] format <textnv>":
        R(Function(textformat.prior_text_format)),
        "<word_limit> [<big>] format <textnv>":
        R(Function(textformat.partial_format_text)),
        "hug <enclosure>":
        R(Function(text_utils.enclose_selected)),
        "dredge [<nnavi10>]":
        R(Key("alt:down, tab/20:%(nnavi10)d, alt:up"),
          rdescript="Core: switch to most recent Windows"),

        # Ccr Mouse Commands
        "kick [<nnavi3>]":
        R(Function(navigation.left_click)) * Repeat(extra="nnavi3"),
        "psychic":
        R(Function(navigation.right_click)),
        "(kick double|double kick)":
        R(Function(navigation.left_click) * Repeat(2)),
        "squat":
        R(Function(navigation.left_down)),
        "bench":
        R(Function(navigation.left_up)),

        # special keystroke commands
        "(lease wally | latch) [<nnavi10>]":
        R(Key("home:%(nnavi10)s")),
        "(ross wally | ratch) [<nnavi10>]":
        R(Key("end:%(nnavi10)s")),
        "sauce wally [<nnavi10>]":
        R(Key("c-home:%(nnavi10)s")),
        "dunce wally [<nnavi10>]":
        R(Key("c-end:%(nnavi10)s")),
        "bird [<nnavi500>]":
        R(Key("c-left:%(nnavi500)s")),
        "firch [<nnavi500>]":
        R(Key("c-right:%(nnavi500)s")),
        "brick [<nnavi500>]":
        R(Key("s-left:%(nnavi500)s")),
        "frick [<nnavi500>]":
        R(Key("s-right:%(nnavi500)s")),
        "blitch [<nnavi500>]":
        R(Key("cs-left:%(nnavi500)s")),
        "flitch [<nnavi500>]":
        R(Key("cs-right:%(nnavi500)s")),
        "<button_dictionary_500_no_prefix_no_modifier> [<nnavi500>]":
        R(Key("%(button_dictionary_500_no_prefix_no_modifier)s") *
          Repeat(extra='nnavi500'),
          rdescript=
          "press buttons from button_dictionary_500_no_prefix_no_modifier"),
        "<modifier> <button_dictionary_500_modifier> [<nnavi500>]":
        R(Key("%(modifier)s-%(button_dictionary_500_modifier)s") *
          Repeat(extra='nnavi500'),
          rdescript=
          "press modifiers plus buttons from button_dictionary_500_modifier"),
        "<modifier> <button_dictionary_1_modifier>":
        R(Key("%(modifier)s-%(button_dictionary_1_modifier)s"),
          rdescript=
          "press modifiers plus buttons from button_dictionary_1_modifier"),
    }

    tell_commands_dict = {
        "dock": ";",
        "doc": ";",
        "sink": "",
        "com": ",",
        "deck": ":"
    }
    tell_commands_dict.update(_tpd)
    button_dictionary_500_no_prefix_no_modifier = {
        "tabby": "tab",
        "clear": "backspace",
        "deli": "del",
        "shock": "enter",
        "lease": "left",
        "ross": "right",
        "sauce": "up",
        "dunce": "down",
        "page (down | dunce)": "pgdown",
        "page (up | sauce)": "pgup",
    }
    button_dictionary_500_modifier = {
        key: value
        for key, value in keyboard_support.button_dictionary_1.items()
        if value in [
            "backspace", "del", "enter", "left", "right", "up", "down",
            "pgdown", "pgup"
        ]
    }
    button_dictionary_1_modifier = {
        key: value
        for key, value in keyboard_support.button_dictionary_1.items()
        if value in ["home", "end"]
    }
    extras = [
        ShortIntegerRef("nnavi10", 1, 11),
        ShortIntegerRef("nnavi3", 1, 4),
        ShortIntegerRef("nnavi50", 1, 50),
        ShortIntegerRef("nnavi500", 1, 500),
        Dictation("textnv"),
        Choice("enclosure", _dtpd),
        Choice(
            "capitalization", {
                "yell": 1,
                "tie": 2,
                "gerrish": 3,
                "sing": 4,
                "laws": 5,
                "say": 6,
                "cop": 7,
                "slip": 8,
            }),
        Choice(
            "spacing", {
                "gum": 1,
                "gun": 1,
                "spine": 2,
                "snake": 3,
                "pebble": 4,
                "incline": 5,
                "dissent": 6,
                "descent": 6,
            }),
        Choice("semi", tell_commands_dict),
        Choice("word_limit", {
            "single": 1,
            "double": 2,
            "triple": 3,
            "Quadra": 4
        }), navigation_support.TARGET_CHOICE,
        Choice("extreme", {
            "Wally": "way",
        }),
        Choice("big", {
            "big": True,
        }),
        Choice("splatdir", {
            "lease": "backspace",
            "ross": "delete",
        }), keyboard_support.modifier_choice_object,
        Choice("button_dictionary_500_no_prefix_no_modifier",
               button_dictionary_500_no_prefix_no_modifier),
        Choice("button_dictionary_500_modifier",
               button_dictionary_500_modifier),
        Choice("button_dictionary_1_modifier", button_dictionary_1_modifier)
    ]

    defaults = {
        "nnavi500": 1,
        "nnavi50": 1,
        "nnavi10": 1,
        "nnavi3": 1,
        "textnv": "",
        "capitalization": 0,
        "spacing": 0,
        "extreme": None,
        "big": False,
        "splatdir": "backspace",
    }
コード例 #2
0
class Navigation(MergeRule):
    non = NavigationNon
    pronunciation = CCRMerger.CORE[1]

    mapping = {
    # "periodic" repeats whatever comes next at 1-second intervals until "cancel" is spoken or 100 tries occur
    "periodic":                     ContextSeeker(forward=[L(S(["cancel"], lambda: None), \
                                                             S(["*"], \
                                                               lambda fnparams: UntilCancelled(Mimic(*filter(lambda s: s != "periodic", fnparams)), 1).execute(), \
                                                               use_spoken=True))]),
    # VoiceCoder-inspired -- these should be done at the IDE level
    "fill <target>":                R(Key("escape, escape, end"), show=False) +
                                    AsynchronousAction([L(S(["cancel"], Function(context.fill_within_line, nexus=_NEXUS)))
                                                   ], time_in_seconds=0.2, repetitions=50, rdescript="Fill" ),
    "jump in":                      AsynchronousAction([L(S(["cancel"], context.nav, ["right", "(~[~{~<"]))
                                                   ], time_in_seconds=0.1, repetitions=50, rdescript="Jump: In" ),
    "jump out":                     AsynchronousAction([L(S(["cancel"], context.nav, ["right", ")~]~}~>"]))
                                                   ], time_in_seconds=0.1, repetitions=50, rdescript="Jump: Out" ),
    "jump back":                    AsynchronousAction([L(S(["cancel"], context.nav, ["left", "(~[~{~<"]))
                                                   ], time_in_seconds=0.1, repetitions=50, rdescript="Jump: Back" ),
    "jump back in":                 AsynchronousAction([L(S(["cancel"], context.nav, ["left", "(~[~{~<"]))
                                                   ], finisher=Key("right"),
                                                      time_in_seconds=0.1,
                                                      repetitions=50,
                                                      rdescript="Jump: Back In" ),

    # keyboard shortcuts
    'save':                         R(Key("c-s"), rspec="save", rdescript="Save"),
    'shock [<nnavi50>]':            R(Key("enter"), rspec="shock", rdescript="Enter")* Repeat(extra="nnavi50"),

    "(<mtn_dir> | <mtn_mode> [<mtn_dir>]) [(<nnavi500> | <extreme>)]": R(Function(textformat.master_text_nav), rdescript="Keyboard Text Navigation"),

    "stoosh [<nnavi500>]":          R(Key("c-c")+Function(navigation.clipboard_to_file, nexus=_NEXUS), rspec="stoosh", rdescript="Copy"),
    "cut [<nnavi500>]":             R(Key("c-x")+Function(navigation.clipboard_to_file, nexus=_NEXUS), rspec="cut", rdescript="Cut"),
    "spark [<nnavi500>]":           R(Function(navigation.drop, nexus=_NEXUS), rspec="spark", rdescript="Paste"),

    "deli [<nnavi50>]":             R(Key("del/5"), rspec="deli", rdescript="Delete") * Repeat(extra="nnavi50"),
    "clear [<nnavi50>]":            R(Key("backspace/5:%(nnavi50)d"), rspec="clear", rdescript="Backspace"),
    SymbolSpecs.CANCEL:             R(Key("escape"), rspec="cancel", rdescript="Cancel Action"),


    "shackle":                      R(Key("home/5, s-end"), rspec="shackle", rdescript="Select Line"),
    "(tell | tau) <semi>":          R(Function(navigation.next_line), rspec="tell dock", rdescript="Complete Line"),
    "duple [<nnavi50>]":            R(Key("escape, home, s-end, c-c, end, enter, c-v"), rspec="duple", rdescript="Duplicate Line") * Repeat(extra="nnavi50"),
    "Kraken":                       R(Key("c-space"), rspec="Kraken", rdescript="Control Space"),

    # text formatting
    "set format (<capitalization> <spacing> | <capitalization> | <spacing>) (bow|bowel)":  R(Function(textformat.set_text_format), rdescript="Set Text Format"),
    "clear caster formatting":      R(Function(textformat.clear_text_format), rdescript="Clear Caster Formatting"),
    "peek format":                  R(Function(textformat.peek_text_format), rdescript="Peek Format"),
    "(<capitalization> <spacing> | <capitalization> | <spacing>) (bow|bowel) <textnv> [brunt]":  R(Function(textformat.master_format_text), rdescript="Text Format"),
    "format <textnv>":              R(Function(textformat.prior_text_format), rdescript="Last Text Format"),
    "<word_limit> format <textnv>": R(Function(textformat.partial_format_text), rdescript="Partial Text Format"),
    "dredge":                       R(Key("a-tab"), rdescript="Alt-Tab"),

    }

    extras = [
        IntegerRefST("nnavi50", 1, 50),
        IntegerRefST("nnavi500", 1, 500),
        Dictation("textnv"),
        Choice("capitalization", {
            "yell": 1,
            "tie": 2,
            "Gerrish": 3,
            "sing": 4,
            "laws": 5
        }),
        Choice("spacing", {
            "gum": 1,
            "gun": 1,
            "spine": 2,
            "snake": 3
        }),
        Choice("semi", {
            "dock": ";",
            "doc": ";",
            "sink": ""
        }),
        Choice("word_limit", {
            "single": 1,
            "double": 2,
            "triple": 3,
            "Quadra": 4
        }),
        navigation.TARGET_CHOICE,
        navigation.get_direction_choice("mtn_dir"),
        Choice("mtn_mode", {
            "shin": "s",
            "queue": "cs",
            "fly": "c",
        }),
        Choice("extreme", {
            "Wally": "way",
        }),
    ]

    defaults = {
        "nnavi500": 1,
        "nnavi50": 1,
        "textnv": "",
        "capitalization": 0,
        "spacing": 0,
        "mtn_mode": None,
        "mtn_dir": "right",
        "extreme": None
    }
コード例 #3
0
    def test_non_ascii_mimic(self):
        """ Test handling of non-ASCII characters in Mimic action. """

        action = Mimic("touché")
        self.assertEqual(str(action), "Mimic(%r)" % ("touché", ))
コード例 #4
0
ファイル: nav.py プロジェクト: tlappas/Caster
class Navigation(MergeRule):
    pronunciation = "navigation"

    mapping = {
        # "periodic" repeats whatever comes next at 1-second intervals until "terminate"
        # or "escape" (or your SymbolSpecs.CANCEL) is spoken or 100 tries occur
        "periodic":
        ContextSeeker(forward=[
            L(
                S(["cancel"], lambda: None),
                S(["*"],
                  lambda fnparams: UntilCancelled(
                      Mimic(*filter(lambda s: s != "periodic", fnparams)), 1).
                  execute(),
                  use_spoken=True))
        ]),
        # VoiceCoder-inspired -- these should be done at the IDE level
        "fill <target>":
        R(Key("escape, escape, end"), show=False) + AsynchronousAction(
            [L(S(["cancel"], Function(context.fill_within_line)))],
            time_in_seconds=0.2,
            repetitions=50),
        "jump in":
        AsynchronousAction(
            [L(S(["cancel"], context.nav, ["right", "(~[~{~<"]))],
            time_in_seconds=0.1,
            repetitions=50),
        "jump out":
        AsynchronousAction(
            [L(S(["cancel"], context.nav, ["right", ")~]~}~>"]))],
            time_in_seconds=0.1,
            repetitions=50),
        "jump back":
        AsynchronousAction(
            [L(S(["cancel"], context.nav, ["left", "(~[~{~<"]))],
            time_in_seconds=0.1,
            repetitions=50),
        "jump back in":
        AsynchronousAction(
            [L(S(["cancel"], context.nav, ["left", "(~[~{~<"]))],
            finisher=Key("right"),
            time_in_seconds=0.1,
            repetitions=50),

        # keyboard shortcuts
        'save':
        R(Key("c-s"), rspec="save"),
        'shock [<nnavi50>]':
        R(Key("enter"), rspec="shock") * Repeat(extra="nnavi50"),
        # "(<mtn_dir> | <mtn_mode> [<mtn_dir>]) [(<nnavi500> | <extreme>)]":
        #     R(Function(text_utils.master_text_nav)), # this is now implemented below
        "shift click":
        R(Key("shift:down") + Mouse("left") + Key("shift:up")),
        "stoosh [<nnavi500>]":
        R(Function(navigation.stoosh_keep_clipboard), rspec="stoosh"),
        "cut [<nnavi500>]":
        R(Function(navigation.cut_keep_clipboard), rspec="cut"),
        "spark [<nnavi500>] [(<capitalization> <spacing> | <capitalization> | <spacing>) [(bow|bowel)]]":
        R(Function(navigation.drop_keep_clipboard), rspec="spark"),
        "splat [<splatdir>] [<nnavi10>]":
        R(Key("c-%(splatdir)s"), rspec="splat") * Repeat(extra="nnavi10"),
        "deli [<nnavi50>]":
        R(Key("del/5"), rspec="deli") * Repeat(extra="nnavi50"),
        "clear [<nnavi50>]":
        R(Key("backspace/5:%(nnavi50)d"), rspec="clear"),
        SymbolSpecs.CANCEL:
        R(Key("escape"), rspec="cancel"),
        "shackle":
        R(Key("home/5, s-end"), rspec="shackle"),
        "(tell | tau) <semi>":
        R(Function(navigation.next_line), rspec="tell dock"),
        "duple [<nnavi50>]":
        R(Function(navigation.duple_keep_clipboard), rspec="duple"),
        "Kraken":
        R(Key("c-space"), rspec="Kraken"),
        "undo [<nnavi10>]":
        R(Key("c-z")) * Repeat(extra="nnavi10"),
        "redo [<nnavi10>]":
        R(
            ContextAction(
                default=Key("c-y") * Repeat(extra="nnavi10"),
                actions=[
                    (AppContext(executable=["rstudio", "foxitreader"]),
                     Key("cs-z") * Repeat(extra="nnavi10")),
                ])),

        # text formatting
        "set [<big>] format (<capitalization> <spacing> | <capitalization> | <spacing>) [(bow|bowel)]":
        R(Function(textformat.set_text_format)),
        "clear castervoice [<big>] formatting":
        R(Function(textformat.clear_text_format)),
        "peek [<big>] format":
        R(Function(textformat.peek_text_format)),
        "(<capitalization> <spacing> | <capitalization> | <spacing>) [(bow|bowel)] <textnv> [brunt]":
        R(Function(textformat.master_format_text)),
        "[<big>] format <textnv>":
        R(Function(textformat.prior_text_format)),
        "<word_limit> [<big>] format <textnv>":
        R(Function(textformat.partial_format_text)),
        "hug <enclosure>":
        R(Function(text_utils.enclose_selected)),
        "dredge [<nnavi10>]":
        R(Key("alt:down, tab/20:%(nnavi10)d, alt:up"),
          rdescript="Core: switch to most recent Windows"),

        # Ccr Mouse Commands
        "kick [<nnavi3>]":
        R(Function(navigation.left_click)) * Repeat(extra="nnavi3"),
        "psychic":
        R(Function(navigation.right_click)),
        "(kick double|double kick)":
        R(Function(navigation.left_click) * Repeat(2)),
        "squat":
        R(Function(navigation.left_down)),
        "bench":
        R(Function(navigation.left_up)),

        # keystroke commands
        "<direction> [<nnavi500>]":
        R(Key("%(direction)s") * Repeat(extra='nnavi500'),
          rdescript="arrow keys"),
        "(lease wally | latch) [<nnavi10>]":
        R(Key("home:%(nnavi10)s")),
        "(ross wally | ratch) [<nnavi10>]":
        R(Key("end:%(nnavi10)s")),
        "sauce wally [<nnavi10>]":
        R(Key("c-home:%(nnavi10)s")),
        "dunce wally [<nnavi10>]":
        R(Key("c-end:%(nnavi10)s")),
        "bird [<nnavi500>]":
        R(Key("c-left:%(nnavi500)s")),
        "firch [<nnavi500>]":
        R(Key("c-right:%(nnavi500)s")),
        "brick [<nnavi500>]":
        R(Key("s-left:%(nnavi500)s")),
        "frick [<nnavi500>]":
        R(Key("s-right:%(nnavi500)s")),
        "blitch [<nnavi500>]":
        R(Key("cs-left:%(nnavi500)s")),
        "flitch [<nnavi500>]":
        R(Key("cs-right:%(nnavi500)s")),
        "<modifier> <button_dictionary_500> [<nnavi500>]":
        R(Key("%(modifier)s%(button_dictionary_500)s") *
          Repeat(extra='nnavi500'),
          rdescript=
          "press modifier keys plus buttons from button_dictionary_500"),
        "<modifier> <button_dictionary_10> [<nnavi10>]":
        R(Key("%(modifier)s%(button_dictionary_10)s") *
          Repeat(extra='nnavi10'),
          rdescript="press modifier keys plus buttons from button_dictionary_10"
          ),
        "<modifier> <button_dictionary_1>":
        R(Key("%(modifier)s%(button_dictionary_1)s"),
          rdescript=
          "press modifiers plus buttons from button_dictionary_1, non-repeatable"
          ),

        # "key stroke [<modifier>] <combined_button_dictionary>":
        #     R(Text('Key("%(modifier)s%(combined_button_dictionary)s")')),

        # "key stroke [<modifier>] <combined_button_dictionary>":
        #     R(Text('Key("%(modifier)s%(combined_button_dictionary)s")')),
    }
    tell_commands_dict = {
        "dock": ";",
        "doc": ";",
        "sink": "",
        "com": ",",
        "deck": ":"
    }
    tell_commands_dict.update(_tpd)

    # I tried to limit which things get repeated how many times in hopes that it will help prevent the bad grammar error
    # this could definitely be changed. perhaps some of these should be made non-CCR
    button_dictionary_500 = {
        "(tab | tabby)": "tab",
        "(backspace | clear)": "backspace",
        "(delete|deli)": "del",
        "(escape | cancel)": "escape",
        "(enter | shock)": "enter",
        "(left | lease)": "left",
        "(right | ross)": "right",
        "(up | sauce)": "up",
        "(down | dunce)": "down",
        "page (down | dunce)": "pgdown",
        "page (up | sauce)": "pgup",
        "space": "space"
    }
    button_dictionary_10 = {
        "(F{}".format(i) + " | function {})".format(i): "f{}".format(i)
        for i in range(1, 13)
    }
    button_dictionary_10.update(caster_alphabet())
    button_dictionary_10.update(_tpd)
    longhand_punctuation_names = {
        "minus": "hyphen",
        "hyphen": "hyphen",
        "comma": "comma",
        "deckle": "colon",
        "colon": "colon",
        "slash": "slash",
        "backslash": "backslash"
    }
    button_dictionary_10.update(longhand_punctuation_names)
    button_dictionary_1 = {
        "(home | lease wally | latch)": "home",
        "(end | ross wally | ratch)": "end",
        "insert": "insert",
        "zero": "0",
        "one": "1",
        "two": "2",
        "three": "3",
        "four": "4",
        "five": "5",
        "six": "6",
        "seven": "7",
        "eight": "8",
        "nine": "9"
    }
    combined_button_dictionary = {}
    for dictionary in [
            button_dictionary_1, button_dictionary_10, button_dictionary_500
    ]:
        combined_button_dictionary.update(dictionary)

    modifier_choice_object = Choice(
        "modifier",
        {
            "(control | fly)": "c-",  #TODO: make DRY
            "(shift | shin)": "s-",
            "alt": "a-",
            "(control shift | que)": "cs-",
            "control alt": "ca-",
            "(shift alt | alt shift)": "sa-",
            "(control alt shift | control shift alt)":
            "csa-",  # control must go first
            "windows": "w-",  # windows should go before alt/shift
            "control windows": "cw-",
            "control windows alt": "cwa-",
            "control windows shift": "cws-",
            "windows shift alt": "wsa-",
            "windows alt shift": "was-",
            "windows shift": "ws-",
            "windows alt": "wa-",
            "control windows alt shift": "cwas-",
            "hit": "",
        })
    extras = [
        IntegerRefST("nnavi10", 1, 11),
        IntegerRefST("nnavi3", 1, 4),
        IntegerRefST("nnavi50", 1, 50),
        IntegerRefST("nnavi500", 1, 500),
        Dictation("textnv"),
        Choice("enclosure", _dtpd),
        Choice("direction", {
            "dunce": "down",
            "sauce": "up",
            "lease": "left",
            "ross": "right",
        }),
        modifier_choice_object,
        Choice("button_dictionary_1", button_dictionary_1),
        Choice("button_dictionary_10", button_dictionary_10),
        Choice("button_dictionary_500", button_dictionary_500),
        Choice("combined_button_dictionary", combined_button_dictionary),
        Choice(
            "capitalization", {
                "yell": 1,
                "tie": 2,
                "gerrish": 3,
                "sing": 4,
                "laws": 5,
                "say": 6,
                "cop": 7,
                "slip": 8,
            }),
        Choice(
            "spacing", {
                "gum": 1,
                "gun": 1,
                "spine": 2,
                "snake": 3,
                "pebble": 4,
                "incline": 5,
                "dissent": 6,
                "descent": 6,
            }),
        Choice("semi", tell_commands_dict),
        Choice("word_limit", {
            "single": 1,
            "double": 2,
            "triple": 3,
            "Quadra": 4
        }),
        navigation_support.TARGET_CHOICE,
        navigation_support.get_direction_choice("mtn_dir"),
        Choice("mtn_mode", {
            "shin": "s",
            "queue": "cs",
            "fly": "c",
        }),
        Choice("extreme", {
            "Wally": "way",
        }),
        Choice("big", {
            "big": True,
        }),
        Choice("splatdir", {
            "lease": "backspace",
            "ross": "delete",
        }),
    ]

    defaults = {
        "nnavi500": 1,
        "nnavi50": 1,
        "nnavi10": 1,
        "nnavi3": 1,
        "textnv": "",
        "capitalization": 0,
        "spacing": 0,
        "mtn_mode": None,
        "mtn_dir": "right",
        "extreme": None,
        "big": False,
        "splatdir": "backspace",
        "modifier": "",
    }
コード例 #5
0
ファイル: nav.py プロジェクト: tyoung87/caster
class Navigation(MergeRule):
    non = NavigationNon
    pronunciation = CCRMerger.CORE[1]

    mapping = {
    # "periodic" repeats whatever comes next at 1-second intervals until "cancel" is spoken or 100 tries occur
    "periodic":                     ContextSeeker(forward=[L(S(["cancel"], lambda: None), \
                                                             S(["*"], \
                                                               lambda fnparams: UntilCancelled(Mimic(*filter(lambda s: s != "periodic", fnparams)), 1).execute(), \
                                                               use_spoken=True))]),
    # VoiceCoder-inspired -- these should be done at the IDE level
    "fill <target>":                R(Key("escape, escape, end"), show=False) +
                                    AsynchronousAction([L(S(["cancel"], Function(context.fill_within_line, nexus=_NEXUS)))
                                                   ], time_in_seconds=0.2, repetitions=50, rdescript="Fill" ),
    "jump in":                      AsynchronousAction([L(S(["cancel"], context.nav, ["right", "(~[~{~<"]))
                                                   ], time_in_seconds=0.1, repetitions=50, rdescript="Jump: In" ),
    "jump out":                     AsynchronousAction([L(S(["cancel"], context.nav, ["right", ")~]~}~>"]))
                                                   ], time_in_seconds=0.1, repetitions=50, rdescript="Jump: Out" ),
    "jump back":                    AsynchronousAction([L(S(["cancel"], context.nav, ["left", "(~[~{~<"]))
                                                   ], time_in_seconds=0.1, repetitions=50, rdescript="Jump: Back" ),
    "jump back in":                 AsynchronousAction([L(S(["cancel"], context.nav, ["left", "(~[~{~<"]))
                                                   ], finisher=Key("right"),
                                                      time_in_seconds=0.1,
                                                      repetitions=50,
                                                      rdescript="Jump: Back In" ),

    # keyboard shortcuts
    'salve':                         R(Key("c-s"), rspec="save", rdescript="Save"),
    'slap [<nnavi50>]':              R(Key("enter"), rspec="slap", rdescript="Enter")* Repeat(extra="nnavi50"),
    'slap up':                       R(Key("escape, up, end, enter"), rspec="slap up", rdescript="Line Above"),
    'slap down':                     R(Key("escape, end, enter"), rspec="slap down", rdescript="Line Below"),
    'curslap':                       R(Key("escape, lbrace, rbrace, left, enter"), rspec="curslap", rdescript="Curly New Line"),

    'north':                     R(Key("c-home"), rspec="north", rdescript="Ctrl Home"),
    'south':                     R(Key("c-end"), rspec="south", rdescript="Ctrl End"),
    'east':                     R(Key("end"), rspec="east", rdescript="End"),
    'west':                     R(Key("home"), rspec="west", rdescript="Home"),

    'page up':                     R(Key("pgup"), rspec="page up", rdescript="Page Up"),
    'page down':                     R(Key("pgdown"), rspec="page down", rdescript="Page Down"),

    "(<mtn_dir> | <mtn_mode> [<mtn_dir>]) [(<nnavi500> | <extreme>)]": R(Function(textformat.master_text_nav), rdescript="Keyboard Text Navigation"),
    "<short_mode> <key> [<nnavi500>]":        R(Function(textformat.master_short), rdescript="Keyboard Shortcut"),
    "<short_mode> <mouse_action>":            R(Function(textformat.master_short_mouse), rdescript="Mouse Shortcut"),
    "hold <short_mode>":                      R(Function(textformat.hold_modifier), rdescript="Hold Modifier"),
    "alt":                          R(Key("alt"), rdescript="Alt"),
    "wind":                         R(Key("win"), rdescript="Win"),
    "null":                         R(Key("n, u, l, l"), rdescript="Null"),

    "stoosh [<nnavi500>]":          R(Key("c-c")+Function(navigation.clipboard_to_file, nexus=_NEXUS), rspec="stoosh", rdescript="Copy"),
    "cut [<nnavi500>]":             R(Key("c-x")+Function(navigation.clipboard_to_file, nexus=_NEXUS), rspec="cut", rdescript="Cut"),
    "spark [<nnavi500>]":           R(Function(navigation.drop, nexus=_NEXUS), rspec="spark", rdescript="Paste"),

    "deli [<nnavi50>]":             R(Key("del/5"), rspec="deli", rdescript="Delete") * Repeat(extra="nnavi50"),
    "clear [<nnavi50>]":            R(Key("backspace/5:%(nnavi50)d"), rspec="clear", rdescript="Backspace"),
    SymbolSpecs.CANCEL:             R(Key("escape"), rspec="cancel", rdescript="Cancel Action"),


    "shackle":                      R(Key("home/5, s-end"), rspec="shackle", rdescript="Select Line"),
    "(tell | tau) <semi>":          R(Function(navigation.next_line), rspec="tell dock", rdescript="Complete Line"),
    "duple [<nnavi50>]":            R(Key("escape, home, s-end, c-c, end, enter, c-v"), rspec="duple", rdescript="Duplicate Line") * Repeat(extra="nnavi50"),
    "Kraken":                       R(Key("c-space"), rspec="Kraken", rdescript="Control Space"),

    # text formatting
    "set format (<spacing> <capitalization> | <capitalization> | <spacing>)":  R(Function(textformat.set_text_format), rdescript="Set Text Format"),
    "clear caster formatting":      R(Function(textformat.clear_text_format), rdescript="Clear Caster Formatting"),
    "peek format":                  R(Function(textformat.peek_text_format), rdescript="Peek Format"),
    "camel <textnv>":                        R(Function(textformat.master_format_text_camel), rdescript="Camel Case"),
    "pascal <textnv>":                       R(Function(textformat.master_format_text_pascal), rdescript="Pascal Case"),
    "dock mel <textnv>":                     R(Key("dot")+Function(textformat.master_format_text_camel), rdescript="Dot Camel Case"),
    "(dop|dot) scal <textnv>":                     R(Key("dot")+Function(textformat.master_format_text_pascal), rdescript="Dot Pascal Case"),
    "(<spacing> <capitalization> | <capitalization> | <spacing>) <textnv>":  R(Function(textformat.master_format_text), rdescript="Text Format"),
    "format <textnv>":              R(Function(textformat.prior_text_format), rdescript="Last Text Format"),

    "dredge":                       R(Key("a-tab"), rdescript="Alt-Tab"),

    }

    extras = [
        alphanumeric.get_key_choice("key"),
        Choice(
            "short_mode", {
                "shift": "s",
                "troll": "c",
                "alt": "a",
                "wind": "w",
                "trot": "ca",
                "shoal": "cs",
                "tron": "wc",
                "shalt": "sa",
                "walt": "wa",
                "shin": "ws",
                "trash": "cas"
            }),
        Choice(
            "mouse_action", {
                "kick": "left",
                "kick mid": "middle",
                "psychic": "right",
                "dub kick": "left:2"
            }),
        IntegerRefST("nnavi50", 1, 50),
        IntegerRefST("nnavi500", 1, 500),
        Dictation("textnv"),
        Choice("capitalization", {
            "scream": 1,
            "scal": 2,
            "mel": 3,
            "tense": 4,
            "laws": 5
        }),
        Choice("spacing", {
            "smash": 1,
            "spine": 2,
            "snake": 3
        }),
        Choice("semi", {
            "dock": ";",
            "doc": ";",
            "sink": ""
        }),
        navigation.TARGET_CHOICE,
        navigation.get_direction_choice("mtn_dir"),
        Choice("mtn_mode", {
            "shin": "s",
            "queue": "cs",
            "fly": "c",
        }),
        Choice("extreme", {
            "Wally": "way",
        }),
    ]

    defaults = {
        "nnavi500": 1,
        "nnavi50": 1,
        "textnv": "",
        "capitalization": 0,
        "spacing": 0,
        "mtn_mode": None,
        "mtn_dir": "right",
        "extreme": None
    }
コード例 #6
0
class CommandRule(MappingRule):

    mapping = {
        "previous (editor | tab) [<n>]":
        R(Key("cs-f6"), rdescript="Eclipse: Previous Tab") * Repeat(
            extra="n"),  # these two must be set up in the eclipse preferences
        "next (editor | tab) [<n>]":
        R(Key("c-f6"), rdescript="Eclipse: Next Tab") * Repeat(extra="n"),
        "close (editor | tab) [<n>]":
        R(Key("c-w"), rdescript="Eclipse: Close Tab") * Repeat(extra="n"),
        "open resource":
        R(Key("cs-r"), rdescript="Eclipse: Open Resource"),
        "open type":
        R(Key("cs-t"), rdescript="Eclipse: Open Type"),
        "[go to] line <n> [<mim>]":
        R(Key("c-l") + Pause("50") + Text("%(n)d") + Key("enter") +
          Pause("50") + Mimic(extra="mim"),
          rdescript="Eclipse: Go To Line"),
        "jump to source":
        R(Key("f3"), rdescript="Eclipse: Jump To Source"),
        "editor select":
        R(Key("c-e"), rdescript="Eclipse: Editor Select"),
        "step over [<n>]":
        R(Key("f6/50") * Repeat(extra="n"), rdescript="Eclipse: Step Over"),
        "step into":
        R(Key("f5"), rdescript="Eclipse: Step Into"),
        "step out [of]":
        R(Key("f7"), rdescript="Eclipse: Step Out"),
        "resume":
        R(Key("f8"), rdescript="Eclipse: Resume"),
        "(debug | run) last":
        R(Key("f11"), rdescript="Eclipse: Run Last"),
        "mark occurrences":
        R(Key("as-o"), rdescript="Eclipse: Mark Occurrences"),

        # "terminate" changes to the settings for this hotkey: (when: in dialogs and windows)
        "terminate":
        R(Key("c-f2"), rdescript="Eclipse: Terminate Running Program"),
        "search for this everywhere":
        R(Key("ca-g"), rdescript="Eclipse: Search Project"),
        "refractor symbol":
        R(Key("sa-r"), rdescript="Eclipse: Re-Factor Symbol"),
        "symbol next [<n>]":
        R(Key("c-k"), rdescript="Eclipse: Symbol Next") * Repeat(extra="n"),
        "symbol prior [<n>]":
        R(Key("cs-k"), rdescript="Eclipse: Symbol Prior") * Repeat(extra="n"),
        "format code":
        R(Key("cs-f"), rdescript="Eclipse: Format Code"),
        "do imports":
        R(Key("cs-o"), rdescript="Eclipse: Do Imports"),
        "comment line":
        R(Key("c-slash"), rdescript="Eclipse: Comment Line"),
        "build it":
        R(Key("c-b"), rdescript="Eclipse: Build"),
        "split view horizontal":
        R(Key("cs-underscore"), rdescript="Eclipse: Split View (H)"),
        "split view vertical":
        R(Key("cs-lbrace"), rdescript="Eclipse: Split View (V)"),
        # requires quick bookmarks plug-in:
        #             "set mark [<n>]":                           Key("a-%(n)d"),
        #             "go mark [<n>]":                            Key("as-%(n)d"),
    }
    extras = [
        Dictation("text"),
        Dictation("mim"),
        IntegerRef("n", 1, 1000),
    ]
    defaults = {"n": 1, "mim": ""}