예제 #1
0
    def updatedict(self):
        self.button_dictionary.update(caster_alphabet())
        self.button_dictionary.update(text_punc_dict())
        # Create function keys 1 through 13
        self.button_dictionary.update({
            "(F{}".format(i) + " | function {})".format(i): "f{}".format(i)
            for i in range(1, 13)
        })
        self.button_dictionary.update({
            "(tab | tabby)": "tab",
            "(backspace | clear)": "backspace",
            "(delete | deli)": "del",
            "(enter | shock)": "enter",
            left_spec: "left",
            right_spec: "right",
            "(up | sauce)": "up",
            "(down | dunce)": "down",
            "page (down | dunce)": "pgdown",
            "page (up | sauce)": "pgup",
            "zero": "0",
            "one": "1",
            "two": "2",
            "three": "3",
            "four": "4",
            "five": "5",
            "six": "6",
            "seven": "7",
            "eight": "8",
            "nine": "9",
            shift_spec: "shift",
            control_spec: "control",
            alt_spec: "alt",
            right_spec + " " + shift_spec: "rshift",
            right_spec + " " + control_spec: "rcontrol",
            right_spec + " " + alt_spec: "ralt",
            SymbolSpecs.CANCEL: "escape",
            "insert": "insert",
            "pause": "pause",
            windows_spec: "win",
            "(apps | popup)": "apps",
            "print screen": "printscreen",
            "scroll lock": "scrolllock",
            "num lock": "numlock",
            "caps lock": "capslock",
            "(home | lease wally | latch)": "home",
            "(end | ross wally | ratch)": "end",
            # number pad numbers deliberately left off
            # volume control deliberately left off as these are dealt with in HardwareRule and I don't think there's a use case for modifiers there
            # track control deliberately left off as these are (or will be) dealt with in HardwareRule and I don't think there's a use case for modifiers there
            # browser forward/back are deliberately left off. These functions are implemented at the browser rule level
        })

        self.button_dictionary.update({
            self.getspec(' '): "space",
            self.getspec(','): "comma",
            self.getspec('-'): "minus",
            self.getspec('/'): "slash",
            self.getspec(':'): "colon",
        })
예제 #2
0
try:
    from keyboard_rules import keyboard_support
except ImportError:
    try:
        from keyboard_support import keyboard_support
    except ImportError:
        from castervoice.rules.core.keyboard_rules import keyboard_support

from castervoice.lib.const import CCRType
from castervoice.lib.ctrl.mgr.rule_details import RuleDetails
from castervoice.lib.merge.mergerule import MergeRule
from castervoice.lib.merge.state.actions import AsynchronousAction, ContextSeeker
from castervoice.lib.merge.state.actions2 import UntilCancelled
from castervoice.lib.merge.state.short import S, L, R

_tpd = text_punc_dict()
_dtpd = double_text_punc_dict()

for key, value in _dtpd.items():
    if len(value) == 2:
        _dtpd[key] = value[0] + "~" + value[1]
    elif len(value) == 4:
        _dtpd[key] = value[0:1] + "~" + value[2:3]
    else:
        msg = "Need to deal with nonstandard pair length in double_text_punc_dict: {}"
        raise Exception(msg.format(str(value)))


class Navigation(MergeRule):
    pronunciation = "navigation"
예제 #3
0
class TextManipulation(MergeRule):
    pronunciation = "text manipulation"

    mapping = {

        # PROBLEM: sometimes Dragon thinks the variables are part of dictation.

        # replace text or character
        "replace <direction> [<number_of_lines_to_search>] [<occurrence_number>] <dictation> with <dictation2>":
        R(Function(
            text_manipulation_support.copypaste_replace_phrase_with_phrase,
            dict(dictation="replaced_phrase", dictation2="replacement_phrase"),
            dictation_versus_character="dictation"),
          rdescript=
          "Text Manipulation: replace text to the left or right of the cursor"
          ),
        "replace <direction>  [<number_of_lines_to_search>] [<occurrence_number>] <character> with <character2>":
        R(Function(
            text_manipulation_support.copypaste_replace_phrase_with_phrase,
            dict(character="replaced_phrase", character2="replacement_phrase"),
            dictation_versus_character="character"),
          rdescript=
          "Text Manipulation: replace character to the left of the cursor"),

        # remove text or character
        "remove <direction> [<number_of_lines_to_search>] [<occurrence_number>] <dictation>":
        R(Function(text_manipulation_support.copypaste_remove_phrase_from_text,
                   dict(dictation="phrase"),
                   dictation_versus_character="dictation"),
          rdescript=
          "Text Manipulation: remove chosen phrase to the left or right of the cursor"
          ),
        "remove <direction> [<number_of_lines_to_search>] [<occurrence_number>] <character>":
        R(Function(text_manipulation_support.copypaste_remove_phrase_from_text,
                   dict(character="phrase"),
                   dictation_versus_character="character"),
          rdescript=
          "Text Manipulation: remove chosen character to the left of the cursor"
          ),

        # remove until text or character
        "remove <direction> [<number_of_lines_to_search>] until [<before_after>] [<occurrence_number>] <dictation>":
        R(Function(text_manipulation_support.copypaste_delete_until_phrase,
                   dict(dictation="phrase"),
                   dictation_versus_character="dictation"),
          rdescript="Text Manipulation: delete until chosen phrase"),
        "remove <direction> [<number_of_lines_to_search>] until [<before_after>] [<occurrence_number>] <character>":
        R(Function(text_manipulation_support.copypaste_delete_until_phrase,
                   dict(character="phrase"),
                   dictation_versus_character="character"),
          rdescript="Text Manipulation: delete until chosen character"),

        # move cursor
        "(go | move) <direction> [<number_of_lines_to_search>] [<before_after>] [<occurrence_number>] <dictation>":
        R(Function(text_manipulation_support.move_until_phrase,
                   dict(dictation="phrase"),
                   dictation_versus_character="dictation"),
          rdescript=
          "Text Manipulation: move to chosen phrase to the left or right of the cursor"
          ),
        "(go | move) <direction> [<number_of_lines_to_search>] [<before_after>] [<occurrence_number>] <character_sequence> [over]":
        Function(
            lambda direction, before_after, number_of_lines_to_search,
            occurrence_number, character_sequence:
            text_manipulation_support.move_until_phrase(
                direction, before_after, "".join(character_sequence),
                number_of_lines_to_search, occurrence_number, "character")),

        # select text or character
        "grab <direction> [<number_of_lines_to_search>] [<occurrence_number>] <dictation>":
        R(Function(text_manipulation_support.select_phrase,
                   dict(dictation="phrase"),
                   dictation_versus_character="dictation"),
          rdescript="Text Manipulation: select chosen phrase"),
        "grab <direction> [<number_of_lines_to_search>] [<occurrence_number>] <character>":
        R(Function(
            text_manipulation_support.select_phrase,
            dict(character="phrase", dictation_versus_character="character")),
          rdescript="Text Manipulation: select chosen character"),

        # select until text or character
        "grab <direction> [<number_of_lines_to_search>] until [<before_after>] [<occurrence_number>] <dictation> ":
        R(Function(text_manipulation_support.select_until_phrase,
                   dict(dictation="phrase"),
                   dictation_versus_character="dictation"),
          rdescript="Text Manipulation: select until chosen phrase"),
        "grab <direction> [<number_of_lines_to_search>] until [<before_after>] [<occurrence_number>] <character>":
        R(Function(text_manipulation_support.select_until_phrase,
                   dict(character="phrase"),
                   dictation_versus_character="character"),
          rdescript="Text Manipulation: select until chosen character"),

        # capitalized 1st word of text or character
        "capital <direction> [<number_of_lines_to_search>] [<occurrence_number>] [<letter_size>] <dictation>":
        R(Function(
            text_manipulation_support.copypaste_change_phrase_capitalization,
            dict(dictation="phrase"),
            dictation_versus_character="dictation"),
          rdescript="Text Manipulation: change capitalization phrase"),
        "capital <direction> [<number_of_lines_to_search>] [<occurrence_number>] [<letter_size>] <character>":
        R(Function(
            text_manipulation_support.copypaste_change_phrase_capitalization,
            dict(character="phrase"),
            dictation_versus_character="character"),
          rdescript="Text Manipulation: change capitalization character"),
    }
    new_text_punc_dict = text_punc_dict()
    new_text_punc_dict.update(alphabet_support.caster_alphabet())
    new_text_punc_dict.update(number_dict)
    character_dict = new_text_punc_dict
    character_choice_object = Choice("character_choice", character_dict)

    extras = [
        Repetition(character_choice_object,
                   min=1,
                   max=3,
                   name="character_sequence"),
        Dictation("dict"),
        Dictation("dictation"),
        Dictation("dictation2"),
        Dictation("text"),
        IntegerRefST("n", 1, 100),
        IntegerRefST("m", 1, 100),
        IntegerRefST("wait_time", 1, 1000),
        IntegerRefST("number_of_lines_to_search", 1, 50),
        Choice("character", character_dict),
        Choice("character2", character_dict),
        Choice("single_character", character_dict),
        Choice(
            "direction",
            {
                "lease": "left",
                "ross": "right",
                "sauce": "up",
                "dunce": "down",
                # note: "sauce" (i.e. "up") will be treated the same as "lease" (i.e. "left") except that
                # the default number_of_lines_to_search will be set to 3
                # in the same way, "dunce" (i.e. "down") will be treated the same as
                # "ross" (i.e. "right")
            }),
        Choice("before_after", {
            "before": "before",
            "after": "after",
        }),
        Choice(
            "letter_size", {
                "upper": "upper",
                "upward": "upper",
                "lower": "lower",
                "lowered": "lower",
            }),
        Choice(
            "occurrence_number", {
                "first": 1,
                "second": 2,
                "third": 3,
                "fourth": 4,
                "fifth": 5,
                "sixth": 6,
                "seventh": 7,
                "eighth": 8,
                "ninth": 9,
                "tenth": 10,
            }),
    ]
    defaults = {
        "before_after": None,
        "letter_size": "upper",
        "number_of_lines_to_search":
        0,  # before changing this default, please read the function deal_with_up_down_directions
        "occurrence_number": 1,
    }  # if direction is up or down, the default number_of_lines_to_search
예제 #4
0
파일: keyboard.py 프로젝트: zilch42/Caster
    from castervoice.rules.core.keyboard_rules import keyboard_support

try:  # Try first loading from caster user directory
    from punctuation_rules import punctuation_support
except ImportError:
    from castervoice.rules.core.punctuation_rules import punctuation_support

from castervoice.lib.actions import Key

from castervoice.lib.ctrl.mgr.rule_details import RuleDetails
from castervoice.lib.merge.mergerule import MergeRule
from castervoice.lib.merge.state.actions import AsynchronousAction, ContextSeeker
from castervoice.lib.merge.state.actions2 import UntilCancelled
from castervoice.lib.merge.state.short import S, L, R

_tpd = punctuation_support.text_punc_dict()


def hold_keys(modifier_choice_key_name):
    modifier_list = modifier_choice_key_name.strip().split(" ")
    for key in modifier_list:
        Key("{}:down".format(key)).execute()


class Keyboard(MappingRule):
    mapping = {
        "<modifier> <button_dictionary_1>":
        R(Key("%(modifier)s-%(button_dictionary_1)s"),
          rdescript="Keyboard: %(modifier)s %(button_dictionary_1)s"),
        "hold <modifier_key_name>":
        R(