예제 #1
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()
예제 #2
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()
예제 #3
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()
예제 #4
0
파일: core.py 프로젝트: alexboche/mathfly
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,
    }
예제 #5
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))
예제 #6
0
파일: core.py 프로젝트: alexboche/mathfly
def alphabet(big, letter):
    if big:
        letter = letter.upper()
    Key(letter).execute()
예제 #7
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,
    }
예제 #8
0
def back_curl(first, second):
    (Text("\\" + str(first)) + Key("lbrace, rbrace, left") + Text(
            str(second))).execute()
    if str(second) != "":
        Key("right").execute()
예제 #9
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",
        }),
    ]
예제 #10
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()
예제 #11
0
def greek(big, greek_letter):
    if big:
        greek_letter = greek_letter.upper()
    Key("c-g, " + greek_letter).execute()
예제 #12
0
def texchar(symbol):
    keychain = "ctrl:down, "
    for character in symbol:
        keychain = keychain + character + ", "
    keychain = keychain + "ctrl:up"
    Key(keychain).execute()
예제 #13
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 = {}