Exemplo n.º 1
0
class sn_mathematicsNon(MergeRule):
    mapping = {
        "text <dict>":
        Key("c-t") +
        Function(lambda dict: Text(str(dict).capitalize()).execute()),
        "<control>":
        Key("%(control)s"),
    }
    extras = [
        Dictation("dict"),
        IntegerRef("n", 1, 10),
        Choice("control", BINDINGS["control"]),
    ]
Exemplo n.º 2
0
def begin_end(environment):
    e, text = utilities.read_selected(False)
    if type(environment) in [str, unicode]:
        env, arg = environment, ""
    elif type(environment) in [tuple, list]:
        env, arg = environment[0], environment[1]
    back_curl("begin", env)
    Text(arg + "\n").execute()
    if text:
        utilities.paste_string(text)
    Key("enter").execute()
    back_curl("end", env)
    if not text:
        Key("up").execute()
Exemplo n.º 3
0
def quote():
    e, text = utilities.read_selected(False)
    if text:
        Text("``" + text + "\'\'").execute()
    else:
        Text("``\'\'").execute()
        Key("left:2").execute()
Exemplo n.º 4
0
def symbol(symbol):
    if type(symbol) in [str, unicode, int]:
        Text("\\" + symbol + " ").execute()
    else:
        Text("\\" + str(symbol[0])).execute()
        Text("{}"*int(symbol[1])).execute()
        Key("left:" + str(2*int(symbol[1])-1)).execute()
Exemplo n.º 5
0
class core(MergeRule):
    non = coreNon

    pronunciation = CORE["pronunciation"]

    mapping = {
        "[<big>] <letter>":
        Function(alphabet),
        CORE["numbers_prefix"] + " <numbers>":
        Text("%(numbers)s"),
        "<punctuation>":
        Key("%(punctuation)s"),
        "(<direction> | <modifier> [<direction>]) [(<n50> | <extreme>)]":
        Function(navigation.text_nav),
        "<repeatable_key> [<n>]":
        Key("%(repeatable_key)s") * Repeat(extra="n"),
        "<non_repeatable_key>":
        Key("%(non_repeatable_key)s"),
        CORE["dictation_prefix"] + " <text>":
        Function(lambda text: Text(str(text).lower()).execute()),
        "shift click":
        Key("shift:down") + Mouse("left") + Key("shift:up"),
    }

    extras = [
        Dictation("text"),
        IntegerRef("n", 1, 10),
        IntegerRef("n50", 1, 50),
        IntegerRefMF("numbers", 0, CORE["numbers_max"]),
        Choice("big", {CORE["capitals_prefix"]: True}),
        Choice("letter", CORE[_LETTERS]),
        Choice("punctuation", CORE["punctuation"]),
        Choice("repeatable_key", CORE["repeatable_keys"]),
        Choice("non_repeatable_key", CORE["non_repeatable_keys"]),
        Choice("direction", CORE[_DIRECTIONS]),
        Choice("modifier", CORE["modifiers"]),
        Choice("extreme", {CORE["extreme"]: True}),
    ]

    defaults = {
        "big": False,
        "extreme": False,
        "n": 1,
        "n50": 1,
        "direction": "left",
        "modifier": "",
    }
Exemplo n.º 6
0
class sn_mathematics(MergeRule):
    non = sn_mathematicsNon
    mwith = CORE["pronunciation"]
    mcontext = AppContext(executable="scientific notebook")
    pronunciation = BINDINGS["pronunciation"]

    nested = sn_nested

    mapping = {
        BINDINGS["symbol_prefix"] + " <symbol>":
        Function(texchar),
        #
        BINDINGS["greek_prefix"] + " [<big>] <greek_letter>":
        Function(greek),
        BINDINGS["accent_prefix"] + " <accent>":
        Key("%(accent)s"),
        BINDINGS["unit_prefix"] + " <units>":
        Function(lambda units: execution.alternating_command(units)),
        "<misc_sn_keys>":
        Key("%(misc_sn_keys)s"),
        "<misc_sn_text>":
        Text("%(misc_sn_text)s"),
        "matrix <rows> by <cols>":
        Function(matrix),
        "<numbers> <denominator>":
        Key("c-f") + Text("%(numbers)s") + Key("down") +
        Text("%(denominator)s") + Key("right"),
    }

    extras = [
        IntegerRef("rows", 1, BINDINGS["max_matrix_size"]),
        IntegerRef("cols", 1, BINDINGS["max_matrix_size"]),
        IntegerRef("numbers", 0, CORE["numbers_max"]),
        Choice("big", {CORE["capitals_prefix"]: True}),
        Choice("greek_letter", BINDINGS["greek_letters"]),
        Choice("units", BINDINGS["units"]),
        Choice("symbol", BINDINGS["tex_symbols"]),
        Choice("accent", BINDINGS["accents"]),
        Choice("misc_sn_keys", BINDINGS["misc_sn_keys"]),
        Choice("misc_sn_text", BINDINGS["misc_sn_text"]),
        Choice("denominator", BINDINGS["denominators"]),
    ]

    defaults = {
        "big": False,
    }
Exemplo n.º 7
0
def alternating_command(command):
    if type(command) in [str, int, unicode]:
        Text(str(command)).execute()
    elif type(command) in [list, tuple]:
        for i in range(len(command)):
            if i % 2 == 0:
                Text(command[i]).execute()
            else:
                Key(command[i]).execute()
Exemplo n.º 8
0
def paren_function(name, dl1="(", dl2=")"):
    e, text = utilities.read_selected(False)
    Text(name + dl1).execute()
    if text:
        utilities.paste_string(text)
        Text(dl2).execute()
    else:
        Text(dl2).execute()
        Key("left:" + str(len(dl2))).execute()
Exemplo n.º 9
0
 def _execute(self, data=None):
     command = data[self.command]
     if type(command) in [str, int, unicode]:
         Text(str(command)).execute()
     elif type(command) in [list, tuple]:
         for i in range(len(command)):
             if i % 2 == 0:
                 Text(command[i]).execute()
             else:
                 Key(command[i]).execute()
Exemplo n.º 10
0
class coreNon(MergeRule):
    mapping = {
        "configure " + CORE["pronunciation"]:
        Function(utilities.load_config, config_name="core.toml"),
        "configure scientific notebook":
        Function(utilities.load_config,
                 config_name="ScientificNotebook55.toml"),
        "configure (LyX | licks)":
        Function(utilities.load_config, config_name="lyx.toml"),
        "<noCCR_repeatable_key> [<n>]":
        Key("%(noCCR_repeatable_key)s") * Repeat(extra="n"),
        "<noCCR_non_repeatable_key>":
        Key("%(noCCR_non_repeatable_key)s"),
    }
    extras = [
        IntegerRef("n", 1, 10),
        Choice("noCCR_repeatable_key", CORE["noCCR_repeatable_keys"]),
        Choice("noCCR_non_repeatable_key", CORE["noCCR_non_repeatable_keys"]),
    ]
    defaults = {
        "n": 1,
    }
Exemplo n.º 11
0
def selection_to_bib(ref_type, bib_path):
    Key("c-c/20").execute()
    cb = Clipboard.get_system_text()
    if ref_type == "book":
        ref = book_citation_generator.citation_from_name(cb)
    elif ref_type == "paper":
        ref = bibtexer.bib_from_title(cb)
    elif ref_type == "link":
        ref = bibtexer.bibtex_from_link(cb)
    with codecs.open(bib_path, encoding="utf-8", mode="a") as f:
        f.write(ref)
    print("Reference added:\n" + ref)
    Clipboard.set_system_text(bibtexer.get_tag(ref))
Exemplo n.º 12
0
def alphabet(big, letter):
    if big:
        letter = letter.upper()
    Key(letter).execute()
Exemplo n.º 13
0
class SublimeRule(MergeRule):
    pronunciation = "sublime"

    mapping = {
        "new (file | pane)":
        Key("c-n"),
        # {"keys": ["ctrl+alt+n"], "command": "new_window"},
        "new window":
        Key("ca-n"),
        "open file":
        Key("c-o"),
        # {"keys": ["ctrl+shift+o"], "command": "prompt_add_folder"},
        "open folder":
        Key("cs-o"),
        "save as":
        Key("cs-s"),
        #
        "comment line":
        Key("c-slash"),
        "comment (block | lines)":
        Key("cs-slash"),
        "outdent lines":
        Key("c-lbracket"),
        "join lines [<n3>]":
        Key("c-j"),
        "match bracket":
        Key("c-m"),
        #
        # "(select | sell) all":  Key("c-a"),
        "(select | sell) scope [<n2>]":
        Key("cs-space"),
        "(select | sell) brackets [<n2>]":
        Key("cs-m"),
        "(select | sell) line [<n2>]":
        Key("c-l"),
        "(select | sell) indent":
        Key("cs-j"),
        # {"keys": ["ctrl+alt+p"], "command": "expand_selection_to_paragraph"},
        "(select | sell) paragraph":
        Key("ca-p"),
        # SelectUntil
        "(select | sell) until":
        Key("as-s"),
        "toggle side bar":
        Key("c-k, c-b"),

        #
        "find":
        Key("c-f"),
        "get all":
        Key("a-enter"),
        "replace":
        Key("c-h"),
        "edit lines":
        Key("cs-l"),
        "edit next [<n3>]":
        Key("c-d"),
        "edit skip next [<n3>]":
        Key("c-k, c-d"),
        "edit all":
        Key("c-d, a-f3"),
        #
        "transform upper":
        Key("c-k, c-u"),
        "transform lower":
        Key("c-k, c-l"),
        # {"keys": ["ctrl+k", "ctrl+t"], "command": "title_case"},
        "transform title":
        Key("c-k, c-t"),
        #
        "line <n11> [<n12>]":
        Key("c-g") + Text("%(n11)s" + "%(n12)s") + Key("enter"),
        "go to file":
        Key("c-p"),
        "go to word":
        Key("c-semicolon"),
        "go to symbol":
        Key("c-r"),
        "go to [symbol in] project":
        Key("cs-r"),
        "command pallette":
        Key("cs-p"),
        "(find | search) in (project | folder | directory)":
        Key("cs-f"),
        #
        "fold":
        Key("cs-lbracket"),
        "unfold":
        Key("cs-rbracket"),
        "unfold all":
        Key("c-k, c-j"),
        "fold [level] <n2>":
        Key("c-k, c-%(n2)s"),
        #
        "full screen":
        Key("f11"),
        "(set | add) bookmark":
        Key("c-f2"),
        "next bookmark":
        Key("f2"),
        "previous bookmark":
        Key("s-f2"),
        "clear bookmarks":
        Key("cs-f2"),
        #
        "build it":
        Key("c-b"),
        # "cancel build": Key("c-break")),
        #
        "record macro":
        Key("c-q"),
        "play [back] macro [<n3>]":
        Key("cs-q"),
        "(new | create) snippet":
        Key("a-n"),
        #
        "close tab":
        Key("c-w"),
        "next tab":
        Key("c-pgdown"),
        "previous tab":
        Key("c-pgup"),
        "<nth> tab":
        Key("a-%(n2)s"),
        #
        "column <cols>":
        Key("as-%(cols)s"),
        "focus <panel>":
        Key("c-%(panel)s"),
        "move <panel>":
        Key("cs-%(panel)s"),
        # {"keys": ["ctrl+alt+v"], "command": "clone_file"}
        "split right":
        Key("as-2, c-1, ca-v, cs-2"),
        #
        "open terminal":
        Key("cs-t"),
        "zoom in [<n2>]":
        Key("c-equal") * Repeat(extra="n2"),
        "zoom out [<n2>]":
        Key("c-minus") * Repeat(extra="n2"),
    }
    extras = [
        IntegerRef("n11", 1, 100),
        IntegerRef("n12", 0, 100),
        IntegerRef("n2", 1, 9),
        IntegerRef("n3", 1, 21),
        Choice(
            "nth", {
                "first": "1",
                "second": "2",
                "third": "3",
                "fourth": "4",
                "fifth": "5",
                "sixth": "6",
                "seventh": "7",
                "eighth": "8",
                "ninth": "9",
                "tenth": "10",
            }),
        Choice("cols", {
            "one": "1",
            "two": "2",
            "three": "3",
            "grid": "5",
        }),
        Choice("panel", {
            "one": "1",
            "left": "1",
            "two": "2",
            "right": "2",
        }),
    ]
    defaults = {
        "n12": "",
        "n2": 1,
        "n3": 1,
    }
Exemplo n.º 14
0
def back_curl(first, second):
    (Text("\\" + str(first)) + Key("lbrace, rbrace, left") + Text(
            str(second))).execute()
    if str(second) != "":
        Key("right").execute()
Exemplo n.º 15
0
class TexmakerRule(MergeRule):
    pronunciation = "texmaker"

    mapping = {
        # file
        "new [file]": Key("c-n"),
        "open": Key("c-o"),
        "open recent": Key("a-f, down:3, right"),
        "close": Key("c-w"),
        "exit": Key("c-q"),
        "restore previous session": Key("cs-f8"),

        # edit
        "[go to] line <m>": Key("c-g") + Text("%(m)s") + Key("enter"),
        "comment": Key("c-t"),
        "uncomment": Key("c-u"),
        "indent": Key("c-rangle"),
        "(outdent | unindent)": Key("c-langle"),
        "find [<text>]": Key("c-f/5") + Text("%(text)s"),
        "find next [<n>]": Key("c-m") * Repeat(extra="n"),
        "replace": Key("c-r"),
        "check spelling": Key("cs-f7"),
        "refresh structure": Key("cs-f1"),

        # tools
        # if you have f1 set to turn on/off microphone, you will need to reset the Texmaker shortcut
        "quick build": Key("f1"),
        # "LaTeX": Key("f2"), # not sure what this does so I'm going to comment it out
        "view DVI": Key("f3"),
        "DVI to postscript": Key("f4"),
        "view postscript": Key("f5"),
        "PDF latex": Key("f6"),
        "view PDF": Key("f7"),
        "postscript to PDF": Key("f8"),
        "DVI to PDF": Key("f9"),
        "view log": Key("f10"),
        "bibtech": Key("f11"),
        "make index": Key("f12"),

        # view
        # Texmaker doesn't seem to have tabs unless I'm missing something
        "next (document | dock) [<n>]": Key("a-pgdown") * Repeat(extra='n'),
        "(previous | prior)  (document | dock)":
        Key("a-pgup") * Repeat(extra='n'),
        "full-screen": Key("cs-f11"),
        "switch pane":
        Key("c-space"),  # switch between editor and embedded viewer
    }

    extras = [
        Dictation("text"),
        IntegerRef("n", 1, 10),
        IntegerRef("m", 1, 1000),
    ]

    defaults = {}
Exemplo n.º 16
0
class sn_nested(NestedRule):
    mapping = {
        "[<before>] integral from <sequence1> to <sequence2>": [
            Function(lambda: texchar("int")) + Key("c-l"),
            Key("right, c-h"),
            Key("right")
        ],
        "[<before>] definite from <sequence1> to <sequence2>": [
            Key("c-6, right, c-l"),
            Key("right, c-h"),
            Key("right, c-left, left")
        ],
        "[<before>] differential <sequence1> by <sequence2>":
        [Key("c-f, d"), Key("down, d"),
         Key("right")],
        "[<before>] sum from <sequence1> to <sequence2>": [
            Key("f10, i, down:11, enter/25, a, enter, f10, i, down:11, enter/25, b, enter"
                ) + Function(lambda: texchar("sum")) + Key("down"),
            Key("up:2"),
            Key("right")
        ],
        "[<before>] limit from <sequence1> to <sequence2>": [
            Key("f10, i, down:11, enter/25, b, enter") +
            Function(lambda: texchar("lim")) + Key("down"),
            Function(lambda: texchar("rightarrow")),
            Key("right")
        ],
        "[<before>] argument that <minmax> <sequence1>": [
            Key("f10, i, down:11, enter/25, b, enter") +
            Text("arg%(minmax)s") + Key("down"),
            Key("right"), None
        ],
        "[<before>] <minmax> by <sequence1>": [
            Key("f10, i, down:11, enter/25, b, enter") + Text("%(minmax)s") +
            Key("down"),
            Key("right"), None
        ],
        "[<before>] <script1> <singleton1> [<after>]":
        [Key("%(script1)s"), Key("right"), None],
        "[<before>] <script1> <singleton1> <script2> <singleton2> [<after>]":
        [Key("%(script1)s"),
         Key("right, %(script2)s"),
         Key("right")],
    }
    extras = [
        Choice("minmax", {
            "(minimum | minimises)": "min",
            "(maximum | maximises)": "max",
        }),
        Choice("script1", {
            "sub": "c-l",
            "super": "c-h",
        }),
        Choice("script2", {
            "sub": "c-l",
            "super": "c-h",
        }),
    ]
Exemplo n.º 17
0
def matrix(rows, cols):
    Key("f10/5, i/5, down:8, enter/50").execute()
    Key(str(rows) + "/50, tab, " + str(cols) + "/50, enter").execute()
Exemplo n.º 18
0
def greek(big, greek_letter):
    if big:
        greek_letter = greek_letter.upper()
    Key("c-g, " + greek_letter).execute()
Exemplo n.º 19
0
def texchar(symbol):
    keychain = "ctrl:down, "
    for character in symbol:
        keychain = keychain + character + ", "
    keychain = keychain + "ctrl:up"
    Key(keychain).execute()