Beispiel #1
0
from dragonfly import Function, Choice

from caster.lib import control, utilities
from caster.lib.dfplus.actions import Key, Text
from caster.lib.dfplus.merge.mergerule import MergeRule

BINDINGS = utilities.load_toml_file(
    utilities.get_full_path("caster/ccr/html/html.toml"))


# Alternate between executing as text and executing as keys
def insert(element):
    if type(element) in [str, int]:
        Text(element).execute()
    elif type(element) in [list, tuple]:
        for i in range(len(element)):
            if i % 2 == 0:
                Text(element[i]).execute()
            else:
                Key(element[i]).execute()


class HTML(MergeRule):
    mapping = {
        "insert <element>": Function(insert),
    }
    extras = [
        Choice("element", BINDINGS["elements"]),
    ]

Beispiel #2
0
'''
Created Jan 2019

@author: Alex Boche, Mike Roberts
'''
from dragonfly import Function, Choice, Mouse, IntegerRef

from caster.lib.actions import Key, Text
from caster.lib import control, utilities
from caster.lib.dfplus.additions import IntegerRefST
from caster.lib.dfplus.merge.mergerule import MergeRule

BINDINGS = utilities.load_toml_file(
    utilities.get_full_path("caster/ccr/mathematics/lyx.toml"))


def greek(big, greek_letter):
    if big:
        greek_letter = greek_letter.title()
    Text("\\" + greek_letter + " ").execute()


def matrix(rows, cols):
    Text("\\bmatrix ").execute()
    for _ in range(0, rows - 1):
        Key("a-m, w, i").execute()
    for _ in range(0, cols - 1):
        Key("a-m, c, i").execute()


# Alternate between executing as text and executing as keys
Beispiel #3
0
from dragonfly import Window, Key
from caster.lib import utilities

import struct
from ctypes import cdll

# https://github.com/mrob95/pyVirtualDesktopAccessor
if struct.calcsize("P") * 8 == 32:
    vda = cdll.LoadLibrary(
        utilities.get_full_path("lib/bin/VirtualDesktopAccessor32.dll"))
else:
    vda = cdll.LoadLibrary(
        utilities.get_full_path("lib/bin/VirtualDesktopAccessor64.dll"))


def move_current_to_n(n=0, follow=False):
    wndh = Window.get_foreground().handle
    vda.MoveWindowToDesktopNumber(wndh, n - 1)
    if follow:
        vda.GoToDesktopNumber(n - 1)


def move_current_to_new(follow=False):
    wndh = Window.get_foreground().handle
    current = vda.GetCurrentDesktopNumber()
    total = vda.GetDesktopCount()
    Key("wc-d").execute()
    vda.MoveWindowToDesktopNumber(wndh, total)
    if not follow:
        vda.GoToDesktopNumber(current)
Beispiel #4
0
Created on Sep 4, 2018

@author: Mike Roberts
'''
import re
from dragonfly import Function, Choice
from caster.lib.actions import Key, Text, Mouse

from caster.ccr.standard import SymbolSpecs
from caster.lib import control, utilities, context
from caster.lib.dfplus.merge.mergerule import MergeRule
from caster.lib.dfplus.state.short import R
from caster.user.latex import word_counter

BINDINGS = utilities.load_toml_file(
    utilities.get_full_path("caster/ccr/latex/latex.toml"))


def quote():
    e, text = context.read_selected_without_altering_clipboard(False)
    if text:
        Text("``" + text + "\'\'").execute()
    else:
        Text("``\'\'").execute()
        Key("left:2").execute()


# Return \first{second}, if second is empty then end inside the brackets for user input
def back_curl(first, second):
    if str(second) != "":
        return (Text("\\") + Text(str(first)) + Key("lbrace, rbrace, left") +
Beispiel #5
0
'''
Created on May 23, 2017

@author: shippy
'''

from dragonfly import Dictation, MappingRule, Choice
from caster.lib.actions import Key, Text, Mouse

from caster.lib import control, utilities
from caster.ccr.standard import SymbolSpecs
from caster.lib.dfplus.merge.mergerule import MergeRule
from caster.lib.dfplus.state.short import R

BINDINGS = utilities.load_toml_file(
    utilities.get_full_path("caster/ccr/r/r.toml"))


class Rlang(MergeRule):
    auto = [".R", ".r"]
    pronunciation = "are"

    mapping = {
        SymbolSpecs.IF:
        R(Text("if ()") + Key("left"), rdescript="Rlang: If"),
        SymbolSpecs.ELSE:
        R(Text("else ") + Key("enter"), rdescript="Rlang: Else"),
        #
        # (no switch in Rlang)
        SymbolSpecs.BREAK:
        R(Text("break"), rdescript="Rlang: Break"),
Beispiel #6
0
Created on Sep 12, 2015

@author: synkarius
Standard merge filter: app_merge'''
from collections import OrderedDict
from itertools import izip_longest
from dragonfly.grammar.elements import RuleRef, Alternative, Repetition
from dragonfly.grammar.grammar_base import Grammar
from dragonfly.grammar.rule_compound import CompoundRule

from caster.lib import utilities
from caster.lib.merge.mergepair import MergePair, MergeInf
from caster.lib.merge.mergerule import MergeRule
from caster.lib.dfplus.recorder import recorder

CCR_PATH = utilities.get_full_path("config/ccr.toml")


def app_merge(mp):
    '''forces app rules to define which parts of the base rule they will accept'''
    if mp.type == MergeInf.APP:
        base = mp.rule1  #base copy, actually
        if base is None:
            return
        app = mp.rule2
        mw = app.get_merge_with()
        specs_per_rulename = mp.extras
        '''flatten acceptable specs into a list'''
        acceptable_specs = []
        for rulename in specs_per_rulename:
            if rulename in mw: