##// END OF EJS Templates
Update copyright/author statements....
Update copyright/author statements. - Updated copyright statements to use the new form: # Copyright (C) 2008-2009 The IPython Development Team I left the old notices in place (just updating the year in some cases), because as far as I know, old copyright statements are not meant to be retroactively modified. - Also, on most files, replaced __author__ marks with an 'Authors' section in the module docstring. This reduces top-level code in the module, while ensuring that the Author(s) get properly acknowledged in auto-generated API docs (sphinx doesn't read __author__ marks, but it will include the module docstring). I only left a few in place for very old files that we ship externally, and for those by Laurent: he had his authorship mark both in the docstring and in __author__ variables, so I think out of courtesy it would be better to ask him about it on the list. All the others were I found regular __author__ variables, I moved them to the main docstring.

File last commit:

r281:d670193a
r1875:bba7e571
Show More
win32clip.py
45 lines | 1.1 KiB | text/x-python | PythonLexer
import IPython.ipapi
ip = IPython.ipapi.get()
def clip_f( self, parameter_s = '' ):
"""Save a set of lines to the clipboard.
Usage:\\
%clip n1-n2 n3-n4 ... n5 .. n6 ...
This function uses the same syntax as %macro for line extraction, but
instead of creating a macro it saves the resulting string to the
clipboard.
When used without arguments, this returns the text contents of the clipboard.
E.g.
mytext = %clip
"""
import win32clipboard as cl
import win32con
args = parameter_s.split()
cl.OpenClipboard()
if len( args ) == 0:
data = cl.GetClipboardData( win32con.CF_TEXT )
cl.CloseClipboard()
return data
api = self.getapi()
if parameter_s.lstrip().startswith('='):
rest = parameter_s[parameter_s.index('=')+1:].strip()
val = str(api.ev(rest))
else:
ranges = args[0:]
val = ''.join( self.extract_input_slices( ranges ) )
cl.EmptyClipboard()
cl.SetClipboardText( val )
cl.CloseClipboard()
print 'The following text was written to the clipboard'
print val
ip.expose_magic( "clip", clip_f )