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