Show More
@@ -0,0 +1,29 b'' | |||
|
1 | import IPython.ipapi | |
|
2 | import win32clipboard | |
|
3 | ||
|
4 | ip = IPython.ipapi.get() | |
|
5 | ||
|
6 | def clip_f(self,parameter_s = ''): | |
|
7 | """Save a set of lines to the clipboard. | |
|
8 | ||
|
9 | Usage:\\ | |
|
10 | %clip n1-n2 n3-n4 ... n5 .. n6 ... | |
|
11 | ||
|
12 | 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 | |
|
14 | clipboard.""" | |
|
15 | ||
|
16 | args = parameter_s.split() | |
|
17 | if len(args) == 0: | |
|
18 | return None # xxx todo return clipboard text | |
|
19 | ||
|
20 | ranges = args[0:] | |
|
21 | cmds = ''.join(self.extract_input_slices(ranges)) | |
|
22 | win32clipboard.OpenClipboard() | |
|
23 | win32clipboard.EmptyClipboard() | |
|
24 | win32clipboard.SetClipboardText(cmds) | |
|
25 | win32clipboard.CloseClipboard() | |
|
26 | print 'The following commands were written to the clipboard' | |
|
27 | print cmds | |
|
28 | ||
|
29 | ip.expose_magic("clip",clip_f) No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now