Exemplo n.º 1
0
    def refresh(self, *args):
        '''args: spec, list of lists of strings'''

        # get mapping
        recorded_macros = utilities.load_toml_file(
            settings.SETTINGS["paths"]["RECORDED_MACROS_PATH"])
        if len(args) > 0:
            recorded_macros[args[0]] = args[1]
            utilities.save_toml_file(
                recorded_macros,
                settings.SETTINGS["paths"]["RECORDED_MACROS_PATH"])
        mapping = {}
        for spec in recorded_macros:
            sequences = recorded_macros[spec]
            delay = settings.SETTINGS["miscellaneous"][
                "history_playback_delay_secs"]
            play = Playback([(sequence, delay) for sequence in sequences])
            command = play * Repeat(
                extra="n") if spec.endswith("[times <n>]") else play
            mapping[spec] = R(command, rdescript="Recorded Macro: " + spec)
        mapping["record from history"] = R(Function(self.record_from_history),
                                           rdescript="Record From History")
        mapping["delete recorded macros"] = R(
            Function(self.delete_recorded_macros),
            rdescript="Delete Recorded Macros")
        # reload with new mapping
        self.reset(mapping)
Exemplo n.º 2
0
    def refresh(self, *args):
        '''args: spec, list of lists of strings'''

        # get mapping
        recorded_macros = utilities.load_toml_file(
            settings.SETTINGS["paths"]["RECORDED_MACROS_PATH"])
        if len(args) > 0:
            recorded_macros[args[0]] = args[1]
            utilities.save_toml_file(
                recorded_macros,
                settings.SETTINGS["paths"]["RECORDED_MACROS_PATH"])
        mapping = {}
        for spec in recorded_macros:
            # Create a copy of the string without Unicode characters.
            ascii_str = str(spec)
            sequences = recorded_macros[spec]
            delay = settings.SETTINGS["miscellaneous"][
                "history_playback_delay_secs"]
            # It appears that the associative string (ascii_str) must be ascii, but the sequences within Playback must be Unicode.
            mapping[ascii_str] = R(
                Playback([(sequence, delay) for sequence in sequences]),
                rdescript="Recorded Macro: " + ascii_str) * Repeat(extra="n")
        mapping["record from history"] = R(Function(self.record_from_history),
                                           rdescript="Record From History")
        mapping["delete recorded macros"] = R(
            Function(self.delete_recorded_macros),
            rdescript="Delete Recorded Macros")
        # reload with new mapping
        self.reset(mapping)
Exemplo n.º 3
0
class NPPRule(MergeRule):
    pronunciation = "notepad plus plus"

    mapping = {
        "(line | zeile) <n>": R(Key("c-g") + Text("%(n)d") + Key("enter")),
        "(save | speichern)": R(Key("c-s")),
        "(save as | speichern als)": R(Key("ca-s")),
    }
    extras = [IntegerRefST("n", 1, 1000)]
    defaults = {"n": 1}
Exemplo n.º 4
0
class Decker(MergeRule):
    pronunciation = "test rule"

    mapping = {
        "doon [<nnavi200>]": R(Key("pagedown")) * Repeat(extra="nnavi200"),
    }
    extras = [IntegerRefST("n", 1, 50), IntegerRefST("nnavi200", 1, 200)]
Exemplo n.º 5
0
    def __init__(self, num_choice_500s, num_specs):

        mapping = {}
        extras = []
        defaults = {}

        w500 = get_500_words()
        spec_base = ""
        text_base = ""

        for k in range(0, num_choice_500s):
            extra_name = "giant_" + str(k)
            spec_base += " <" + extra_name + ">"
            text_base += " %(" + extra_name + ")s"
            extras.append(get_giant_choice(extra_name))

        for i in range(0, num_specs):
            word = w500[i]
            mapping[word + spec_base] = R(Text(word + text_base), show=False)

        MergeRule.__init__(self,
                           name="complexity test",
                           mapping=mapping,
                           extras=extras,
                           defaults=defaults)
Exemplo n.º 6
0
    def test_cancel(self):
        mutable_integer = {"value": 0}

        def increment():
            mutable_integer["value"] += 1

        '''make fake AsynchronousAction'''
        context_set = S(["test", "words"], increment)
        unused_context_set = S(["other"], Text, "words")
        context_level = L(context_set, unused_context_set)
        aa1 = AsynchronousAction([context_level],
                                 time_in_seconds=0.2,
                                 repetitions=20,
                                 blocking=False)
        aa1.set_nexus(self.nexus)
        '''make fake StackItemAsynchronous'''
        alt = MockAlternative(u"gray", u"fox")
        sia1 = StackItemAsynchronous(
            aa1, {"_node": alt})  # the dictionary is fake Dragonfly data
        '''add it'''
        self.nexus.state.add(sia1)
        '''make fake canceling RegisteredAction'''
        cancel = R(NullAction(), rspec="test")
        cancel.set_nexus(self.nexus)
        '''make fake StackItemRegisteredAction'''
        alt2 = MockAlternative(u"my", u"spoken", u"words")
        sira1 = StackItemRegisteredAction(cancel, {"_node": alt2})
        '''add it'''
        self.nexus.state.add(sira1)
        '''AsynchronousAction should have executed exactly once, 
        when it was added, then immediately gotten canceled'''
        self.assertEqual(mutable_integer["value"], 1)
Exemplo n.º 7
0
def add_modkeys(rule):
    release = R(Key("shift:up, ctrl:up, alt:up"), rdescript="Mod Keys Up")

    if not hasattr(rule, "marked") and\
    rule.get_pronunciation()[0:6] != "Merged": # don't augment merged rules-- they'd get it twice
        for spec in rule.mapping_actual().keys():
            rule.mapping_actual(
            )[spec] = release + rule.mapping_actual()[spec] + release
        rule.marked = True
Exemplo n.º 8
0
    def test_blocking(self):
        '''
        Tests:
        1 - successful termination (queued actions execute immediately)
        2 - unsuccessful termination (queued actions are dropped)
        3 - cancellation (queued actions are dropped)
        '''

        for i in range(0, 3):
            '''make fake AsynchronousAction'''
            context_set = S(["cancel", "words"], NullAction())
            context_level = L(context_set)
            aa1 = AsynchronousAction([context_level],
                                     blocking=True)  # turn blocking on
            aa1.set_nexus(self.nexus)
            '''make fake StackItemAsynchronous'''
            alt = MockAlternative(u"run", u"blocker")
            sia1 = StackItemAsynchronous(
                aa1, {"_node": alt})  # the dictionary is fake Dragonfly data
            '''add it'''
            self.nexus.state.add(sia1)
            '''blocked function'''
            mutable_integer = {"value": 0}

            def increment():
                mutable_integer["value"] += 1

            '''make fake incrementing RegisteredAction'''
            inc = R(Function(increment), rspec="inc")
            inc.set_nexus(self.nexus)
            '''make fake StackItemRegisteredAction'''
            alt2 = MockAlternative(u"my", u"spoken", u"words")
            sira1 = StackItemRegisteredAction(inc, {"_node": alt2})
            '''add it'''
            self.nexus.state.add(sira1)
            '''incrementing should be blocked at this point'''
            self.assertEqual(mutable_integer["value"], 0)

            if i == 0:
                '''incrementing should happen that moment of unblocking'''
                self.nexus.state.terminate_asynchronous(True)
                self.assertEqual(mutable_integer["value"], 1)
            elif i == 1:
                '''incrementing gets dropped'''
                self.nexus.state.terminate_asynchronous(False)
                self.assertEqual(mutable_integer["value"], 0)
            elif i == 2:
                '''make fake canceling RegisteredAction'''
                cancel = NullAction(rspec="cancel")
                cancel.set_nexus(self.nexus)
                '''make fake StackItemRegisteredAction'''
                alt3 = MockAlternative(u"my", u"cancel", u"words")
                sira2 = StackItemRegisteredAction(cancel, {"_node": alt3})
                '''add it'''
                self.nexus.state.add(sira2)
                '''incrementing gets dropped'''
                self.assertEqual(mutable_integer["value"], 0)
Exemplo n.º 9
0
class DragonRule(MergeRule):
    pronunciation = "dragon"

    mapping = {
        "reboot (dragon|caster) (german|deutsch)":
        R(Function(utilities.reboot_Deutsch),
          rdescript="Reboot Dragon Naturallyspeaking"),
        "reboot (dragon|caster) (english|englisch)":
        R(Function(utilities.reboot_Englisch),
          rdescript="Reboot Dragon Naturallyspeaking"),
    }

    extras = [
        Dictation("text"),
        Dictation("mim"),
        IntegerRefST("n", 1, 1000),
    ]
    defaults = {"n": 1, "mim": ""}
Exemplo n.º 10
0
class HexChatRule(MergeRule):
    pronunciation = "hex chat"

    mapping = {
        "network list":
            R(Key("c-s")),

        # from nav: next / prior tab
    }
Exemplo n.º 11
0
class Zahlen(MergeRule):
    pronunciation = "zahlen"

    mapping = {
        "wort ziffer <wn>": R(Function(wort_zahl, extra="wn")),
    }

    extras = [
        IntegerRefST("wn", 0, 10),
    ]
    defaults = {}
Exemplo n.º 12
0
class IERule(MergeRule):
    pronunciation = "explorer"

    mapping = {
        "get up [<n>]": R(Key("a-up")) * Repeat(extra="n"),
        "get back [<n>]": R(Key("a-left")) * Repeat(extra="n"),
        "get forward [<n>]": R(Key("a-right")) * Repeat(extra="n"),
        "new folder": R(Key("cs-n")),
        "address bar": R(Key("c-l")),
        "search": R(Key("c-l, tab")),
        "left pane": R(Key("c-l, tab:2")),
        "center pane": R(Key("c-l, tab:3")),
        "sort": R(Key("c-l, tab:4")),
    }
    extras = [IntegerRefST("n", 1, 10)]
    defaults = {
        "n": 1,
    }
Exemplo n.º 13
0
class Punctuation(MergeRule):
    pronunciation = CCRMerger.CORE[3]

    mapping = {
        "[<long>] <text_punc> [<npunc>]":
        R(Text("%(long)s" + "%(text_punc)s" + "%(long)s")) *
        Repeat(extra="npunc"),
        # For some reason, this one doesn't work through the other function
        "[<long>] backslash [<npunc>]":
        R(Text("%(long)s" + "\\" + "%(long)s")) * Repeat(extra="npunc"),
    }

    extras = [
        IntegerRefST("npunc", 0, 10),
        Choice("long", {
            "long": " ",
        }),
        Choice("text_punc", text_punc_dict)
    ]
    defaults = {
        "npunc": 1,
        "long": "",
    }
Exemplo n.º 14
0
    def test_list_pruning(self):
        '''make fake RegisteredAction'''
        action = R(NullAction(), rspec="test")
        action.set_nexus(self.nexus)

        for i in range(0, self.nexus.state.stack.max_list_size + 5):
            '''make fake StackItemRegisteredAction'''
            alt = MockAlternative(u"my", u"spoken", u"words")
            sira1 = StackItemRegisteredAction(action, {"_node": alt})
            '''add it'''
            self.nexus.state.add(sira1)

        self.assertEqual(len(self.nexus.state.stack.list),
                         self.nexus.state.stack.max_list_size)
Exemplo n.º 15
0
    def test_preserving_spoken_words(self):
        '''make fake RegisteredAction'''
        action = R(NullAction(), rspec="test")
        action.set_nexus(self.nexus)
        '''make fake StackItemRegisteredAction'''
        spoken = [u"my", u"spoken", u"words"]
        alt = MockAlternative(*spoken)
        sira1 = StackItemRegisteredAction(action, {"_node": alt})
        '''add it'''
        self.nexus.state.add(sira1)

        last_item = self.nexus.state.stack.list[
            len(self.nexus.state.stack.list) - 1]
        self.assertEqual(spoken, last_item.get_preserved())
Exemplo n.º 16
0
class DevelopmentHelp(MappingRule):
    mapping = {
        # castervoice development tools
        "(show | open) <url> documentation":
            Function(launch_url),
        "open natlink folder":
            R(BringApp("C:/Windows/explorer.exe",
                       settings.SETTINGS["paths"]["BASE_PATH"].replace("/", "\\")),
              rdescript="Open Natlink Folder"),
        "refresh debug file":
            R(Function(devgen.refresh), rdescript="Dev: Refreshed Debug File"),
        "Agrippa <filetype> <path>":
            Function(grep_this),
        "run rule complexity test":
            Function(lambda: run_tests()),
        "run unit tests":
            Function(testrunner.run_tests),
        "run remote debugger":
            Function(run_remote_debugger),
    }
    extras = [
        Dictation("text"),
        Choice("path", {
            "natlink": "c:/natlink/natlink",
            "sea": "C:/",
        }),
        Choice("filetype", {
            "java": "*.java",
            "python": "*.py",
        }),
        Choice(
            "url", {
                "caster": "https://caster.readthedocs.io/en/latest/",
                "dragonfly": "https://dragonfly2.readthedocs.io/en/latest/",
            }),
    ]
    defaults = {"text": ""}
Exemplo n.º 17
0
class Punctuation(MergeRule):
    pronunciation = CCRMerger.CORE[3]

    mapping = {
        "[<long>] <text_punc> [<npunc>]":
        R(Text("%(long)s" + "%(text_punc)s" + "%(long)s")) *
        Repeat(extra="npunc"),
        # For some reason, this one doesn't work through the other function
        "[<long>] backslash [<npunc>]":
        R(Text("%(long)s" + "\\" + "%(long)s")) * Repeat(extra="npunc"),
        "<double_text_punc> [<npunc>]":
        R(Text("%(double_text_punc)s") + Key("left")) * Repeat(extra="npunc"),
        "tabby [<npunc>]":
        R(Key("tab")) * Repeat(extra="npunc"),
        "(back | shin) tabby [<npunc>]":
        R(Key("s-tab")) * Repeat(extra="npunc"),
        "boom [<npunc>]":
        R(Text(", ")) * Repeat(extra="npunc"),
        "bam [<npunc>]":
        R(Text(". ")) * Repeat(extra="npunc"),
        "ace [<npunc100>]":
        R(Text(" ")) * Repeat(extra="npunc100"),
    }

    extras = [
        IntegerRefST("npunc", 0, 10),
        IntegerRefST("npunc100", 0, 100),
        Choice("long", {
            "long": " ",
        }),
        Choice("text_punc", text_punc_dict),
        Choice("double_text_punc", double_text_punc_dict)
    ]
    defaults = {
        "npunc": 1,
        "npunc100": 1,
        "long": "",
    }
Exemplo n.º 18
0
class GridControlRule(MergeRule):

    mapping = {
        "<x> [by] <y> [<action>]":
        R(Function(send_input, nexus=_NEXUS),
          rdescript="Douglas Grid: Action"),
        "<x1> [by] <y1> select <x2> [by] <y2>":
        R(Function(send_input_select, nexus=_NEXUS),
          rdescript="Douglas Grid: Select (long version)"),
        "<x1> [by] <y1> select <x2>":
        R(Function(send_input_select_short, nexus=_NEXUS),
          rdescript="Douglas Grid: Select (short version)"),
        "point <point>":
        R(Function(store_point), rdescript="Douglas Grid: Stor point"),
        "select":
        R(Function(select_text, nexus=_NEXUS),
          rdescript="Douglas Grid: Select (point version)"),
        "exit | escape | cancel":
        R(Function(kill, nexus=_NEXUS), rdescript="Douglas Grid: Exit"),
    }
    extras = [
        IntegerRefST("x", 0, 300),
        IntegerRefST("y", 0, 300),
        IntegerRefST("x1", 0, 300),
        IntegerRefST("y1", 0, 300),
        IntegerRefST("x2", 0, 300),
        IntegerRefST("y2", 0, 300),
        Choice("action", {
            "kick": 0,
            "psychic": 1,
            "move": 2,
        }),
        Choice("point", {
            "one": 1,
            "two": 2,
        }),
    ]
    defaults = {
        "action": 0,
    }
Exemplo n.º 19
0
class GridControlRule(MergeRule):

    mapping = {
        "[<pre>] <color> <n> [<action>]":
        R(Function(send_input, nexus=_NEXUS),
          rdescript="Rainbow Grid: Action"),
        "[<pre1>] <color1> <n1> select [<pre2>] <color2> <n2>":
        R(Function(send_input_select, nexus=_NEXUS),
          rdescript="Rainbow Grid: Select (long version)"),
        "[<pre1>] <color1> <n1> select <n2>":
        R(Function(send_input_select_short, nexus=_NEXUS),
          rdescript="Rainbow Grid: Select (short version)"),
        "point <point>":
        R(Function(store_point), rdescript="Rainbow Grid: Store point"),
        "select":
        R(Function(select_text, nexus=_NEXUS),
          rdescript="Rainbow Grid: Select (point version)"),
        "exit | escape | cancel":
        R(Function(kill, nexus=_NEXUS), rdescript="Rainbow Grid: Exit"),
    }
    extras = [
        IntegerRefST("pre", 0, 9),
        IntegerRefST("pre1", 0, 9),
        IntegerRefST("pre2", 0, 9),
        Choice(
            "color", {
                "(red | rot)": 0,
                "(orange | tan | brown | braun)": 1,
                "(yellow | gelb)": 2,
                "(green | gruen)": 3,
                "(blue | blau)": 4,
                "(purple | lila)": 5
            }),
        Choice(
            "color1", {
                "(red | rot)": 0,
                "(orange | tan | brown | braun)": 1,
                "(yellow | gelb)": 2,
                "(green | gruen)": 3,
                "(blue | blau)": 4,
                "(purple | lila)": 5
            }),
        Choice(
            "color2", {
                "(red | rot)": 0,
                "(orange | tan | brown | braun)": 1,
                "(yellow | gelb)": 2,
                "(green | gruen)": 3,
                "(blue | blau)": 4,
                "(purple | lila)": 5
            }),
        IntegerRefST("n", 0, 100),
        IntegerRefST("n1", 0, 100),
        IntegerRefST("n2", 0, 100),
        Choice("action", {
            "kick": 0,
            "psychic": 1,
            "move": 2,
        }),
        Choice("point", {
            "one": 1,
            "two": 2,
        }),
    ]
    defaults = {
        "pre": 0,
        "pre1": 0,
        "pre2": 0,
        "action": 0,
    }
Exemplo n.º 20
0
class MainRule(MergeRule):
    @staticmethod
    def generate_ccr_choices(nexus):
        choices = {}
        for ccr_choice in nexus.merger.global_rule_names():
            choices[ccr_choice] = ccr_choice
        return Choice("name", choices)

    @staticmethod
    def generate_sm_ccr_choices(nexus):
        choices = {}
        for ccr_choice in nexus.merger.selfmod_rule_names():
            choices[ccr_choice] = ccr_choice
        return Choice("name2", choices)

    mapping = {
        # update management
        "update caster":
        R(DependencyUpdate([pip, "install", "--upgrade", "castervoice"])),
        "update dragonfly":
        R(DependencyUpdate([pip, "install", "--upgrade", "dragonfly2"])),

        # hardware management
        "volume <volume_mode> [<n>]":
        R(Function(navigation.volume_control, extra={'n', 'volume_mode'})),
        "change monitor":
        R(Key("w-p") + Pause("100") + Function(change_monitor)),

        # window management
        'minimize':
        R(Playback([(["minimize", "window"], 0.0)])),
        'maximize':
        R(Playback([(["maximize", "window"], 0.0)])),
        "remax":
        R(Key("a-space/10,r/10,a-space/10,x")),

        # passwords

        # mouse alternatives
        "legion [<monitor>]":
        R(Function(navigation.mouse_alternates, mode="legion", nexus=_NEXUS)),
        "rainbow [<monitor>]":
        R(Function(navigation.mouse_alternates, mode="rainbow", nexus=_NEXUS)),
        "douglas [<monitor>]":
        R(Function(navigation.mouse_alternates, mode="douglas", nexus=_NEXUS)),

        # ccr de/activation
        "<enable> <name>":
        R(Function(_NEXUS.merger.global_rule_changer(), save=True)),
        "<enable> <name2>":
        R(Function(_NEXUS.merger.selfmod_rule_changer(), save=True)),
        "enable caster":
        R(Function(_NEXUS.merger.merge, time=MergeInf.RUN, name="numbers")),
        "disable caster":
        R(Function(_NEXUS.merger.ccr_off)),
    }
    extras = [
        IntegerRefST("n", 1, 50),
        Dictation("text"),
        Dictation("text2"),
        Dictation("text3"),
        Choice("enable", {
            "enable": True,
            "disable": False
        }),
        Choice("volume_mode", {
            "mute": "mute",
            "up": "up",
            "down": "down"
        }),
        generate_ccr_choices.__func__(_NEXUS),
        generate_sm_ccr_choices.__func__(_NEXUS),
        IntegerRefST("monitor", 1, 10)
    ]
    defaults = {
        "n": 1,
        "nnv": 1,
        "text": "",
        "volume_mode": "setsysvolume",
        "enable": -1
    }
Exemplo n.º 21
0
class StackTest(MappingRule):
    '''test battery for the ContextStack'''

    mapping = {
        "close last tag":
            ContextSeeker([
                L(
                    S(["cancel"], None),
                    S(["html spoken"], close_last_spoken, use_spoken=True),
                    S(["span", "div"], close_last_rspec, use_rspec=True))
            ]),
        "html":
            R(Text("<html>")),
        "divider":
            R(Text("<div>")),
        "span":
            R(Text("<span>")),
        "backward seeker [<text>]":
            ContextSeeker([
                L(
                    S(["ashes"], Text("ashes1 [%(text)s] ")),
                    S(["bravery"], Text("bravery1 [%(text)s] "))),
                L(
                    S(["ashes"], Text("ashes2 [%(text)s] ")),
                    S(["bravery"], Text("bravery2 [%(text)s] ")))
            ]),
        "forward seeker [<text>]":
            ContextSeeker(forward=[
                L(
                    S(["ashes"], Text("ashes1 [%(text)s] ")),
                    S(["bravery"], Text("bravery1 [%(text)s] "))),
                L(
                    S(["ashes"], Text("ashes2 [%(text)s] ")),
                    S(["bravery"], Text("bravery2 [%(text)s] ")))
            ]),
        "asynchronous test":
            AsynchronousAction([
                L(
                    S(["ashes", "charcoal"], print_time, None),
                    S(["bravery"], Text, "bravery1"))
            ],
                               time_in_seconds=0.2,
                               repetitions=20,
                               finisher=Text(FINISHER_TEXT),
                               blocking=False),
        "ashes":
            RegisteredAction(Text("ashes _ ")),
        "bravery":
            RegisteredAction(Text("bravery _ ")),
        "charcoal <text> [<n>]":
            R(Text("charcoal _ %(text)s")),
        "test confirm action":
            ConfirmAction(
                Key("a"), rdescript="Confirm Action Test",
                instructions="some words here"),
        "test box action":
            BoxAction(
                lambda data: _abc(data),
                rdescript="Test Box Action",
                box_type=settings.QTYPE_DEFAULT,
                log_failure=True),
    }
    extras = [Dictation("text"), Dictation("text2"), IntegerRefST("n", 1, 5)]
    defaults = {"text": "", "text2": ""}
def lazy_value(c,f,**kwargs):
    return  R(Function(noob_send, command = c, format = f,**kwargs))
Exemplo n.º 23
0
class FirefoxRule(MergeRule):
    pronunciation = "fire fox"

    mapping = {
        "(new tab|neuer Tab) [<n>]": R(Key("c-t")) * Repeat(extra="n"),
        "reopen tab [<n>]": R(Key("cs-t")) * Repeat(extra="n"),
        "show history": R(Key("c-h")),
        "show downloads": R(Key("c-j")),
        "show bookmarks": R(Key("c-b")),
        "[add] bookmark": R(Key("c-d")),
        "cancel bookmark":  # Call this after "[add] bookmark" if you want to cancel
        R(Key("a-b")),
        "delete bookmark":  # Call if you are on a page you have bookmarked before
        R(Key("c-d") + Pause("200") + Key("a-e")),
        "full screen": R(Key("f11")),
        "zoom in [<n>]": R(Key("c-plus/20")) * Repeat(extra="n"),
        "zoom out [<n>]": R(Key("c-minus/20")) * Repeat(extra="n"),
        "(leiste | address bar)": R(Key("c-l")),

        # the following commands requires the vim vixen extension
        "(scroll down | runter) [<n>]": R(Key("c-f")) * Repeat(extra="n"),
        "(scroll down | runter) half [<n>]": R(Key("c-d")) * Repeat(extra="n"),
        "(scroll up | hoeher) [<n>]": R(Key("c-b")) * Repeat(extra="n"),
        "(scroll up | hoeher) half [<n>]": R(Key("c-u")) * Repeat(extra="n"),
        "scroll top": R(Key("g") + Key("g")),
        "scroll bottom": R(Key("G")),
        "reload": R(Key("r")),
        "toggle pin": R(Key("z") + Key("p")),
        "(loesche pin | delete pin)": R(Key("!") + Key("d")),
        "(history back|zurueck) [<n>]": R(Key("H")) * Repeat(extra="n"),
        "(history forward|vorwaerts) [<n>]": R(Key("L")) * Repeat(extra="n"),
        "parent [<n>]": R(Key("g") + Key("u")) * Repeat(extra="n"),
        "root": R(Key("g") + Key("U")),
        "link":  # opens in new tab
        R(Key("F")),
        "link here": R(Key("f")),
        "mark <letter>": R(Key("m") + Text("%(letter)s")),
        "jump <letter>": R(Key("'") + Text("%(letter)s")),
        "focus input": R(Text("gi")),
        "copy url":  # copy URL in current tab
        R(Text("y")),
        "clipboard tab":  # open clipboard's URL in current tab
        R(Text("p")),
        "clipboard new tab":  # open clipboard's URL in new tab
        R(Text("P")),
        "toggle":  # enables / disables add on
        R(Key("s-escape")),

        # from nav: next / prior / close tab
    }
    extras = [
        IntegerRefST("n", 1, 100),
        alphanumeric.get_alphabet_choice("letter"),
    ]
    defaults = {"n": 1}
Exemplo n.º 24
0
def update_carrot(rule):
    if "carrot" in rule.mapping_actual().keys():
        rule.mapping_actual()["carrot"] = R(
            Key("caret") + Key("left") + Key("delete"))
Exemplo n.º 25
0
class GitterRule(MergeRule):
    pronunciation = "Gitter"

    mapping = {
        "(rooms | raeume)":
        R(Key("cs-1") + Key("right")),
        "(search | suche)":
        R(Key("cs-1") + Key("cs-2")),
        "chat":
        R(Key("escape") + Key("cs-c")),
        "edit":
        R(Key("up")),
        "(bold | fett)":
        R(Text("****") + Key("left:2")),
        "(emphasize | hervorheben)":
        R(Text("**") + Key("left")),
        "(new line | neue zeile)":
        R(Key("s-enter")),
        "(block quote | zitat)":
        R(Text("> ")),
        "(mention | erwaehnen)":
        R(Text("@")),
        "(insert link | link einfuegen)":
        R(Text("[]()") + Key("left:3")),
        "(short code | kurzer code)":
        R(Text("```") + Key("left")),
        "(insert code | code einfuegen)":
        R(
            Text("```") + Key("backspace") + Key("backspace") + Text("```") +
            Key("s-enter") + Key("s-enter") + Text("```") + Key("backspace") +
            Key("backspace") + Text("```") + Text("```") + Key("backspace") +
            Key("backspace") + Key("backspace") + Key("up")),
    }
Exemplo n.º 26
0
def add_is_to_python(rule):
    if rule.get_pronunciation() == "Python":
        rule.mapping_actual()["identity is"] = R(Text(" is "),
                                                 rdescript="Python: Is")
Exemplo n.º 27
0
def update_python(rule):
    if "shells" in rule.mapping_actual().keys():
        rule.mapping_actual()["shells"] = R(Text("not allowed to use 'else'"),
                                            rdescript="Troll Replacement")
Exemplo n.º 28
0
class ThunderbirdRule(MergeRule):
    pronunciation = "thunderbird"

    mapping = {
        "(new message | neue nachricht)": R(Key("c-n")),
        "(reply | antworten)": R(Key("c-r")),
        "(reply all | allen antworten)": R(Key("cs-r")),
        "(forward message | nachricht weiterleiten)": R(Key("cs-r")),
        "(retrieve | abholen)": R(Key("s-f5")),
        "(expand | aufklappen)": R(Key("*")),
        "(collapse | einklappen)": R(Key("\\")),
        "(toggle read | gelesen | ungelesen)": R(Key("m")),
        "(no | kein) spam": R(Key("s-j")),
        "spam": R(Key("j")),
        "(toggle star | favorit)": R(Key("s")),
        "(next message | weitere nachricht)": R(Key("n")),
        "(previous message | vorherige nachricht)": R(Key("p")),
        "toggle pane": R(Key("f6")),
        "(next | naechster) tab": R(Key("c-tab")),
        "(previous | vorheriger) tab": R(Key("cs-tab")),
        "(attach file | datei anhaengen)": R(Key("cs-a")),
    }
Exemplo n.º 29
0
class FileDialogueRule(MergeRule):
    pronunciation = "file dialogue"

    mapping = {
        "get up [<n>]": R(Key("a-up")) * Repeat(extra="n"),
        "get back [<n>]": R(Key("a-left")) * Repeat(extra="n"),
        "get forward [<n>]": R(Key("a-right")) * Repeat(extra="n"),
        "new folder": R(Key("cs-n")),
        "address bar": R(Key("c-l")),
        "search": R(Key("c-l, tab")),
        "left pane": R(Key("c-l, tab:3")),
        "center pane": R(Key("c-l, tab:4")),
        "sort": R(Key("c-l, tab:5")),
        "organize": R(Key("c-l, tab:2")),
        "(dateiname | filename)": R(Key("c-l, tab:6")),
        "(dateityp | file type)": R(Key("c-l, tab:7")),
    }
    extras = [IntegerRefST("n", 1, 10)]
    defaults = {
        "n": 1,
    }
Exemplo n.º 30
0
class SlackRule(MergeRule):
    pronunciation = "Slack"

    mapping = {
        "(up | hoch)":
        R(Key("a-up")),
        "(down | runter)":
        R(Key("a-down")),
        "(next message | naechste nachricht)":
        R(Key("as-up")),
        "(previous message | vorherige nachricht)":
        R(Key("as-down")),
        "edit":
        R(Key("up")),
        "(new line | neue zeile)":
        R(Key("s-enter")),
        "(bold | fett)":
        R(Text("**") + Key("left")),
        "(emphasize | hervorheben)":
        R(Text("__") + Key("left")),
        "(search | suche)":
        R(Key("c-f")),
        "(block quote | zitat)":
        R(Text("> ")),
        "(mention | erwaehnen)":
        R(Text("@")),
        "(short code | kurzer code)":
        R(Text("```") + Key("left")),
        "(insert code | code einfuegen)":
        R(
            Text("```") + Key("backspace") + Text("```") + Key("s-enter") +
            Key("s-enter") + Text("```") + Key("backspace") +
            Key("backspace") + Text("```") + Text("```") + Key("backspace") +
            Key("backspace") + Key("backspace") + Key("up")),
    }