Exemplo n.º 1
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)
Exemplo n.º 2
0
# save the clipboard so we can restore it
try:
    clip_text = get_clip()
except:
    # catches errors or an empty clipboard
    clip_text = ''

if re.match('[a-zA-Z]+://', clip_text):
    url = clip_text
else:
    notify_warn('No URL found on clipboard')
    url = ''

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

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

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

if clip_text:
    time.sleep(0.1)
    set_clip(clip_text)  # restore previous clipboard contents