Beispiel #1
0
def quote():
    text = utilities.read_selected(False)
    if text:
        Text("``" + text + "\'\'").execute()
    else:
        Text("``\'\'").execute()
        Key("left:2").execute()
Beispiel #2
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()
Beispiel #3
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()
Beispiel #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()
Beispiel #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()
Beispiel #6
0
def section(sub, text):
    Text("\\" + sub + "section{}").execute()
    Key("left").execute()
    Text(text.capitalize()).execute()
    Key("c-enter").execute()
Beispiel #7
0
def greek_letters(big, greek_letter):
    Text("\\" + str(greek_letter.title() if big else greek_letter) +
         " ").execute()
Beispiel #8
0
def back_curl(first, second):
    (Text("\\" + str(first)) + Key("lbrace, rbrace, left") +
     Text(str(second))).execute()
    if str(second) != "":
        Key("right").execute()
Beispiel #9
0
def master_format_text(capitalisation, spacing, text):
    Text(formatted_text(capitalisation, spacing, unicode(text))).execute()