Esempio n. 1
0
def drop(nnavi500, nexus, capitalisation, spacing, paste_key="c-v"):
    # Remove newlines before pasting into terminal
    if paste_key == "s-insert":
        Clipboard.set_system_text(Clipboard.get_system_text().replace(
            "\n", ""))
    # Maintain standard spark functionality for non-strings
    if capitalisation == 0 and spacing == 0 and nnavi500 == 1:
        Key(paste_key).execute()
        return

    # Get clipboard text
    if nnavi500 > 1:
        if str(nnavi500) in nexus.clip:
            text = nexus.clip[str(nnavi500)]
        else:
            text = None
    else:
        text = Clipboard.get_system_text()
    # Format if necessary, and paste
    if text is not None:
        cb = Clipboard(from_system=True)
        if capitalisation != 0 or spacing != 0:
            text = textformat.formatted_text(capitalisation, spacing, text)
        Clipboard.set_system_text(text)
        time.sleep(SETTINGS["keypress_wait"])
        Key(paste_key).execute()
        time.sleep(SETTINGS["keypress_wait"])
        # Restore the clipboard contents.
        cb.copy_to_system()
Esempio n. 2
0
def duple(n, esc=True):
    cb = Clipboard(from_system=True)
    if esc: Key("escape").execute()
    Key("home, s-end, c-c, end").execute()
    time.sleep(SETTINGS["keypress_wait"])
    for _ in range(n):
        Key("enter, c-v").execute()
        time.sleep(SETTINGS["keypress_wait"])
    cb.copy_to_system()
Esempio n. 3
0
def stoosh(nnavi500, nexus, copy_key="c-c"):
    if nnavi500 == 1:
        Key(copy_key).execute()
    else:
        cb = Clipboard(from_system=True)
        Key(copy_key).execute()
        # time for keypress to execute
        time.sleep(SETTINGS["keypress_wait"])
        nexus.clip[str(nnavi500)] = Clipboard.get_system_text()
        utilities.save_toml_relative(nexus.clip, SETTINGS["clipboard_path"])
        cb.copy_to_system()
Esempio n. 4
0
def action_lines(action,
                 ln1,
                 ln2,
                 go_to_line="c-g",
                 select_line_down="s-down",
                 wait=""):
    num_lines = max(int(ln2) - int(ln1) + 1,
                    int(ln1) - int(ln2) + 1) if ln2 else 1
    top_line = min(int(ln2), int(ln1)) if ln2 else int(ln1)
    command = Key(go_to_line) + Text(str(top_line)) + Key(
        "enter%s, home%s, %s%s:%s, %s" %
        (wait, wait, select_line_down, wait, str(num_lines), action))
    command.execute()
Esempio n. 5
0
def begin_end(environment):
    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()
Esempio n. 6
0
def quote():
    text = utilities.read_selected(False)
    if text:
        Text("``" + text + "\'\'").execute()
    else:
        Text("``\'\'").execute()
        Key("left:2").execute()
Esempio n. 7
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()
Esempio n. 8
0
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()
Esempio n. 9
0
def splat(splatdir, n, extreme, manual=False):
    if extreme and splatdir == "left":
        key = "s-home, delete"
    elif extreme and splatdir == "right":
        key = "s-end, delete"
    elif manual:
        key = "cs-%s:%s, delete" % (splatdir, n)
    elif splatdir == "left":
        key = "c-backspace:%s" % n
    elif splatdir == "right":
        key = "c-delete:%s" % n
    Key(key).execute()
Esempio n. 10
0
def text_nav(modifier, direction, n, extreme):
    k = ""
    if extreme:
        if direction in ["left", "up"]:
            k = "home"
        else:
            k = "end"
        if direction in ["up", "down"]:
            k = "c-" + k
    else:
        k = str(direction) + ":" + str(n)
    if modifier:
        if "c-" in k:
            k = str(modifier).replace("c", "") + k
        else:
            k = str(modifier) + "-" + k.replace("c-", "")
    Key(k).execute()
Esempio n. 11
0
def section(sub, text):
    Text("\\" + sub + "section{}").execute()
    Key("left").execute()
    Text(text.capitalize()).execute()
    Key("c-enter").execute()
Esempio n. 12
0
def back_curl(first, second):
    (Text("\\" + str(first)) + Key("lbrace, rbrace, left") +
     Text(str(second))).execute()
    if str(second) != "":
        Key("right").execute()