Esempio n. 1
0
def wrap_tag(tag):
    clipboard_empty = False
    try:
        clip = get_clip()
    except:
        clip = ""
        clipboard_empty = True

    clip = "<{0}>{1}</{0}>".format(tag, clip)

    try:
        set_clip(clip)
    except Exception as e:
        notify_error(e)
# Same basic thing as "Wrap in blockquote tags" except it ignores
# any selected text (and is maybe a bit simpler)
from scriptlib import get_clip, set_clip, notify_error

clipboard_empty = False
try:
    clip = get_clip()
except:
    clip = ""
    clipboard_empty = True

clip = "<blockquote>" + clip + "</blockquote>"

try:
    set_clip(clip)
except Exception as e:
    notify_error(e)

time.sleep(0.01)

# Firefox doesn't understand Shift+Ctrl+V as another paste
keyboard.send_keys("<ctrl>+v")
Esempio n. 3
0
# Wrap the selection text in a PHP 'print_r' statement for debugging If
# selection is empty, just put the cursor inside the 'print_r()'
import time
from scriptlib import get_sel, get_clip, set_clip

# get existing clipboard text, so we can restore it
try:
    clip_text = get_clip()
except:
    clip_text = ''

try:
    sel = get_sel()
except:
    sel = ''

set_clip(sel)

engine.run_script('PHP echo raw (from clipboard)')

if clip_text:
    time.sleep(0.1)
    set_clip(clip_text)
Esempio n. 4
0
import time
from scriptlib import wrap_clip, get_clip, set_clip

# save the clipboard so we can restore it
try:
    oldclip = get_clip()
except:
    # catches errors or an empty clipboard
    oldclip = ''

# wrap_clip returns the # of times to press <left> to get cursor in
# the position specified in the format string ('%|')
lefts = wrap_clip('[[wp:%c%||%c]]')
keyboard.send_keys("<ctrl>+v")

# give it a tick to finish pasting that...
time.sleep(0.1)
keyboard.send_keys('<left>' * lefts)

if oldclip:
    time.sleep(0.1)
    set_clip(oldclip)  # restore previous clipboard contents
Esempio n. 5
0
# Wrap the selected text in "teletype" tags (<tt></tt>)
from scriptlib import get_sel, get_clip, set_clip, for_length_of

no_selection = False
try:
    sel = get_sel()
except:
    sel = ""
    no_selection = True
try:
    clip_text = get_clip()  # because we're about to clobber it
except:
    clip_text = ""

sel = "<tt>" + sel + "</tt>"

try:
    set_clip(sel)
except Exception as e:
    notify_error(e)

time.sleep(0.01)
keyboard.send_keys("<shift>+<ctrl>+v")  # paste over the selection

# Put the cursor inside the <tt></tt> tags if the selection was empty
if no_selection:
    time.sleep(0.01)
    keyboard.send_keys(for_length_of("</tt>", "<left>"))

if clip_text:
    time.sleep(0.1)
Esempio n. 6
0
# Wrap the selection in blockquote tags, or just make blockquote tags
# and put the cursor inside them if the selection was empty
from scriptlib import get_sel, get_clip, set_clip, for_length_of, \
                      notify_error

no_selection = False

try:
    sel = get_sel()
except:
    sel = ""
    no_selection = True
try:
    clipb = get_clip()  # because we're about to clobber it
except:
    clipb = ""

sel = "<blockquote>" + sel + "</blockquote>"

try:
    set_clip(sel)
except Exception as e:
    notify_error(e)

time.sleep(0.01)

# Firefox doesn't understand Shift+Ctrl+V as another paste
keyboard.send_keys("<ctrl>+v")  # paste over the selection

# Put the cursor inside the <blockquote></blockquote> tags if the
# selection was empty