from magneto.mergerule import MergeRule
from magneto.settings import ModuleDictionary



from magneto.nexus import nexus
from magneto.mergerule import MergeRule

print('loading purescript rules')

def _import(t):
    Text("import "+ t).execute()

class Purescript(MergeRule):

    mapping = {
    Spec.IMPORT+" <t>": Function(_import)
    }

    extras = [
        Dictation("t"),

    ]

    defaults = {
    }

nexus().merger.add_global_rule(Purescript())

Beispiel #2
0
        "work <n12>": Function(workspace_switcher),
        "switch [<n100>]": Key('alt:down,tab:%(n100)s,alt:up'),
        "swap [<n100>]": Key('alt:down,backtick:%(n100)s,alt:up'),
        "swipe [<n100>]": Key('alt:down,ctrl:down,tab:%(n100)s,ctrl:down,alt:up'),
        "window move <n12>": Function(workspace_mover),
        "window <window_direction>": Function(resize_window),
        "launcher": Key("win:down,ctrl:down,l,ctrl:up,win:up"),
        # "swap <n100>": Key('alt:down/25,tab/25:%(n100)s,alt:up')
    }

    extras = [
        IntegerRef("n100", 1, 100),
        IntegerRef("n500", 1, 500),
        IntegerRef("n12", 1, 13),
        Choice("single_shortcut", single_shortcut),
        Choice("repeat_shortcut", repeat_shortcut),
        Choice("window_direction", {
            "left": "left",
            "right": "right",
            "maximize": "maximize",
            "minimize": "minimize",
            })
    ]

    defaults = {
        "n100": 1,
        "n500": 1,
    }

nexus().merger.add_global_rule(Shortcuts())
Beispiel #3
0
def set_format(the_format):
    global TEXT_FORMAT
    TEXT_FORMAT = the_format

def format_text(t, the_format=None):
    t = prepare_text(the_format, t)

    Text(t).execute()


class FormatText(MergeRule):

    mapping = {
        "<the_format> <t> [stop]": Function(format_text),
        # should make this a 'non' in caster lingo
        "<t>": Function(format_text),
        "format <the_format>": Function(set_format),
    }

    extras = [
        Choice("the_format", format_choices),
        Dictation("t")
    ]

    defaults = {
        "n100": 1,
        "n500": 1,
    }

nexus().merger.add_global_rule(FormatText())
    Function,
    Playback,
)

import aenea
import aenea.misc
import aenea.vocabulary
import aenea.configuration
import aenea.format

from aenea import (AeneaContext, AppContext, Alternative, CompoundRule,
                   Dictation, DictList, DictListRef, Grammar, IntegerRef, Key,
                   Literal, ProxyAppContext, MappingRule, NeverContext,
                   Repetition, Repeat, RuleRef, Sequence, Text)

from magneto.nexus import nexus
from magneto.mergerule import MergeRule
from magneto.settings import ModuleDictionary

print('loading Vocabulary')

dictionary = ModuleDictionary("core\\vocabulary").dictionary
print("dict", dictionary)


class Vocabulary(MergeRule):
    mapping = {key: Text(value) for key, value in dictionary.items()}


nexus().merger.add_global_rule(Vocabulary())
Beispiel #5
0
def propagate_copy():
    """move previous copy to index 2, 2 to 3, etc. drop 9.

    TODO Function not working"""
    print("propagating")
    for i in range(8,1):
        previous = str(i)
        next_key = str(i+1)
        if previous in CLIPBOARD:
            CLIPBOARD[next_key] = CLIPBOARD[previous]
    CLIPBOARD["1"] = CLIPBOARD["default"]

class CopyPaste(MergeRule):
    mapping = {
        "copy [<t> | <n>]": Function(copy),
        "paste [<t> | <n>]": Function(paste),
    }

    extras = [
        Dictation("t"),
        IntegerRef("n",0,9)
    ]

    defaults = {
        "t": 'default',
        "n": 0
    }

nexus().merger.add_global_rule(CopyPaste())
Beispiel #6
0
    pass


do_nothing_words = ["him", "the", "it's"]


def test_server_functionality():
    aenea.communications.server.greet_user("tyler")
    aenea.communications.server.paste("testing one two three")


class Dragon(MergeRule):

    mapping = {
        "reboot dragon": Function(reboot_dragon),
        "snooze": Playback([(["go to sleep"], 0.0)]),
        # the next two words are often misrecognized on their own
        "him": Function(do_nothing),
        "the": Function(do_nothing),
        "it's": Function(do_nothing),
        "server test": Function(test_server_functionality)
    }
    mapping.update({word: Function(do_nothing) for word in do_nothing_words})

    extras = []

    defaults = {}


nexus().merger.add_global_rule(Dragon())
Beispiel #7
0
    mapping = {
        "<single_key>": Function(single_press),
        "[<modify_letter>] <alphabet_key>": Function(alphabet_press),
        "<repeat_key> [<n500>]": Function(repeat_press),
        '<modifier_key> <any_key> [<n100>]': Function(any_press),
        "develop testing": Key('colon'),
        "super [<any_key>]": Function(super_press),
        "hold <modifier_full_name>": Key("%(modifier_full_name)s:down"),
        "release": Key("ctrl:up,alt:up,shift:up,win:up")
    }

    extras = [
        IntegerRef("n100", 1, 100),
        IntegerRef("n500", 1, 500),
        Choice("single_key", single_key),
        Choice("repeat_key", repeat_key),
        Choice("any_key", any_key),
        Choice("modifier_key", modifier_key),
        Choice("alphabet_key", alphabet_key),
        Choice("modify_letter", {"cap": "cap"}),
        Choice("modifier_full_name", modifier_full_name)
    ]

    defaults = {
        "n100": 1,
        "n500": 1,
    }


nexus().merger.add_global_rule(Keyboard())
Beispiel #8
0
        "[<button>] kick":
        Function(click_mouse),
        # "[<button>] click": Function(move_and_click_mouse),
        "[<button>] lick [<n500>]":
        Function(adjust_and_click_mouse, button="left", direction="left"),
        "[<button>] rick [<n500>]":
        Function(adjust_and_click_mouse, button="left", direction="right"),
        "[<button>] sick [<n500>]":
        Function(adjust_and_click_mouse, button="left", direction="up"),
        "[<button>] dick [<n500>]":
        Function(adjust_and_click_mouse, button="left", direction="down"),
    }

    extras = [
        IntegerRef("n500", 1, 500),
        Choice("button", {
            "left": "left",
            "right": "right",
            "middle": "middle",
            "dub": "double"
        }),
    ]

    defaults = {
        "n100": 1,
        "button": 'left',
    }


nexus().merger.add_global_rule(Mousing())
Beispiel #9
0
'''
main magneto module
Created on Aug 7, 2016
Based on Caster by synkarius
Forked and modified by tbenst
'''
import logging
logging.basicConfig()

from magneto import settings, nexus
import os

settings.set_path(os.path.join(os.path.dirname(__file__), "magneto\\"))
# settings.set_path("E://magneto/etc/magneto.yaml")
print('settings', settings.MAGNETO)
NEXUS = nexus.nexus()

from magneto.mergerule import MergeRule
from magneto.ccrmerger import Inf
from magneto import modules

from dragonfly import (
    Choice,
    Function,
    # Key,
    Playback,
    # Repeat,
    # Text
)

from aenea import (Key, Text, Choice, MappingRule, Grammar)