##// END OF EJS Templates
reindent win32clip.py, add s = %clip
vivainio -
Show More
@@ -1,5 +1,4 b''
1 import IPython.ipapi
1 import IPython.ipapi
2 import win32clipboard
3
2
4 ip = IPython.ipapi.get()
3 ip = IPython.ipapi.get()
5
4
@@ -11,18 +10,30 b" def clip_f(self,parameter_s = ''):"
11
10
12 This function uses the same syntax as %macro for line extraction, but
11 This function uses the same syntax as %macro for line extraction, but
13 instead of creating a macro it saves the resulting string to the
12 instead of creating a macro it saves the resulting string to the
14 clipboard."""
13 clipboard.
15
14
15 When used without arguments, this returns the text contents of the clipboard.
16 E.g.
17
18 mytext = %clip
19
20 """
21
22 import win32clipboard as cl
23 import win32con
16 args = parameter_s.split()
24 args = parameter_s.split()
25 cl.OpenClipboard()
17 if len(args) == 0:
26 if len( args ) == 0:
18 return None # xxx todo return clipboard text
27 data = cl.GetClipboardData( win32con.CF_TEXT )
28 cl.CloseClipboard()
29 return data
19
30
20 ranges = args[0:]
31 ranges = args[0:]
21 cmds = ''.join(self.extract_input_slices(ranges))
32 cmds = ''.join( self.extract_input_slices( ranges ) )
22 win32clipboard.OpenClipboard()
33
23 win32clipboard.EmptyClipboard()
34 cl.EmptyClipboard()
24 win32clipboard.SetClipboardText(cmds)
35 cl.SetClipboardText( cmds )
25 win32clipboard.CloseClipboard()
36 cl.CloseClipboard()
26 print 'The following commands were written to the clipboard'
37 print 'The following commands were written to the clipboard'
27 print cmds
38 print cmds
28
39
General Comments 0
You need to be logged in to leave comments. Login now