Ejemplo n.º 1
0
        send_idea_command("action EditorCopy")
        send_idea_command("goto {} {}".format(old_line, old_col))
        send_idea_command("action EditorPaste")
    finally:
        clip.set(old_clip)


def is_real_jetbrains_editor(app, window):
    if app.bundle not in port_mapping:
        return False
    # XXX Expose "does editor have focus" as plugin endpoint.
    # XXX Window title empty in full screen.
    return "[" in window.title or len(window.title) == 0


group = ContextGroup("jetbrains")
ctx = Context("jetbrains", func=is_real_jetbrains_editor)  # , group=group)

ctx.keymap({
    "comment toggle":
    Key("cmd-/"),
    "compile": [Key("ctrl-c"), "c"],
    "run": [Key("ctrl-c"), "r"],
    "go to [<dgndictation>]": [
        Key("cmd-e"),
        # idea("action SearchEverywhere"),
        text,
    ],
    "ace [<dgndictation>]": [Key("ctrl-;"), text],
    "toggle":
    Key("ctrl-tab"),
Ejemplo n.º 2
0
        sleep(0.5)
        press('cmd-shift-alt-d')


def talon_mode(m):
    global is_swedish_mode
    speech.set_enabled(True)
    engine.mimic('go to sleep'.split())
    if is_swedish_mode == True:
        is_swedish_mode = False
        sleep(0.5)
        press('cmd-shift-alt-d')


def dragon_mode(m):
    speech.set_enabled(False)
    engine.mimic('wake up'.split())


sleep_group = ContextGroup('sleepy')
sleepy = Context('sleepy', group=sleep_group)

sleepy.keymap({
    'snore': lambda m: speech.set_enabled(False),
    'activate': lambda m: speech.set_enabled(True),
    'dragon mode': dragon_mode,
    'talon mode': talon_mode,
    'swedish mode': swedish_mode,
})
sleep_group.load()
Ejemplo n.º 3
0

def narrow(m):
    for d in m["mouseSnapNine.digits"]:
        mg.narrow(int(d))


def click():
    x, y = ctrl.mouse_pos()
    ctrl.mouse_click(pos=(x, y), button=0, times=1, wait=16000)


digits = dict((str(n), n) for n in range(1, 11))

mg = MouseSnapNine()
group = ContextGroup("snapNine")
ctx = Context("mouseSnapNine", group=group)
keymap = {
    "{mouseSnapNine.digits}+":
    narrow,
    "(oops | back)":
    mg.go_back,
    "(reset | clear | escape)":
    mg.reset,
    "done": [
        mg.stop, lambda _: ctx.unload(), lambda _: speech.set_enabled(True),
        lambda _: click()
    ],
    "exit":
    [mg.stop, lambda _: ctx.unload(), lambda _: speech.set_enabled(True)],
}
Ejemplo n.º 4
0
import time

from talon.voice import Context, ContextGroup, Key

from ..utils import text


def delay(amount):
    return lambda _: time.sleep(amount)


# I don't want to interleave jira navigation with other commands, like dictation.
group = ContextGroup("jira")
ctx = Context("jira",
              func=lambda app, win: win.title.endswith(" JIRA2"),
              group=group)
ctx.vocab = ["sub-task", "Dwight"]
ctx.keymap({
    "dashboard": Key("g d"),
    "boards": Key("g b"),
    "issues": Key("g i"),
    "find": Key("/"),
    "create": Key("c"),
    "assign [to] <dgndictation> [over]": [Key("a"), delay(0.6), text],
    "assign to me": Key("i"),
    "comment": Key("m"),
    "edit": Key("e"),
    "action <dgndictation> [over]": [Key("."), delay(0.6), text],
    "submit": Key("ctrl+return"),
    "copy link": Key("cmd+l cmd+c"),
    "copy id": Key("cmd+l right alt+shift+left alt+shift+left cmd+c"),
Ejemplo n.º 5
0
from talon import tap, voice
from talon.voice import Context, ContextGroup
from talon.engine import engine
from talon_plugins import speech

sleep_group = ContextGroup("sleepy")
sleepy = Context("sleepy", group=sleep_group)

dictation_group = ContextGroup("dictation")
dictation = Context("dictation", group=dictation_group)
dictation_group.load()
dictation_group.disable()


class VoiceType:
    SLEEPING = 1
    TALON = 2
    DRAGON = 3
    DICTATION = 4


voice_type = VoiceType.TALON
last_voice_type = VoiceType.TALON


def set_voice_type(type):
    global voice_type, last_voice_type
    if voice_type != VoiceType.SLEEPING:
        last_voice_type = voice_type
    voice_type = type
Ejemplo n.º 6
0
from talon.voice import Context, ContextGroup
from talon.engine import engine
from talon_plugins import speech

sleep_group = ContextGroup("sleepy")
sleepy = Context("sleepy", group=sleep_group)

sleepy.keymap({
    "talon sleep":
    lambda m: speech.set_enabled(False),
    "talon wake":
    lambda m: speech.set_enabled(True),
    "dragon mode": [
        lambda m: speech.set_enabled(False),
        lambda m: engine.mimic("wake up".split()),
    ],
    "talon mode": [
        lambda m: speech.set_enabled(True),
        lambda m: engine.mimic("go to sleep".split()),
    ],
})
sleep_group.load()
Ejemplo n.º 7
0
    is_debug_enabled = enable


def open_debug_log(m):
    # Opens the Talon logs in Console.app, which is where print statements and debugging data is usually sent unless Repl is active
    os.system('open -a Console ~/.talon/talon.log')


def on_eye_control(menu_string):
    # Respect the enabled-ness of default talon ContextGroup for these Voice Commands
    if talon.enabled:
        eye_mouse.on_menu(menu_string)


context_group = ContextGroup('talon_control')
context = Context('talon_control', group=context_group)

context.keymap({
    # Enable/disable voice recognition
    'talon [voice] sleep':
    lambda m: disable_talon(),
    'talon [voice] wake':
    lambda m: enable_talon(),

    # Switch between Dragon dictation and Talon recognition
    'talon dragon mode':
    lambda m: enable_dragon_mode(),
    'talon standard mode':
    lambda m: enable_talon(),
Ejemplo n.º 8
0
    def insert_word(self, word):
        word = str(word).lstrip("\\").split("\\", 1)[0]
        word = mapping.get(word, word)
        word = word.rstrip("-")

        if self.caps:
            word = word[0].upper() + word[1:]

        if self.space and word[0] not in punctuation and "\n" not in word:
            insert(" ")

        insert(word)

        self.caps = word in sentence_ends
        self.space = "\n" not in word

    def phrase(self, m):
        for word in m.dgndictation[0]:
            self.insert_word(word)


dictation_group = ContextGroup("dictation")
dictation = Context("dictation", group=dictation_group)
dictation_group.load()
dictation_group.disable()

auto_format = AutoFormat()
dictation.keymap({"<dgndictation> [over]": auto_format.phrase})
# , "press enter": Key("enter")
Ejemplo n.º 9
0
            (self.offset_x, self.offset_y, self.width, self.height))

    def go_back(self, _):
        last_state = self.states.pop()
        self.offset_x, self.offset_y, self.width, self.height = last_state
        self.count -= 1


def narrow(m):
    mg.narrow(m["mouseSnapSquid.digits"])


digits = dict((str(n), n) for n in range(0, 10))

mg = MouseSnapSquid()
group = ContextGroup("squid")
ctx = Context("mouseSnapSquid", group=group)
keymap = {
    "{mouseSnapSquid.digits}+": narrow,
    "squid":
    [mg.stop, lambda _: ctx.unload(), lambda _: speech.set_enabled(True)],
}
keymap.update({k: [v, mg.reset] for k, v in click_keymap.items()})
ctx.keymap(keymap)
ctx.set_list("digits", digits.keys())
group.load()
ctx.unload()

startCtx = Context("mouseSnapSquidStarter")
startCtx.keymap({
    "squid": [
Ejemplo n.º 10
0
        Str(format(parse_dgndictation(m.dgndictation[0]), get_unique_formatters(m)))(None)

# Allowing the input of formatter words, with optional formatting
# Some formatter words can be entered by using "phrasing", but not all of them accurately, thus this extra method
# Examples:
#   "phraser cram" => 'cram'
#   "phraser title cram" => 'Cram'
#   "phraser caps caps" => 'CAPS'
def formatted_literal_formatter(m):
    if enabled():
        Str(format([parse_word(m._words[-1])], get_unique_formatters(m)))(None)

# Allowing the input of trigger word 'phrasing', with optional formatting
# Examples:
#   "phraser phrasing" => 'phrasing'
#   "phraser caps phrasing" => 'PHRASING'
def formatted_literal_phrasing(m):
    if enabled():
        Str(format(['phrasing'], get_unique_formatters(m)))(None)

context_group = ContextGroup('literal_string_entry')
context = Context('literal_string_entry', group=context_group)

context.keymap({
    'phraser (%s)* phrasing'%(capitalization_string): formatted_literal_phrasing,
    'phraser (%s)+'%(formatter_string): formatted_literal_formatter,
    'phrasing (%s)* <dgndictation>'%(formatter_string): formatted_literal_phrase,
})

context_group.load()
Ejemplo n.º 11
0
from talon.voice import Context, ContextGroup
from talon.engine import engine
from talon_plugins import speech

sleep_group = ContextGroup('sleepy')
sleepy = Context('sleepy', group=sleep_group)

dictation_group = ContextGroup('dictation')
dictation = Context('dictation', group=dictation_group)
dictation_group.load()
dictation_group.disable()

sleepy.keymap({
    'talon sleep': lambda m: speech.set_enabled(False),
    'talon wake': lambda m: speech.set_enabled(True),

    'dragon mode': [lambda m: speech.set_enabled(False), lambda m: dictation_group.disable(), lambda m: engine.mimic('wake up'.split())],
    'dictation mode': [lambda m: speech.set_enabled(False), lambda m: engine.mimic('go to sleep'.split()), lambda m: dictation_group.enable()],
    'talon mode': [lambda m: speech.set_enabled(True), lambda m: dictation_group.disable(), lambda m: engine.mimic('go to sleep'.split())],
    'full sleep mode': [lambda m: speech.set_enabled(False), lambda m: dictation_group.disable(), lambda m: engine.mimic('go to sleep'.split())]
})
sleep_group.load()