##// END OF EJS Templates
- Add \N escape for the actual prompt number, without any coloring.
fperez -
Show More
@@ -2,7 +2,7 b''
2 2 """
3 3 Classes for handling input/output prompts.
4 4
5 $Id: Prompts.py 1850 2006-10-28 19:48:13Z fptest $"""
5 $Id: Prompts.py 2192 2007-04-01 20:51:06Z fperez $"""
6 6
7 7 #*****************************************************************************
8 8 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
@@ -124,56 +124,59 b' ROOT_SYMBOL = "$#"[os.name==\'nt\' or os.getuid()==0]'
124 124 prompt_specials_color = {
125 125 # Prompt/history count
126 126 '%n' : '${self.col_num}' '${self.cache.prompt_count}' '${self.col_p}',
127 '\\#': '${self.col_num}' '${self.cache.prompt_count}' '${self.col_p}',
127 r'\#': '${self.col_num}' '${self.cache.prompt_count}' '${self.col_p}',
128 # Just the prompt counter number, WITHOUT any coloring wrappers, so users
129 # can get numbers displayed in whatever color they want.
130 r'\N': '${self.cache.prompt_count}',
128 131 # Prompt/history count, with the actual digits replaced by dots. Used
129 132 # mainly in continuation prompts (prompt_in2)
130 '\\D': '${"."*len(str(self.cache.prompt_count))}',
133 r'\D': '${"."*len(str(self.cache.prompt_count))}',
131 134 # Current working directory
132 '\\w': '${os.getcwd()}',
135 r'\w': '${os.getcwd()}',
133 136 # Current time
134 '\\t' : '${time.strftime("%H:%M:%S")}',
137 r'\t' : '${time.strftime("%H:%M:%S")}',
135 138 # Basename of current working directory.
136 139 # (use os.sep to make this portable across OSes)
137 '\\W' : '${os.getcwd().split("%s")[-1]}' % os.sep,
140 r'\W' : '${os.getcwd().split("%s")[-1]}' % os.sep,
138 141 # These X<N> are an extension to the normal bash prompts. They return
139 142 # N terms of the path, after replacing $HOME with '~'
140 '\\X0': '${os.getcwd().replace("%s","~")}' % HOME,
141 '\\X1': '${self.cwd_filt(1)}',
142 '\\X2': '${self.cwd_filt(2)}',
143 '\\X3': '${self.cwd_filt(3)}',
144 '\\X4': '${self.cwd_filt(4)}',
145 '\\X5': '${self.cwd_filt(5)}',
143 r'\X0': '${os.getcwd().replace("%s","~")}' % HOME,
144 r'\X1': '${self.cwd_filt(1)}',
145 r'\X2': '${self.cwd_filt(2)}',
146 r'\X3': '${self.cwd_filt(3)}',
147 r'\X4': '${self.cwd_filt(4)}',
148 r'\X5': '${self.cwd_filt(5)}',
146 149 # Y<N> are similar to X<N>, but they show '~' if it's the directory
147 150 # N+1 in the list. Somewhat like %cN in tcsh.
148 '\\Y0': '${self.cwd_filt2(0)}',
149 '\\Y1': '${self.cwd_filt2(1)}',
150 '\\Y2': '${self.cwd_filt2(2)}',
151 '\\Y3': '${self.cwd_filt2(3)}',
152 '\\Y4': '${self.cwd_filt2(4)}',
153 '\\Y5': '${self.cwd_filt2(5)}',
151 r'\Y0': '${self.cwd_filt2(0)}',
152 r'\Y1': '${self.cwd_filt2(1)}',
153 r'\Y2': '${self.cwd_filt2(2)}',
154 r'\Y3': '${self.cwd_filt2(3)}',
155 r'\Y4': '${self.cwd_filt2(4)}',
156 r'\Y5': '${self.cwd_filt2(5)}',
154 157 # Hostname up to first .
155 '\\h': HOSTNAME_SHORT,
158 r'\h': HOSTNAME_SHORT,
156 159 # Full hostname
157 '\\H': HOSTNAME,
160 r'\H': HOSTNAME,
158 161 # Username of current user
159 '\\u': USER,
162 r'\u': USER,
160 163 # Escaped '\'
161 164 '\\\\': '\\',
162 165 # Newline
163 '\\n': '\n',
166 r'\n': '\n',
164 167 # Carriage return
165 '\\r': '\r',
168 r'\r': '\r',
166 169 # Release version
167 '\\v': __version__,
170 r'\v': __version__,
168 171 # Root symbol ($ or #)
169 '\\$': ROOT_SYMBOL,
172 r'\$': ROOT_SYMBOL,
170 173 }
171 174
172 175 # A copy of the prompt_specials dictionary but with all color escapes removed,
173 176 # so we can correctly compute the prompt length for the auto_rewrite method.
174 177 prompt_specials_nocolor = prompt_specials_color.copy()
175 178 prompt_specials_nocolor['%n'] = '${self.cache.prompt_count}'
176 prompt_specials_nocolor['\\#'] = '${self.cache.prompt_count}'
179 prompt_specials_nocolor[r'\#'] = '${self.cache.prompt_count}'
177 180
178 181 # Add in all the InputTermColors color escapes as valid prompt characters.
179 182 # They all get added as \\C_COLORNAME, so that we don't have any conflicts
@@ -183,7 +186,7 b" prompt_specials_nocolor['\\\\#'] = '${self.cache.prompt_count}'"
183 186 input_colors = ColorANSI.InputTermColors
184 187 for _color in dir(input_colors):
185 188 if _color[0] != '_':
186 c_name = '\\C_'+_color
189 c_name = r'\C_'+_color
187 190 prompt_specials_color[c_name] = getattr(input_colors,_color)
188 191 prompt_specials_nocolor[c_name] = ''
189 192
@@ -422,8 +425,12 b' class CachedOutput:'
422 425
423 426 # Set input prompt strings and colors
424 427 if cache_size == 0:
425 if ps1.find('%n') > -1 or ps1.find('\\#') > -1: ps1 = '>>> '
426 if ps2.find('%n') > -1 or ps2.find('\\#') > -1: ps2 = '... '
428 if ps1.find('%n') > -1 or ps1.find(r'\#') > -1 \
429 or ps1.find(r'\N') > -1:
430 ps1 = '>>> '
431 if ps2.find('%n') > -1 or ps2.find(r'\#') > -1 \
432 or ps2.find(r'\N') > -1:
433 ps2 = '... '
427 434 self.ps1_str = self._set_prompt_str(ps1,'In [\\#]: ','>>> ')
428 435 self.ps2_str = self._set_prompt_str(ps2,' .\\D.: ','... ')
429 436 self.ps_out_str = self._set_prompt_str(ps_out,'Out[\\#]: ','')
@@ -1,7 +1,7 b''
1 1 # -*- coding: utf-8 -*-
2 2 """Release data for the IPython project.
3 3
4 $Id: Release.py 2160 2007-03-19 05:40:59Z fperez $"""
4 $Id: Release.py 2192 2007-04-01 20:51:06Z fperez $"""
5 5
6 6 #*****************************************************************************
7 7 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
@@ -22,7 +22,7 b" name = 'ipython'"
22 22 # because bdist_rpm does not accept dashes (an RPM) convention, and
23 23 # bdist_deb does not accept underscores (a Debian convention).
24 24
25 revision = '2159'
25 revision = '2191'
26 26
27 27 #version = '0.7.3'
28 28
@@ -1,3 +1,10 b''
1 2007-04-01 Fernando Perez <Fernando.Perez@colorado.edu>
2
3 * IPython/Prompts.py (prompt_specials_color): Add \N for the
4 actual prompt number, without any coloring. This allows users to
5 produce numbered prompts with their own colors. Added after a
6 report/request by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
7
1 8 2007-03-31 Walter Doerwald <walter@livinglogic.de>
2 9
3 10 * IPython/Extensions/igrid.py: Map the return key
@@ -6372,7 +6372,17 b' bash'
6372 6372 \begin_layout Description
6373 6373
6374 6374 \backslash
6375 # the prompt/history count number
6375 # the prompt/history count number.
6376 This escape is automatically wrapped in the coloring codes for the currently
6377 active color scheme.
6378 \end_layout
6379
6380 \begin_layout Description
6381
6382 \backslash
6383 N the 'naked' prompt/history count number: this is just the number itself,
6384 without any coloring applied to it.
6385 This lets you produce numbered prompts with your own colors.
6376 6386 \end_layout
6377 6387
6378 6388 \begin_layout Description
@@ -6699,7 +6709,7 b' fperez'
6699 6709 ]
6700 6710 \color green
6701 6711 1>
6702 \color default
6712 \color none
6703 6713 1+2
6704 6714 \newline
6705 6715
@@ -6734,7 +6744,7 b' hspace*{0mm}'
6734 6744
6735 6745 \color red
6736 6746 <1>
6737 \color default
6747 \color none
6738 6748 3
6739 6749 \newline
6740 6750
@@ -6748,7 +6758,7 b' fperez'
6748 6758 ]
6749 6759 \color green
6750 6760 2>
6751 \color default
6761 \color none
6752 6762 for i in (1,2,3):
6753 6763 \newline
6754 6764
@@ -6782,7 +6792,7 b' hspace*{0mm}'
6782 6792
6783 6793 \color green
6784 6794 ...>
6785 \color default
6795 \color none
6786 6796 \InsetSpace ~
6787 6797 \InsetSpace ~
6788 6798 \InsetSpace ~
@@ -6820,7 +6830,7 b' hspace*{0mm}'
6820 6830
6821 6831 \color green
6822 6832 ...>
6823 \color default
6833 \color none
6824 6834
6825 6835 \newline
6826 6836 1 2 3
General Comments 0
You need to be logged in to leave comments. Login now