##// END OF EJS Templates
provide single readline config place through rlineimpl
vivainio -
Show More
@@ -0,0 +1,43 b''
1 # -*- coding: utf-8 -*-
2 """ Imports and provides the "correct" version of readline for the platform.
3
4 Readline is used throughout IPython as "import IPython.rlineimpl as readline.
5
6 In addition to normal readline stuff, this module provides have_readline boolean
7 and _outputfile variable used in genutils.
8
9 $Id: Magic.py 1096 2006-01-28 20:08:02Z vivainio $"""
10
11
12 import sys
13
14 have_readline = False
15
16 if sys.platform == 'win32':
17 try:
18 from pyreadline import *
19 print "Using the new pyreadline (thanks for participating in the testing!)"
20 have_readline = True
21 except ImportError:
22 print "The IPython team recommends the new pyreadline for Windows use, it wasn't found."
23 print "It's superior especially with non-US keyboard layouts."
24 print "Try installing it with 'easy_install pyreadline (ctypes is required) or"
25 print "svn co http://ipython.scipy.org/svn/ipython/pyreadline/trunk pyreadline"
26 print "Trying 'old' windows readline."
27
28 from readline import *
29 have_readline = True
30 else:
31 try:
32 from readline import *
33 have_readline = True
34 except ImportError:
35 pass
36
37
38 if have_readline:
39 try:
40 _outputfile=GetOutputFile()
41 except AttributeError:
42 have_readline = False
43
@@ -1,7 +1,7 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """Magic functions for InteractiveShell.
2 """Magic functions for InteractiveShell.
3
3
4 $Id: Magic.py 1096 2006-01-28 20:08:02Z vivainio $"""
4 $Id: Magic.py 1099 2006-01-29 21:05:57Z vivainio $"""
5
5
6 #*****************************************************************************
6 #*****************************************************************************
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
@@ -2008,22 +2008,9 b' Currently the magic system has the following functions:\\n"""'
2008 if not new_scheme:
2008 if not new_scheme:
2009 print 'You must specify a color scheme.'
2009 print 'You must specify a color scheme.'
2010 return
2010 return
2011 # Under Windows, check for Gary Bishop's readline, which is necessary
2011 import IPython.rlineimpl as readline
2012 # for ANSI coloring
2012 if not readline.have_readline:
2013 if os.name in ['nt','dos']:
2013 msg = """\
2014 try:
2015 import readline
2016 except ImportError:
2017 has_readline = 0
2018 else:
2019 try:
2020 readline.GetOutputFile()
2021 except AttributeError:
2022 has_readline = 0
2023 else:
2024 has_readline = 1
2025 if not has_readline:
2026 msg = """\
2027 Proper color support under MS Windows requires Gary Bishop's readline library.
2014 Proper color support under MS Windows requires Gary Bishop's readline library.
2028 You can find it at:
2015 You can find it at:
2029 http://sourceforge.net/projects/uncpythontools
2016 http://sourceforge.net/projects/uncpythontools
@@ -2031,8 +2018,8 b" Gary's readline needs the ctypes module, from:"
2031 http://starship.python.net/crew/theller/ctypes
2018 http://starship.python.net/crew/theller/ctypes
2032
2019
2033 Defaulting color scheme to 'NoColor'"""
2020 Defaulting color scheme to 'NoColor'"""
2034 new_scheme = 'NoColor'
2021 new_scheme = 'NoColor'
2035 warn(msg)
2022 warn(msg)
2036 # local shortcut
2023 # local shortcut
2037 shell = self.shell
2024 shell = self.shell
2038
2025
@@ -27,7 +27,7 b' IPython tries to:'
27
27
28 IPython requires Python 2.2 or newer.
28 IPython requires Python 2.2 or newer.
29
29
30 $Id: __init__.py 1025 2006-01-16 20:22:21Z vivainio $"""
30 $Id: __init__.py 1099 2006-01-29 21:05:57Z vivainio $"""
31
31
32 #*****************************************************************************
32 #*****************************************************************************
33 # Copyright (C) 2001-2004 Fernando Perez. <fperez@colorado.edu>
33 # Copyright (C) 2001-2004 Fernando Perez. <fperez@colorado.edu>
@@ -45,7 +45,7 b" if sys.version[0:3] < '2.3':"
45 __all__ = ['deep_reload','genutils','ipstruct','ultraTB','DPyGetOpt',
45 __all__ = ['deep_reload','genutils','ipstruct','ultraTB','DPyGetOpt',
46 'Itpl','hooks','ConfigLoader','OutputTrap','Release','Shell',
46 'Itpl','hooks','ConfigLoader','OutputTrap','Release','Shell',
47 'platutils','platutils_win32','platutils_posix','platutils_dummy',
47 'platutils','platutils_win32','platutils_posix','platutils_dummy',
48 'ipapi','path']
48 'ipapi','path','rlineimpl']
49
49
50 # Load __all__ in IPython namespace so that a simple 'import IPython' gives
50 # Load __all__ in IPython namespace so that a simple 'import IPython' gives
51 # access to them via IPython.<name>
51 # access to them via IPython.<name>
@@ -69,8 +69,9 b' import glob'
69 import keyword
69 import keyword
70 import os
70 import os
71 import re
71 import re
72 import readline
73 import sys
72 import sys
73 import IPython.rlineimpl as readline
74
74 import types
75 import types
75
76
76 # Python 2.4 offers sets as a builtin
77 # Python 2.4 offers sets as a builtin
@@ -5,7 +5,7 b' General purpose utilities.'
5 This is a grab-bag of stuff I find useful in most programs I write. Some of
5 This is a grab-bag of stuff I find useful in most programs I write. Some of
6 these things are also convenient when working at the command line.
6 these things are also convenient when working at the command line.
7
7
8 $Id: genutils.py 1077 2006-01-24 18:15:27Z vivainio $"""
8 $Id: genutils.py 1099 2006-01-29 21:05:57Z vivainio $"""
9
9
10 #*****************************************************************************
10 #*****************************************************************************
11 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
11 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
@@ -71,8 +71,8 b' except AttributeError:'
71 _quotesre = re.compile(r'[\'"](.*)[\'"]')
71 _quotesre = re.compile(r'[\'"](.*)[\'"]')
72 _wordchars = ('abcdfeghijklmnopqrstuvwxyz'
72 _wordchars = ('abcdfeghijklmnopqrstuvwxyz'
73 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-.~*?'
73 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-.~*?'
74 'ßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ'
74 'ßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ'
75 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ%s'
75 'À�ÂÃÄÅÆÇÈÉÊËÌ�Î��ÑÒÓÔÕÖØÙÚÛÜ�Þ%s'
76 % os.sep)
76 % os.sep)
77
77
78 def shlex_split(s):
78 def shlex_split(s):
@@ -147,24 +147,12 b' class IOTerm:'
147 # Global variable to be used for all I/O
147 # Global variable to be used for all I/O
148 Term = IOTerm()
148 Term = IOTerm()
149
149
150 # Windows-specific code to load Gary Bishop's readline and configure it
150 import IPython.rlineimpl as readline
151 # automatically for the users
151 # Remake Term to use the readline i/o facilities
152 # Note: os.name on cygwin returns posix, so this should only pick up 'native'
152 if readline.have_readline:
153 # windows. Cygwin returns 'cygwin' for sys.platform.
153
154 if os.name == 'nt':
154 Term = IOTerm(cout=readline._outputfile,cerr=readline._outputfile)
155 try:
155
156 import readline
157 except ImportError:
158 pass
159 else:
160 try:
161 _out = readline.GetOutputFile()
162 except AttributeError:
163 pass
164 else:
165 # Remake Term to use the readline i/o facilities
166 Term = IOTerm(cout=_out,cerr=_out)
167 del _out
168
156
169 #****************************************************************************
157 #****************************************************************************
170 # Generic warning/error printer, used by everything else
158 # Generic warning/error printer, used by everything else
@@ -6,7 +6,7 b' Requires Python 2.3 or newer.'
6
6
7 This file contains all the classes and helper functions specific to IPython.
7 This file contains all the classes and helper functions specific to IPython.
8
8
9 $Id: iplib.py 1098 2006-01-29 16:14:21Z vivainio $
9 $Id: iplib.py 1099 2006-01-29 21:05:57Z vivainio $
10 """
10 """
11
11
12 #*****************************************************************************
12 #*****************************************************************************
@@ -1170,29 +1170,15 b' want to merge them back into the new files.""" % locals()'
1170
1170
1171 def init_readline(self):
1171 def init_readline(self):
1172 """Command history completion/saving/reloading."""
1172 """Command history completion/saving/reloading."""
1173
1173
1174 using_pyreadline = False
1174 import IPython.rlineimpl as readline
1175 if sys.platform == 'win32':
1175 if not readline.have_readline:
1176 try:
1177 import pyreadline as readline
1178 using_pyrl = True
1179 print "Using the new pyreadline (thanks for participating in the testing!)"
1180 except ImportError:
1181 print "The IPython team recommends the new pyreadline for Windows use, it wasn't found."
1182 print "Try installing it with 'easy_install pyreadline (ctypes is required) or"
1183 print "svn co http://ipython.scipy.org/svn/ipython/pyreadline/trunk pyreadline"
1184 print "Trying 'old' windows readline."
1185
1186
1187 try:
1188 if not using_pyreadline:
1189 import readline
1190 except ImportError:
1191 self.has_readline = 0
1176 self.has_readline = 0
1192 self.readline = None
1177 self.readline = None
1193 # no point in bugging windows users with this every time:
1178 # no point in bugging windows users with this every time:
1194 warn('Readline services not available on this platform.')
1179 warn('Readline services not available on this platform.')
1195 else:
1180 else:
1181 sys.modules['readline'] = readline
1196 import atexit
1182 import atexit
1197 from IPython.completer import IPCompleter
1183 from IPython.completer import IPCompleter
1198 self.Completer = IPCompleter(self,
1184 self.Completer = IPCompleter(self,
General Comments 0
You need to be logged in to leave comments. Login now