Show More
The requested changes are too big and content was truncated. Show full diff
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
@@ -1,56 +1,56 b'' | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | """ Imports and provides the 'correct' version of readline for the platform. |
|
3 | 3 | |
|
4 | 4 | Readline is used throughout IPython as 'import IPython.rlineimpl as readline'. |
|
5 | 5 | |
|
6 | 6 | In addition to normal readline stuff, this module provides have_readline |
|
7 | 7 | boolean and _outputfile variable used in genutils. |
|
8 | 8 | |
|
9 | 9 | $Id: Magic.py 1096 2006-01-28 20:08:02Z vivainio $""" |
|
10 | 10 | |
|
11 | 11 | import sys |
|
12 | 12 | |
|
13 | 13 | try: |
|
14 | 14 | from readline import * |
|
15 | 15 | import readline as _rl |
|
16 | 16 | have_readline = True |
|
17 | 17 | except ImportError: |
|
18 | 18 | try: |
|
19 | 19 | from pyreadline import * |
|
20 | 20 | import pyreadline as _rl |
|
21 | 21 | have_readline = True |
|
22 | 22 | except ImportError: |
|
23 | 23 | have_readline = False |
|
24 | 24 | |
|
25 | 25 | if sys.platform == 'win32' and have_readline: |
|
26 | 26 | try: |
|
27 | 27 | _outputfile=_rl.GetOutputFile() |
|
28 | 28 | except AttributeError: |
|
29 | 29 | print "Failed GetOutputFile" |
|
30 | 30 | have_readline = False |
|
31 | 31 | |
|
32 | 32 | # Test to see if libedit is being used instead of GNU readline. |
|
33 | 33 | # Thanks to Boyd Waters for this patch. |
|
34 | 34 | uses_libedit = False |
|
35 | 35 | if sys.platform == 'darwin' and have_readline: |
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
|
42 |
|
|
|
36 | import commands | |
|
37 | (status, result) = commands.getstatusoutput( "otool -L %s | grep libedit" % _rl.__file__ ) | |
|
38 | if status == 0 and len(result) > 0: | |
|
39 | # we are bound to libedit - new in Leopard | |
|
40 | _rl.parse_and_bind("bind ^I rl_complete") | |
|
41 | print "Leopard libedit detected." | |
|
42 | uses_libedit = True | |
|
43 | 43 | |
|
44 | 44 | |
|
45 | 45 | # the clear_history() function was only introduced in Python 2.4 and is |
|
46 | 46 | # actually optional in the readline API, so we must explicitly check for its |
|
47 | 47 | # existence. Some known platforms actually don't have it. This thread: |
|
48 | 48 | # http://mail.python.org/pipermail/python-dev/2003-August/037845.html |
|
49 | 49 | # has the original discussion. |
|
50 | 50 | |
|
51 | 51 | if have_readline: |
|
52 | 52 | try: |
|
53 | 53 | _rl.clear_history |
|
54 | 54 | except AttributeError: |
|
55 | 55 | def clear_history(): pass |
|
56 | 56 | _rl.clear_history = clear_history No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now