##// END OF EJS Templates
Improvements to exception handling to transport structured tracebacks....
Improvements to exception handling to transport structured tracebacks. This code is still fairly hackish, but we're starting to get there. We still need to improve the api, because right now runlines() does way too much, and I had to set the exception state in a temporary private variable. But client-side things are working better, so we can continue fixing the kernel without bottlenecking Evan.

File last commit:

r2791:e03aec3e
r2838:cbe60016
Show More
prompts.py
444 lines | 16.3 KiB | text/x-python | PythonLexer
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 # -*- coding: utf-8 -*-
Brian Granger
Refactor of prompts and the displayhook....
r2781 """Classes for handling input/output prompts.
Authors:
* Fernando Perez
* Brian Granger
Fernando Perez
Remove svn-style $Id marks from docstrings and Release imports....
r1853 """
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0
Brian Granger
Refactor of prompts and the displayhook....
r2781 #-----------------------------------------------------------------------------
# Copyright (C) 2008-2010 The IPython Development Team
Fernando Perez
Update copyright/author statements....
r1875 # Copyright (C) 2001-2007 Fernando Perez <fperez@colorado.edu>
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 #
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
Brian Granger
Refactor of prompts and the displayhook....
r2781 #-----------------------------------------------------------------------------
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0
Brian Granger
Refactor of prompts and the displayhook....
r2781 #-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
Brian Granger
Work to address the review comments on Fernando's branch....
r2498
fperez
Cosmetic cleanups: put all imports in a single line, and sort them...
r52 import os
Brian Granger
Work to address the review comments on Fernando's branch....
r2498 import re
fperez
Cosmetic cleanups: put all imports in a single line, and sort them...
r52 import socket
import sys
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0
Brian Granger
Release.py => core/release.py and imports updated.
r2043 from IPython.core import release
Fernando Perez
Update copyright/author statements....
r1875 from IPython.external.Itpl import ItplNS
Brian Granger
Work to address the review comments on Fernando's branch....
r2498 from IPython.utils import coloransi
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0
Brian Granger
Refactor of prompts and the displayhook....
r2781 #-----------------------------------------------------------------------------
# Color schemes for prompts
#-----------------------------------------------------------------------------
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0
Brian Granger
ColorANSI.py -> utils/coloransi.py and all imports updated.
r2010 PromptColors = coloransi.ColorSchemeTable()
InputColors = coloransi.InputTermColors # just a shorthand
Colors = coloransi.TermColors # just a shorthand
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0
Brian Granger
ColorANSI.py -> utils/coloransi.py and all imports updated.
r2010 PromptColors.add_scheme(coloransi.ColorScheme(
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 'NoColor',
in_prompt = InputColors.NoColor, # Input prompt
in_number = InputColors.NoColor, # Input prompt number
in_prompt2 = InputColors.NoColor, # Continuation prompt
in_normal = InputColors.NoColor, # color off (usu. Colors.Normal)
out_prompt = Colors.NoColor, # Output prompt
out_number = Colors.NoColor, # Output prompt number
normal = Colors.NoColor # color off (usu. Colors.Normal)
))
fperez
- Fairly significant changes to include Vivian's patches for improved pdb...
r46
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 # make some schemes as instances so we can copy them for modification easily:
Brian Granger
ColorANSI.py -> utils/coloransi.py and all imports updated.
r2010 __PColLinux = coloransi.ColorScheme(
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 'Linux',
in_prompt = InputColors.Green,
in_number = InputColors.LightGreen,
in_prompt2 = InputColors.Green,
in_normal = InputColors.Normal, # color off (usu. Colors.Normal)
out_prompt = Colors.Red,
out_number = Colors.LightRed,
normal = Colors.Normal
)
# Don't forget to enter it into the table!
PromptColors.add_scheme(__PColLinux)
fperez
- Fairly significant changes to include Vivian's patches for improved pdb...
r46
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 # Slightly modified Linux for light backgrounds
fperez
- Fairly significant changes to include Vivian's patches for improved pdb...
r46 __PColLightBG = __PColLinux.copy('LightBG')
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0
__PColLightBG.colors.update(
in_prompt = InputColors.Blue,
in_number = InputColors.LightBlue,
in_prompt2 = InputColors.Blue
)
PromptColors.add_scheme(__PColLightBG)
del Colors,InputColors
#-----------------------------------------------------------------------------
Brian Granger
Refactor of prompts and the displayhook....
r2781 # Utilities
#-----------------------------------------------------------------------------
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 def multiple_replace(dict, text):
""" Replace in 'text' all occurences of any key in the given
dictionary by its corresponding value. Returns the new string."""
# Function by Xavier Defrang, originally found at:
# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81330
# Create a regular expression from the dictionary keys
regex = re.compile("(%s)" % "|".join(map(re.escape, dict.keys())))
# For each match, look-up corresponding value in dictionary
return regex.sub(lambda mo: dict[mo.string[mo.start():mo.end()]], text)
#-----------------------------------------------------------------------------
# Special characters that can be used in prompt templates, mainly bash-like
Brian Granger
Refactor of prompts and the displayhook....
r2781 #-----------------------------------------------------------------------------
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0
# If $HOME isn't defined (Windows), make it an absurd string so that it can
# never be expanded out into '~'. Basically anything which can never be a
# reasonable directory name will do, we just want the $HOME -> '~' operation
# to become a no-op. We pre-compute $HOME here so it's not done on every
# prompt call.
# FIXME:
# - This should be turned into a class which does proper namespace management,
# since the prompt specials need to be evaluated in a certain namespace.
# Currently it's just globals, which need to be managed manually by code
# below.
# - I also need to split up the color schemes from the prompt specials
# somehow. I don't have a clean design for that quite yet.
HOME = os.environ.get("HOME","//////:::::ZZZZZ,,,~~~")
# We precompute a few more strings here for the prompt_specials, which are
# fixed once ipython starts. This reduces the runtime overhead of computing
# prompt strings.
USER = os.environ.get("USER")
HOSTNAME = socket.gethostname()
HOSTNAME_SHORT = HOSTNAME.split(".")[0]
ROOT_SYMBOL = "$#"[os.name=='nt' or os.getuid()==0]
prompt_specials_color = {
# Prompt/history count
'%n' : '${self.col_num}' '${self.cache.prompt_count}' '${self.col_p}',
fperez
- Add \N escape for the actual prompt number, without any coloring.
r579 r'\#': '${self.col_num}' '${self.cache.prompt_count}' '${self.col_p}',
# Just the prompt counter number, WITHOUT any coloring wrappers, so users
# can get numbers displayed in whatever color they want.
r'\N': '${self.cache.prompt_count}',
Fernando Perez
Add tests to ensure that %run does not modify __builtins__...
r1953
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 # Prompt/history count, with the actual digits replaced by dots. Used
# mainly in continuation prompts (prompt_in2)
Fernando Perez
Add tests to ensure that %run does not modify __builtins__...
r1953 #r'\D': '${"."*len(str(self.cache.prompt_count))}',
Fernando Perez
Ensure that __builtin__ is always available and compute prompts from it....
r2485
# More robust form of the above expression, that uses the __builtin__
# module. Note that we can NOT use __builtins__ (note the 's'), because
# that can either be a dict or a module, and can even mutate at runtime,
# depending on the context (Python makes no guarantees on it). In
# contrast, __builtin__ is always a module object, though it must be
# explicitly imported.
r'\D': '${"."*__builtin__.len(__builtin__.str(self.cache.prompt_count))}',
Fernando Perez
Add tests to ensure that %run does not modify __builtins__...
r1953
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 # Current working directory
fperez
- Add \N escape for the actual prompt number, without any coloring.
r579 r'\w': '${os.getcwd()}',
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 # Current time
fperez
- Add \N escape for the actual prompt number, without any coloring.
r579 r'\t' : '${time.strftime("%H:%M:%S")}',
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 # Basename of current working directory.
# (use os.sep to make this portable across OSes)
fperez
- Add \N escape for the actual prompt number, without any coloring.
r579 r'\W' : '${os.getcwd().split("%s")[-1]}' % os.sep,
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 # These X<N> are an extension to the normal bash prompts. They return
# N terms of the path, after replacing $HOME with '~'
fperez
- Add \N escape for the actual prompt number, without any coloring.
r579 r'\X0': '${os.getcwd().replace("%s","~")}' % HOME,
r'\X1': '${self.cwd_filt(1)}',
r'\X2': '${self.cwd_filt(2)}',
r'\X3': '${self.cwd_filt(3)}',
r'\X4': '${self.cwd_filt(4)}',
r'\X5': '${self.cwd_filt(5)}',
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 # Y<N> are similar to X<N>, but they show '~' if it's the directory
# N+1 in the list. Somewhat like %cN in tcsh.
fperez
- Add \N escape for the actual prompt number, without any coloring.
r579 r'\Y0': '${self.cwd_filt2(0)}',
r'\Y1': '${self.cwd_filt2(1)}',
r'\Y2': '${self.cwd_filt2(2)}',
r'\Y3': '${self.cwd_filt2(3)}',
r'\Y4': '${self.cwd_filt2(4)}',
r'\Y5': '${self.cwd_filt2(5)}',
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 # Hostname up to first .
fperez
- Add \N escape for the actual prompt number, without any coloring.
r579 r'\h': HOSTNAME_SHORT,
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 # Full hostname
fperez
- Add \N escape for the actual prompt number, without any coloring.
r579 r'\H': HOSTNAME,
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 # Username of current user
fperez
- Add \N escape for the actual prompt number, without any coloring.
r579 r'\u': USER,
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 # Escaped '\'
'\\\\': '\\',
# Newline
fperez
- Add \N escape for the actual prompt number, without any coloring.
r579 r'\n': '\n',
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 # Carriage return
fperez
- Add \N escape for the actual prompt number, without any coloring.
r579 r'\r': '\r',
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 # Release version
Brian Granger
Release.py => core/release.py and imports updated.
r2043 r'\v': release.version,
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 # Root symbol ($ or #)
fperez
- Add \N escape for the actual prompt number, without any coloring.
r579 r'\$': ROOT_SYMBOL,
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 }
# A copy of the prompt_specials dictionary but with all color escapes removed,
# so we can correctly compute the prompt length for the auto_rewrite method.
prompt_specials_nocolor = prompt_specials_color.copy()
prompt_specials_nocolor['%n'] = '${self.cache.prompt_count}'
fperez
- Add \N escape for the actual prompt number, without any coloring.
r579 prompt_specials_nocolor[r'\#'] = '${self.cache.prompt_count}'
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0
# Add in all the InputTermColors color escapes as valid prompt characters.
# They all get added as \\C_COLORNAME, so that we don't have any conflicts
# with a color name which may begin with a letter used by any other of the
# allowed specials. This of course means that \\C will never be allowed for
# anything else.
Brian Granger
ColorANSI.py -> utils/coloransi.py and all imports updated.
r2010 input_colors = coloransi.InputTermColors
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 for _color in dir(input_colors):
if _color[0] != '_':
fperez
- Add \N escape for the actual prompt number, without any coloring.
r579 c_name = r'\C_'+_color
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 prompt_specials_color[c_name] = getattr(input_colors,_color)
prompt_specials_nocolor[c_name] = ''
# we default to no color for safety. Note that prompt_specials is a global
# variable used by all prompt objects.
prompt_specials = prompt_specials_nocolor
#-----------------------------------------------------------------------------
Brian Granger
Refactor of prompts and the displayhook....
r2781 # More utilities
#-----------------------------------------------------------------------------
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 def str_safe(arg):
"""Convert to a string, without ever raising an exception.
If str(arg) fails, <ERROR: ... > is returned, where ... is the exception
error message."""
fperez
Unicode fixes (utf-8 used by default if ascii is not enough). This should fix some reported crashes....
r5
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 try:
fperez
Unicode fixes (utf-8 used by default if ascii is not enough). This should fix some reported crashes....
r5 out = str(arg)
except UnicodeError:
try:
out = arg.encode('utf_8','replace')
except Exception,msg:
# let's keep this little duplication here, so that the most common
# case doesn't suffer from a double try wrapping.
out = '<ERROR: %s>' % msg
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 except Exception,msg:
fperez
Unicode fixes (utf-8 used by default if ascii is not enough). This should fix some reported crashes....
r5 out = '<ERROR: %s>' % msg
Fernando Perez
Comment out accidentally left over 'raise'....
r2486 #raise # dbg
fperez
Unicode fixes (utf-8 used by default if ascii is not enough). This should fix some reported crashes....
r5 return out
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0
Brian Granger
Refactor of prompts and the displayhook....
r2781 #-----------------------------------------------------------------------------
# Prompt classes
#-----------------------------------------------------------------------------
fperez
- new doctest_mode magic to toggle doctest pasting/prompts....
r763 class BasePrompt(object):
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 """Interactive prompt similar to Mathematica's."""
fperez
- new doctest_mode magic to toggle doctest pasting/prompts....
r763
def _get_p_template(self):
return self._p_template
def _set_p_template(self,val):
self._p_template = val
self.set_p_str()
p_template = property(_get_p_template,_set_p_template,
doc='Template for prompt string creation')
Brian Granger
Refactor of prompts and the displayhook....
r2781 def __init__(self, cache, sep, prompt, pad_left=False):
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0
# Hack: we access information about the primary prompt through the
# cache argument. We need this, because we want the secondary prompt
# to be aligned with the primary one. Color table info is also shared
# by all prompt classes through the cache. Nice OO spaghetti code!
self.cache = cache
self.sep = sep
# regexp to count the number of spaces at the end of a prompt
# expression, useful for prompt auto-rewriting
self.rspace = re.compile(r'(\s*)$')
# Flag to left-pad prompt strings to match the length of the primary
# prompt
self.pad_left = pad_left
fperez
- new doctest_mode magic to toggle doctest pasting/prompts....
r763
# Set template to create each actual prompt (where numbers change).
# Use a property
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 self.p_template = prompt
self.set_p_str()
def set_p_str(self):
""" Set the interpolating prompt strings.
This must be called every time the color settings change, because the
prompt_specials global may have changed."""
import os,time # needed in locals for prompt string handling
loc = locals()
vivainio
do not crash on illegal prompt strings (catch itpl exceptions)
r934 try:
self.p_str = ItplNS('%s%s%s' %
('${self.sep}${self.col_p}',
multiple_replace(prompt_specials, self.p_template),
Brian Granger
Refactor of prompts and the displayhook....
r2781 '${self.col_norm}'),self.cache.shell.user_ns,loc)
vivainio
do not crash on illegal prompt strings (catch itpl exceptions)
r934
self.p_str_nocolor = ItplNS(multiple_replace(prompt_specials_nocolor,
self.p_template),
Brian Granger
Refactor of prompts and the displayhook....
r2781 self.cache.shell.user_ns,loc)
vivainio
do not crash on illegal prompt strings (catch itpl exceptions)
r934 except:
print "Illegal prompt template (check $ usage!):",self.p_template
self.p_str = self.p_template
self.p_str_nocolor = self.p_template
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0
Brian Granger
Refactor of prompts and the displayhook....
r2781 def write(self, msg):
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 sys.stdout.write(msg)
return ''
def __str__(self):
"""Return a string form of the prompt.
This for is useful for continuation and output prompts, since it is
left-padded to match lengths with the primary one (if the
self.pad_left attribute is set)."""
out_str = str_safe(self.p_str)
if self.pad_left:
# We must find the amount of padding required to match lengths,
# taking the color escapes (which are invisible on-screen) into
# account.
esc_pad = len(out_str) - len(str_safe(self.p_str_nocolor))
format = '%%%ss' % (len(str(self.cache.last_prompt))+esc_pad)
return format % out_str
else:
return out_str
# these path filters are put in as methods so that we can control the
# namespace where the prompt strings get evaluated
Brian Granger
Refactor of prompts and the displayhook....
r2781 def cwd_filt(self, depth):
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 """Return the last depth elements of the current working directory.
$HOME is always replaced with '~'.
If depth==0, the full path is returned."""
cwd = os.getcwd().replace(HOME,"~")
out = os.sep.join(cwd.split(os.sep)[-depth:])
if out:
return out
else:
return os.sep
Brian Granger
Refactor of prompts and the displayhook....
r2781 def cwd_filt2(self, depth):
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 """Return the last depth elements of the current working directory.
$HOME is always replaced with '~'.
If depth==0, the full path is returned."""
vivainio
prompt and set_term_title now include drive letter and / characters on win32
r794 full_cwd = os.getcwd()
cwd = full_cwd.replace(HOME,"~").split(os.sep)
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 if '~' in cwd and len(cwd) == depth+1:
depth += 1
vivainio
prompt and set_term_title now include drive letter and / characters on win32
r794 drivepart = ''
if sys.platform == 'win32' and len(cwd) > depth:
drivepart = os.path.splitdrive(full_cwd)[0]
out = drivepart + '/'.join(cwd[-depth:])
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 if out:
return out
else:
return os.sep
fperez
- New dtutils module for running doctests interactively with more...
r909 def __nonzero__(self):
"""Implement boolean behavior.
Checks whether the p_str attribute is non-empty"""
return bool(self.p_template)
Brian Granger
Refactor of prompts and the displayhook....
r2781
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 class Prompt1(BasePrompt):
"""Input interactive prompt similar to Mathematica's."""
Brian Granger
Refactor of prompts and the displayhook....
r2781 def __init__(self, cache, sep='\n', prompt='In [\\#]: ', pad_left=True):
BasePrompt.__init__(self, cache, sep, prompt, pad_left)
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0
def set_colors(self):
self.set_p_str()
Colors = self.cache.color_table.active_colors # shorthand
self.col_p = Colors.in_prompt
self.col_num = Colors.in_number
self.col_norm = Colors.in_normal
# We need a non-input version of these escapes for the '--->'
# auto-call prompts used in the auto_rewrite() method.
self.col_p_ni = self.col_p.replace('\001','').replace('\002','')
self.col_norm_ni = Colors.normal
Brian Granger
Prompt messages are now implemented for both in/out prompts.
r2791
def peek_next_prompt(self):
"""Get the next prompt, but don't increment the counter."""
self.cache.prompt_count += 1
next_prompt = str_safe(self.p_str)
self.cache.prompt_count -= 1
return next_prompt
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 def __str__(self):
self.cache.prompt_count += 1
self.cache.last_prompt = str_safe(self.p_str_nocolor).split('\n')[-1]
return str_safe(self.p_str)
def auto_rewrite(self):
"""Print a string of the form '--->' which lines up with the previous
input string. Useful for systems which re-write the user input when
handling automatically special syntaxes."""
curr = str(self.cache.last_prompt)
nrspaces = len(self.rspace.search(curr).group())
return '%s%s>%s%s' % (self.col_p_ni,'-'*(len(curr)-nrspaces-1),
' '*nrspaces,self.col_norm_ni)
Brian Granger
Refactor of prompts and the displayhook....
r2781
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 class PromptOut(BasePrompt):
"""Output interactive prompt similar to Mathematica's."""
Brian Granger
Refactor of prompts and the displayhook....
r2781 def __init__(self, cache, sep='', prompt='Out[\\#]: ', pad_left=True):
BasePrompt.__init__(self, cache, sep, prompt, pad_left)
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 if not self.p_template:
self.__str__ = lambda: ''
def set_colors(self):
self.set_p_str()
Colors = self.cache.color_table.active_colors # shorthand
self.col_p = Colors.out_prompt
self.col_num = Colors.out_number
self.col_norm = Colors.normal
Brian Granger
Refactor of prompts and the displayhook....
r2781
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 class Prompt2(BasePrompt):
"""Interactive continuation prompt."""
Brian Granger
Refactor of prompts and the displayhook....
r2781 def __init__(self, cache, prompt=' .\\D.: ', pad_left=True):
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 self.cache = cache
self.p_template = prompt
self.pad_left = pad_left
self.set_p_str()
def set_p_str(self):
import os,time # needed in locals for prompt string handling
loc = locals()
self.p_str = ItplNS('%s%s%s' %
('${self.col_p2}',
multiple_replace(prompt_specials, self.p_template),
'$self.col_norm'),
Brian Granger
Refactor of prompts and the displayhook....
r2781 self.cache.shell.user_ns,loc)
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 self.p_str_nocolor = ItplNS(multiple_replace(prompt_specials_nocolor,
self.p_template),
Brian Granger
Refactor of prompts and the displayhook....
r2781 self.cache.shell.user_ns,loc)
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0
def set_colors(self):
self.set_p_str()
Colors = self.cache.color_table.active_colors
self.col_p2 = Colors.in_prompt2
self.col_norm = Colors.in_normal
# FIXME (2004-06-16) HACK: prevent crashes for users who haven't
# updated their prompt_in2 definitions. Remove eventually.
self.col_p = Colors.out_prompt
self.col_num = Colors.out_number